Skip to content

Commit 5b6b166

Browse files
committed
MDEV-20730: Syntax error on SELECT INTO @variable with CTE
added forgotem WITH option to spacial case with INTO
1 parent 421d52e commit 5b6b166

File tree

4 files changed

+62
-0
lines changed

4 files changed

+62
-0
lines changed

mysql-test/main/cte_nonrecursive.result

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,3 +1673,14 @@ with columns as (select 1 as t) select * from columns;
16731673
t
16741674
1
16751675
use test;
1676+
#
1677+
# MDEV-20730: Syntax error on SELECT INTO @variable with CTE
1678+
#
1679+
with data as (select 1 as id)
1680+
select id into @myid from data;
1681+
set @save_sql_mode = @@sql_mode;
1682+
set sql_mode="oracle";
1683+
with data as (select 1 as id)
1684+
select id into @myid from data;
1685+
set sql_mode= @save_sql_mode;
1686+
# End of 10.4 tests

mysql-test/main/cte_nonrecursive.test

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,3 +1182,18 @@ with t as (select 1 as t) select * from t;
11821182
with columns as (select 1 as t) select * from columns;
11831183

11841184
use test;
1185+
1186+
1187+
--echo #
1188+
--echo # MDEV-20730: Syntax error on SELECT INTO @variable with CTE
1189+
--echo #
1190+
1191+
with data as (select 1 as id)
1192+
select id into @myid from data;
1193+
set @save_sql_mode = @@sql_mode;
1194+
set sql_mode="oracle";
1195+
with data as (select 1 as id)
1196+
select id into @myid from data;
1197+
set sql_mode= @save_sql_mode;
1198+
1199+
--echo # End of 10.4 tests

sql/sql_yacc.yy

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9213,6 +9213,24 @@ select_into:
92139213
if (Lex->select_finalize(unit))
92149214
MYSQL_YYABORT;
92159215
}
9216+
| with_clause
9217+
select_into_query_specification
9218+
{
9219+
if (Lex->push_select($2))
9220+
MYSQL_YYABORT;
9221+
}
9222+
opt_order_limit_lock
9223+
{
9224+
SELECT_LEX_UNIT *unit;
9225+
if (!(unit = Lex->create_unit($2)))
9226+
MYSQL_YYABORT;
9227+
if ($4)
9228+
unit= Lex->add_tail_to_query_expression_body(unit, $4);
9229+
unit->set_with_clause($1);
9230+
$1->attach_to($2);
9231+
if (Lex->select_finalize(unit))
9232+
MYSQL_YYABORT;
9233+
}
92169234
;
92179235

92189236
simple_table:

sql/sql_yacc_ora.yy

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9314,6 +9314,24 @@ select_into:
93149314
if (Lex->select_finalize(unit))
93159315
MYSQL_YYABORT;
93169316
}
9317+
| with_clause
9318+
select_into_query_specification
9319+
{
9320+
if (Lex->push_select($2))
9321+
MYSQL_YYABORT;
9322+
}
9323+
opt_order_limit_lock
9324+
{
9325+
SELECT_LEX_UNIT *unit;
9326+
if (!(unit = Lex->create_unit($2)))
9327+
MYSQL_YYABORT;
9328+
if ($4)
9329+
unit= Lex->add_tail_to_query_expression_body(unit, $4);
9330+
unit->set_with_clause($1);
9331+
$1->attach_to($2);
9332+
if (Lex->select_finalize(unit))
9333+
MYSQL_YYABORT;
9334+
}
93179335
;
93189336

93199337

0 commit comments

Comments
 (0)