Skip to content

Commit 85e4f5c

Browse files
MDEV-39119: Improve error handling when using OLD_VALUE as alias name
Analysis: Since OLD_VALUE_SYM was part of reserved keywords, it did not allow old_value in the alias. Fix: Change OLD_VALUE_SYM from reserved keyword to keyword_sp_var_and_label.
1 parent 343d4ec commit 85e4f5c

3 files changed

Lines changed: 20 additions & 1 deletion

File tree

mysql-test/main/update.result

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,4 +1128,13 @@ UPDATE t3 SET a = 10 RETURNING a;
11281128
a
11291129
10
11301130
DROP TABLE t3;
1131+
#
1132+
# MDEV-39119: Improve error handling when using OLD_VALUE as alias name
1133+
#
1134+
CREATE OR REPLACE TABLE t3(a INT);
1135+
INSERT INTO t3 VALUES (1);
1136+
UPDATE t3 SET a = 10 RETURNING OLD_VALUE(a) AS old_value;
1137+
old_value
1138+
1
1139+
DROP TABLE t3;
11311140
# End of 13.0 test

mysql-test/main/update.test

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,4 +985,14 @@ UPDATE t3 SET a = 10 RETURNING a;
985985

986986
DROP TABLE t3;
987987

988+
--echo #
989+
--echo # MDEV-39119: Improve error handling when using OLD_VALUE as alias name
990+
--echo #
991+
992+
CREATE OR REPLACE TABLE t3(a INT);
993+
INSERT INTO t3 VALUES (1);
994+
UPDATE t3 SET a = 10 RETURNING OLD_VALUE(a) AS old_value;
995+
996+
DROP TABLE t3;
997+
988998
--echo # End of 13.0 test

sql/sql_yacc.yy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17191,6 +17191,7 @@ keyword_sp_var_and_label:
1719117191
| MINUTE_SYM
1719217192
| MONTH_SYM
1719317193
| NEXTVAL_SYM
17194+
| OLD_VALUE_SYM
1719417195
| OVERLAPS_SYM
1719517196
| RECORD_SYM
1719617197
%ifdef MARIADB
@@ -17346,7 +17347,6 @@ reserved_keyword_udt_not_param_type:
1734617347
| NTILE_SYM
1734717348
| NULL_SYM
1734817349
| NTH_VALUE_SYM
17349-
| OLD_VALUE_SYM
1735017350
| ON
1735117351
| OPTIMIZE
1735217352
| OPTIONALLY

0 commit comments

Comments
 (0)