1
0
mirror of https://github.com/MariaDB/server.git synced 2026-01-06 05:22:24 +03:00

Fix bug#14186 select datefield is null not updated

Date field was declared as not null, thus expression 'datefield is null'
was always false. For SELECT special handling of such cases is used. 
There 'datefield is null' converted to 'datefield eq "0000-00-00"'.

In mysql_update() before creation of select added remove_eq_conds() call.
It makes some optimization of conds and in particular performs conversion
from 'is null' to 'eq'. 
Also remove_eq_conds() makes some evaluation of conds and if it founds that
conds is always false then update statement is not processed further.
All this allows to perform some update statements process faster due to
optimized conds, and not wasting resources if conds known to be false. 


sql/sql_select.cc:
  Fix bug#14186  select datefield is null not updated
  Remove static from remove_eq_conds()
sql/sql_select.h:
   Fix bug#14186  select datefield is null not updated
  Added remove_eq_conds() prototype.
mysql-test/r/update.result:
  Test case for  bug#14186  select datefield is null not updated
mysql-test/t/update.test:
  Test case for  bug#14186  select datefield is null not updated
sql/sql_update.cc:
  Fix bug#14186  select datefield is null not updated
  To mysql_update() added call to remove_eq_conds() to optimize conds and convert 'datefield is null' to 'datefield eq 0000-00-00'
This commit is contained in:
unknown
2005-10-28 01:24:11 +04:00
parent fe90e5677c
commit 6020281e95
5 changed files with 31 additions and 7 deletions

View File

@@ -70,7 +70,7 @@ int mysql_update(THD *thd,
ha_rows updated, found;
key_map old_used_keys;
TABLE *table;
SQL_SELECT *select;
SQL_SELECT *select= 0;
READ_RECORD info;
TABLE_LIST *update_table_list= ((TABLE_LIST*)
thd->lex->select_lex.table_list.first);
@@ -131,11 +131,19 @@ int mysql_update(THD *thd,
DBUG_RETURN(-1); /* purecov: inspected */
}
if (conds)
{
Item::cond_result cond_value;
conds= remove_eq_conds(thd, conds, &cond_value);
if (cond_value == Item::COND_FALSE)
limit= 0; // Impossible WHERE
}
// Don't count on usage of 'only index' when calculating which key to use
table->used_keys.clear_all();
select=make_select(table,0,0,conds,&error);
if (error ||
(select && select->check_quick(thd, safe_update, limit)) || !limit)
if (limit)
select=make_select(table,0,0,conds,&error);
if (error || !limit ||
(select && select->check_quick(thd, safe_update, limit)))
{
delete select;
free_underlaid_joins(thd, &thd->lex->select_lex);