List:Commits« Previous MessageNext Message »
From:<gshchepa Date:July 13 2007 10:07pm
Subject:bk commit into 5.0 tree (gshchepa:1.2533) BUG#29480
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of uchum. When uchum 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-07-14 03:07:33+05:00, gshchepa@stripped +3 -0
  Fixed bug #29480.
  To repeat this bug the value of the global sql_mode variable
  should be set to STRICT_TRANS_TABLES. Also some of table fields
  have to be defined as NOT NULL without the default values.
  After the first successful INSERT into that table, next statement
  should be INSERT or INSERT SELECT with an implicit assignment
  to some field defined without default value.
  The last statement hung instead of the error reporting.
  
  Definition of the `STRICT_TRANS_TABLES' mode:
   For non-transactional storage engines, a statement aborts if the
   error occurs in the first row to be inserted or updated. (When the
   error occurs in the first row, the statement can be aborted to
   leave the table unchanged, just as for a transactional table.)
   Errors in rows after the first do not abort the statement, because
   the table has already been changed by the first row. Instead, bad
   data values are adjusted and result in warnings rather than
   errors. In other words, with `STRICT_TRANS_TABLES', a wrong value
   causes MySQL to roll back all updates done so far, if that can be
   done without changing the table. But once the table has been
   changed, further errors result in adjustments and warnings.
  
  The write_record functions sets the thd->no_trans_update.stmt flag
  value to TRUE after the successful insert into a table.
  This flag is used by multi-insert statements to ignore "default
  value" errors during all subsequent inserts of that multi-insert
  statement.
  
  However, this flag was not reset to FALSE after the completion of
  the invocation of an INSERT statement, and the next INSERT or
  INSERT SELECT statement called neither send_ok nor net_send_error
  function in case of "default value" error.

  mysql-test/r/insert.result@stripped, 2007-07-14 03:05:10+05:00, gshchepa@stripped +17 -0
    Updated test case for bug #29480.

  mysql-test/t/insert.test@stripped, 2007-07-14 03:04:53+05:00, gshchepa@stripped +22 -0
    Updated test case for bug #29480.

  sql/sql_insert.cc@stripped, 2007-07-14 03:04:42+05:00, gshchepa@stripped +7 -5
    Fixed bug #29480.
    The mysql_insert and the select_insert::prepare functions have been changed
    to reset the thd->no_trans_update.stmt flag to the FALSE value before the
    call to the check_that_all_fields_are_given_values function.

diff -Nrup a/mysql-test/r/insert.result b/mysql-test/r/insert.result
--- a/mysql-test/r/insert.result	2007-05-30 17:04:02 +05:00
+++ b/mysql-test/r/insert.result	2007-07-14 03:05:10 +05:00
@@ -461,4 +461,21 @@ i
 2
 2
 DROP TABLE t1, t2;
+SET @tmp=@@sql_mode;
+SET sql_mode='STRICT_TRANS_TABLES';
+CREATE TABLE t1 (c1 INT, c2 INT NOT NULL);
+INSERT INTO t1 (c1, c2) VALUES (1, 2);
+INSERT INTO t1 (c1)     VALUES (3);
+ERROR HY000: Field 'c2' doesn't have a default value
+SHOW WARNINGS;
+Level	Code	Message
+Error	1364	Field 'c2' doesn't have a default value
+INSERT INTO t1 (c1)     SELECT 4;
+ERROR HY000: Field 'c2' doesn't have a default value
+SHOW WARNINGS;
+Level	Code	Message
+Error	1364	Field 'c2' doesn't have a default value
+Warning	1196	Some non-transactional changed tables couldn't be rolled back
+SET sql_mode=@tmp;
+DROP TABLE t1;
 End of 5.0 tests.
diff -Nrup a/mysql-test/t/insert.test b/mysql-test/t/insert.test
--- a/mysql-test/t/insert.test	2007-05-16 10:51:03 +05:00
+++ b/mysql-test/t/insert.test	2007-07-14 03:04:53 +05:00
@@ -353,5 +353,27 @@ SELECT * FROM t2;
 
 DROP TABLE t1, t2;
 
+#
+# BUG#29480: Under sql_mode=STRICT_TRANS_TABLES the second
+# INSERT/INSERT ... SELECT stmt hangs on the implicit assignment
+# to a field without a default value.
+#
+
+SET @tmp=@@sql_mode;
+SET sql_mode='STRICT_TRANS_TABLES';
+
+CREATE TABLE t1 (c1 INT, c2 INT NOT NULL);
+
+INSERT INTO t1 (c1, c2) VALUES (1, 2);
+--error 1364
+INSERT INTO t1 (c1)     VALUES (3);
+SHOW WARNINGS;
+--error 1364
+INSERT INTO t1 (c1)     SELECT 4;
+SHOW WARNINGS;
+
+SET sql_mode=@tmp;
+DROP TABLE t1;
+
 --echo End of 5.0 tests.
 
diff -Nrup a/sql/sql_insert.cc b/sql/sql_insert.cc
--- a/sql/sql_insert.cc	2007-07-06 21:00:08 +05:00
+++ b/sql/sql_insert.cc	2007-07-14 03:04:42 +05:00
@@ -620,6 +620,12 @@ bool mysql_insert(THD *thd,TABLE_LIST *t
   values= its++;
   value_count= values->elements;
 
+  thd->no_trans_update.stmt= FALSE;
+  thd->abort_on_warning= (!ignore && (thd->variables.sql_mode &
+                                       (MODE_STRICT_TRANS_TABLES |
+                                        MODE_STRICT_ALL_TABLES)));
+
+
   if (mysql_prepare_insert(thd, table_list, table, fields, values,
 			   update_fields, update_values, duplic, &unused_conds,
                            FALSE,
@@ -732,11 +738,6 @@ bool mysql_insert(THD *thd,TABLE_LIST *t
   if (lock_type != TL_WRITE_DELAYED && !thd->prelocked_mode)
     table->file->start_bulk_insert(values_list.elements);
 
-  thd->no_trans_update.stmt= FALSE;
-  thd->abort_on_warning= (!ignore && (thd->variables.sql_mode &
-                                       (MODE_STRICT_TRANS_TABLES |
-                                        MODE_STRICT_ALL_TABLES)));
-
   prepare_triggers_for_insert_stmt(thd, table, duplic);
 
   if (table_list->prepare_where(thd, 0, TRUE) ||
@@ -2654,6 +2655,7 @@ select_insert::prepare(List<Item> &value
     thd->abort_on_warning= !info.ignore && (thd->variables.sql_mode &
                                             (MODE_STRICT_TRANS_TABLES |
                                              MODE_STRICT_ALL_TABLES));
+    thd->no_trans_update.stmt= FALSE;
     res= check_that_all_fields_are_given_values(thd, table_list->table, 
                                                 table_list);
     thd->abort_on_warning= saved_abort_on_warning;
Thread
bk commit into 5.0 tree (gshchepa:1.2533) BUG#29480gshchepa13 Jul