summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJorgen Loland <jorgen.loland@sun.com>2009-11-13 12:22:39 +0100
committerJorgen Loland <jorgen.loland@sun.com>2009-11-13 12:22:39 +0100
commita120e969a83128f075b54a06155ccee0bb46b312 (patch)
tree647243c578e4358668d708f8fb7854fc8b3d9d76
parentcf872354a8b20daced728a9c76c4d25648f88da8 (diff)
downloadmariadb-git-a120e969a83128f075b54a06155ccee0bb46b312.tar.gz
Bug#48052: Valgrind warning - uninitialized value in
init_read_record() - (records.cc:274) Item_cond::used_tables_cache was accessed in records.cc#init_read_record() without being initialized. It had not been initialized because it was wrongly assumed that the Item's variables would not be accessed, and hence quick_fix_field() was used instead of fix_fields() to save a few CPU cycles at creation time. The fix is to properly initilize the Item by replacing quick_fix_field() with fix_fields(). mysql-test/r/select.result: Add test for BUG#48052 mysql-test/t/select.test: Add test for BUG#48052 sql/sql_select.cc: Properly initialize Item_cond_and by calling fix_fields (instead of quick_fix_field) when the Item that "ANDs" WHERE clause conditions with HAVING clause conditions is created.
-rw-r--r--mysql-test/r/select.result18
-rw-r--r--mysql-test/t/select.test33
-rw-r--r--sql/sql_select.cc8
3 files changed, 53 insertions, 6 deletions
diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result
index e528b63ddb7..d0b2a575a32 100644
--- a/mysql-test/r/select.result
+++ b/mysql-test/r/select.result
@@ -4591,4 +4591,22 @@ field2
15:13:38
drop table A,AA,B,BB;
#end of test for bug#45266
+#
+# BUG#48052: Valgrind warning - uninitialized value in init_read_record()
+#
+CREATE TABLE t1 (
+pk int(11) NOT NULL,
+i int(11) DEFAULT NULL,
+v varchar(1) DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+INSERT INTO t1 VALUES (2,7,'m');
+INSERT INTO t1 VALUES (3,9,'m');
+SELECT v
+FROM t1
+WHERE NOT pk > 0
+HAVING v <= 't'
+ORDER BY pk;
+v
+DROP TABLE t1;
End of 5.1 tests
diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test
index 7502f451b69..ac65e5cbaf5 100644
--- a/mysql-test/t/select.test
+++ b/mysql-test/t/select.test
@@ -3931,4 +3931,37 @@ SELECT table1 .`time_key` field2 FROM B table1 LEFT JOIN BB JOIN A table5 ON
drop table A,AA,B,BB;
--echo #end of test for bug#45266
+
+--echo #
+--echo # BUG#48052: Valgrind warning - uninitialized value in init_read_record()
+--echo #
+
+# Needed in 6.0 codebase
+#--echo # Disable Index condition pushdown
+#--replace_column 1 #
+#SELECT @old_icp:=@@engine_condition_pushdown;
+#SET SESSION engine_condition_pushdown = 'OFF';
+
+CREATE TABLE t1 (
+ pk int(11) NOT NULL,
+ i int(11) DEFAULT NULL,
+ v varchar(1) DEFAULT NULL,
+ PRIMARY KEY (pk)
+);
+
+INSERT INTO t1 VALUES (2,7,'m');
+INSERT INTO t1 VALUES (3,9,'m');
+
+SELECT v
+FROM t1
+WHERE NOT pk > 0
+HAVING v <= 't'
+ORDER BY pk;
+
+# Needed in 6.0 codebase
+#--echo # Restore old value for Index condition pushdown
+#SET SESSION engine_condition_pushdown=@old_icp;
+
+DROP TABLE t1;
+
--echo End of 5.1 tests
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 7a4ab1c8365..00080b9b9d9 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -2131,17 +2131,13 @@ JOIN::exec()
DBUG_VOID_RETURN;
if (!curr_table->select->cond)
curr_table->select->cond= sort_table_cond;
- else // This should never happen
+ else
{
if (!(curr_table->select->cond=
new Item_cond_and(curr_table->select->cond,
sort_table_cond)))
DBUG_VOID_RETURN;
- /*
- Item_cond_and do not need fix_fields for execution, its parameters
- are fixed or do not need fix_fields, too
- */
- curr_table->select->cond->quick_fix_field();
+ curr_table->select->cond->fix_fields(thd, 0);
}
curr_table->select_cond= curr_table->select->cond;
curr_table->select_cond->top_level_item();