summaryrefslogtreecommitdiff
path: root/sql/sql_insert.cc
diff options
context:
space:
mode:
authorunknown <jimw@mysql.com>2005-01-13 18:23:34 -0800
committerunknown <jimw@mysql.com>2005-01-13 18:23:34 -0800
commitd923ebf9fff81840b52e715aadc14d0d377e935d (patch)
treee4c435a8dda482a7c10a95252cb154e42eaa4a06 /sql/sql_insert.cc
parentfb78b3495dc8e0867a431562cae9ea8d1530ef61 (diff)
downloadmariadb-git-d923ebf9fff81840b52e715aadc14d0d377e935d.tar.gz
In TRADITIONAL mode, don't allow a NOT NULL field with no default be set to
DEFAULT (with no argument) or to the field's type's default by not being listed in the list of fields being inserted. (Bug #5986) sql/item.cc: Add Item_default_value::save_in_field(), with check for setting fields with no default value set. sql/item.h: Implementation of Item_default_value::save_in_field moved to item.cc sql/sql_insert.cc: Call check_that_all_fields_are_given_values() if no values were given and we would be filling row with all default values mysql-test/t/strict.test: Add tests for setting fields to DEFAULT in traditional and regular modes mysql-test/r/strict.result: Add results
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r--sql/sql_insert.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index ceb31f76953..d93010d9915 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -311,7 +311,8 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
(MODE_STRICT_TRANS_TABLES |
MODE_STRICT_ALL_TABLES)));
- if (fields.elements && check_that_all_fields_are_given_values(thd, table))
+ if ((fields.elements || !value_count) &&
+ check_that_all_fields_are_given_values(thd, table))
{
/* thd->net.report_error is now set, which will abort the next loop */
error= 1;