1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

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

This commit is contained in:
Alexander Barkov
2019-05-21 14:22:49 +04:00
parent ed39181a27
commit 8164bd24a6
6 changed files with 65 additions and 8 deletions

View File

@ -0,0 +1,26 @@
#
# 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;

View File

@ -0,0 +1,28 @@
--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;

View File

@ -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:

View File

@ -4452,6 +4452,7 @@ public:
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,

View File

@ -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;
}
;

View File

@ -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;
}
;