diff options
-rw-r--r-- | mysql-test/r/bdb_notembedded.result | 35 | ||||
-rw-r--r-- | mysql-test/r/delayed.result | 29 | ||||
-rw-r--r-- | mysql-test/t/bdb_notembedded.test | 38 | ||||
-rw-r--r-- | mysql-test/t/delayed.test | 31 | ||||
-rw-r--r-- | sql/sql_insert.cc | 8 |
5 files changed, 68 insertions, 73 deletions
diff --git a/mysql-test/r/bdb_notembedded.result b/mysql-test/r/bdb_notembedded.result deleted file mode 100644 index 14cb5fad915..00000000000 --- a/mysql-test/r/bdb_notembedded.result +++ /dev/null @@ -1,35 +0,0 @@ -set autocommit=1; -reset master; -create table bug16206 (a int); -insert into bug16206 values(1); -start transaction; -insert into bug16206 values(2); -commit; -show binlog events; -Log_name Pos Event_type Server_id End_log_pos Info -f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4 -f n Query 1 n use `test`; create table bug16206 (a int) -f n Query 1 n use `test`; insert into bug16206 values(1) -f n Query 1 n use `test`; insert into bug16206 values(2) -drop table bug16206; -reset master; -create table bug16206 (a int) engine= bdb; -insert into bug16206 values(0); -insert into bug16206 values(1); -start transaction; -insert into bug16206 values(2); -commit; -insert into bug16206 values(3); -show binlog events; -Log_name Pos Event_type Server_id End_log_pos Info -f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4 -f n Query 1 n use `test`; create table bug16206 (a int) engine= bdb -f n Query 1 n use `test`; insert into bug16206 values(0) -f n Query 1 n use `test`; insert into bug16206 values(1) -f n Query 1 n use `test`; BEGIN -f n Query 1 n use `test`; insert into bug16206 values(2) -f n Query 1 n use `test`; COMMIT -f n Query 1 n use `test`; insert into bug16206 values(3) -drop table bug16206; -set autocommit=0; -End of 5.0 tests diff --git a/mysql-test/r/delayed.result b/mysql-test/r/delayed.result index b37679847be..5b56a6e27bc 100644 --- a/mysql-test/r/delayed.result +++ b/mysql-test/r/delayed.result @@ -255,3 +255,32 @@ CREATE TABLE t2(c1 INT) ENGINE=MERGE UNION=(t1); INSERT DELAYED INTO t2 VALUES(1); ERROR HY000: Table storage engine for 't2' doesn't have this option DROP TABLE t1, t2; +DROP TABLE IF EXISTS t1,t2; +SET SQL_MODE='NO_AUTO_VALUE_ON_ZERO'; +CREATE TABLE `t1` ( +`id` int(11) PRIMARY KEY auto_increment, +`f1` varchar(10) NOT NULL UNIQUE +); +INSERT DELAYED INTO t1 VALUES(0,"test1"); +SELECT * FROM t1; +id f1 +0 test1 +SET SQL_MODE='PIPES_AS_CONCAT'; +INSERT DELAYED INTO t1 VALUES(0,'a' || 'b'); +SELECT * FROM t1; +id f1 +0 test1 +1 ab +SET SQL_MODE='ERROR_FOR_DIVISION_BY_ZERO,STRICT_ALL_TABLES'; +INSERT DELAYED INTO t1 VALUES(mod(1,0),"test3"); +ERROR 22012: Division by 0 +CREATE TABLE t2 ( +`id` int(11) PRIMARY KEY auto_increment, +`f1` date +); +SET SQL_MODE='NO_ZERO_DATE,STRICT_ALL_TABLES,NO_ZERO_IN_DATE'; +INSERT DELAYED INTO t2 VALUES (0,'0000-00-00'); +ERROR 22007: Incorrect date value: '0000-00-00' for column 'f1' at row 1 +INSERT DELAYED INTO t2 VALUES (0,'2007-00-00'); +ERROR 22007: Incorrect date value: '2007-00-00' for column 'f1' at row 1 +DROP TABLE t1,t2; diff --git a/mysql-test/t/bdb_notembedded.test b/mysql-test/t/bdb_notembedded.test deleted file mode 100644 index 24e64ebbfb2..00000000000 --- a/mysql-test/t/bdb_notembedded.test +++ /dev/null @@ -1,38 +0,0 @@ --- source include/not_embedded.inc --- source include/have_bdb.inc - -# -# Bug #16206: Superfluous COMMIT event in binlog when updating BDB in autocommit mode -# -set autocommit=1; - -let $VERSION=`select version()`; - -reset master; -create table bug16206 (a int); -insert into bug16206 values(1); -start transaction; -insert into bug16206 values(2); -commit; ---replace_result $VERSION VERSION ---replace_column 1 f 2 n 5 n -show binlog events; -drop table bug16206; - -reset master; -create table bug16206 (a int) engine= bdb; -insert into bug16206 values(0); -insert into bug16206 values(1); -start transaction; -insert into bug16206 values(2); -commit; -insert into bug16206 values(3); ---replace_result $VERSION VERSION ---replace_column 1 f 2 n 5 n -show binlog events; -drop table bug16206; - -set autocommit=0; - - ---echo End of 5.0 tests diff --git a/mysql-test/t/delayed.test b/mysql-test/t/delayed.test index 13615c8c269..505556998be 100644 --- a/mysql-test/t/delayed.test +++ b/mysql-test/t/delayed.test @@ -251,4 +251,35 @@ CREATE TABLE t2(c1 INT) ENGINE=MERGE UNION=(t1); --error 1031 INSERT DELAYED INTO t2 VALUES(1); DROP TABLE t1, t2; +# +# Bug#27358 INSERT DELAYED does not honour SQL_MODE of the client +# +--disable_warnings +DROP TABLE IF EXISTS t1,t2; +--enable_warnings +SET SQL_MODE='NO_AUTO_VALUE_ON_ZERO'; +CREATE TABLE `t1` ( + `id` int(11) PRIMARY KEY auto_increment, + `f1` varchar(10) NOT NULL UNIQUE +); +INSERT DELAYED INTO t1 VALUES(0,"test1"); +sleep 1; +SELECT * FROM t1; +SET SQL_MODE='PIPES_AS_CONCAT'; +INSERT DELAYED INTO t1 VALUES(0,'a' || 'b'); +sleep 1; +SELECT * FROM t1; +SET SQL_MODE='ERROR_FOR_DIVISION_BY_ZERO,STRICT_ALL_TABLES'; +--error 1365 +INSERT DELAYED INTO t1 VALUES(mod(1,0),"test3"); +CREATE TABLE t2 ( + `id` int(11) PRIMARY KEY auto_increment, + `f1` date +); +SET SQL_MODE='NO_ZERO_DATE,STRICT_ALL_TABLES,NO_ZERO_IN_DATE'; +--error ER_TRUNCATED_WRONG_VALUE +INSERT DELAYED INTO t2 VALUES (0,'0000-00-00'); +--error ER_TRUNCATED_WRONG_VALUE +INSERT DELAYED INTO t2 VALUES (0,'2007-00-00'); +DROP TABLE t1,t2; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 5edce08e481..07f2ed8694e 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1587,6 +1587,8 @@ public: ulonglong next_insert_id; ulong auto_increment_increment; ulong auto_increment_offset; + ulong sql_mode; + bool auto_increment_field_not_null; timestamp_auto_set_type timestamp_field_type; uint query_length; @@ -2048,6 +2050,9 @@ int write_delayed(THD *thd,TABLE *table,enum_duplicates duplic, bool ignore, /* The session variable settings can always be copied. */ row->auto_increment_increment= thd->variables.auto_increment_increment; row->auto_increment_offset= thd->variables.auto_increment_offset; + row->sql_mode= thd->variables.sql_mode; + row->auto_increment_field_not_null= table->auto_increment_field_not_null; + /* Next insert id must be set for the first value in a multi-row insert only. So clear it after the first use. Assume a multi-row insert. @@ -2436,10 +2441,13 @@ bool Delayed_insert::handle_inserts(void) thd.last_insert_id_used=row->last_insert_id_used; thd.insert_id_used=row->insert_id_used; table->timestamp_field_type= row->timestamp_field_type; + table->auto_increment_field_not_null= row->auto_increment_field_not_null; /* The session variable settings can always be copied. */ thd.variables.auto_increment_increment= row->auto_increment_increment; thd.variables.auto_increment_offset= row->auto_increment_offset; + thd.variables.sql_mode= row->sql_mode; + /* Next insert id must be used only if non-zero. */ if (row->next_insert_id) thd.next_insert_id= row->next_insert_id; |