Below is the list of changes that have just been committed into a local
4.1 repository of tomash. When tomash 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, 2006-08-31 17:22:42+04:00, kroki@stripped +5 -0
BUG#21354: (COUNT(*) = 1) not working in SELECT inside prepared
statement.
The problem was that during statement re-execution if the result was
empty the old result could be returned for group functions.
The solution is to implement proper cleanup() method in group
functions.
mysql-test/r/ps.result@stripped, 2006-08-31 17:22:39+04:00, kroki@stripped +97 -0
Add result for bug#21354: (COUNT(*) = 1) not working in SELECT inside
prepared statement.
mysql-test/t/func_gconcat.test@stripped, 2006-08-31 17:22:39+04:00, kroki@stripped
+1 -1
Add a comment that the test case is from bug#836.
mysql-test/t/ps.test@stripped, 2006-08-31 17:22:39+04:00, kroki@stripped +73 -1
Add test case for bug#21354: (COUNT(*) = 1) not working in SELECT inside
prepared statement.
sql/item_sum.cc@stripped, 2006-08-31 17:22:39+04:00, kroki@stripped +1 -0
Call clear() in Item_sum_count::cleanup().
sql/item_sum.h@stripped, 2006-08-31 17:22:39+04:00, kroki@stripped +15 -0
Add proper cleanup() methods.
# 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: kroki
# Host: moonlight.intranet
# Root: /home/tomash/src/mysql_ab/mysql-4.1-bug21354
--- 1.148/sql/item_sum.cc 2006-08-31 17:22:46 +04:00
+++ 1.149/sql/item_sum.cc 2006-08-31 17:22:46 +04:00
@@ -312,6 +312,7 @@ longlong Item_sum_count::val_int()
void Item_sum_count::cleanup()
{
DBUG_ENTER("Item_sum_count::cleanup");
+ clear();
Item_sum_int::cleanup();
used_table_cache= ~(table_map) 0;
DBUG_VOID_RETURN;
--- 1.83/sql/item_sum.h 2006-08-31 17:22:46 +04:00
+++ 1.84/sql/item_sum.h 2006-08-31 17:22:46 +04:00
@@ -304,6 +304,11 @@ class Item_sum_avg :public Item_sum_num
void no_rows_in_result() {}
const char *func_name() const { return "avg"; }
Item *copy_or_same(THD* thd);
+ void cleanup()
+ {
+ clear();
+ Item_sum_num::cleanup();
+ }
};
class Item_sum_variance;
@@ -361,6 +366,11 @@ class Item_sum_variance : public Item_su
void no_rows_in_result() {}
const char *func_name() const { return "variance"; }
Item *copy_or_same(THD* thd);
+ void cleanup()
+ {
+ clear();
+ Item_sum_num::cleanup();
+ }
};
class Item_sum_std;
@@ -485,6 +495,11 @@ public:
void update_field();
void fix_length_and_dec()
{ decimals=0; max_length=21; unsigned_flag=1; maybe_null=null_value=0; }
+ void cleanup()
+ {
+ clear();
+ Item_sum_int::cleanup();
+ }
};
--- 1.50/mysql-test/r/ps.result 2006-08-31 17:22:46 +04:00
+++ 1.51/mysql-test/r/ps.result 2006-08-31 17:22:46 +04:00
@@ -889,3 +889,100 @@ create temporary table if not exists t1
execute stmt;
drop temporary table t1;
deallocate prepare stmt;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (i INT, INDEX(i));
+INSERT INTO t1 VALUES (1);
+PREPARE stmt FROM "SELECT (COUNT(i) = 1), COUNT(i) FROM t1 WHERE i = ?";
+SET @a = 0;
+EXECUTE stmt USING @a;
+(COUNT(i) = 1) COUNT(i)
+0 0
+SET @a = 1;
+EXECUTE stmt USING @a;
+(COUNT(i) = 1) COUNT(i)
+1 1
+SET @a = 0;
+EXECUTE stmt USING @a;
+(COUNT(i) = 1) COUNT(i)
+0 0
+PREPARE stmt FROM "SELECT (AVG(i) = 1), AVG(i) FROM t1 WHERE i = ?";
+SET @a = 0;
+EXECUTE stmt USING @a;
+(AVG(i) = 1) AVG(i)
+NULL NULL
+SET @a = 1;
+EXECUTE stmt USING @a;
+(AVG(i) = 1) AVG(i)
+1 1.0000
+SET @a = 0;
+EXECUTE stmt USING @a;
+(AVG(i) = 1) AVG(i)
+NULL NULL
+PREPARE stmt FROM "SELECT (VARIANCE(i) = 1), VARIANCE(i) FROM t1 WHERE i = ?";
+SET @a = 0;
+EXECUTE stmt USING @a;
+(VARIANCE(i) = 1) VARIANCE(i)
+NULL NULL
+SET @a = 1;
+EXECUTE stmt USING @a;
+(VARIANCE(i) = 1) VARIANCE(i)
+0 0.0000
+SET @a = 0;
+EXECUTE stmt USING @a;
+(VARIANCE(i) = 1) VARIANCE(i)
+NULL NULL
+PREPARE stmt FROM "SELECT (STDDEV(i) = 1), STDDEV(i) FROM t1 WHERE i = ?";
+SET @a = 0;
+EXECUTE stmt USING @a;
+(STDDEV(i) = 1) STDDEV(i)
+NULL NULL
+SET @a = 1;
+EXECUTE stmt USING @a;
+(STDDEV(i) = 1) STDDEV(i)
+0 0.0000
+SET @a = 0;
+EXECUTE stmt USING @a;
+(STDDEV(i) = 1) STDDEV(i)
+NULL NULL
+PREPARE stmt FROM "SELECT (BIT_OR(i) = 1), BIT_OR(i) FROM t1 WHERE i = ?";
+SET @a = 0;
+EXECUTE stmt USING @a;
+(BIT_OR(i) = 1) BIT_OR(i)
+0 0
+SET @a = 1;
+EXECUTE stmt USING @a;
+(BIT_OR(i) = 1) BIT_OR(i)
+1 1
+SET @a = 0;
+EXECUTE stmt USING @a;
+(BIT_OR(i) = 1) BIT_OR(i)
+0 0
+PREPARE stmt FROM "SELECT (BIT_AND(i) = 1), BIT_AND(i) FROM t1 WHERE i = ?";
+SET @a = 0;
+EXECUTE stmt USING @a;
+(BIT_AND(i) = 1) BIT_AND(i)
+0 18446744073709551615
+SET @a = 1;
+EXECUTE stmt USING @a;
+(BIT_AND(i) = 1) BIT_AND(i)
+1 1
+SET @a = 0;
+EXECUTE stmt USING @a;
+(BIT_AND(i) = 1) BIT_AND(i)
+0 18446744073709551615
+PREPARE stmt FROM "SELECT (BIT_XOR(i) = 1), BIT_XOR(i) FROM t1 WHERE i = ?";
+SET @a = 0;
+EXECUTE stmt USING @a;
+(BIT_XOR(i) = 1) BIT_XOR(i)
+0 0
+SET @a = 1;
+EXECUTE stmt USING @a;
+(BIT_XOR(i) = 1) BIT_XOR(i)
+1 1
+SET @a = 0;
+EXECUTE stmt USING @a;
+(BIT_XOR(i) = 1) BIT_XOR(i)
+0 0
+DEALLOCATE PREPARE stmt;
+DROP TABLE t1;
+End of 4.1 tests.
--- 1.51/mysql-test/t/ps.test 2006-08-31 17:22:46 +04:00
+++ 1.52/mysql-test/t/ps.test 2006-08-31 17:22:46 +04:00
@@ -951,4 +951,76 @@ execute stmt;
drop temporary table t1;
deallocate prepare stmt;
-# End of 4.1 tests
+
+#
+# BUG#21354: (COUNT(*) = 1) not working in SELECT inside prepared
+# statement
+#
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (i INT, INDEX(i));
+INSERT INTO t1 VALUES (1);
+
+PREPARE stmt FROM "SELECT (COUNT(i) = 1), COUNT(i) FROM t1 WHERE i = ?";
+SET @a = 0;
+EXECUTE stmt USING @a;
+SET @a = 1;
+EXECUTE stmt USING @a;
+SET @a = 0;
+EXECUTE stmt USING @a;
+
+PREPARE stmt FROM "SELECT (AVG(i) = 1), AVG(i) FROM t1 WHERE i = ?";
+SET @a = 0;
+EXECUTE stmt USING @a;
+SET @a = 1;
+EXECUTE stmt USING @a;
+SET @a = 0;
+EXECUTE stmt USING @a;
+
+PREPARE stmt FROM "SELECT (VARIANCE(i) = 1), VARIANCE(i) FROM t1 WHERE i = ?";
+SET @a = 0;
+EXECUTE stmt USING @a;
+SET @a = 1;
+EXECUTE stmt USING @a;
+SET @a = 0;
+EXECUTE stmt USING @a;
+
+PREPARE stmt FROM "SELECT (STDDEV(i) = 1), STDDEV(i) FROM t1 WHERE i = ?";
+SET @a = 0;
+EXECUTE stmt USING @a;
+SET @a = 1;
+EXECUTE stmt USING @a;
+SET @a = 0;
+EXECUTE stmt USING @a;
+
+PREPARE stmt FROM "SELECT (BIT_OR(i) = 1), BIT_OR(i) FROM t1 WHERE i = ?";
+SET @a = 0;
+EXECUTE stmt USING @a;
+SET @a = 1;
+EXECUTE stmt USING @a;
+SET @a = 0;
+EXECUTE stmt USING @a;
+
+PREPARE stmt FROM "SELECT (BIT_AND(i) = 1), BIT_AND(i) FROM t1 WHERE i = ?";
+SET @a = 0;
+EXECUTE stmt USING @a;
+SET @a = 1;
+EXECUTE stmt USING @a;
+SET @a = 0;
+EXECUTE stmt USING @a;
+
+PREPARE stmt FROM "SELECT (BIT_XOR(i) = 1), BIT_XOR(i) FROM t1 WHERE i = ?";
+SET @a = 0;
+EXECUTE stmt USING @a;
+SET @a = 1;
+EXECUTE stmt USING @a;
+SET @a = 0;
+EXECUTE stmt USING @a;
+
+DEALLOCATE PREPARE stmt;
+DROP TABLE t1;
+
+
+--echo End of 4.1 tests.
--- 1.37/mysql-test/t/func_gconcat.test 2006-08-31 17:22:46 +04:00
+++ 1.38/mysql-test/t/func_gconcat.test 2006-08-31 17:22:46 +04:00
@@ -99,7 +99,7 @@ select ifnull(group_concat(concat(t1.id,
select distinct ifnull(group_concat(concat(t1.id, ':', t1.name)), 'shortname') as 'with
distinct: cutoff at length of shortname' from t1;
drop table t1;
-# check zero rows
+# check zero rows (bug#836)
create table t1(id int);
create table t2(id int);
insert into t1 values(0),(1);
| Thread |
|---|
| • bk commit into 4.1 tree (kroki:1.2538) BUG#21354 | kroki | 31 Aug |