Commit 8164bd24 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-19535 sql_mode=ORACLE: 'SELECT INTO @var FOR UPDATE' does not lock the table

parent ed39181a
#
# MDEV-19535 sql_mode=ORACLE: 'SELECT INTO @var FOR UPDATE' does not lock the table
#
SET sql_mode='ORACLE';
CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY) engine=innodb;
INSERT INTO t1 VALUES (1);
START TRANSACTION;
SELECT a AS a_con1 FROM t1 INTO @a FOR UPDATE;
Warnings:
Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
connect con2,localhost,root,,;
SET sql_mode='ORACLE';
START TRANSACTION;
SELECT a AS a_con2 FROM t1 INTO @a FOR UPDATE;;
connection default;
UPDATE t1 SET a=a+100;
COMMIT;
connection con2;
Warnings:
Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
SELECT a AS con2 FROM t1;
con2
101
COMMIT;
connection default;
DROP TABLE t1;
--source include/have_innodb.inc
--echo #
--echo # MDEV-19535 sql_mode=ORACLE: 'SELECT INTO @var FOR UPDATE' does not lock the table
--echo #
SET sql_mode='ORACLE';
CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY) engine=innodb;
INSERT INTO t1 VALUES (1);
START TRANSACTION;
SELECT a AS a_con1 FROM t1 INTO @a FOR UPDATE;
--connect(con2,localhost,root,,)
SET sql_mode='ORACLE';
START TRANSACTION;
--send SELECT a AS a_con2 FROM t1 INTO @a FOR UPDATE;
--connection default
UPDATE t1 SET a=a+100;
COMMIT;
--connection con2
--reap
SELECT a AS con2 FROM t1;
COMMIT;
--connection default
DROP TABLE t1;
......@@ -9470,6 +9470,12 @@ bool LEX::select_finalize(st_select_lex_unit *expr)
}
bool LEX::select_finalize(st_select_lex_unit *expr, Lex_select_lock l)
{
return expr->set_lock_to_the_last_select(l) ||
select_finalize(expr);
}
/*
"IN" and "EXISTS" subselect can appear in two statement types:
......
......@@ -4452,6 +4452,7 @@ struct LEX: public Query_tables_list
LEX_CSTRING *alias);
bool parsed_create_view(SELECT_LEX_UNIT *unit, int check);
bool select_finalize(st_select_lex_unit *expr);
bool select_finalize(st_select_lex_unit *expr, Lex_select_lock l);
void relink_hack(st_select_lex *select_lex);
bool stmt_install_plugin(const DDL_options_st &opt,
......
......@@ -9122,9 +9122,7 @@ select:
opt_procedure_or_into
{
Lex->pop_select();
if ($1->set_lock_to_the_last_select($3))
MYSQL_YYABORT;
if (Lex->select_finalize($1))
if (Lex->select_finalize($1, $3))
MYSQL_YYABORT;
}
| with_clause query_expression_body
......@@ -9139,9 +9137,7 @@ select:
Lex->pop_select();
$2->set_with_clause($1);
$1->attach_to($2->first_select());
if ($2->set_lock_to_the_last_select($4))
MYSQL_YYABORT;
if (Lex->select_finalize($2))
if (Lex->select_finalize($2, $4))
MYSQL_YYABORT;
}
;
......
......@@ -9239,7 +9239,7 @@ select:
opt_procedure_or_into
{
Lex->pop_select();
if (Lex->select_finalize($1))
if (Lex->select_finalize($1, $3))
MYSQL_YYABORT;
}
| with_clause query_expression_body
......@@ -9254,7 +9254,7 @@ select:
Lex->pop_select();
$2->set_with_clause($1);
$1->attach_to($2->first_select());
if (Lex->select_finalize($2))
if (Lex->select_finalize($2, $4))
MYSQL_YYABORT;
}
;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment