Skip to content

Commit

Permalink
WL#13325: Deprecate VALUES syntax in INSERT ... ON DUPLICATE KEY UPDATE
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kahatlen committed Jan 30, 2020
1 parent 455cc9c commit 6f3b9df
Show file tree
Hide file tree
Showing 37 changed files with 301 additions and 13 deletions.
8 changes: 8 additions & 0 deletions mysql-test/include/mix1.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand Down
2 changes: 2 additions & 0 deletions mysql-test/r/errors.result
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions mysql-test/r/func_test.result
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions mysql-test/r/insert.result
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
2 changes: 2 additions & 0 deletions mysql-test/r/insert_select.result
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
41 changes: 41 additions & 0 deletions mysql-test/r/insert_update.result
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,31 @@ 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
3 4 127 NULL
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
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);
Expand Down Expand Up @@ -163,13 +169,17 @@ 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
3 4 127 NULL
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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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]}
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions mysql-test/r/insert_update_myisam.result
Original file line number Diff line number Diff line change
Expand Up @@ -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` (
Expand Down
6 changes: 6 additions & 0 deletions mysql-test/r/roles_bugs.result
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions mysql-test/r/roles_bugs_debug.result
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions mysql-test/r/trigger.result
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions mysql-test/r/type_blob.result
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions mysql-test/r/view.result
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions mysql-test/r/view_myisam.result
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions mysql-test/suite/binlog_nogtid/r/binlog_unsafe.result
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions mysql-test/suite/binlog_nogtid/t/binlog_unsafe.test
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading

0 comments on commit 6f3b9df

Please sign in to comment.