From 6f3b9df50b6aee5f1f868dc099cc27c660cac130 Mon Sep 17 00:00:00 2001 From: Knut Anders Hatlen Date: Fri, 10 Jan 2020 10:51:09 +0100 Subject: [PATCH] WL#13325: Deprecate VALUES syntax in INSERT ... ON DUPLICATE KEY UPDATE VALUES can be called as a function from the ON DUPLICATE KEY UPDATE clause of an INSERT statement and be used to get a value from the INSERT portion of the statement. This use of VALUES is now deprecated. Statements that use VALUES in this way, should be rewritten from this form: INSERT INTO t1(id, x) VALUES (1, 2) ON DUPLICATE KEY UPDATE x = x + VALUES(x); To this form: INSERT INTO t1(id, x) VALUES (1, 2) AS t2 ON DUPLICATE KEY UPDATE x = t1.x + t2.x; VALUES can also be called as a function in other contexts where function calls are allowed, outside of ON DUPLICATE KEY UPDATE clauses. Such calls always return NULL. This use of VALUES is also deprecated. Change-Id: Iddaa706910075a35ad7c65d0cbb9f982e51b322a --- mysql-test/include/mix1.inc | 8 ++++ mysql-test/r/errors.result | 2 + mysql-test/r/func_test.result | 2 + mysql-test/r/insert.result | 22 ++++++++++ mysql-test/r/insert_select.result | 2 + mysql-test/r/insert_update.result | 41 +++++++++++++++++++ mysql-test/r/insert_update_myisam.result | 2 + mysql-test/r/roles_bugs.result | 6 +++ mysql-test/r/roles_bugs_debug.result | 2 + mysql-test/r/trigger.result | 6 +++ mysql-test/r/type_blob.result | 2 + mysql-test/r/view.result | 2 + mysql-test/r/view_myisam.result | 2 + .../binlog_nogtid/r/binlog_unsafe.result | 2 + .../suite/binlog_nogtid/t/binlog_unsafe.test | 2 + mysql-test/suite/innodb/r/innodb_mysql.result | 10 +++++ mysql-test/suite/innodb/r/iodku.result | 34 +++++++++++++++ mysql-test/suite/innodb/t/iodku.test | 28 +++++++++++++ mysql-test/suite/json/inc/json_functions.inc | 2 + .../suite/json/r/json_functions_innodb.result | 6 +++ .../suite/json/r/json_functions_ndb.result | 6 +++ .../suite/x/r/performance_schema_stmt.result | 2 +- mysql-test/t/func_test.test | 2 + mysql-test/t/insert.test | 15 +++++++ mysql-test/t/insert_select.test | 2 + mysql-test/t/insert_update.test | 20 ++++++++- mysql-test/t/insert_update_myisam.test | 2 + mysql-test/t/roles_bugs.test | 2 + mysql-test/t/trigger.test | 2 + mysql-test/t/type_blob.test | 2 + mysql-test/t/view.test | 2 + mysql-test/t/view_myisam.test | 2 + plugin/x/src/insert_statement_builder.cc | 8 ++-- share/messages_to_clients.txt | 5 +++ sql/item.cc | 19 +++++++++ sql/item.h | 26 +++++++++++- .../xplugin/xpl/insert_statement_builder_t.cc | 14 ++++--- 37 files changed, 301 insertions(+), 13 deletions(-) diff --git a/mysql-test/include/mix1.inc b/mysql-test/include/mix1.inc index e766598415d8..f6b01121239e 100644 --- a/mysql-test/include/mix1.inc +++ b/mysql-test/include/mix1.inc @@ -480,16 +480,20 @@ primary key (id), unique key (c) ) engine=innodb; +--disable_ps_protocol # Different number of warnings until WL#6570. insert into t1 (id, c) values (NULL, 'a'), (NULL, 'a') on duplicate key update id = values(id), counter = counter + 1; +--enable_ps_protocol select * from t1; +--disable_ps_protocol # Different number of warnings until WL#6570. insert into t1 (id, c) values (NULL, 'b') on duplicate key update id = values(id), counter = counter + 1; +--enable_ps_protocol select * from t1; @@ -499,13 +503,17 @@ insert into t1 (id, c) values (NULL, 'a'); select * from t1; +--disable_ps_protocol # Different number of warnings until WL#6570. insert into t1 (id, c) values (NULL, 'b'), (NULL, 'b') on duplicate key update id = values(id), c = values(c), counter = counter + 1; +--enable_ps_protocol select * from t1; +--disable_ps_protocol # Different number of warnings until WL#6570. insert into t1 (id, c) values (NULL, 'a') on duplicate key update id = values(id), c = values(c), counter = counter + 1; +--enable_ps_protocol select * from t1; diff --git a/mysql-test/r/errors.result b/mysql-test/r/errors.result index ffc35babf52d..ac5f27b4db76 100644 --- a/mysql-test/r/errors.result +++ b/mysql-test/r/errors.result @@ -165,6 +165,8 @@ b=(SELECT '' AS b FROM t1 GROUP BY VALUES(b)); ERROR 42S22: Unknown column '' in 'VALUES() function' INSERT INTO t2(a,b) VALUES (1,0) ON DUPLICATE KEY UPDATE b=(SELECT VALUES(a)+2 FROM t1); +Warnings: +Warning 1287 The VALUES function is deprecated and will be removed in a future release. It always returns NULL in this context. If you meant to access a value from the VALUES clause of the INSERT statement, consider using an alias (INSERT INTO ... VALUES (...) AS alias) and reference alias.col instead of VALUES(col) in the ON DUPLICATE KEY UPDATE clause. DROP TABLE t1, t2; # # Bug#54812: assert in Diagnostics_area::set_ok_status during EXPLAIN diff --git a/mysql-test/r/func_test.result b/mysql-test/r/func_test.result index 91e0c1afffbb..5ba20ba3f613 100644 --- a/mysql-test/r/func_test.result +++ b/mysql-test/r/func_test.result @@ -683,6 +683,8 @@ Warnings: Warning 1681 Integer display width is deprecated and will be removed in a future release. INSERT INTO t1 VALUES (1, 13836376518955650385); INSERT INTO t1 VALUES (1, 13836376518955650385) ON DUPLICATE KEY UPDATE b=GREATEST(b, VALUES(b)); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead SELECT * FROM t1; a b 1 13836376518955650385 diff --git a/mysql-test/r/insert.result b/mysql-test/r/insert.result index 490fb25a2e56..56beb6120f18 100644 --- a/mysql-test/r/insert.result +++ b/mysql-test/r/insert.result @@ -319,6 +319,8 @@ insert into t1 (a,b) values (a,b); insert into t1 SET a=1, b=a+1; insert into t1 (a,b) select 1,2; INSERT INTO t1 ( a ) SELECT 0 ON DUPLICATE KEY UPDATE a = a + VALUES (a); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead prepare stmt1 from ' replace into t1 (a,a) select 100, ''hundred'' '; ERROR 42000: Column 'a' specified twice insert into t1 (a,b) values (1,1,1); @@ -1018,3 +1020,23 @@ WHERE alias1.f1 < 20 ); FLUSH TABLES; DROP TABLE t1, t2; +# +# WL#13325: Deprecate VALUES syntax in INSERT ... ON DUPLICATE KEY UPDATE +# +CREATE TABLE t(id INT PRIMARY KEY, x INT); +INSERT INTO t VALUES (0, 0) ON DUPLICATE KEY UPDATE x = VALUES(x) + 1; +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +INSERT INTO t VALUES (0, 0) +ON DUPLICATE KEY UPDATE x = (SELECT VALUES(x)+1 FROM t t1); +Warnings: +Warning 1287 The VALUES function is deprecated and will be removed in a future release. It always returns NULL in this context. If you meant to access a value from the VALUES clause of the INSERT statement, consider using an alias (INSERT INTO ... VALUES (...) AS alias) and reference alias.col instead of VALUES(col) in the ON DUPLICATE KEY UPDATE clause. +SELECT VALUES(x) FROM t; +VALUES(x) +NULL +Warnings: +Warning 1681 'VALUES function' is deprecated and will be removed in a future release. +INSERT INTO t VALUES (1, VALUES(x)); +Warnings: +Warning 1681 'VALUES function' is deprecated and will be removed in a future release. +DROP TABLE t; diff --git a/mysql-test/r/insert_select.result b/mysql-test/r/insert_select.result index c8277a1e5869..9e95a611da4e 100644 --- a/mysql-test/r/insert_select.result +++ b/mysql-test/r/insert_select.result @@ -594,6 +594,8 @@ drop table t1; create table t1(x int, y int); create table t2(x int, z int); insert into t1(x,y) select x,z from t2 on duplicate key update x=values(x); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead insert into t1(x,y) select x,z from t2 on duplicate key update x=values(z); ERROR 42S22: Unknown column 'z' in 'field list' insert into t1(x,y) select x,z from t2 on duplicate key update x=values(t2.x); diff --git a/mysql-test/r/insert_update.result b/mysql-test/r/insert_update.result index 6275e94e2706..ad2d4d362619 100644 --- a/mysql-test/r/insert_update.result +++ b/mysql-test/r/insert_update.result @@ -49,6 +49,8 @@ a b c 5 0 30 8 9 60 INSERT t1 VALUES (2,1,11), (7,4,40) ON DUPLICATE KEY UPDATE c=c+VALUES(a); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead SELECT *, VALUES(a) FROM t1; a b c VALUES(a) 1 2 10 NULL @@ -56,6 +58,8 @@ a b c VALUES(a) 5 0 30 NULL 8 9 60 NULL 2 1 11 NULL +Warnings: +Warning 1681 'VALUES function' is deprecated and will be removed in a future release. analyze table t1; Table Op Msg_type Msg_text test.t1 analyze status OK @@ -63,11 +67,13 @@ explain SELECT *, VALUES(a) FROM t1; id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 NULL ALL NULL NULL NULL NULL # 100.00 NULL Warnings: +Warning 1#81 'VALUES function' is deprecated and will be removed in a future release. Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,NULL AS `VALUES(a)` from `test`.`t1` explain select * from t1 where values(a); id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE Warnings: +Warning 1681 'VALUES function' is deprecated and will be removed in a future release. Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where false DROP TABLE t1; create table t1(a int primary key, b int); @@ -163,6 +169,8 @@ a b c INSERT t1 SELECT a,b,c FROM t2 WHERE d=2 ON DUPLICATE KEY UPDATE c=c+VALUES(a); ERROR 23000: Column 'c' in field list is ambiguous INSERT t1 SELECT a,b,c FROM t2 WHERE d=2 ON DUPLICATE KEY UPDATE c=t1.c+VALUES(t1.a); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead SELECT *, VALUES(a) FROM t1; a b c VALUES(a) 1 2 10 NULL @@ -170,6 +178,8 @@ a b c VALUES(a) 5 0 30 NULL 8 9 60 NULL 2 1 11 NULL +Warnings: +Warning 1681 'VALUES function' is deprecated and will be removed in a future release. DROP TABLE t1; DROP TABLE t2; CREATE TABLE t1 @@ -180,16 +190,25 @@ PRIMARY KEY (a) ); INSERT INTO t1 VALUES (45, 1) ON DUPLICATE KEY UPDATE b = IF(VALUES(b) > t1.b, VALUES(b), t1.b); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead SELECT * FROM t1; a b 45 1 INSERT INTO t1 VALUES (45, 2) ON DUPLICATE KEY UPDATE b = IF(VALUES(b) > t1.b, VALUES(b), t1.b); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead SELECT * FROM t1; a b 45 2 INSERT INTO t1 VALUES (45, 1) ON DUPLICATE KEY UPDATE b = IF(VALUES(b) > t1.b, VALUES(b), t1.b); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead SELECT * FROM t1; a b 45 2 @@ -895,6 +914,9 @@ CREATE TABLE insert_2_keys (a INT UNIQUE KEY, b INT UNIQUE KEY); INSERT INTO insert_2_keys values (1, 1); INSERT INTO insert_2_keys VALUES (1, 2) ON DUPLICATE KEY UPDATE a= VALUES(a) + 10, b= VALUES(b) + 10; +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead SELECT * FROM insert_2_keys; a b 11 12 @@ -913,16 +935,22 @@ DROP TABLE insert_2_keys; CREATE TABLE t(id INT PRIMARY KEY, j JSON); INSERT INTO t VALUES (1, '[1]') ON DUPLICATE KEY UPDATE j = JSON_OBJECT("a", VALUES(j)); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead SELECT * FROM t; id j 1 [1] INSERT INTO t VALUES (1, '[1,2]') ON DUPLICATE KEY UPDATE j = JSON_OBJECT("ab", VALUES(j)); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead SELECT * FROM t; id j 1 {"ab": [1, 2]} INSERT INTO t VALUES (1, '[1,2,3]') ON DUPLICATE KEY UPDATE j = JSON_OBJECT("abc", VALUES(j)); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead SELECT * FROM t; id j 1 {"abc": [1, 2, 3]} @@ -953,6 +981,8 @@ INSERT INTO t1 VALUES (10); INSERT INTO t2(a, b) VALUES (1, 0); INSERT INTO t2(a, b) VALUES (1, 0) ON DUPLICATE KEY UPDATE b= (SELECT VALUES(a) + 2 FROM t1); +Warnings: +Warning 1287 The VALUES function is deprecated and will be removed in a future release. It always returns NULL in this context. If you meant to access a value from the VALUES clause of the INSERT statement, consider using an alias (INSERT INTO ... VALUES (...) AS alias) and reference alias.col instead of VALUES(col) in the ON DUPLICATE KEY UPDATE clause. SELECT * FROM t2; a b 1 NULL @@ -976,6 +1006,8 @@ CREATE TABLE t1(a INT PRIMARY KEY, b INT); INSERT INTO t1 VALUES (1, 2); INSERT INTO t1 VALUES (1, 3) ON DUPLICATE KEY UPDATE b= GREATEST(b, VALUES(b)); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead SELECT * FROM t1; a b 1 3 @@ -994,8 +1026,14 @@ DROP TABLE t1; CREATE TABLE t1 (a INT, b BLOB, UNIQUE KEY(a)); INSERT INTO t1 SET b='11', a=0 ON DUPLICATE KEY UPDATE b= VALUES(a), a= values(b); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead INSERT INTO t1 SET b='11', a=0 ON DUPLICATE KEY UPDATE b= VALUES(a), a= values(b); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead SELECT * FROM t1; a b 11 0 @@ -1016,6 +1054,9 @@ CREATE TABLE t1(id INT NOT NULL, text1 TEXT, text2 TEXT, PRIMARY KEY (id)); INSERT INTO t1 VALUES (0, "x", "x"), (1, "y", "y"); INSERT INTO t1 (id, text1, text2) VALUES (0, "x", "y") ON DUPLICATE KEY UPDATE text1 = VALUES(text1), text2 = VALUES(text2); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead SELECT * FROM t1; id text1 text2 0 x y diff --git a/mysql-test/r/insert_update_myisam.result b/mysql-test/r/insert_update_myisam.result index 7537b5783dcb..f414c15d60a4 100644 --- a/mysql-test/r/insert_update_myisam.result +++ b/mysql-test/r/insert_update_myisam.result @@ -31,6 +31,8 @@ PRIMARY KEY (a) Warnings: Warning 1681 Integer display width is deprecated and will be removed in a future release. INSERT INTO t1 ( a ) SELECT 0 ON DUPLICATE KEY UPDATE a = a + VALUES (a) ; +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead DROP TABLE t1; SET SQL_MODE='NO_AUTO_VALUE_ON_ZERO'; CREATE TABLE `t1` ( diff --git a/mysql-test/r/roles_bugs.result b/mysql-test/r/roles_bugs.result index af96e099680c..b9861d2f9c52 100644 --- a/mysql-test/r/roles_bugs.result +++ b/mysql-test/r/roles_bugs.result @@ -76,8 +76,14 @@ END $$ INSERT into my_db.t1 values(5); # Inserts are now allowed if grants are given through role INSERT into my_db.t1 values(8) on duplicate key UPDATE id = values(id) + 800; +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead CALL my_db.foo_proc(); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead CALL my_db.baz_proc(); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead # Now revoke all privileges from the roles and user REVOKE ALL ON *.* FROM my_role; REVOKE ALL ON *.* FROM foo@localhost; diff --git a/mysql-test/r/roles_bugs_debug.result b/mysql-test/r/roles_bugs_debug.result index 23a5cc3bec8d..ec47b2b3e135 100644 --- a/mysql-test/r/roles_bugs_debug.result +++ b/mysql-test/r/roles_bugs_debug.result @@ -17,6 +17,8 @@ SET DEBUG_SYNC='now WAIT_FOR s1'; SET DEBUG_SYNC='after_table_grant_revoke SIGNAL s2'; REVOKE ALL ON my_db.t1 FROM foo_role; # Despite all privileges are revoked current SQL statement will succeed. +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead SET DEBUG_SYNC= 'RESET'; # But the subsequent statement will fail. INSERT into my_db.t1 values(9) on duplicate key UPDATE id = values(id) + 90; diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result index b23a8dea36bb..b9a461db6cc4 100644 --- a/mysql-test/r/trigger.result +++ b/mysql-test/r/trigger.result @@ -1258,8 +1258,14 @@ id val 1 test1 2 test2 INSERT INTO t1 VALUES (2,'test2') ON DUPLICATE KEY UPDATE val=VALUES(val); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead INSERT INTO t1 VALUES (2,'test3') ON DUPLICATE KEY UPDATE val=VALUES(val); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead INSERT INTO t1 VALUES (3,'test4') ON DUPLICATE KEY UPDATE val=VALUES(val); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead SELECT * FROM t1; id val 1 test1 diff --git a/mysql-test/r/type_blob.result b/mysql-test/r/type_blob.result index 0875950984e4..490ec115aca5 100644 --- a/mysql-test/r/type_blob.result +++ b/mysql-test/r/type_blob.result @@ -1268,6 +1268,8 @@ CREATE TABLE t1 (c1 INTEGER PRIMARY KEY, c2 TEXT, c3 INTEGER); INSERT INTO t1(c1) VALUES(0); INSERT INTO t1(c1) VALUES(0) ON DUPLICATE KEY UPDATE c2 = VALUES(c2), c3 = NULL; +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead SELECT * FROM t1; c1 c2 c3 0 NULL NULL diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 65e6ed4f9ec3..8638f2f55711 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -1581,6 +1581,8 @@ insert into v3(a) select a from t2; insert into v3(b) select b from t2; ERROR 23000: Column 'a' cannot be null insert into v3(a) values (1) on duplicate key update a=a+10000+VALUES(a); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead select * from t1; a b 10 NULL diff --git a/mysql-test/r/view_myisam.result b/mysql-test/r/view_myisam.result index 084bd96c09e5..9d5c51afb02c 100644 --- a/mysql-test/r/view_myisam.result +++ b/mysql-test/r/view_myisam.result @@ -48,6 +48,8 @@ insert into v3(b) select b from t2; Warnings: Warning 1048 Column 'a' cannot be null insert into v3(a) values (1) on duplicate key update a=a+10000+VALUES(a); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead select * from t1 ; a b 10002 NULL diff --git a/mysql-test/suite/binlog_nogtid/r/binlog_unsafe.result b/mysql-test/suite/binlog_nogtid/r/binlog_unsafe.result index 5a60e8877564..4e13f732517f 100644 --- a/mysql-test/suite/binlog_nogtid/r/binlog_unsafe.result +++ b/mysql-test/suite/binlog_nogtid/r/binlog_unsafe.result @@ -2734,6 +2734,8 @@ Note 1592 Unsafe statement written to the binary log using statement format sinc INSERT INTO insert_2_keys VALUES (1, 2) ON DUPLICATE KEY UPDATE a=VALUES(a)+10, b=VALUES(b)+10; Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT... ON DUPLICATE KEY UPDATE on a table with more than one UNIQUE KEY is unsafe DROP TABLE filler_table; DROP TABLE insert_table; diff --git a/mysql-test/suite/binlog_nogtid/t/binlog_unsafe.test b/mysql-test/suite/binlog_nogtid/t/binlog_unsafe.test index 857065d981fe..b48e4e63376d 100644 --- a/mysql-test/suite/binlog_nogtid/t/binlog_unsafe.test +++ b/mysql-test/suite/binlog_nogtid/t/binlog_unsafe.test @@ -750,8 +750,10 @@ CREATE TABLE create_replace_test (a INT, b INT, PRIMARY KEY(b)) REPLACE SELECT * CREATE TEMPORARY TABLE temp1 (a INT, b INT, PRIMARY KEY(b)) REPLACE SELECT * FROM filler_table; #INSERT.... ON DUP KEY UPDATE on a table with more than one UNIQUE KEY +--disable_ps_protocol # Different number of warnings until WL#6570. INSERT INTO insert_2_keys VALUES (1, 2) ON DUPLICATE KEY UPDATE a=VALUES(a)+10, b=VALUES(b)+10; +--enable_ps_protocol #WAIT_FOR_EXECUTED_GTID_SET is also unsafe statement. The test for that is #added here binlog.binlog_wait_for_executed_gtid_set_unsafe_statement. diff --git a/mysql-test/suite/innodb/r/innodb_mysql.result b/mysql-test/suite/innodb/r/innodb_mysql.result index 5dd49747722b..ca8e0a6c8cce 100644 --- a/mysql-test/suite/innodb/r/innodb_mysql.result +++ b/mysql-test/suite/innodb/r/innodb_mysql.result @@ -520,12 +520,16 @@ insert into t1 (id, c) values (NULL, 'a'), (NULL, 'a') on duplicate key update id = values(id), counter = counter + 1; +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead select * from t1; id c counter 2 a 2 insert into t1 (id, c) values (NULL, 'b') on duplicate key update id = values(id), counter = counter + 1; +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead select * from t1; id c counter 2 a 2 @@ -537,12 +541,18 @@ id c counter 1 a 1 insert into t1 (id, c) values (NULL, 'b'), (NULL, 'b') on duplicate key update id = values(id), c = values(c), counter = counter + 1; +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead select * from t1; id c counter 1 a 1 3 b 2 insert into t1 (id, c) values (NULL, 'a') on duplicate key update id = values(id), c = values(c), counter = counter + 1; +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead select * from t1; id c counter 3 b 2 diff --git a/mysql-test/suite/innodb/r/iodku.result b/mysql-test/suite/innodb/r/iodku.result index ada2371f571d..6bd0c1beba64 100644 --- a/mysql-test/suite/innodb/r/iodku.result +++ b/mysql-test/suite/innodb/r/iodku.result @@ -20,11 +20,17 @@ a b c # Transaction trx1 START TRANSACTION; INSERT INTO t1 VALUES (2, 2, 3) ON DUPLICATE KEY UPDATE c=VALUES(c); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead COMMIT; # Transaction trx2 START TRANSACTION; INSERT INTO t1 VALUES (2, 1, 2) ON DUPLICATE KEY UPDATE c=VALUES(c); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead INSERT INTO t1 VALUES (2, 3, 4) ON DUPLICATE KEY UPDATE c=VALUES(c); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead COMMIT; # Result: SELECT * FROM t1; @@ -51,11 +57,17 @@ a b c # Transaction trx2 START TRANSACTION; INSERT INTO t1 VALUES (2, 1, 2) ON DUPLICATE KEY UPDATE c=VALUES(c); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead INSERT INTO t1 VALUES (2, 3, 4) ON DUPLICATE KEY UPDATE c=VALUES(c); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead COMMIT; # Transaction trx1 START TRANSACTION; INSERT INTO t1 VALUES (2, 2, 3) ON DUPLICATE KEY UPDATE c=VALUES(c); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead COMMIT; # Result: SELECT * FROM t1; @@ -92,6 +104,8 @@ a b c # Transaction trx1: START TRANSACTION; INSERT INTO t1 VALUES (2, 1, 2) ON DUPLICATE KEY UPDATE c=VALUES(c); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead SELECT * FROM t1; a b c 0 0 0 @@ -100,6 +114,8 @@ a b c INSERT INTO t1 VALUES (2, 2, 3) ON DUPLICATE KEY UPDATE c=VALUES(c); # Connection default: INSERT INTO t1 VALUES (2, 3, 4) ON DUPLICATE KEY UPDATE c=VALUES(c); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead SELECT * FROM t1; a b c 0 0 0 @@ -107,6 +123,8 @@ a b c 2 3 4 COMMIT; # Connection other: +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead # Connection default: # Result: SELECT * FROM t1; @@ -135,11 +153,17 @@ a b c # Transaction trx1 START TRANSACTION; INSERT INTO t1 VALUES (2, 2, 3) ON DUPLICATE KEY UPDATE c=VALUES(c); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead COMMIT; # Transaction trx2 START TRANSACTION; INSERT INTO t1 VALUES (1, 2, 2) ON DUPLICATE KEY UPDATE c=VALUES(c); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead INSERT INTO t1 VALUES (3, 2, 4) ON DUPLICATE KEY UPDATE c=VALUES(c); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead COMMIT; # Result: SELECT * FROM t1; @@ -166,11 +190,17 @@ a b c # Transaction trx2 START TRANSACTION; INSERT INTO t1 VALUES (1, 2, 2) ON DUPLICATE KEY UPDATE c=VALUES(c); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead INSERT INTO t1 VALUES (3, 2, 4) ON DUPLICATE KEY UPDATE c=VALUES(c); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead COMMIT; # Transaction trx1 START TRANSACTION; INSERT INTO t1 VALUES (2, 2, 3) ON DUPLICATE KEY UPDATE c=VALUES(c); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead COMMIT; # Result: SELECT * FROM t1; @@ -198,6 +228,8 @@ a b c # Transaction trx1: START TRANSACTION; INSERT INTO t1 VALUES (1, 2, 2) ON DUPLICATE KEY UPDATE c=VALUES(c); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead SELECT * FROM t1; a b c 1 1 2 @@ -209,6 +241,8 @@ ERROR HY000: Lock wait timeout exceeded; try restarting transaction COMMIT; # Connection default: INSERT INTO t1 VALUES (3, 2, 4) ON DUPLICATE KEY UPDATE c=VALUES(c); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead COMMIT; # Result: SELECT * FROM t1; diff --git a/mysql-test/suite/innodb/t/iodku.test b/mysql-test/suite/innodb/t/iodku.test index 55955c1004f2..3df926e3ad7f 100644 --- a/mysql-test/suite/innodb/t/iodku.test +++ b/mysql-test/suite/innodb/t/iodku.test @@ -15,13 +15,17 @@ SELECT * FROM t1; --echo # Transaction trx1 START TRANSACTION; +--disable_ps_protocol # Different number of warnings until WL#6570. INSERT INTO t1 VALUES (2, 2, 3) ON DUPLICATE KEY UPDATE c=VALUES(c); +--enable_ps_protocol COMMIT; --echo # Transaction trx2 START TRANSACTION; +--disable_ps_protocol # Different number of warnings until WL#6570. INSERT INTO t1 VALUES (2, 1, 2) ON DUPLICATE KEY UPDATE c=VALUES(c); INSERT INTO t1 VALUES (2, 3, 4) ON DUPLICATE KEY UPDATE c=VALUES(c); +--enable_ps_protocol COMMIT; --echo # Result: @@ -41,13 +45,17 @@ SELECT * FROM t1; --echo # Transaction trx2 START TRANSACTION; +--disable_ps_protocol # Different number of warnings until WL#6570. INSERT INTO t1 VALUES (2, 1, 2) ON DUPLICATE KEY UPDATE c=VALUES(c); INSERT INTO t1 VALUES (2, 3, 4) ON DUPLICATE KEY UPDATE c=VALUES(c); +--enable_ps_protocol COMMIT; --echo # Transaction trx1 START TRANSACTION; +--disable_ps_protocol # Different number of warnings until WL#6570. INSERT INTO t1 VALUES (2, 2, 3) ON DUPLICATE KEY UPDATE c=VALUES(c); +--enable_ps_protocol COMMIT; --echo # Result: @@ -82,13 +90,17 @@ SELECT * FROM t1; --echo # Transaction trx1: START TRANSACTION; +--disable_ps_protocol # Different number of warnings until WL#6570. INSERT INTO t1 VALUES (2, 1, 2) ON DUPLICATE KEY UPDATE c=VALUES(c); +--enable_ps_protocol SELECT * FROM t1; --echo # Connection other: --connect (other,localhost,root,,test,,) --send +--disable_ps_protocol # Different number of warnings until WL#6570. INSERT INTO t1 VALUES (2, 2, 3) ON DUPLICATE KEY UPDATE c=VALUES(c); +--enable_ps_protocol --echo # Connection default: --connection default @@ -101,7 +113,9 @@ let $wait_condition= --source include/wait_condition.inc +--disable_ps_protocol # Different number of warnings until WL#6570. INSERT INTO t1 VALUES (2, 3, 4) ON DUPLICATE KEY UPDATE c=VALUES(c); +--enable_ps_protocol SELECT * FROM t1; COMMIT; @@ -129,13 +143,17 @@ SELECT * FROM t1; --echo # Transaction trx1 START TRANSACTION; +--disable_ps_protocol # Different number of warnings until WL#6570. INSERT INTO t1 VALUES (2, 2, 3) ON DUPLICATE KEY UPDATE c=VALUES(c); +--enable_ps_protocol COMMIT; --echo # Transaction trx2 START TRANSACTION; +--disable_ps_protocol # Different number of warnings until WL#6570. INSERT INTO t1 VALUES (1, 2, 2) ON DUPLICATE KEY UPDATE c=VALUES(c); INSERT INTO t1 VALUES (3, 2, 4) ON DUPLICATE KEY UPDATE c=VALUES(c); +--enable_ps_protocol COMMIT; --echo # Result: @@ -154,13 +172,17 @@ SELECT * FROM t1; --echo # Transaction trx2 START TRANSACTION; +--disable_ps_protocol # Different number of warnings until WL#6570. INSERT INTO t1 VALUES (1, 2, 2) ON DUPLICATE KEY UPDATE c=VALUES(c); INSERT INTO t1 VALUES (3, 2, 4) ON DUPLICATE KEY UPDATE c=VALUES(c); +--enable_ps_protocol COMMIT; --echo # Transaction trx1 START TRANSACTION; +--disable_ps_protocol # Different number of warnings until WL#6570. INSERT INTO t1 VALUES (2, 2, 3) ON DUPLICATE KEY UPDATE c=VALUES(c); +--enable_ps_protocol COMMIT; --echo # Result: @@ -181,7 +203,9 @@ SELECT * FROM t1; --echo # Transaction trx1: START TRANSACTION; +--disable_ps_protocol # Different number of warnings until WL#6570. INSERT INTO t1 VALUES (1, 2, 2) ON DUPLICATE KEY UPDATE c=VALUES(c); +--enable_ps_protocol SELECT * FROM t1; --echo # Connection other: @@ -194,7 +218,9 @@ COMMIT; --echo # Connection default: --connection default +--disable_ps_protocol # Different number of warnings until WL#6570. INSERT INTO t1 VALUES (3, 2, 4) ON DUPLICATE KEY UPDATE c=VALUES(c); +--enable_ps_protocol COMMIT; --echo # Result: @@ -215,7 +241,9 @@ SELECT * FROM t1; --echo # Connection other: connection other; START TRANSACTION; +--disable_ps_protocol # Different number of warnings until WL#6570. INSERT INTO t1 VALUES(2, 10, 200) ON DUPLICATE KEY UPDATE f3 = 120; +--enable_ps_protocol --echo # Connection default connection default; diff --git a/mysql-test/suite/json/inc/json_functions.inc b/mysql-test/suite/json/inc/json_functions.inc index 0d84862ab0aa..5c45a185a7a5 100644 --- a/mysql-test/suite/json/inc/json_functions.inc +++ b/mysql-test/suite/json/inc/json_functions.inc @@ -3044,6 +3044,7 @@ DROP TABLE t; --echo # JSON should work with INSERT .. ON DUPLICATE KEY UPDATE --echo # CREATE TABLE t(id INT PRIMARY KEY, j JSON); +--disable_ps_protocol # Different number of warnings until WL#6570. INSERT INTO t VALUES (1, '[1]') ON DUPLICATE KEY UPDATE j = JSON_OBJECT("a", VALUES(j)); SELECT * FROM t; @@ -3052,6 +3053,7 @@ ON DUPLICATE KEY UPDATE j = JSON_OBJECT("ab", VALUES(j)); SELECT * FROM t; INSERT INTO t VALUES (1, '[1,2,3]') ON DUPLICATE KEY UPDATE j = JSON_OBJECT("abc", VALUES(j)); +--enable_ps_protocol SELECT * FROM t; DROP TABLE t; diff --git a/mysql-test/suite/json/r/json_functions_innodb.result b/mysql-test/suite/json/r/json_functions_innodb.result index e50cb54978bf..4c257c6ef0cd 100644 --- a/mysql-test/suite/json/r/json_functions_innodb.result +++ b/mysql-test/suite/json/r/json_functions_innodb.result @@ -8538,16 +8538,22 @@ DROP TABLE t; CREATE TABLE t(id INT PRIMARY KEY, j JSON); INSERT INTO t VALUES (1, '[1]') ON DUPLICATE KEY UPDATE j = JSON_OBJECT("a", VALUES(j)); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead SELECT * FROM t; id j 1 [1] INSERT INTO t VALUES (1, '[1,2]') ON DUPLICATE KEY UPDATE j = JSON_OBJECT("ab", VALUES(j)); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead SELECT * FROM t; id j 1 {"ab": [1, 2]} INSERT INTO t VALUES (1, '[1,2,3]') ON DUPLICATE KEY UPDATE j = JSON_OBJECT("abc", VALUES(j)); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead SELECT * FROM t; id j 1 {"abc": [1, 2, 3]} diff --git a/mysql-test/suite/json/r/json_functions_ndb.result b/mysql-test/suite/json/r/json_functions_ndb.result index a6fce0ebe54b..38a1e37c5291 100644 --- a/mysql-test/suite/json/r/json_functions_ndb.result +++ b/mysql-test/suite/json/r/json_functions_ndb.result @@ -8684,16 +8684,22 @@ DROP TABLE t; CREATE TABLE t(id INT PRIMARY KEY, j JSON); INSERT INTO t VALUES (1, '[1]') ON DUPLICATE KEY UPDATE j = JSON_OBJECT("a", VALUES(j)); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead SELECT * FROM t; id j 1 [1] INSERT INTO t VALUES (1, '[1,2]') ON DUPLICATE KEY UPDATE j = JSON_OBJECT("ab", VALUES(j)); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead SELECT * FROM t; id j 1 {"ab": [1, 2]} INSERT INTO t VALUES (1, '[1,2,3]') ON DUPLICATE KEY UPDATE j = JSON_OBJECT("abc", VALUES(j)); +Warnings: +Warning 1287 'VALUES function' is deprecated and will be removed in a future release. Please use an alias (INSERT INTO ... VALUES (...) AS alias) and replace VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col instead SELECT * FROM t; id j 1 {"abc": [1, 2, 3]} diff --git a/mysql-test/suite/x/r/performance_schema_stmt.result b/mysql-test/suite/x/r/performance_schema_stmt.result index 4f994a0c8923..eb6f66af24cb 100644 --- a/mysql-test/suite/x/r/performance_schema_stmt.result +++ b/mysql-test/suite/x/r/performance_schema_stmt.result @@ -28,7 +28,7 @@ INSERT INTO `xtest`.`test` (doc) VALUES ('{\"_id\": \"one\"}') 1 rows affected Query SELECT @@mysqlx_document_id_unique_prefix,@@auto_increment_offset,@@auto_increment_increment -INSERT INTO `xtest`.`test` (doc) VALUES ('{\"_id\": \"two\"}') ON DUPLICATE KEY UPDATE doc = IF(JSON_UNQUOTE(JSON_EXTRACT(doc, '$._id')) = JSON_UNQUOTE(JSON_EXTRACT(VALUES(doc), '$._id')), VALUES(doc), MYSQLX_ERROR(5018)) +INSERT INTO `xtest`.`test` (doc) VALUES ('{\"_id\": \"two\"}') AS _UPSERT_NEW_VALUES_(_NEW_DOC_) ON DUPLICATE KEY UPDATE doc = IF(JSON_UNQUOTE(JSON_EXTRACT(doc, '$._id')) = JSON_UNQUOTE(JSON_EXTRACT(_UPSERT_NEW_VALUES_._NEW_DOC_, '$._id')), _UPSERT_NEW_VALUES_._NEW_DOC_, MYSQLX_ERROR(5018)) 0 rows affected ######### Crud.Update ######### diff --git a/mysql-test/t/func_test.test b/mysql-test/t/func_test.test index 833f9a2ef0d5..b75ae641db9a 100644 --- a/mysql-test/t/func_test.test +++ b/mysql-test/t/func_test.test @@ -359,7 +359,9 @@ DROP TABLE t1; CREATE TABLE t1 (a INT PRIMARY KEY, b BIGINT(20) UNSIGNED); INSERT INTO t1 VALUES (1, 13836376518955650385); +--disable_ps_protocol # Different number of warnings until WL#6570. INSERT INTO t1 VALUES (1, 13836376518955650385) ON DUPLICATE KEY UPDATE b=GREATEST(b, VALUES(b)); +--enable_ps_protocol SELECT * FROM t1; DROP TABLE t1; diff --git a/mysql-test/t/insert.test b/mysql-test/t/insert.test index 051a89d5e669..ad668e3e8e15 100644 --- a/mysql-test/t/insert.test +++ b/mysql-test/t/insert.test @@ -208,7 +208,9 @@ create table t1 (a int, b int); insert into t1 (a,b) values (a,b); insert into t1 SET a=1, b=a+1; insert into t1 (a,b) select 1,2; +--disable_ps_protocol # Different number of warnings until WL#6570. INSERT INTO t1 ( a ) SELECT 0 ON DUPLICATE KEY UPDATE a = a + VALUES (a); +--enable_ps_protocol --error ER_FIELD_SPECIFIED_TWICE prepare stmt1 from ' replace into t1 (a,a) select 100, ''hundred'' '; --error ER_WRONG_VALUE_COUNT_ON_ROW @@ -932,3 +934,16 @@ INSERT INTO t2 FLUSH TABLES; DROP TABLE t1, t2; + +--echo # +--echo # WL#13325: Deprecate VALUES syntax in INSERT ... ON DUPLICATE KEY UPDATE +--echo # +CREATE TABLE t(id INT PRIMARY KEY, x INT); +--disable_ps_protocol # Different number of warnings until WL#6570. +INSERT INTO t VALUES (0, 0) ON DUPLICATE KEY UPDATE x = VALUES(x) + 1; +--enable_ps_protocol +INSERT INTO t VALUES (0, 0) + ON DUPLICATE KEY UPDATE x = (SELECT VALUES(x)+1 FROM t t1); +SELECT VALUES(x) FROM t; +INSERT INTO t VALUES (1, VALUES(x)); +DROP TABLE t; diff --git a/mysql-test/t/insert_select.test b/mysql-test/t/insert_select.test index 36ee05b7a759..d8747c3c5587 100644 --- a/mysql-test/t/insert_select.test +++ b/mysql-test/t/insert_select.test @@ -130,7 +130,9 @@ drop table t1; # with ON DUPLICATE and SELECT create table t1(x int, y int); create table t2(x int, z int); +--disable_ps_protocol # Different number of warnings until WL#6570. insert into t1(x,y) select x,z from t2 on duplicate key update x=values(x); +--enable_ps_protocol --error 1054 insert into t1(x,y) select x,z from t2 on duplicate key update x=values(z); --error 1054 diff --git a/mysql-test/t/insert_update.test b/mysql-test/t/insert_update.test index c35ce4a2e27d..d8e857626c1c 100644 --- a/mysql-test/t/insert_update.test +++ b/mysql-test/t/insert_update.test @@ -22,7 +22,9 @@ INSERT t1 VALUES (5,6,30), (7,4,40), (8,9,60) ON DUPLICATE KEY UPDATE c=c+100; SELECT * FROM t1; INSERT t1 SET a=5 ON DUPLICATE KEY UPDATE b=0; SELECT * FROM t1; +--disable_ps_protocol # Different number of warnings until WL#6570. INSERT t1 VALUES (2,1,11), (7,4,40) ON DUPLICATE KEY UPDATE c=c+VALUES(a); +--enable_ps_protocol SELECT *, VALUES(a) FROM t1; analyze table t1; --replace_regex /[56]/#/ @@ -81,7 +83,9 @@ INSERT t1 SET a=5 ON DUPLICATE KEY UPDATE b=0; SELECT * FROM t1; --error ER_NON_UNIQ_ERROR INSERT t1 SELECT a,b,c FROM t2 WHERE d=2 ON DUPLICATE KEY UPDATE c=c+VALUES(a); +--disable_ps_protocol # Different number of warnings until WL#6570. INSERT t1 SELECT a,b,c FROM t2 WHERE d=2 ON DUPLICATE KEY UPDATE c=t1.c+VALUES(t1.a); +--enable_ps_protocol SELECT *, VALUES(a) FROM t1; DROP TABLE t1; DROP TABLE t2; @@ -99,6 +103,7 @@ CREATE TABLE t1 PRIMARY KEY (a) ); +--disable_ps_protocol # Different number of warnings until WL#6570. INSERT INTO t1 VALUES (45, 1) ON DUPLICATE KEY UPDATE b = IF(VALUES(b) > t1.b, VALUES(b), t1.b); SELECT * FROM t1; @@ -108,6 +113,7 @@ SELECT * FROM t1; INSERT INTO t1 VALUES (45, 1) ON DUPLICATE KEY UPDATE b = IF(VALUES(b) > t1.b, VALUES(b), t1.b); SELECT * FROM t1; +--enable_ps_protocol DROP TABLE t1; @@ -789,8 +795,10 @@ DROP VIEW v; CREATE TABLE insert_2_keys (a INT UNIQUE KEY, b INT UNIQUE KEY); INSERT INTO insert_2_keys values (1, 1); +--disable_ps_protocol # Different number of warnings until WL#6570. INSERT INTO insert_2_keys VALUES (1, 2) ON DUPLICATE KEY UPDATE a= VALUES(a) + 10, b= VALUES(b) + 10; +--enable_ps_protocol SELECT * FROM insert_2_keys; @@ -810,6 +818,7 @@ DROP TABLE insert_2_keys; --echo # json_functions.inc. JSON should work with INSERT .. ON DUPLICATE KEY UPDATE. --echo # Old syntax. CREATE TABLE t(id INT PRIMARY KEY, j JSON); +--disable_ps_protocol # Different number of warnings until WL#6570. INSERT INTO t VALUES (1, '[1]') ON DUPLICATE KEY UPDATE j = JSON_OBJECT("a", VALUES(j)); SELECT * FROM t; @@ -819,6 +828,7 @@ SELECT * FROM t; INSERT INTO t VALUES (1, '[1,2,3]') ON DUPLICATE KEY UPDATE j = JSON_OBJECT("abc", VALUES(j)); SELECT * FROM t; +--enable_ps_protocol DROP TABLE t; --echo # New syntax. @@ -842,8 +852,10 @@ CREATE TABLE t2(a INT PRIMARY KEY, b INT); INSERT INTO t1 VALUES (10); INSERT INTO t2(a, b) VALUES (1, 0); +--disable_ps_protocol # Different number of warnings until WL#6570. INSERT INTO t2(a, b) VALUES (1, 0) ON DUPLICATE KEY UPDATE b= (SELECT VALUES(a) + 2 FROM t1); +--enable_ps_protocol SELECT * FROM t2; @@ -870,8 +882,10 @@ DROP TABLE t2; CREATE TABLE t1(a INT PRIMARY KEY, b INT); INSERT INTO t1 VALUES (1, 2); +--disable_ps_protocol # Different number of warnings until WL#6570. INSERT INTO t1 VALUES (1, 3) ON DUPLICATE KEY UPDATE b= GREATEST(b, VALUES(b)); +--enable_ps_protocol SELECT * FROM t1; @@ -892,11 +906,13 @@ DROP TABLE t1; --echo # Old syntax. CREATE TABLE t1 (a INT, b BLOB, UNIQUE KEY(a)); +--disable_ps_protocol # Different number of warnings until WL#6570. INSERT INTO t1 SET b='11', a=0 ON DUPLICATE KEY UPDATE b= VALUES(a), a= values(b); INSERT INTO t1 SET b='11', a=0 ON DUPLICATE KEY UPDATE b= VALUES(a), a= values(b); +--enable_ps_protocol SELECT * FROM t1; @@ -920,8 +936,10 @@ DROP TABLE t1; CREATE TABLE t1(id INT NOT NULL, text1 TEXT, text2 TEXT, PRIMARY KEY (id)); INSERT INTO t1 VALUES (0, "x", "x"), (1, "y", "y"); +--disable_ps_protocol # Different number of warnings until WL#6570. INSERT INTO t1 (id, text1, text2) VALUES (0, "x", "y") ON DUPLICATE KEY UPDATE text1 = VALUES(text1), text2 = VALUES(text2); +--enable_ps_protocol SELECT * FROM t1; @@ -950,4 +968,4 @@ ON DUPLICATE KEY UPDATE vc= 199; SELECT * FROM t0; DROP TABLE t0; -DROP VIEW v; \ No newline at end of file +DROP VIEW v; diff --git a/mysql-test/t/insert_update_myisam.test b/mysql-test/t/insert_update_myisam.test index c737d902a3f2..8a41e2d8b65e 100644 --- a/mysql-test/t/insert_update_myisam.test +++ b/mysql-test/t/insert_update_myisam.test @@ -29,7 +29,9 @@ CREATE TABLE t1 ( PRIMARY KEY (a) ) ENGINE=MyISAM; +--disable_ps_protocol # Different number of warnings until WL#6570. INSERT INTO t1 ( a ) SELECT 0 ON DUPLICATE KEY UPDATE a = a + VALUES (a) ; +--enable_ps_protocol DROP TABLE t1; diff --git a/mysql-test/t/roles_bugs.test b/mysql-test/t/roles_bugs.test index ae89338044d3..a550e11b73b8 100644 --- a/mysql-test/t/roles_bugs.test +++ b/mysql-test/t/roles_bugs.test @@ -90,7 +90,9 @@ DELIMITER ;$$ --connect(my_user_con, localhost, my_user,,,) INSERT into my_db.t1 values(5); --echo # Inserts are now allowed if grants are given through role +--disable_ps_protocol # Different number of warnings until WL#6570. INSERT into my_db.t1 values(8) on duplicate key UPDATE id = values(id) + 800; +--enable_ps_protocol CALL my_db.foo_proc(); CALL my_db.baz_proc(); diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test index 706d16374e94..ba5282b7e974 100644 --- a/mysql-test/t/trigger.test +++ b/mysql-test/t/trigger.test @@ -1564,9 +1564,11 @@ DELIMITER ;| INSERT INTO t1(val) VALUES ('test1'),('test2'); SELECT * FROM t1; SELECT * FROM t2; +--disable_ps_protocol # Different number of warnings until WL#6570. INSERT INTO t1 VALUES (2,'test2') ON DUPLICATE KEY UPDATE val=VALUES(val); INSERT INTO t1 VALUES (2,'test3') ON DUPLICATE KEY UPDATE val=VALUES(val); INSERT INTO t1 VALUES (3,'test4') ON DUPLICATE KEY UPDATE val=VALUES(val); +--enable_ps_protocol SELECT * FROM t1; SELECT * FROM t2; DROP TRIGGER trg27006_a_insert; diff --git a/mysql-test/t/type_blob.test b/mysql-test/t/type_blob.test index 5c6062d9342b..15ef9242c636 100644 --- a/mysql-test/t/type_blob.test +++ b/mysql-test/t/type_blob.test @@ -847,8 +847,10 @@ CREATE TABLE t1 (c1 INTEGER PRIMARY KEY, c2 TEXT, c3 INTEGER); INSERT INTO t1(c1) VALUES(0); +--disable_ps_protocol # Different number of warnings until WL#6570. INSERT INTO t1(c1) VALUES(0) ON DUPLICATE KEY UPDATE c2 = VALUES(c2), c3 = NULL; +--enable_ps_protocol SELECT * FROM t1; DROP TABLE t1; diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index bc48f6e80305..61ea44b5614e 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -1433,7 +1433,9 @@ insert into v3(b) values (10); insert into v3(a) select a from t2; --error ER_BAD_NULL_ERROR insert into v3(b) select b from t2; +--disable_ps_protocol # Different number of warnings until WL#6570. insert into v3(a) values (1) on duplicate key update a=a+10000+VALUES(a); +--enable_ps_protocol --sorted_result select * from t1; --sorted_result diff --git a/mysql-test/t/view_myisam.test b/mysql-test/t/view_myisam.test index c73c8f4b348e..6754299ab85d 100644 --- a/mysql-test/t/view_myisam.test +++ b/mysql-test/t/view_myisam.test @@ -45,7 +45,9 @@ insert into v3(a) values (1); insert into v3(b) values (10); insert into v3(a) select a from t2; insert into v3(b) select b from t2; +--disable_ps_protocol # Different number of warnings until WL#6570. insert into v3(a) values (1) on duplicate key update a=a+10000+VALUES(a); +--enable_ps_protocol select * from t1 ; select * from t2 ; # try delete from join view diff --git a/plugin/x/src/insert_statement_builder.cc b/plugin/x/src/insert_statement_builder.cc index 7079c7093ce8..ca5b68147580 100644 --- a/plugin/x/src/insert_statement_builder.cc +++ b/plugin/x/src/insert_statement_builder.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2.0, @@ -132,10 +132,12 @@ void Insert_statement_builder::add_upsert(const bool is_relational) const { ER_X_BAD_INSERT_DATA, "Unable update on duplicate key for TABLE data model"); m_builder.put( + " AS _UPSERT_NEW_VALUES_(_NEW_DOC_)" " ON DUPLICATE KEY UPDATE" " doc = IF(JSON_UNQUOTE(JSON_EXTRACT(doc, '$._id'))" - " = JSON_UNQUOTE(JSON_EXTRACT(VALUES(doc), '$._id'))," - " VALUES(doc), MYSQLX_ERROR(" STRINGIFY_ARG(ER_X_BAD_UPSERT_DATA) "))"); + " = JSON_UNQUOTE(JSON_EXTRACT(_UPSERT_NEW_VALUES_._NEW_DOC_, '$._id'))," + " _UPSERT_NEW_VALUES_._NEW_DOC_, MYSQLX_ERROR(" STRINGIFY_ARG( + ER_X_BAD_UPSERT_DATA) "))"); } bool Insert_statement_builder::add_document_literal( diff --git a/share/messages_to_clients.txt b/share/messages_to_clients.txt index 2517ec2b803a..097f4d395bca 100644 --- a/share/messages_to_clients.txt +++ b/share/messages_to_clients.txt @@ -9293,6 +9293,11 @@ ER_WARN_DEPRECATED_JSON_TABLE_ON_ERROR_ON_EMPTY ER_WARN_DEPRECATED_INNER_INTO eng "The INTO clause is deprecated inside query blocks of query expressions and will be removed in a future release. Please move the INTO clause to the end of statement instead." + +# When using this error message, use the ER_WARN_DEPRECATED_SYNTAX error code. +ER_WARN_DEPRECATED_VALUES_FUNCTION_ALWAYS_NULL + eng "The VALUES function is deprecated and will be removed in a future release. It always returns NULL in this context. If you meant to access a value from the VALUES clause of the INSERT statement, consider using an alias (INSERT INTO ... VALUES (...) AS alias) and reference alias.col instead of VALUES(col) in the ON DUPLICATE KEY UPDATE clause." + # # End of 8.0 error messages (server-to-client). # Do NOT add messages intended for the error log above! diff --git a/sql/item.cc b/sql/item.cc index 1e8e76111c3d..7da372f3dd71 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -8155,12 +8155,31 @@ bool Item_insert_value::fix_fields(THD *thd, Item **reference) { } set_field(def_field); + + // The VALUES function is deprecated. + if (m_is_values_function) + push_deprecated_warn( + thd, "VALUES function", + "an alias (INSERT INTO ... VALUES (...) AS alias) and replace " + "VALUES(col) in the ON DUPLICATE KEY UPDATE clause with alias.col"); } else { // VALUES() is used out-of-scope - its value is always NULL Prepared_stmt_arena_holder ps_arena_holder(thd); Item *const item = new Item_null(this->item_name); if (!item) return true; *reference = item; + + // The VALUES function is deprecated. It always returns NULL in this + // context, but if it is inside an ON DUPLICATE KEY UPDATE clause, the user + // probably meant something else. In that case, suggest an alternative + // syntax which doesn't always return NULL. + DBUG_ASSERT(m_is_values_function); + if (thd->lex->in_update_value_clause) { + push_warning(thd, Sql_condition::SL_WARNING, ER_WARN_DEPRECATED_SYNTAX, + ER_THD(thd, ER_WARN_DEPRECATED_VALUES_FUNCTION_ALWAYS_NULL)); + } else { + push_deprecated_warn_no_replacement(thd, "VALUES function"); + } } return false; } diff --git a/sql/item.h b/sql/item.h index 8e1d69363951..7f6489395716 100644 --- a/sql/item.h +++ b/sql/item.h @@ -5565,10 +5565,24 @@ class Item_insert_value final : public Item_field { public: Item *arg; + + /** + Constructs an Item_insert_value that represents a call to the deprecated + VALUES function. + */ Item_insert_value(const POS &pos, Item *a) - : Item_field(pos, nullptr, nullptr, nullptr), arg(a) {} + : Item_field(pos, nullptr, nullptr, nullptr), + arg(a), + m_is_values_function(true) {} + + /** + Constructs an Item_insert_value that represents a derived table that wraps a + table value constructor. + */ Item_insert_value(Name_resolution_context *context_arg, Item *a) - : Item_field(context_arg, nullptr, nullptr, nullptr), arg(a) {} + : Item_field(context_arg, nullptr, nullptr, nullptr), + arg(a), + m_is_values_function(false) {} bool itemize(Parse_context *pc, Item **res) override { if (skip_itemize(res)) return false; @@ -5597,6 +5611,14 @@ class Item_insert_value final : public Item_field { func_arg->banned_function_name = "values"; return true; } + + private: + /** + This flag is true if the item represents a call to the deprecated VALUES + function. It is false if the item represents a derived table that wraps a + table value constructor. + */ + const bool m_is_values_function; }; /** diff --git a/unittest/gunit/xplugin/xpl/insert_statement_builder_t.cc b/unittest/gunit/xplugin/xpl/insert_statement_builder_t.cc index acdd7c5414f6..0e507ca738bd 100644 --- a/unittest/gunit/xplugin/xpl/insert_statement_builder_t.cc +++ b/unittest/gunit/xplugin/xpl/insert_statement_builder_t.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2.0, @@ -177,10 +177,11 @@ TEST_F(Insert_statement_builder_test, add_projection_document_one_item) { TEST_F(Insert_statement_builder_test, add_upsert) { ASSERT_NO_THROW(builder().add_upsert(k_dm_document)); EXPECT_STREQ( + " AS _UPSERT_NEW_VALUES_(_NEW_DOC_)" " ON DUPLICATE KEY UPDATE" " doc = IF(JSON_UNQUOTE(JSON_EXTRACT(doc, '$._id'))" - " = JSON_UNQUOTE(JSON_EXTRACT(VALUES(doc), '$._id'))," - " VALUES(doc), MYSQLX_ERROR(5018))", + " = JSON_UNQUOTE(JSON_EXTRACT(_UPSERT_NEW_VALUES_._NEW_DOC_, '$._id'))," + " _UPSERT_NEW_VALUES_._NEW_DOC_, MYSQLX_ERROR(5018))", query.get().c_str()); ASSERT_THROW(builder().add_upsert(k_dm_table), ngs::Error_code); } @@ -213,10 +214,11 @@ TEST_F(Insert_statement_builder_test, build_document_upsert) { EXPECT_STREQ( "INSERT INTO `xtest`.`xcoll` (doc) VALUES " "('" EXPECT_DOC_EXAMPLE1 "'),('" EXPECT_DOC_EXAMPLE2 - "') ON DUPLICATE KEY UPDATE" + "') AS _UPSERT_NEW_VALUES_(_NEW_DOC_)" + " ON DUPLICATE KEY UPDATE" " doc = IF(JSON_UNQUOTE(JSON_EXTRACT(doc, '$._id'))" - " = JSON_UNQUOTE(JSON_EXTRACT(VALUES(doc), '$._id'))," - " VALUES(doc), MYSQLX_ERROR(5018))", + " = JSON_UNQUOTE(JSON_EXTRACT(_UPSERT_NEW_VALUES_._NEW_DOC_, '$._id'))," + " _UPSERT_NEW_VALUES_._NEW_DOC_, MYSQLX_ERROR(5018))", query.get().c_str()); }