diff options
author | unknown <gshchepa/uchum@gleb.loc> | 2007-05-11 03:17:05 +0500 |
---|---|---|
committer | unknown <gshchepa/uchum@gleb.loc> | 2007-05-11 03:17:05 +0500 |
commit | 361905687e473a71083c5d3c69f3b939943cce7c (patch) | |
tree | 2a5e5eab8d8320caa2167e039b0e9d304ef309af /mysql-test/t/insert_update.test | |
parent | 184cc3b5fa723e81236c34a2e60c1b5fc0a37406 (diff) | |
download | mariadb-git-361905687e473a71083c5d3c69f3b939943cce7c.tar.gz |
Fixed bug #28000.
Bug occurs in INSERT IGNORE ... SELECT ... ON DUPLICATE KEY UPDATE
statements, when SELECT returns duplicated values and UPDATE clause
tries to assign NULL values to NOT NULL fields.
NOTE: By current design MySQL server treats INSERT IGNORE ... ON
DUPLICATE statements as INSERT ... ON DUPLICATE with update of
duplicated records, but MySQL manual lacks this information.
After this fix such behaviour becomes legalized.
The write_record() function was returning error values even within
INSERT IGNORE, because ignore_errors parameter of
the fill_record_n_invoke_before_triggers() function call was
always set to FALSE. FALSE is replaced by info->ignore.
sql/sql_insert.cc:
Fixed bug #28000:
The write_record() function was returning error values even within
INSERT IGNORE, because ignore_errors parameter of
the fill_record_n_invoke_before_triggers() function call was
always set to FALSE. FALSE is replaced by info->ignore.
mysql-test/t/insert_update.test:
Added test case for bug #28000.
mysql-test/r/insert_update.result:
Added test case for bug #28000.
Diffstat (limited to 'mysql-test/t/insert_update.test')
-rw-r--r-- | mysql-test/t/insert_update.test | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/mysql-test/t/insert_update.test b/mysql-test/t/insert_update.test index 0e199dab4bd..725fbdb25d7 100644 --- a/mysql-test/t/insert_update.test +++ b/mysql-test/t/insert_update.test @@ -264,3 +264,29 @@ INSERT INTO t1 (c1) VALUES ('A'), ('X'), ('Y'), ('Z') ON DUPLICATE KEY UPDATE cnt=cnt+1; SELECT * FROM t1; DROP TABLE t1; + +# +# Bug#28000: INSERT IGNORE ... SELECT ... ON DUPLICATE +# with erroneous UPDATE: NOT NULL field with NULL value. +# +CREATE TABLE t1 ( + id INT AUTO_INCREMENT PRIMARY KEY, + c1 INT NOT NULL, + cnt INT DEFAULT 1 +); +INSERT INTO t1 (id,c1) VALUES (1,10); +SELECT * FROM t1; +CREATE TABLE t2 (id INT, c1 INT); +INSERT INTO t2 VALUES (1,NULL), (2,2); +--error 1048 +INSERT INTO t1 (id,c1) SELECT 1,NULL + ON DUPLICATE KEY UPDATE c1=NULL; +SELECT * FROM t1; +INSERT IGNORE INTO t1 (id,c1) SELECT 1,NULL + ON DUPLICATE KEY UPDATE c1=NULL, cnt=cnt+1; +SELECT * FROM t1; +INSERT IGNORE INTO t1 (id,c1) SELECT * FROM t2 + ON DUPLICATE KEY UPDATE c1=NULL, cnt=cnt+1; +SELECT * FROM t1; + +DROP TABLE t1; |