summaryrefslogtreecommitdiff
path: root/sql/sql_select.h
diff options
context:
space:
mode:
authorOleg Smirnov <olernov@gmail.com>2023-01-29 19:39:14 +0700
committerOleg Smirnov <olernov@gmail.com>2023-04-19 17:08:29 +0700
commit135f877f278d4e85cf8ecb83385b5631cb20229d (patch)
treeea6a78f52701104fc08246ceda172a35657b2328 /sql/sql_select.h
parent2e1c532bd2d9f9a35559e54f66d33c81e33009b1 (diff)
downloadmariadb-git-bb-10.4-mdev-30143.tar.gz
MDEV-30143 Segfault on select query using index for group-by and filesortbb-10.4-mdev-30143
The problem was trying to access JOIN_TAB::select which is set to NULL when using the filesort. The correct way is accessing either JOIN_TAB::select or JOIN_TAB::filesort->select depending on whether the filesort is used. This commit introduces member function JOIN_TAB::get_sql_select() encapsulating that check so the code duplication is eliminated
Diffstat (limited to 'sql/sql_select.h')
-rw-r--r--sql/sql_select.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/sql/sql_select.h b/sql/sql_select.h
index 0dfecc98a48..a438f29bd23 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -535,14 +535,19 @@ typedef struct st_join_table {
void cleanup();
inline bool is_using_loose_index_scan()
{
- const SQL_SELECT *sel= filesort ? filesort->select : select;
+ const SQL_SELECT *sel= get_sql_select();
return (sel && sel->quick &&
(sel->quick->get_type() == QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX));
}
bool is_using_agg_loose_index_scan ()
{
+ const SQL_SELECT *sel= get_sql_select();
return (is_using_loose_index_scan() &&
- ((QUICK_GROUP_MIN_MAX_SELECT *)select->quick)->is_agg_distinct());
+ ((QUICK_GROUP_MIN_MAX_SELECT *)sel->quick)->is_agg_distinct());
+ }
+ const SQL_SELECT *get_sql_select()
+ {
+ return filesort ? filesort->select : select;
}
bool is_inner_table_of_semi_join_with_first_match()
{