1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

More fixes for strict mode:

More tests.
Better error messages.
Fixed bug when checking if we updated all needed columns for INSERT.
Give an error if we encounter a wrong float value during parsing.
Don't print DEFAULT for columns without a default value in SHOW CREATE/SHOW FIELDS.
Fixed UPDATE IGNORE when using STRICT mode.
This commit is contained in:
monty@mishka.local
2004-10-02 22:20:08 +03:00
parent 1fc7e6af85
commit be4ca46fbe
65 changed files with 661 additions and 258 deletions

View File

@ -246,9 +246,10 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
/*
Count warnings for all inserts.
For single line insert, generate an error if try to set a NOT NULL field
to NULL
to NULL.
*/
thd->count_cuted_fields= ((values_list.elements == 1) ?
thd->count_cuted_fields= ((values_list.elements == 1 &&
duplic != DUP_IGNORE) ?
CHECK_FIELD_ERROR_FOR_NULL :
CHECK_FIELD_WARN);
thd->cuted_fields = 0L;
@ -276,7 +277,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
(MODE_STRICT_TRANS_TABLES |
MODE_STRICT_ALL_TABLES)));
if (check_that_all_fields_are_given_values(thd, table))
if (fields.elements && check_that_all_fields_are_given_values(thd, table))
{
/* thd->net.report_error is now set, which will abort the next loop */
error= 1;
@ -784,13 +785,11 @@ err:
/******************************************************************************
Check that all fields with arn't null_fields are used
If DONT_USE_DEFAULT_FIELDS isn't defined use default value for not set
fields.
******************************************************************************/
int check_that_all_fields_are_given_values(THD *thd, TABLE *entry)
{
if (!thd->abort_on_warning)
if (!thd->abort_on_warning) // No check if not strict mode
return 0;
for (Field **field=entry->field ; *field ; field++)
@ -1666,7 +1665,8 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
(thd->variables.sql_mode &
(MODE_STRICT_TRANS_TABLES |
MODE_STRICT_ALL_TABLES)));
DBUG_RETURN(check_that_all_fields_are_given_values(thd, table));
DBUG_RETURN(fields->elements &&
check_that_all_fields_are_given_values(thd, table));
}