diff options
author | Igor Babaev <igor@askmonty.org> | 2021-11-19 14:51:12 -0800 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2021-11-20 11:23:24 -0800 |
commit | 0dae41637abd24c8f08e925ef00490e949ce581d (patch) | |
tree | 9751e978ca358b11c20997a80b6c092ddeeaa411 /sql | |
parent | e9f171b4fe65399e9ebbb1660198b690582e2ef5 (diff) | |
download | mariadb-git-0dae41637abd24c8f08e925ef00490e949ce581d.tar.gz |
MDEV-27086 "No database selected" when using UNION of CTEs to define table
This bug concerned only CREATE TABLE statements of the form
CREATE TABLE <table name> AS <with clause> <union>.
For such a statement not all references to CTE used in <union> were resolved.
As a result a bogus message was reported for the first unresolved reference.
This happened because for such statements the function resolving references
to CTEs LEX::check_cte_dependencies_and_resolve_references() was called
prematurely in the parser.
Approved by Oleksandr Byelkin <sanja@mariadb.com>
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_yacc.yy | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 312ea682975..4dd292258d3 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -4869,6 +4869,10 @@ create_like: opt_create_select: /* empty */ {} | opt_duplicate opt_as create_select_query_expression + { + if (Lex->check_cte_dependencies_and_resolve_references()) + MYSQL_YYABORT; + } ; create_select_query_expression: @@ -4877,16 +4881,12 @@ create_select_query_expression: { Select->set_braces(0); Select->set_with_clause($1); - if (Lex->check_cte_dependencies_and_resolve_references()) - MYSQL_YYABORT; } union_clause | opt_with_clause SELECT_SYM create_select_part2 create_select_part3_union_not_ready create_select_part4 { Select->set_with_clause($1); - if (Lex->check_cte_dependencies_and_resolve_references()) - MYSQL_YYABORT; } | '(' create_select_query_specification ')' | '(' create_select_query_specification ')' |