List:Commits« Previous MessageNext Message »
From:Dmitry Shulga Date:August 29 2012 5:44am
Subject:bzr push into mysql-trunk branch (Dmitry.Shulga:4199 to 4200) WL#6030
View as plain text  
 4200 Dmitry Shulga	2012-08-29
      Follow-up for WL#6030.
      
      It's reverted changes related to warning about
      statement INSERT if not all columns are specified 
      in the clause VALUES and there is a trigger that sets
      the missed collumns to some values.

    modified:
      mysql-test/r/wl6030.result
      sql/sql_insert.cc
 4199 Alexander Nozdrin	2012-08-27
      WL#6030: The BEFORE triggers are not processed for NOT NULL columns.
      
      - Review comments (applied)
      - Added a new test case (it doesn't pass yet)
      - Updated wl6030.dat to include \N

    modified:
      mysql-test/r/wl6030.result
      mysql-test/std_data/wl6030.dat
      mysql-test/t/wl6030.test
      sql/field.cc
      sql/field.h
      sql/sql_base.cc
      sql/sql_insert.cc
      sql/sql_load.cc
      sql/sql_trigger.cc
=== modified file 'mysql-test/r/wl6030.result'
--- a/mysql-test/r/wl6030.result	2012-08-27 07:05:07 +0000
+++ b/mysql-test/r/wl6030.result	2012-08-29 05:42:56 +0000
@@ -122,6 +122,8 @@ SET NEW.b = 1;
 END IF;
 END|
 INSERT INTO t1(a) VALUES(NULL);
+Warnings:
+Warning	1364	Field 'b' doesn't have a default value
 SELECT * FROM t1;
 a	b
 NULL	1
@@ -134,6 +136,8 @@ SET NEW.b = NEW.a - 1;
 END IF;
 END|
 INSERT INTO t1(a) VALUES (1), (2), (3), (4), (5), (6);
+Warnings:
+Warning	1364	Field 'b' doesn't have a default value
 SELECT * FROM t1;
 a	b
 1	0

=== modified file 'sql/sql_insert.cc'
--- a/sql/sql_insert.cc	2012-08-27 07:05:07 +0000
+++ b/sql/sql_insert.cc	2012-08-29 05:42:56 +0000
@@ -969,28 +969,6 @@ bool mysql_insert(THD *thd,TABLE_LIST *t
 
   prepare_triggers_for_insert_stmt(table);
 
-  /*
-    Check fields for the INSERT INTO ... VALUES statement.
-
-    If there is a trigger for the table being updated, check that every field
-      - is assigned in the VALUES-clause;
-      or
-      - has the default value;
-      or
-      - is set in the trigger;
-
-    If there is no trigger for the table, that check has been already done in
-    mysql_prepare_insert().
-  */
-
-  if (table->triggers &&
-      (fields.elements || !value_count || table_list->view))
-  {
-    res= safely_check_that_all_fields_are_given_values(thd, table, table_list,
-                                                       !ignore &&
-                                                       thd->is_strict_mode());
-  }
-
   if (table_list->prepare_where(thd, 0, TRUE) ||
       table_list->prepare_check_option(thd))
     error= 1;
@@ -1535,35 +1513,18 @@ bool mysql_prepare_insert(THD *thd, TABL
           check_insert_fields(thd, context->table_list, fields, *values,
                               !insert_into_view, 0, &map));
 
-    /*
-      Check fields for the INSERT INTO ... VALUES statement.
-
-      If there is no trigger for the table being updated, check that every field
-      is either assigned in the VALUES-clause or has the default value.
-
-      If there is a trigger for the table, that check will be done during
-      inserting rows into the table in mysql_insert() because the trigger might
-      assign the column value.
-    */
-
     if (!res && check_fields)
     {
       TABLE *t= table;
-
       if (!t)
         t= context->table_list->table;
-
-      if (!t->triggers)
-      {
-        res= safely_check_that_all_fields_are_given_values(thd, t,
-                                                           context->table_list,
-                                                           abort_on_warning);
-      }
+      res= safely_check_that_all_fields_are_given_values(thd, t,
+                                                         context->table_list,
+                                                         abort_on_warning);
     }
-
-   if (!res)
-     res= setup_fields(thd, Ref_ptr_array(),
-                       update_values, MARK_COLUMNS_READ, 0, 0);
+    if (!res)
+      res= setup_fields(thd, Ref_ptr_array(),
+                        update_values, MARK_COLUMNS_READ, 0, 0);
 
     if (!res && duplic == DUP_UPDATE)
     {

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (Dmitry.Shulga:4199 to 4200) WL#6030Dmitry Shulga29 Aug