Below is the list of changes that have just been committed into a local
4.1 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
1.2466 05/10/28 01:24:11 evgen@stripped +5 -0
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_update.cc
1.147 05/10/28 01:23:05 evgen@stripped +12 -4
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'
mysql-test/t/update.test
1.25 05/10/28 01:19:13 evgen@stripped +9 -0
Test case for bug#14186 select datefield is null not updated
mysql-test/r/update.result
1.27 05/10/28 01:17:34 evgen@stripped +8 -0
Test case for bug#14186 select datefield is null not updated
sql/sql_select.h
1.77 05/10/28 01:15:33 evgen@stripped +1 -0
Fix bug#14186 select datefield is null not updated
Added remove_eq_conds() prototype.
sql/sql_select.cc
1.441 05/10/28 01:14:17 evgen@stripped +1 -3
Fix bug#14186 select datefield is null not updated
Remove static from remove_eq_conds()
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: evgen
# Host: moonbone.local
# Root: /work/14186-bug-4.1-mysql
--- 1.440/sql/sql_select.cc 2005-10-13 18:25:25 +04:00
+++ 1.441/sql/sql_select.cc 2005-10-28 01:14:17 +04:00
@@ -69,8 +69,6 @@
SELECT_LEX_UNIT *unit);
static COND *optimize_cond(THD *thd, COND *conds,
Item::cond_result *cond_value);
-static COND *remove_eq_conds(THD *thd, COND *cond,
- Item::cond_result *cond_value);
static bool const_expression_in_where(COND *conds,Item *item, Item **comp_item);
static bool open_tmp_table(TABLE *table);
static bool create_myisam_tmp_table(TABLE *table,TMP_TABLE_PARAM *param,
@@ -4611,7 +4609,7 @@
COND_FALSE always false ( 1 = 2 )
*/
-static COND *
+COND *
remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value)
{
if (cond->type() == Item::COND_ITEM)
--- 1.76/sql/sql_select.h 2005-06-23 17:13:38 +04:00
+++ 1.77/sql/sql_select.h 2005-10-28 01:15:33 +04:00
@@ -456,3 +456,4 @@
bool error_if_full_join(JOIN *join);
int report_error(TABLE *table, int error);
int safe_index_read(JOIN_TAB *tab);
+COND *remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value);
--- 1.146/sql/sql_update.cc 2005-10-25 03:27:29 +04:00
+++ 1.147/sql/sql_update.cc 2005-10-28 01:23:05 +04:00
@@ -70,7 +70,7 @@
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 @@
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);
--- 1.26/mysql-test/r/update.result 2005-10-25 03:27:29 +04:00
+++ 1.27/mysql-test/r/update.result 2005-10-28 01:17:34 +04:00
@@ -337,3 +337,11 @@
22 3
23 3
drop table t1;
+create table t1 (f1 date not null);
+insert into t1 values('2000-01-01'),('0000-00-00');
+update t1 set f1='2002-02-02' where f1 is null;
+select * from t1;
+f1
+2000-01-01
+2002-02-02
+drop table t1;
--- 1.24/mysql-test/t/update.test 2005-10-25 03:27:29 +04:00
+++ 1.25/mysql-test/t/update.test 2005-10-28 01:19:13 +04:00
@@ -261,4 +261,13 @@
select * from t1 order by a;
drop table t1;
+
+#
+# Bug#14186 select datefield is null not updated
+#
+create table t1 (f1 date not null);
+insert into t1 values('2000-01-01'),('0000-00-00');
+update t1 set f1='2002-02-02' where f1 is null;
+select * from t1;
+drop table t1;
# End of 4.1 tests
| Thread |
|---|
| • bk commit into 4.1 tree (evgen:1.2466) BUG#14186 | eugene | 27 Oct |