Below is the list of changes that have just been committed into a local
5.0 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.2144 06/05/17 22:51:16 evgen@stripped +5 -0
Fixed bug#19077: Too early applied subselect optimization leads to wrong
result.
The convert_constant_item() functions converts constant items to ints on
prepare phase to optimize execution speed. But due to locking schema
subselects evaluated at this phase will return wrong result.
New flag with_subselect is added to the Item class. It shows that expression
which this item represents is a subselect or contains a subselect.
It is set to 0 by default.
For subselects it is set to 1 in the Item_subselect constructor.
For Item_func and Item_cond derived items it is set after fixing any argument
in Item_func::fix_fields() and Item_cond::fix_fields accordingly.
The convert_constant_item() function now doesn't convert a constant item
with the with_subselect flag set.
sql/item.cc
1.223 06/05/17 22:49:16 evgen@stripped +1 -0
Fixed bug#19077: Too early applied subselect optimization leads to wrong
result.
Set new with_subselect flag to default value - 0 at the Item constructor.
sql/item.h
1.197 06/05/17 22:48:06 evgen@stripped +3 -0
Fixed bug#19077: Too early applied subselect optimization leads to wrong
result.
New flag with_subselect is added to the Item class. It shows that expression
which this item represents is a subselect or contains a subselect.
It is set to 0 by default.
sql/item_cmpfunc.cc
1.201 06/05/17 22:44:36 evgen@stripped +21 -5
Fixed bug#19077: Too early applied subselect optimization leads to wrong
result.
The convert_constant_item() function now doesn't convert a constant item
with the with_subselect flag set.
The Item_cond::fix_fields() sets new with_subselect flag from with_subselect f
lags of its arguments.
sql/item_func.cc
1.287 06/05/17 22:43:05 evgen@stripped +1 -0
Fixed bug#19077: Too early applied subselect optimization leads to wrong
result.
The Item_func::fix_fields() sets new with_subselect flag from with_subselect flags of
its arguments.
sql/item_subselect.cc
1.125 06/05/17 22:42:05 evgen@stripped +1 -0
Fixed bug#19077: Too early applied subselect optimization leads to wrong
resultThe Item_subselect class constructor sets new with_subselect flag to 1.
# 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/19077-bug-5.0-mysql
--- 1.222/sql/item.cc 2006-05-16 03:44:39 +04:00
+++ 1.223/sql/item.cc 2006-05-17 22:49:16 +04:00
@@ -304,6 +304,7 @@
marker= 0;
maybe_null=null_value=with_sum_func=unsigned_flag=0;
decimals= 0; max_length= 0;
+ with_subselect= 0;
/* Put item in free list so that we can free all items at end */
THD *thd= current_thd;
--- 1.196/sql/item.h 2006-05-16 03:44:39 +04:00
+++ 1.197/sql/item.h 2006-05-17 22:48:06 +04:00
@@ -460,6 +460,9 @@
my_bool is_autogenerated_name; /* indicate was name of this Item
autogenerated or set by user */
DTCollation collation;
+ my_bool with_subselect; /* If this item is a subselect or some
+ of its arguments is or contains a
+ subselect */
// alloc & destruct is done as start of select using sql_alloc
Item();
--- 1.200/sql/item_cmpfunc.cc 2006-04-25 01:50:25 +04:00
+++ 1.201/sql/item_cmpfunc.cc 2006-05-17 22:44:36 +04:00
@@ -204,10 +204,25 @@
/*
- Convert a constant expression or string to an integer.
- This is done when comparing DATE's of different formats and
- also when comparing bigint to strings (in which case the string
- is converted once to a bigint).
+ Convert a constant item to an int and replace original item
+
+ SYNOPSIS
+ convert_constant_item()
+ thd thread handle
+ field item will be converted using this field
+ item [in/out] reference to the item to convert
+
+ DESCRIPTION
+ Convert a constant expression or string to an integer and
+ replace original item with new on successful conversion.
+ This is done when comparing DATE/TIME of different formats and
+ also when comparing bigint to strings (in which case the string
+ is converted once to a bigint).
+ This function should be used only on prepare phase.
+
+ NOTES
+ Due to the locking schema subselect items or items that contain
+ subselects can't be converted here.
RESULT VALUES
0 Can't convert item
@@ -216,7 +231,7 @@
static bool convert_constant_item(THD *thd, Field *field, Item **item)
{
- if ((*item)->const_item())
+ if (!(*item)->with_subselect && (*item)->const_item())
{
/* For comparison purposes allow invalid dates like 2000-01-32 */
ulong orig_sql_mode= field->table->in_use->variables.sql_mode;
@@ -2578,6 +2593,7 @@
const_item_cache= FALSE;
}
with_sum_func= with_sum_func || item->with_sum_func;
+ with_subselect|= item->with_subselect;
if (item->maybe_null)
maybe_null=1;
}
--- 1.286/sql/item_func.cc 2006-05-15 15:28:10 +04:00
+++ 1.287/sql/item_func.cc 2006-05-17 22:43:05 +04:00
@@ -184,6 +184,7 @@
used_tables_cache|= item->used_tables();
not_null_tables_cache|= item->not_null_tables();
const_item_cache&= item->const_item();
+ with_subselect|= item->with_subselect;
}
}
fix_length_and_dec();
--- 1.124/sql/item_subselect.cc 2006-05-11 16:30:49 +04:00
+++ 1.125/sql/item_subselect.cc 2006-05-17 22:42:05 +04:00
@@ -39,6 +39,7 @@
engine(0), old_engine(0), used_tables_cache(0), have_to_be_excluded(0),
const_item_cache(1), engine_changed(0), changed(0)
{
+ with_subselect= 1;
reset();
/*
item value is NULL if select_subselect not changed this value
| Thread |
|---|
| • bk commit into 5.0 tree (evgen:1.2144) BUG#19077 | eugene | 17 May |