Below is the list of changes that have just been committed into a local
5.0 repository of elkin. When elkin 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@stripped, 2007-03-22 19:17:15+02:00, aelkin@andrepl.(none) +3 -0
Bug #27354 stored function in where condition was always treated as const
Possible problems: function call could be eliminated from where class and only
be evaluated once; function can be evaluated during table and item setup phase which could
cause side effects not to be registered in binlog.
Fixed with introducing func_item_sp::used_tables() returning the correct table_map constant.
mysql-test/r/sp.result@stripped, 2007-03-22 19:17:13+02:00, aelkin@andrepl.(none) +25 -0
results changed
mysql-test/t/sp.test@stripped, 2007-03-22 19:17:13+02:00, aelkin@andrepl.(none) +24 -0
regression test demonstrating that function's returns match where condition
of the top-level query table.
sql/item_func.h@stripped, 2007-03-22 19:17:13+02:00, aelkin@andrepl.(none) +3 -1
private used_tables() method returning the correct table_bit with meaning the item is not
a constant
# 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: aelkin
# Host: andrepl.(none)
# Root: /home/elkin/MySQL/MAIN/mysql-5.0-marvel
--- 1.160/sql/item_func.h 2007-01-09 22:23:37 +02:00
+++ 1.161/sql/item_func.h 2007-03-22 19:17:13 +02:00
@@ -1411,7 +1411,7 @@ private:
bool execute(Field **flp);
bool execute_impl(THD *thd, Field *return_value_fld);
Field *sp_result_field(void) const;
-
+
public:
Item_func_sp(Name_resolution_context *context_arg, sp_name *name);
@@ -1421,6 +1421,8 @@ public:
virtual ~Item_func_sp()
{}
+
+ table_map used_tables() const { return RAND_TABLE_BIT; }
void cleanup();
--- 1.221/mysql-test/r/sp.result 2007-03-08 19:34:05 +02:00
+++ 1.222/mysql-test/r/sp.result 2007-03-22 19:17:13 +02:00
@@ -5779,3 +5779,28 @@ SUM(f2) bug25373(f1)
DROP FUNCTION bug25373|
DROP TABLE t3|
drop table t1,t2;
+CREATE TABLE t1 (a int auto_increment primary key) engine=MyISAM;
+CREATE TABLE t2 (a int auto_increment primary key, b int) engine=innodb;
+set @a=0;
+CREATE function bug27354() RETURNS int deterministic
+begin
+insert into t1 values (null);
+set @a=@a+1;
+return @a;
+end|
+update t2 set b=1 where a=bug27354();
+select count(t_1.a),count(t_2.a) from t1 as t_1, t2 as t_2 /* must be 0,0 */;
+count(t_1.a) count(t_2.a)
+0 0
+insert into t2 values (1,1),(2,2),(3,3);
+update t2 set b=-b where a=bug27354();
+select * from t2 /* must return 1,-1 ... */;
+a b
+1 -1
+2 -2
+3 -3
+select count(*) from t1 /* must be 3 */;
+count(*)
+3
+drop table t1,t2;
+drop function bug27354;
--- 1.211/mysql-test/t/sp.test 2007-03-08 19:29:57 +02:00
+++ 1.212/mysql-test/t/sp.test 2007-03-22 19:17:13 +02:00
@@ -6770,3 +6770,27 @@ DROP TABLE t3|
# practical, or create table t3, t4 etc temporarily (and drop them).
delimiter ;|
drop table t1,t2;
+
+CREATE TABLE t1 (a int auto_increment primary key) engine=MyISAM;
+CREATE TABLE t2 (a int auto_increment primary key, b int) engine=innodb;
+set @a=0;
+
+delimiter |;
+CREATE function bug27354() RETURNS int deterministic
+begin
+insert into t1 values (null);
+set @a=@a+1;
+return @a;
+end|
+
+delimiter ;|
+update t2 set b=1 where a=bug27354();
+select count(t_1.a),count(t_2.a) from t1 as t_1, t2 as t_2 /* must be 0,0 */;
+insert into t2 values (1,1),(2,2),(3,3);
+update t2 set b=-b where a=bug27354();
+select * from t2 /* must return 1,-1 ... */;
+select count(*) from t1 /* must be 3 */;
+
+
+drop table t1,t2;
+drop function bug27354;
| Thread |
|---|
| • bk commit into 5.0 tree (aelkin:1.2487) BUG#27354 | Andrei Elkin | 22 Mar |