summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2019-10-17 23:20:34 +0200
committerOleksandr Byelkin <sanja@mariadb.com>2019-10-17 23:20:34 +0200
commit5b6b16636d48345475bfae7bae4eb7f0b2f0fb4e (patch)
tree4e90eb0a26a3c14001254ae5f6febb882acb34bb
parent421d52e89627d85794d7e8e4b70216b14f384178 (diff)
downloadmariadb-git-bb-10.5-MDEV-20730.tar.gz
MDEV-20730: Syntax error on SELECT INTO @variable with CTEbb-10.5-MDEV-20730
added forgotem WITH option to spacial case with INTO
-rw-r--r--mysql-test/main/cte_nonrecursive.result11
-rw-r--r--mysql-test/main/cte_nonrecursive.test15
-rw-r--r--sql/sql_yacc.yy18
-rw-r--r--sql/sql_yacc_ora.yy18
4 files changed, 62 insertions, 0 deletions
diff --git a/mysql-test/main/cte_nonrecursive.result b/mysql-test/main/cte_nonrecursive.result
index 8fba35d8ed4..91f67e34749 100644
--- a/mysql-test/main/cte_nonrecursive.result
+++ b/mysql-test/main/cte_nonrecursive.result
@@ -1673,3 +1673,14 @@ with columns as (select 1 as t) select * from columns;
t
1
use test;
+#
+# MDEV-20730: Syntax error on SELECT INTO @variable with CTE
+#
+with data as (select 1 as id)
+select id into @myid from data;
+set @save_sql_mode = @@sql_mode;
+set sql_mode="oracle";
+with data as (select 1 as id)
+select id into @myid from data;
+set sql_mode= @save_sql_mode;
+# End of 10.4 tests
diff --git a/mysql-test/main/cte_nonrecursive.test b/mysql-test/main/cte_nonrecursive.test
index bd8af55071a..5626f720adf 100644
--- a/mysql-test/main/cte_nonrecursive.test
+++ b/mysql-test/main/cte_nonrecursive.test
@@ -1182,3 +1182,18 @@ with t as (select 1 as t) select * from t;
with columns as (select 1 as t) select * from columns;
use test;
+
+
+--echo #
+--echo # MDEV-20730: Syntax error on SELECT INTO @variable with CTE
+--echo #
+
+with data as (select 1 as id)
+select id into @myid from data;
+set @save_sql_mode = @@sql_mode;
+set sql_mode="oracle";
+with data as (select 1 as id)
+select id into @myid from data;
+set sql_mode= @save_sql_mode;
+
+--echo # End of 10.4 tests
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 3e8e478e28f..249ed584aee 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -9213,6 +9213,24 @@ select_into:
if (Lex->select_finalize(unit))
MYSQL_YYABORT;
}
+ | with_clause
+ select_into_query_specification
+ {
+ if (Lex->push_select($2))
+ MYSQL_YYABORT;
+ }
+ opt_order_limit_lock
+ {
+ SELECT_LEX_UNIT *unit;
+ if (!(unit = Lex->create_unit($2)))
+ MYSQL_YYABORT;
+ if ($4)
+ unit= Lex->add_tail_to_query_expression_body(unit, $4);
+ unit->set_with_clause($1);
+ $1->attach_to($2);
+ if (Lex->select_finalize(unit))
+ MYSQL_YYABORT;
+ }
;
simple_table:
diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy
index 812f2032c18..9370faf7ef5 100644
--- a/sql/sql_yacc_ora.yy
+++ b/sql/sql_yacc_ora.yy
@@ -9314,6 +9314,24 @@ select_into:
if (Lex->select_finalize(unit))
MYSQL_YYABORT;
}
+ | with_clause
+ select_into_query_specification
+ {
+ if (Lex->push_select($2))
+ MYSQL_YYABORT;
+ }
+ opt_order_limit_lock
+ {
+ SELECT_LEX_UNIT *unit;
+ if (!(unit = Lex->create_unit($2)))
+ MYSQL_YYABORT;
+ if ($4)
+ unit= Lex->add_tail_to_query_expression_body(unit, $4);
+ unit->set_with_clause($1);
+ $1->attach_to($2);
+ if (Lex->select_finalize(unit))
+ MYSQL_YYABORT;
+ }
;