List:Commits« Previous MessageNext Message »
From:eugene Date:January 11 2008 5:10pm
Subject:bk commit into 5.0 tree (evgen:1.2588) BUG#29477
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of evgen.  When evgen 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, 2008-01-11 20:10:54+03:00, evgen@stripped +3 -0
  Bug#29477: Not all fields of the target table were checked to have a default
  value when inserting into a view.
  
  The mysql_prepare_insert function checks all fields of the target table that
  directly or indirectly (through a view) are specified in the INSERT
  statement to have a default value. This check can be skipped if the INSERT
  statement doesn't mention any insert fields. In case of a view this allows
  fields that aren't mentioned in the view to bypass the check.
  
  Now fields of the target table are always checked to have a default value
  when insert goes into a view.

  mysql-test/r/view.result@stripped, 2008-01-11 19:54:26+03:00, evgen@stripped +16 -0
    Added a test case for the bug#29477: Not all fields of the target table were 
    checked to have a default value when inserting into a view.

  mysql-test/t/view.test@stripped, 2008-01-11 19:54:15+03:00, evgen@stripped +14 -0
    Added a test case for the bug#29477: Not all fields of the target table were 
    checked to have a default value when inserting into a view.

  sql/sql_insert.cc@stripped, 2008-01-11 20:03:15+03:00, evgen@stripped +2 -1
    Bug#29477: Not all fields of the target table were checked to have a default
    value when inserting into a view.
    Now fields of the target table are always checked to have a default value
    when insert goes into a view.

diff -Nrup a/mysql-test/r/view.result b/mysql-test/r/view.result
--- a/mysql-test/r/view.result	2007-10-10 11:16:12 +04:00
+++ b/mysql-test/r/view.result	2008-01-11 19:54:26 +03:00
@@ -3602,4 +3602,20 @@ DROP VIEW v1;
 DROP VIEW v2;
 DROP VIEW v3;
 DROP TABLE t1;
+#
+# Bug#29477: Not all fields of the target table were checked to have
+#            a default value when inserting into a view.
+#
+create table t1(f1 int, f2 int not null);
+create view v1 as select f1 from t1;
+insert into v1 values(1);
+Warnings:
+Warning	1423	Field of view 'test.v1' underlying table doesn't have a default value
+set @old_mode=@@sql_mode;
+set @@sql_mode=traditional;
+insert into v1 values(1);
+ERROR HY000: Field of view 'test.v1' underlying table doesn't have a default value
+set @@sql_mode=@old_mode;
+drop view v1;
+drop table t1;
 End of 5.0 tests.
diff -Nrup a/mysql-test/t/view.test b/mysql-test/t/view.test
--- a/mysql-test/t/view.test	2007-10-10 11:16:12 +04:00
+++ b/mysql-test/t/view.test	2008-01-11 19:54:15 +03:00
@@ -3456,5 +3456,19 @@ DROP VIEW v2;
 DROP VIEW v3;
 DROP TABLE t1;
 
+--echo #
+--echo # Bug#29477: Not all fields of the target table were checked to have
+--echo #            a default value when inserting into a view.
+--echo #
+create table t1(f1 int, f2 int not null);
+create view v1 as select f1 from t1;
+insert into v1 values(1);
+set @old_mode=@@sql_mode;
+set @@sql_mode=traditional;
+--error ER_NO_DEFAULT_FOR_VIEW_FIELD
+insert into v1 values(1);
+set @@sql_mode=@old_mode;
+drop view v1;
+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-12-13 13:52:47 +03:00
+++ b/sql/sql_insert.cc	2008-01-11 20:03:15 +03:00
@@ -630,7 +630,8 @@ bool mysql_insert(THD *thd,TABLE_LIST *t
   if (mysql_prepare_insert(thd, table_list, table, fields, values,
 			   update_fields, update_values, duplic, &unused_conds,
                            FALSE,
-                           (fields.elements || !value_count),
+                           (fields.elements || !value_count ||
+                            table_list->view != 0),
                            !ignore && (thd->variables.sql_mode &
                                        (MODE_STRICT_TRANS_TABLES |
                                         MODE_STRICT_ALL_TABLES))))
Thread
bk commit into 5.0 tree (evgen:1.2588) BUG#29477eugene11 Jan