1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-04-18 21:44:02 +03:00

fix(plugin): MCOL-5703 fix server crash on 'UNION ALL VALUES' queries (#3335)

* fix(plugin): MCOL-5703 fix server crash on 'UNION ALL VALUES' queries
This commit is contained in:
Alexey Antipovsky 2024-11-10 19:31:38 +01:00 committed by GitHub
parent a6eb5ca689
commit 6f4274760e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 53 additions and 6 deletions

View File

@ -880,7 +880,7 @@ select_handler* create_columnstore_select_handler_(THD* thd, SELECT_LEX* sel_lex
create_explain_query_if_not_exists(thd->lex, thd->mem_root);
Query_arena *arena, backup;
arena = thd->activate_stmt_arena_if_needed(&backup);
COND* conds = join->conds;
COND* conds = join ? join->conds : nullptr;
select_lex->where = conds;
if (isPS)
@ -888,7 +888,11 @@ select_handler* create_columnstore_select_handler_(THD* thd, SELECT_LEX* sel_lex
select_lex->prep_where = conds ? conds->copy_andor_structure(thd) : 0;
}
select_lex->update_used_tables();
// no join indicates that there is no tables to update
if (join)
{
select_lex->update_used_tables();
}
if (arena)
thd->restore_active_arena(arena, &backup);
@ -914,7 +918,8 @@ select_handler* create_columnstore_select_handler_(THD* thd, SELECT_LEX* sel_lex
JOIN* join = select_lex->join;
// This is taken from JOIN::optimize()
join->fields = &select_lex->item_list;
if (join)
join->fields = &select_lex->item_list;
// Instantiate handler::table, which is the place for the result set.
if ((i == 0) && handler->prepare())
@ -957,7 +962,7 @@ select_handler* create_columnstore_select_handler_(THD* thd, SELECT_LEX* sel_lex
return handler;
}
if (!join->zero_result_cause && join->exec_const_cond && !join->exec_const_cond->val_int())
if (join && !join->zero_result_cause && join->exec_const_cond && !join->exec_const_cond->val_int())
join->zero_result_cause = "Impossible WHERE noticed after reading const tables";
// We've called exec_const_cond->val_int(). This may have caused an error.
@ -968,7 +973,7 @@ select_handler* create_columnstore_select_handler_(THD* thd, SELECT_LEX* sel_lex
return handler;
}
if (join->zero_result_cause)
if (join && join->zero_result_cause)
{
if (join->select_lex->have_window_funcs() && join->send_row_on_empty_set())
{
@ -988,7 +993,7 @@ select_handler* create_columnstore_select_handler_(THD* thd, SELECT_LEX* sel_lex
}
}
if ((join->select_lex->options & OPTION_SCHEMA_TABLE) &&
if (join && (join->select_lex->options & OPTION_SCHEMA_TABLE) &&
get_schema_tables_result(join, PROCESSED_BY_JOIN_EXEC))
{
if (!thd->is_error())

View File

@ -0,0 +1,16 @@
DROP DATABASE IF EXISTS mcol5703;
CREATE DATABASE mcol5703;
USE mcol5703;
CREATE TABLE `doubles` (
`a` int(11),
`b` int(11)
) ENGINE=Columnstore DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
INSERT INTO doubles VALUES (1, 2), (2, 4);
SELECT a, b FROM doubles UNION VALUES (3, 6);
ERROR 42000: The storage engine for the table doesn't support subquery with VALUES
SELECT a, b FROM doubles UNION ALL VALUES (3, 6);
ERROR 42000: The storage engine for the table doesn't support subquery with VALUES
SELECT a, b FROM doubles UNION DISTINCT VALUES (3, 6);
ERROR 42000: The storage engine for the table doesn't support subquery with VALUES
DROP TABLE doubles;
DROP DATABASE mcol5703;

View File

@ -0,0 +1,26 @@
--source ../include/have_columnstore.inc
--disable_warnings
DROP DATABASE IF EXISTS mcol5703;
--enable_warnings
CREATE DATABASE mcol5703;
USE mcol5703;
CREATE TABLE `doubles` (
`a` int(11),
`b` int(11)
) ENGINE=Columnstore DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
INSERT INTO doubles VALUES (1, 2), (2, 4);
--ERROR 1178
SELECT a, b FROM doubles UNION VALUES (3, 6);
--ERROR 1178
SELECT a, b FROM doubles UNION ALL VALUES (3, 6);
--ERROR 1178
SELECT a, b FROM doubles UNION DISTINCT VALUES (3, 6);
DROP TABLE doubles;
DROP DATABASE mcol5703;