List:Commits« Previous MessageNext Message »
From:kpettersson Date:August 23 2007 8:22am
Subject:bk commit into 5.0 tree (thek:1.2512) BUG#27358
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of thek. When thek does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-08-23 10:22:20+02:00, thek@adventure.(none) +3 -0
  Bug#27358 INSERT DELAYED does not honour SQL_MODE of the client
  
  SQL_MODE was ignored when a client issued INSERT DELAYED.
  
  Some system settings weren't copied as intended when a record was saved for
  a delayed insert. 

  mysql-test/r/delayed.result@stripped, 2007-08-23 10:22:18+02:00, thek@adventure.(none) +29 -0
    Added test case

  mysql-test/t/delayed.test@stripped, 2007-08-23 10:22:18+02:00, thek@adventure.(none) +31 -0
    Added test case

  sql/sql_insert.cc@stripped, 2007-08-23 10:22:18+02:00, thek@adventure.(none) +8 -0
    - Added two new variables (sql_mode, auto_increment_field_not_null) to support
      SQL_MODE in INSERT DELAYED statements.

diff -Nrup a/mysql-test/r/delayed.result b/mysql-test/r/delayed.result
--- a/mysql-test/r/delayed.result	2007-03-20 14:53:54 +01:00
+++ b/mysql-test/r/delayed.result	2007-08-23 10:22:18 +02:00
@@ -255,3 +255,32 @@ CREATE TABLE t2(c1 INT) ENGINE=MERGE UNI
 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 -Nrup a/mysql-test/t/delayed.test b/mysql-test/t/delayed.test
--- a/mysql-test/t/delayed.test	2007-03-20 14:53:54 +01:00
+++ b/mysql-test/t/delayed.test	2007-08-23 10:22:18 +02:00
@@ -251,4 +251,35 @@ CREATE TABLE t2(c1 INT) ENGINE=MERGE UNI
 --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 -Nrup a/sql/sql_insert.cc b/sql/sql_insert.cc
--- a/sql/sql_insert.cc	2007-07-30 17:27:30 +02:00
+++ b/sql/sql_insert.cc	2007-08-23 10:22:18 +02:00
@@ -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,
   /* 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;
Thread
bk commit into 5.0 tree (thek:1.2512) BUG#27358kpettersson23 Aug
  • Re: bk commit into 5.0 tree (thek:1.2512) BUG#27358Konstantin Osipov7 Sep