1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Strict mode & better warnings

Under strict mode MySQL will generate an error message if there was any conversion when assigning data to a field.
Added checking of date/datetime fields.
If strict mode, give error if we have not given value to field without a default value (for INSERT)


client/mysqltest.c:
  Added --exit as an option to abort a test in a middle (good for debugging)
include/my_time.h:
  Added flags to allow checking of dates in strict mode
include/mysql_com.h:
  Added flag to check if field has a default value or not
include/mysqld_error.h:
  New error messages for strict mode
include/sql_state.h:
  Fixed SQL states (for strict mode tests)
mysql-test/r/auto_increment.result:
  Updated error messages
mysql-test/r/func_sapdb.result:
  Added test for ALLOW_INVALID_DATES
mysql-test/r/func_str.result:
  Updated error messages
mysql-test/r/func_time.result:
  Updated error messages
mysql-test/r/insert.result:
  Updated error messages
mysql-test/r/loaddata.result:
  Updated error messages
mysql-test/r/select.result:
  Updated error messages
mysql-test/r/sp.result:
  Updated error messages
mysql-test/r/timezone2.result:
  Updated error messages
mysql-test/r/type_datetime.result:
  Updated error messages
mysql-test/r/type_decimal.result:
  Updated error messages
mysql-test/r/type_float.result:
  Updated error messages
mysql-test/r/type_ranges.result:
  Updated error messages
mysql-test/r/type_time.result:
  Updated error messages
mysql-test/r/type_uint.result:
  Updated error messages
mysql-test/r/warnings.result:
  Updated error messages
mysql-test/t/func_sapdb.test:
  Aded test
sql-common/my_time.c:
  Added checking of dates
sql/field.cc:
  Better error messages
  Optimization of warning handling (by introducing of check_int())
  Changed to use my_strtoll10()
sql/field.h:
  Added check_int()
sql/item_func.cc:
  Warnings when dividing by NULL
sql/item_func.h:
  Warnings when dividing by NULL
sql/item_timefunc.cc:
  Testing of date/datetime
  Use macros instead of constants
sql/mysql_priv.h:
  New modes (part of strict mode)
sql/mysqld.cc:
  New modes (part of strict mode)
sql/opt_range.cc:
  Simple optimizations
sql/protocol.cc:
  Add note/warning level to find_handler()
sql/set_var.cc:
  Added mode 'traditional'
sql/share/czech/errmsg.txt:
  New error messages for strict mode
sql/share/danish/errmsg.txt:
  New error messages for strict mode
sql/share/dutch/errmsg.txt:
  New error messages for strict mode
sql/share/english/errmsg.txt:
  New error messages for strict mode
sql/share/estonian/errmsg.txt:
  New error messages for strict mode
sql/share/french/errmsg.txt:
  New error messages for strict mode
sql/share/german/errmsg.txt:
  New error messages for strict mode
sql/share/greek/errmsg.txt:
  New error messages for strict mode
sql/share/hungarian/errmsg.txt:
  New error messages for strict mode
sql/share/italian/errmsg.txt:
  New error messages for strict mode
sql/share/japanese/errmsg.txt:
  New error messages for strict mode
sql/share/korean/errmsg.txt:
  New error messages for strict mode
sql/share/norwegian-ny/errmsg.txt:
  New error messages for strict mode
sql/share/norwegian/errmsg.txt:
  New error messages for strict mode
sql/share/polish/errmsg.txt:
  New error messages for strict mode
sql/share/portuguese/errmsg.txt:
  New error messages for strict mode
sql/share/romanian/errmsg.txt:
  New error messages for strict mode
sql/share/russian/errmsg.txt:
  New error messages for strict mode
sql/share/serbian/errmsg.txt:
  New error messages for strict mode
sql/share/slovak/errmsg.txt:
  New error messages for strict mode
sql/share/spanish/errmsg.txt:
  New error messages for strict mode
sql/share/swedish/errmsg.txt:
  New error messages for strict mode
sql/share/ukrainian/errmsg.txt:
  New error messages for strict mode
sql/sp_rcontext.cc:
  Add note/warning level to find_handler()
sql/sp_rcontext.h:
  Add note/warning level to find_handler()
sql/sql_base.cc:
  Fix bug for detecting crashed table
sql/sql_class.cc:
  Variables for strct mode
sql/sql_class.h:
  Variables for strct mode
sql/sql_error.cc:
  In strict mode, convert warnings to errors
sql/sql_insert.cc:
  Strict mode
  If strict mode, give error if we have not given value to field without a default value
sql/sql_load.cc:
  Strict mode
sql/sql_parse.cc:
  Strict mode.
  Add flag to field if it doesn't have a default value
sql/sql_select.cc:
  Added comment
  Prepare for upper level handling of table->status
sql/sql_union.cc:
  Added THD to write_record()
sql/sql_update.cc:
  Strict mode
sql/table.cc:
  Handling of default values
sql/time.cc:
  Checking of dates
This commit is contained in:
unknown
2004-09-28 20:08:00 +03:00
parent e74b00bbc9
commit 2a49121590
72 changed files with 1965 additions and 446 deletions

View File

@ -348,6 +348,12 @@ int mysql_update(THD *thd,
thd->proc_info="Updating";
query_id=thd->query_id;
transactional_table= table->file->has_transactions();
thd->no_trans_update= 0;
thd->abort_on_warning= test(thd->variables.sql_mode &
(MODE_STRICT_TRANS_TABLES |
MODE_STRICT_ALL_TABLES));
while (!(error=info.read_record(&info)) && !thd->killed)
{
if (!(select && select->skip_record()))
@ -366,6 +372,7 @@ int mysql_update(THD *thd,
(byte*) table->record[0])))
{
updated++;
thd->no_trans_update= !transactional_table;
}
else if (handle_duplicates != DUP_IGNORE ||
error != HA_ERR_FOUND_DUPP_KEY)
@ -406,7 +413,6 @@ int mysql_update(THD *thd,
query_cache_invalidate3(thd, table_list, 1);
}
transactional_table= table->file->has_transactions();
log_delayed= (transactional_table || table->tmp_table);
if ((updated || (error < 0)) && (error <= 0 || !transactional_table))
{
@ -460,6 +466,7 @@ err:
table->key_read=0;
table->file->extra(HA_EXTRA_NO_KEYREAD);
}
thd->abort_on_warning= 0;
DBUG_RETURN(-1);
}
@ -657,6 +664,11 @@ int mysql_multi_update(THD *thd,
handle_duplicates)))
DBUG_RETURN(-1);
thd->no_trans_update= 0;
thd->abort_on_warning= test(thd->variables.sql_mode &
(MODE_STRICT_TRANS_TABLES |
MODE_STRICT_ALL_TABLES));
List<Item> total_list;
res= mysql_select(thd, &select_lex->ref_pointer_array,
table_list, select_lex->with_wild,
@ -666,6 +678,7 @@ int mysql_multi_update(THD *thd,
options | SELECT_NO_JOIN_CACHE | SELECT_NO_UNLOCK,
result, unit, select_lex);
delete result;
thd->abort_on_warning= 0;
DBUG_RETURN(res);
}
@ -1013,6 +1026,8 @@ bool multi_update::send_data(List<Item> &not_used_values)
updated--;
DBUG_RETURN(1);
}
if (!table->file->has_transactions())
thd->no_trans_update= 1;
}
}
else