Below is the list of changes that have just been committed into a local
5.0 repository of igor. When igor 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.1828 05/04/15 20:43:45 igor@stripped +5 -0
subselect.result, subselect.test:
Added a test case for bug #9338.
sql_select.cc:
Fixed bug #9338.
When an occurence of a field reference has to be replaced
by another field reference the whole Item_field must be
replaced.
item.cc:
Fixed bug #9338.
The method Item_field::replace_equal_field_processor was
replaced by Item_field::replace_equal_field. The new method
is used to replace the occurences of Item_field objects.
item.h:
Fixed bug #9338.
The virtual function replace_equal_field_processor was replaced
by replace_equal_field. The latter is supposed to be used as a
callback function in calls of the method transform.
mysql-test/r/subselect.result
1.110 05/04/15 20:41:18 igor@stripped +16 -0
Added a test case for bug #9338.
mysql-test/t/subselect.test
1.96 05/04/15 20:40:33 igor@stripped +21 -0
Added a test case for bug #9338.
sql/sql_select.cc
1.315 05/04/15 20:36:11 igor@stripped +1 -1
Fixed bug #9338.
When an occurence of a field reference has to be replaced
by another field reference the whole Item_field must be
replaced.
sql/item.cc
1.110 05/04/15 20:34:44 igor@stripped +13 -16
The method Item_field::replace_equal_field_processor was
replaced by Item_field::replace_equal_field The new method
is used to replace the occurences of Item_field objects.
sql/item.h
1.114 05/04/15 20:24:19 igor@stripped +2 -2
Fixed bug #9338.
The virtual function replace_equal_field_processor was replaced
by replace_equal_field. The latter is supposed to be used as a
callback function in calls of the method transform.
# 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: igor
# Host: rurik.mysql.com
# Root: /home/igor/dev/mysql-5.0-0
--- 1.109/sql/item.cc Wed Apr 13 08:43:48 2005
+++ 1.110/sql/item.cc Fri Apr 15 20:34:44 2005
@@ -2978,41 +2978,38 @@
/*
- Set a pointer to the multiple equality the field reference belongs to
+ Replace an Item_field for an equal Item_field that evaluated earlier
(if any)
SYNOPSIS
- replace_equal_field_processor()
+ replace_equal_field_()
arg - a dummy parameter, is not used here
DESCRIPTION
- The function replaces a pointer to a field in the Item_field object
- by a pointer to another field.
- The replacement field is taken from the very beginning of
- the item_equal list which the Item_field object refers to (belongs to)
- If the Item_field object does not refer any Item_equal object,
- nothing is done.
+ The function returns a pointer to an item that is taken from
+ the very beginning of the item_equal list which the Item_field
+ object refers to (belongs to).
+ If the Item_field object does not refer any Item_equal object
+ 'this' is returned
NOTES
This function is supposed to be called as a callback parameter in calls
- of the walk method.
+ of the thransformer method.
RETURN VALUES
- 0
+ pointer to a replacement Item_field if there is a better equal item;
+ this - otherwise.
*/
-bool Item_field::replace_equal_field_processor(byte *arg)
+Item *Item_field::replace_equal_field(byte *arg)
{
if (item_equal)
{
Item_field *subst= item_equal->get_first();
if (!field->eq(subst->field))
- {
- field= subst->field;
- return 0;
- }
+ return subst;
}
- return 0;
+ return this;
}
--- 1.113/sql/item.h Tue Apr 5 19:45:08 2005
+++ 1.114/sql/item.h Fri Apr 15 20:24:19 2005
@@ -520,7 +520,7 @@
virtual bool collect_item_field_processor(byte * arg) { return 0; }
virtual Item *equal_fields_propagator(byte * arg) { return this; }
virtual Item *set_no_const_sub(byte *arg) { return this; }
- virtual bool replace_equal_field_processor(byte * arg) { return 0; }
+ virtual Item *replace_equal_field(byte * arg) { return this; }
virtual Item *this_item() { return this; } /* For SPs mostly. */
virtual Item *this_const_item() const { return const_cast<Item*>(this); } /* For
SPs mostly. */
@@ -750,7 +750,7 @@
Item_equal *find_item_equal(COND_EQUAL *cond_equal);
Item *equal_fields_propagator(byte *arg);
Item *set_no_const_sub(byte *arg);
- bool replace_equal_field_processor(byte *arg);
+ Item *replace_equal_field(byte *arg);
inline uint32 max_disp_length() { return field->max_length(); }
Item_field *filed_for_view_update() { return this; }
Item *safe_charset_converter(CHARSET_INFO *tocs);
--- 1.314/sql/sql_select.cc Mon Apr 11 01:22:28 2005
+++ 1.315/sql/sql_select.cc Fri Apr 15 20:36:11 2005
@@ -7050,7 +7050,7 @@
return eliminate_item_equal(0, cond_equal, item_equal);
}
else
- cond->walk(&Item::replace_equal_field_processor, 0);
+ cond->transform(&Item::replace_equal_field, 0);
return cond;
}
--- 1.109/mysql-test/r/subselect.result Fri Apr 1 04:06:31 2005
+++ 1.110/mysql-test/r/subselect.result Fri Apr 15 20:41:18 2005
@@ -2746,3 +2746,19 @@
2.00
4.00
drop table t1;
+CREATE table t1 ( c1 integer );
+INSERT INTO t1 VALUES ( 1 );
+INSERT INTO t1 VALUES ( 2 );
+INSERT INTO t1 VALUES ( 3 );
+CREATE TABLE t2 ( c2 integer );
+INSERT INTO t2 VALUES ( 1 );
+INSERT INTO t2 VALUES ( 4 );
+INSERT INTO t2 VALUES ( 5 );
+SELECT * FROM t1 LEFT JOIN t2 ON c1 = c2 WHERE c2 IN (1);
+c1 c2
+1 1
+SELECT * FROM t1 LEFT JOIN t2 ON c1 = c2
+WHERE c2 IN ( SELECT c2 FROM t2 WHERE c2 IN ( 1 ) );
+c1 c2
+1 1
+DROP TABLE t1,t2;
--- 1.95/mysql-test/t/subselect.test Fri Apr 1 04:06:31 2005
+++ 1.96/mysql-test/t/subselect.test Fri Apr 15 20:40:33 2005
@@ -1752,3 +1752,24 @@
select * from t1;
select min(a) from t1 group by grp;
drop table t1;
+
+#
+# Test for bug #9338: lame substitution of c1 instead of c2
+#
+
+CREATE table t1 ( c1 integer );
+INSERT INTO t1 VALUES ( 1 );
+INSERT INTO t1 VALUES ( 2 );
+INSERT INTO t1 VALUES ( 3 );
+
+CREATE TABLE t2 ( c2 integer );
+INSERT INTO t2 VALUES ( 1 );
+INSERT INTO t2 VALUES ( 4 );
+INSERT INTO t2 VALUES ( 5 );
+
+SELECT * FROM t1 LEFT JOIN t2 ON c1 = c2 WHERE c2 IN (1);
+
+SELECT * FROM t1 LEFT JOIN t2 ON c1 = c2
+ WHERE c2 IN ( SELECT c2 FROM t2 WHERE c2 IN ( 1 ) );
+
+DROP TABLE t1,t2;
| Thread |
|---|
| • bk commit into 5.0 tree (igor:1.1828) BUG#9338 | igor | 16 Apr |