#At file:///Users/malff/BZR_TREE/mysql-trunk-bug59740/ based on revid:marc.alff@stripped
3568 Marc Alff 2011-01-28 [merge]
Local merge
modified:
mysql-test/include/icp_tests.inc
mysql-test/r/innodb_icp.result
mysql-test/r/innodb_icp_none.result
mysql-test/r/myisam_icp.result
mysql-test/r/myisam_icp_none.result
mysql-test/suite/parts/inc/partition_layout_check1.inc
mysql-test/suite/parts/inc/partition_layout_check2.inc
mysql-test/suite/parts/r/partition_recover_myisam.result
mysql-test/suite/parts/t/partition_alter1_1_2_myisam.test
mysql-test/suite/parts/t/partition_alter1_1_myisam.test
mysql-test/suite/parts/t/partition_alter1_2_myisam.test
mysql-test/suite/parts/t/partition_basic_myisam.test
mysql-test/suite/parts/t/partition_engine_myisam.test
mysql-test/suite/parts/t/partition_recover_myisam.test
mysql-test/suite/parts/t/partition_syntax_myisam.test
sql/item.h
sql/item_func.h
sql/item_timefunc.h
sql/sql_partition.cc
sql/sql_select.cc
sql/table.cc
=== modified file 'mysql-test/include/icp_tests.inc'
--- a/mysql-test/include/icp_tests.inc 2011-01-28 10:21:56 +0000
+++ b/mysql-test/include/icp_tests.inc 2011-01-28 12:57:04 +0000
@@ -726,6 +726,37 @@ WHERE NOT EXISTS
DROP TABLE t1,t2;
--echo #
+--echo # Bug#59186 Wrong results of join when ICP is enabled
+--echo #
+
+CREATE TABLE t1 (
+ pk INTEGER NOT NULL,
+ c1 VARCHAR(3) NOT NULL,
+ PRIMARY KEY (pk)
+);
+
+INSERT INTO t1 VALUES (1,'y'),(0,'or');
+
+CREATE TABLE t2 (
+ pk INTEGER NOT NULL,
+ c1 VARCHAR(3) NOT NULL,
+ c2 VARCHAR(6) NOT NULL,
+ PRIMARY KEY (pk)
+);
+
+INSERT INTO t2 VALUES (6,'y','RPOYT'),(10,'m','JINQE');
+
+let query=
+SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1
+WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR
+ (t1.pk > 1 AND t2.pk BETWEEN 6 AND 6);
+
+eval EXPLAIN $query;
+eval $query;
+
+DROP TABLE t1, t2;
+
+--echo #
--echo # Bug#58838 "Wrong results with HAVING + LIMIT without GROUP BY when
--echo # ICP is enabled"
--echo #
=== modified file 'mysql-test/r/innodb_icp.result'
--- a/mysql-test/r/innodb_icp.result 2011-01-28 10:21:56 +0000
+++ b/mysql-test/r/innodb_icp.result 2011-01-28 12:57:04 +0000
@@ -673,6 +673,33 @@ id select_type table type possible_keys
DROP TABLE t1,t2;
#
+# Bug#59186 Wrong results of join when ICP is enabled
+#
+CREATE TABLE t1 (
+pk INTEGER NOT NULL,
+c1 VARCHAR(3) NOT NULL,
+PRIMARY KEY (pk)
+);
+INSERT INTO t1 VALUES (1,'y'),(0,'or');
+CREATE TABLE t2 (
+pk INTEGER NOT NULL,
+c1 VARCHAR(3) NOT NULL,
+c2 VARCHAR(6) NOT NULL,
+PRIMARY KEY (pk)
+);
+INSERT INTO t2 VALUES (6,'y','RPOYT'),(10,'m','JINQE');
+EXPLAIN SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1
+WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR
+(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 1 Using index condition
+1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using where; Using join buffer (BNL, incremental buffers)
+SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1
+WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR
+(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6);
+c2
+DROP TABLE t1, t2;
+#
# Bug#58838 "Wrong results with HAVING + LIMIT without GROUP BY when
# ICP is enabled"
#
=== modified file 'mysql-test/r/innodb_icp_none.result'
--- a/mysql-test/r/innodb_icp_none.result 2011-01-28 10:21:56 +0000
+++ b/mysql-test/r/innodb_icp_none.result 2011-01-28 12:57:04 +0000
@@ -672,6 +672,33 @@ id select_type table type possible_keys
DROP TABLE t1,t2;
#
+# Bug#59186 Wrong results of join when ICP is enabled
+#
+CREATE TABLE t1 (
+pk INTEGER NOT NULL,
+c1 VARCHAR(3) NOT NULL,
+PRIMARY KEY (pk)
+);
+INSERT INTO t1 VALUES (1,'y'),(0,'or');
+CREATE TABLE t2 (
+pk INTEGER NOT NULL,
+c1 VARCHAR(3) NOT NULL,
+c2 VARCHAR(6) NOT NULL,
+PRIMARY KEY (pk)
+);
+INSERT INTO t2 VALUES (6,'y','RPOYT'),(10,'m','JINQE');
+EXPLAIN SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1
+WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR
+(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 1 Using where
+1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 Using where; Using join buffer (BNL, incremental buffers)
+SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1
+WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR
+(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6);
+c2
+DROP TABLE t1, t2;
+#
# Bug#58838 "Wrong results with HAVING + LIMIT without GROUP BY when
# ICP is enabled"
#
=== modified file 'mysql-test/r/myisam_icp.result'
--- a/mysql-test/r/myisam_icp.result 2011-01-28 10:21:56 +0000
+++ b/mysql-test/r/myisam_icp.result 2011-01-28 12:57:04 +0000
@@ -671,6 +671,33 @@ id select_type table type possible_keys
DROP TABLE t1,t2;
#
+# Bug#59186 Wrong results of join when ICP is enabled
+#
+CREATE TABLE t1 (
+pk INTEGER NOT NULL,
+c1 VARCHAR(3) NOT NULL,
+PRIMARY KEY (pk)
+);
+INSERT INTO t1 VALUES (1,'y'),(0,'or');
+CREATE TABLE t2 (
+pk INTEGER NOT NULL,
+c1 VARCHAR(3) NOT NULL,
+c2 VARCHAR(6) NOT NULL,
+PRIMARY KEY (pk)
+);
+INSERT INTO t2 VALUES (6,'y','RPOYT'),(10,'m','JINQE');
+EXPLAIN SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1
+WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR
+(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using index condition
+1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using where; Using join buffer (BNL, incremental buffers)
+SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1
+WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR
+(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6);
+c2
+DROP TABLE t1, t2;
+#
# Bug#58838 "Wrong results with HAVING + LIMIT without GROUP BY when
# ICP is enabled"
#
=== modified file 'mysql-test/r/myisam_icp_none.result'
--- a/mysql-test/r/myisam_icp_none.result 2011-01-28 10:21:56 +0000
+++ b/mysql-test/r/myisam_icp_none.result 2011-01-28 12:57:04 +0000
@@ -670,6 +670,33 @@ id select_type table type possible_keys
DROP TABLE t1,t2;
#
+# Bug#59186 Wrong results of join when ICP is enabled
+#
+CREATE TABLE t1 (
+pk INTEGER NOT NULL,
+c1 VARCHAR(3) NOT NULL,
+PRIMARY KEY (pk)
+);
+INSERT INTO t1 VALUES (1,'y'),(0,'or');
+CREATE TABLE t2 (
+pk INTEGER NOT NULL,
+c1 VARCHAR(3) NOT NULL,
+c2 VARCHAR(6) NOT NULL,
+PRIMARY KEY (pk)
+);
+INSERT INTO t2 VALUES (6,'y','RPOYT'),(10,'m','JINQE');
+EXPLAIN SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1
+WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR
+(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where
+1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 Using where; Using join buffer (BNL, incremental buffers)
+SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1
+WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR
+(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6);
+c2
+DROP TABLE t1, t2;
+#
# Bug#58838 "Wrong results with HAVING + LIMIT without GROUP BY when
# ICP is enabled"
#
=== modified file 'mysql-test/suite/parts/inc/partition_layout_check1.inc'
--- a/mysql-test/suite/parts/inc/partition_layout_check1.inc 2010-09-15 08:22:12 +0000
+++ b/mysql-test/suite/parts/inc/partition_layout_check1.inc 2011-01-28 12:28:15 +0000
@@ -29,14 +29,10 @@ DELETE FROM t0_definition;
let $MYSQLD_DATADIR= `select LEFT(@@datadir, LENGTH(@@datadir)-1)`;
#echo MYSQLD_DATADIR: $MYSQLD_DATADIR;
-# Dump the current definition of the table t1 to tmp1
-# This complicated method - let another mysqltest collect the output - is used
-# because of two reasons
+# Save the current definition of the table t1
# - SHOW CREATE TABLE t1 is at least currently most probably more reliable than
# the corresponding SELECT on the INFORMATION_SCHEMA
-# - SHOW CREATE TABLE .. cannot write its out put into a file like SELECT
-let $show_file= $MYSQLD_DATADIR/test/tmp1;
---exec echo "SHOW CREATE TABLE t1; exit; " | $MYSQL_TEST > $show_file 2>&1
+let $show_create= `SHOW CREATE TABLE t1`;
if ($do_file_tests)
{
# List the files belonging to the table t1
@@ -57,12 +53,13 @@ if (!$do_file_tests)
# Insert the current definition of the table t1 into t0_definition
eval INSERT INTO t0_definition SET state = 'old',
- create_command = load_file('$show_file'),
+ create_command = "$show_create",
file_list = @aux;
# Print the create table statement into the protocol
+# Added the concat to avoid changing the result files
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR '\r' ''
-SELECT create_command FROM t0_definition WHERE state = 'old';
+SELECT concat('SHOW CREATE TABLE t1;\nTable\tCreate Table\n',create_command,'\n') as `create_command` FROM t0_definition WHERE state = 'old';
if ($do_file_tests)
{
# We stored the list of files, therefore printing the content makes sense
=== modified file 'mysql-test/suite/parts/inc/partition_layout_check2.inc'
--- a/mysql-test/suite/parts/inc/partition_layout_check2.inc 2010-09-15 08:22:12 +0000
+++ b/mysql-test/suite/parts/inc/partition_layout_check2.inc 2011-01-28 12:28:15 +0000
@@ -28,9 +28,8 @@ DELETE FROM t0_definition WHERE state =
let $MYSQLD_DATADIR= `select LEFT(@@datadir, LENGTH(@@datadir)-1)`;
#echo MYSQLD_DATADIR: $MYSQLD_DATADIR;
-# Dump the current definition of the table t1 to tmp1
-let $show_file= $MYSQLD_DATADIR/test/tmp1;
---exec echo "SHOW CREATE TABLE t1; exit; " | $MYSQL_TEST > $show_file 2>&1
+# Save the current definition of the table t1
+let $show_create= `SHOW CREATE TABLE t1`;
if ($do_file_tests)
{
@@ -52,7 +51,7 @@ if (!$do_file_tests)
# Insert the current definition of the table t1 into t0_definition
eval INSERT INTO t0_definition SET state = 'new',
- create_command = load_file('$show_file'),
+ create_command = "$show_create",
file_list = @aux;
# Print the old and new table layout, if they differ
=== modified file 'mysql-test/suite/parts/r/partition_recover_myisam.result'
--- a/mysql-test/suite/parts/r/partition_recover_myisam.result 2010-10-01 16:11:50 +0000
+++ b/mysql-test/suite/parts/r/partition_recover_myisam.result 2011-01-28 13:49:59 +0000
@@ -18,6 +18,13 @@ a
9
10
11
+Warnings:
+Error 145 Table './test/t1_will_crash' is marked as crashed and should be repaired
+Error 1194 Table 't1_will_crash' is marked as crashed and should be repaired
+Error 1034 1 client is using or hasn't closed the table properly
+Error 1034 Size of indexfile is: 1024 Should be: 2048
+Error 1034 Size of datafile is: 77 Should be: 7
+Error 1034 Number of rows changed from 1 to 11
DROP TABLE t1_will_crash;
CREATE TABLE t1_will_crash (a INT, KEY (a))
ENGINE=MyISAM
@@ -41,4 +48,11 @@ a
9
10
11
+Warnings:
+Error 145 Table './test/t1_will_crash#P#p1' is marked as crashed and should be repaired
+Error 1194 Table 't1_will_crash' is marked as crashed and should be repaired
+Error 1034 1 client is using or hasn't closed the table properly
+Error 1034 Size of indexfile is: 1024 Should be: 2048
+Error 1034 Size of datafile is: 28 Should be: 7
+Error 1034 Number of rows changed from 1 to 4
DROP TABLE t1_will_crash;
=== modified file 'mysql-test/suite/parts/t/partition_alter1_1_2_myisam.test'
--- a/mysql-test/suite/parts/t/partition_alter1_1_2_myisam.test 2010-06-17 17:17:17 +0000
+++ b/mysql-test/suite/parts/t/partition_alter1_1_2_myisam.test 2011-01-28 13:49:59 +0000
@@ -45,9 +45,6 @@ let $more_pk_ui_tests= 0;
# The server must support partitioning.
--source include/have_partition.inc
-# Does not work with --embedded
---source include/not_embedded.inc
-
#------------------------------------------------------------------------------#
# Engine specific settings and requirements
=== modified file 'mysql-test/suite/parts/t/partition_alter1_1_myisam.test'
--- a/mysql-test/suite/parts/t/partition_alter1_1_myisam.test 2010-06-17 17:17:17 +0000
+++ b/mysql-test/suite/parts/t/partition_alter1_1_myisam.test 2011-01-28 13:49:59 +0000
@@ -46,9 +46,6 @@ let $more_pk_ui_tests= 0;
# The server must support partitioning.
--source include/have_partition.inc
-# Does not work with --embedded
---source include/not_embedded.inc
-
#------------------------------------------------------------------------------#
# Engine specific settings and requirements
=== modified file 'mysql-test/suite/parts/t/partition_alter1_2_myisam.test'
--- a/mysql-test/suite/parts/t/partition_alter1_2_myisam.test 2010-06-17 17:17:17 +0000
+++ b/mysql-test/suite/parts/t/partition_alter1_2_myisam.test 2011-01-28 13:49:59 +0000
@@ -46,9 +46,6 @@ let $more_pk_ui_tests= 0;
# The server must support partitioning.
--source include/have_partition.inc
-# Does not work with --embedded
---source include/not_embedded.inc
-
#------------------------------------------------------------------------------#
# Engine specific settings and requirements
=== modified file 'mysql-test/suite/parts/t/partition_basic_myisam.test'
--- a/mysql-test/suite/parts/t/partition_basic_myisam.test 2010-06-17 17:17:17 +0000
+++ b/mysql-test/suite/parts/t/partition_basic_myisam.test 2011-01-28 13:49:59 +0000
@@ -43,9 +43,6 @@ let $more_pk_ui_tests= 0;
# The server must support partitioning.
--source include/have_partition.inc
-# Does not work with --embedded
---source include/not_embedded.inc
-
#------------------------------------------------------------------------------#
# Engine specific settings and requirements
=== modified file 'mysql-test/suite/parts/t/partition_engine_myisam.test'
--- a/mysql-test/suite/parts/t/partition_engine_myisam.test 2010-06-17 17:17:17 +0000
+++ b/mysql-test/suite/parts/t/partition_engine_myisam.test 2011-01-28 13:49:59 +0000
@@ -42,9 +42,6 @@ let $more_pk_ui_tests= 0;
# The server must support partitioning.
--source include/have_partition.inc
-# Does not work with --embedded
---source include/not_embedded.inc
-
#------------------------------------------------------------------------------#
# Engine specific settings and requirements
=== modified file 'mysql-test/suite/parts/t/partition_recover_myisam.test'
--- a/mysql-test/suite/parts/t/partition_recover_myisam.test 2010-10-01 16:11:50 +0000
+++ b/mysql-test/suite/parts/t/partition_recover_myisam.test 2011-01-28 13:49:59 +0000
@@ -20,7 +20,8 @@ FLUSH TABLES;
let $MYSQLD_DATADIR= `select @@datadir`;
--remove_file $MYSQLD_DATADIR/test/t1_will_crash.MYI
--copy_file std_data/corrupt_t1.MYI $MYSQLD_DATADIR/test/t1_will_crash.MYI
---disable_warnings
+--replace_result \\ /
+--replace_regex /Table '.*data/Table './
SELECT * FROM t1_will_crash;
--enable_warnings
DROP TABLE t1_will_crash;
@@ -35,7 +36,8 @@ FLUSH TABLES;
--echo # head -c1024 t1#P#p1.MYI > corrupt_t1#P#p1.MYI
--remove_file $MYSQLD_DATADIR/test/t1_will_crash#P#p1.MYI
--copy_file std_data/corrupt_t1#P#p1.MYI $MYSQLD_DATADIR/test/t1_will_crash#P#p1.MYI
---disable_warnings
+--replace_result \\ /
+--replace_regex /Table '.*data/Table './
SELECT * FROM t1_will_crash;
--enable_warnings
DROP TABLE t1_will_crash;
=== modified file 'mysql-test/suite/parts/t/partition_syntax_myisam.test'
--- a/mysql-test/suite/parts/t/partition_syntax_myisam.test 2010-06-17 17:17:17 +0000
+++ b/mysql-test/suite/parts/t/partition_syntax_myisam.test 2011-01-28 13:49:59 +0000
@@ -42,9 +42,6 @@ let $more_pk_ui_tests= 0;
# The server must support partitioning.
--source include/have_partition.inc
-# Does not work with --embedded
---source include/not_embedded.inc
-
#------------------------------------------------------------------------------#
# Engine specific settings and requirements
=== modified file 'sql/item.h'
--- a/sql/item.h 2011-01-10 16:37:47 +0000
+++ b/sql/item.h 2011-01-28 13:49:59 +0000
@@ -1,7 +1,7 @@
#ifndef ITEM_INCLUDED
#define ITEM_INCLUDED
-/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
=== modified file 'sql/item_func.h'
--- a/sql/item_func.h 2011-01-10 16:37:47 +0000
+++ b/sql/item_func.h 2011-01-28 13:49:59 +0000
@@ -1,7 +1,7 @@
#ifndef ITEM_FUNC_INCLUDED
#define ITEM_FUNC_INCLUDED
-/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
=== modified file 'sql/item_timefunc.h'
--- a/sql/item_timefunc.h 2011-01-10 16:37:47 +0000
+++ b/sql/item_timefunc.h 2011-01-28 13:49:59 +0000
@@ -1,7 +1,7 @@
#ifndef ITEM_TIMEFUNC_INCLUDED
#define ITEM_TIMEFUNC_INCLUDED
-/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
=== modified file 'sql/sql_partition.cc'
--- a/sql/sql_partition.cc 2011-01-26 21:12:56 +0000
+++ b/sql/sql_partition.cc 2011-01-28 13:49:59 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc 2011-01-28 10:21:56 +0000
+++ b/sql/sql_select.cc 2011-01-28 12:57:04 +0000
@@ -10036,8 +10036,8 @@ static bool uses_index_fields_only(Item
Item *make_cond_for_index(Item *cond, TABLE *table, uint keyno,
bool other_tbls_ok)
{
- if (!cond)
- return NULL;
+ DBUG_ASSERT(cond != NULL);
+
if (cond->type() == Item::COND_ITEM)
{
uint n_marked= 0;
@@ -10046,7 +10046,7 @@ Item *make_cond_for_index(Item *cond, TA
table_map used_tables= 0;
Item_cond_and *new_cond=new Item_cond_and;
if (!new_cond)
- return (Item*) 0;
+ return NULL;
List_iterator<Item> li(*((Item_cond*) cond)->argument_list());
Item *item;
while ((item=li++))
@@ -10063,7 +10063,7 @@ Item *make_cond_for_index(Item *cond, TA
cond->marker= ICP_COND_USES_INDEX_ONLY;
switch (new_cond->argument_list()->elements) {
case 0:
- return (Item*) 0;
+ return NULL;
case 1:
new_cond->used_tables_cache= used_tables;
return new_cond->argument_list()->head();
@@ -10077,14 +10077,14 @@ Item *make_cond_for_index(Item *cond, TA
{
Item_cond_or *new_cond=new Item_cond_or;
if (!new_cond)
- return (Item*) 0;
+ return NULL;
List_iterator<Item> li(*((Item_cond*) cond)->argument_list());
Item *item;
while ((item=li++))
{
Item *fix= make_cond_for_index(item, table, keyno, other_tbls_ok);
if (!fix)
- return (Item*) 0;
+ return NULL;
new_cond->argument_list()->push_back(fix);
n_marked += test(item->marker == ICP_COND_USES_INDEX_ONLY);
}
@@ -10098,7 +10098,15 @@ Item *make_cond_for_index(Item *cond, TA
}
if (!uses_index_fields_only(cond, table, keyno, other_tbls_ok))
- return (Item*) 0;
+ {
+ /*
+ Reset marker since it might have the value
+ ICP_COND_USES_INDEX_ONLY if this condition is part of the select
+ condition for multiple tables.
+ */
+ cond->marker= 0;
+ return NULL;
+ }
cond->marker= ICP_COND_USES_INDEX_ONLY;
return cond;
}
@@ -10182,11 +10190,11 @@ Item *make_cond_remainder(Item *cond, bo
static void push_index_cond(JOIN_TAB *tab, uint keyno, bool other_tbls_ok)
{
DBUG_ENTER("push_index_cond");
- Item *idx_cond;
/*
We will only attempt to push down an index condition when the
following criteria are true:
+ 0. The table has a select condition
1. The storage engine supports ICP.
2. The system variable for enabling ICP is ON.
3. The query is not a multi-table update or delete statement. The reason
@@ -10196,7 +10204,8 @@ static void push_index_cond(JOIN_TAB *ta
when doing the update part and result in either not finding
the record to update or updating the wrong record.
*/
- if (tab->table->file->index_flags(keyno, 0, 1) &
+ if (tab->select_cond &&
+ tab->table->file->index_flags(keyno, 0, 1) &
HA_DO_INDEX_COND_PUSHDOWN &&
tab->join->thd->optimizer_switch_flag(OPTIMIZER_SWITCH_INDEX_CONDITION_PUSHDOWN) &&
tab->join->thd->lex->sql_command != SQLCOM_UPDATE_MULTI &&
@@ -10204,8 +10213,8 @@ static void push_index_cond(JOIN_TAB *ta
{
DBUG_EXECUTE("where", print_where(tab->select_cond, "full cond",
QT_ORDINARY););
- idx_cond= make_cond_for_index(tab->select_cond, tab->table, keyno,
- other_tbls_ok);
+ Item *idx_cond= make_cond_for_index(tab->select_cond, tab->table, keyno,
+ other_tbls_ok);
DBUG_EXECUTE("where", print_where(idx_cond, "idx cond", QT_ORDINARY););
if (idx_cond)
{
=== modified file 'sql/table.cc'
--- a/sql/table.cc 2011-01-18 10:32:38 +0000
+++ b/sql/table.cc 2011-01-28 13:49:59 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
No bundle (reason: revision is a merge).
| Thread |
|---|
| • bzr commit into mysql-trunk branch (marc.alff:3568) | Marc Alff | 28 Jan |