From 8c9b2f3429fd385ded604ec048f1fcbd89c3a846 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Sat, 15 Feb 2014 01:21:46 +0400 Subject: [PATCH 1/8] MDEV-5581: Server crashes in in JOIN::prepare on 2nd execution of PS with materialization+semijoin - The problem was that JOIN::prepare() tried to set TABLE::maybe_null for a table in join. Non-merged semi-join tables 1) are present as join's base tables on second EXECUTE, but 2) do not yet have a TABLE object. Worked around the problem by putting mixed_implicit_grouping into JOIN object, and then passing it to JTBM tables in setup_jtbm_semi_joins(). --- mysql-test/r/subselect_sj.result | 16 ++++++++++++++++ mysql-test/r/subselect_sj_jcl6.result | 16 ++++++++++++++++ mysql-test/t/subselect_sj.test | 19 +++++++++++++++++++ sql/opt_subselect.cc | 1 + sql/sql_select.cc | 4 ++-- sql/sql_select.h | 3 ++- 6 files changed, 56 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/subselect_sj.result b/mysql-test/r/subselect_sj.result index d32cba1952b..73498fb2c19 100644 --- a/mysql-test/r/subselect_sj.result +++ b/mysql-test/r/subselect_sj.result @@ -2782,4 +2782,20 @@ db mysql information_schema DROP TABLE t1; +# +# MDEV-5581: Server crashes in in JOIN::prepare on 2nd execution of PS with materialization+semijoin +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (2),(3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (8),(9); +CREATE TABLE t3 (c INT, INDEX(c)); +INSERT INTO t2 VALUES (5),(6); +PREPARE stmt FROM +"SELECT * FROM t1 WHERE ( 9, 5 ) IN ( SELECT b, COUNT(*) FROM t2 WHERE 1 IN ( SELECT MIN(c) FROM t3 ) )"; +EXECUTE stmt; +a +EXECUTE stmt; +a +DROP TABLE t1,t2,t3; set optimizer_switch=@subselect_sj_tmp; diff --git a/mysql-test/r/subselect_sj_jcl6.result b/mysql-test/r/subselect_sj_jcl6.result index 55068ce257a..bc8fb3cf04a 100644 --- a/mysql-test/r/subselect_sj_jcl6.result +++ b/mysql-test/r/subselect_sj_jcl6.result @@ -2796,6 +2796,22 @@ db information_schema mysql DROP TABLE t1; +# +# MDEV-5581: Server crashes in in JOIN::prepare on 2nd execution of PS with materialization+semijoin +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (2),(3); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (8),(9); +CREATE TABLE t3 (c INT, INDEX(c)); +INSERT INTO t2 VALUES (5),(6); +PREPARE stmt FROM +"SELECT * FROM t1 WHERE ( 9, 5 ) IN ( SELECT b, COUNT(*) FROM t2 WHERE 1 IN ( SELECT MIN(c) FROM t3 ) )"; +EXECUTE stmt; +a +EXECUTE stmt; +a +DROP TABLE t1,t2,t3; set optimizer_switch=@subselect_sj_tmp; # # BUG#49129: Wrong result with IN-subquery with join_cache_level=6 and firstmatch=off diff --git a/mysql-test/t/subselect_sj.test b/mysql-test/t/subselect_sj.test index c05896fadda..9469b4acb3a 100644 --- a/mysql-test/t/subselect_sj.test +++ b/mysql-test/t/subselect_sj.test @@ -2489,5 +2489,24 @@ INSERT INTO t1 VALUES ('mysql'),('information_schema'); SELECT * FROM t1 WHERE db IN (SELECT `SCHEMA_NAME` FROM information_schema.SCHEMATA); DROP TABLE t1; +--echo # +--echo # MDEV-5581: Server crashes in in JOIN::prepare on 2nd execution of PS with materialization+semijoin +--echo # +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (2),(3); + +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (8),(9); + +CREATE TABLE t3 (c INT, INDEX(c)); +INSERT INTO t2 VALUES (5),(6); + +PREPARE stmt FROM +"SELECT * FROM t1 WHERE ( 9, 5 ) IN ( SELECT b, COUNT(*) FROM t2 WHERE 1 IN ( SELECT MIN(c) FROM t3 ) )"; +EXECUTE stmt; +EXECUTE stmt; + +DROP TABLE t1,t2,t3; + # The following command must be the last one the file set optimizer_switch=@subselect_sj_tmp; diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index 60eee3fd48f..f19d9550f68 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -5204,6 +5204,7 @@ bool setup_jtbm_semi_joins(JOIN *join, List *join_list, if (!(*join_where)->fixed) (*join_where)->fix_fields(join->thd, join_where); } + table->table->maybe_null= test(join->mixed_implicit_grouping); } if ((nested_join= table->nested_join)) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 6f96a432a97..8d85d46f244 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -616,7 +616,7 @@ JOIN::prepare(Item ***rref_pointer_array, aggregate functions in the SELECT list is a MySQL exptenstion that is allowed only if the ONLY_FULL_GROUP_BY sql mode is not set. */ - bool mixed_implicit_grouping= false; + mixed_implicit_grouping= false; if ((~thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY) && select_lex->with_sum_func && !group_list) { @@ -655,7 +655,7 @@ JOIN::prepare(Item ***rref_pointer_array, Note: this loop doesn't touch tables inside merged semi-joins, because subquery-to-semijoin conversion has not been done yet. This is intended. */ - if (mixed_implicit_grouping) + if (mixed_implicit_grouping && tbl->table) tbl->table->maybe_null= 1; } diff --git a/sql/sql_select.h b/sql/sql_select.h index be595972671..569c0394d6e 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -1110,7 +1110,8 @@ public: */ JOIN *tmp_join; ROLLUP rollup; ///< Used with rollup - + + bool mixed_implicit_grouping; bool select_distinct; ///< Set if SELECT DISTINCT /** If we have the GROUP BY statement in the query, From 820b1a66870639951cdf7f1cbfef14c3ba889615 Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Tue, 18 Feb 2014 17:15:25 +0400 Subject: [PATCH 2/8] MDEV-5615 crash in Gcalc_function::add_operation. The result is EMPTY for a buffer(line, -1), but we still need one FALSE operation to be stored in the condition. And we actually add it but forgot to alloc memory to store it. --- mysql-test/r/gis-precise.result | 3 +++ mysql-test/t/gis-precise.test | 3 +++ sql/item_geofunc.cc | 6 ++++-- sql/spatial.cc | 3 ++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/gis-precise.result b/mysql-test/r/gis-precise.result index 5f3c5988f1e..37a1509e19f 100644 --- a/mysql-test/r/gis-precise.result +++ b/mysql-test/r/gis-precise.result @@ -452,3 +452,6 @@ ST_NUMPOINTS(ST_EXTERIORRING(ST_BUFFER( POLYGONFROMTEXT( 'POLYGON( ( 0.0 -3.0, 0.0 -3.0 ))' ), 136 +select astext(buffer(st_linestringfromwkb(linestring(point(-1,1), point(-1,-2))),-1)); +astext(buffer(st_linestringfromwkb(linestring(point(-1,1), point(-1,-2))),-1)) +GEOMETRYCOLLECTION EMPTY diff --git a/mysql-test/t/gis-precise.test b/mysql-test/t/gis-precise.test index d021bb0b53d..0c6410b5a75 100644 --- a/mysql-test/t/gis-precise.test +++ b/mysql-test/t/gis-precise.test @@ -325,3 +325,6 @@ SELECT ST_NUMPOINTS(ST_EXTERIORRING(ST_BUFFER( POLYGONFROMTEXT( 'POLYGON( ( 0.0 0.0 -3.0 ))' ), 3 ))); +# MDEV-5615 crash in Gcalc_function::add_operation +select astext(buffer(st_linestringfromwkb(linestring(point(-1,1), point(-1,-2))),-1)); + diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc index 211140c029b..d8612abb59c 100644 --- a/sql/item_geofunc.cc +++ b/sql/item_geofunc.cc @@ -857,7 +857,7 @@ String *Item_func_spatial_operation::val_str(String *str_value) str_value->length(0); str_value->q_append(srid); - if (!Geometry::create_from_opresult(&buffer1, str_value, res_receiver)) + if (Geometry::create_from_opresult(&buffer1, str_value, res_receiver)) goto exit; exit: @@ -1114,6 +1114,8 @@ int Item_func_buffer::Transporter::start_line() { if (buffer_op == Gcalc_function::op_difference) { + if (m_fn->reserve_op_buffer(1)) + return 1; m_fn->add_operation(Gcalc_function::op_false, 0); skip_line= TRUE; return 0; @@ -1315,7 +1317,7 @@ String *Item_func_buffer::val_str(String *str_value) str_value->length(0); str_value->q_append(srid); - if (!Geometry::create_from_opresult(&buffer, str_value, res_receiver)) + if (Geometry::create_from_opresult(&buffer, str_value, res_receiver)) goto mem_error; null_value= 0; diff --git a/sql/spatial.cc b/sql/spatial.cc index 8f74d4fa4a7..551c79d4d90 100644 --- a/sql/spatial.cc +++ b/sql/spatial.cc @@ -298,7 +298,8 @@ int Geometry::create_from_opresult(Geometry_buffer *g_buf, res->q_append((char) wkb_ndr); res->q_append(geom_type); - return obj->init_from_opresult(res, rr.result(), rr.length()); + return obj->init_from_opresult(res, rr.result(), rr.length()) == 0 && + rr.length(); } From 84580f950cca0bd0c7369e3e84b60d4dcfe81ba6 Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Tue, 18 Feb 2014 17:45:08 +0400 Subject: [PATCH 3/8] MDEV-5481 mysqldump fails to dump geometry types properly. Fixed so the MYSQL_TYPE_GEOMETRY is treated as BLOB. --- client/mysqldump.c | 3 ++- mysql-test/r/mysqldump.result | 14 ++++++++++++++ mysql-test/t/mysqldump.test | 15 +++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index bf4dcfefa19..3c8e0f9a508 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -3637,7 +3637,8 @@ static void dump_table(char *table, char *db) field->type == MYSQL_TYPE_BLOB || field->type == MYSQL_TYPE_LONG_BLOB || field->type == MYSQL_TYPE_MEDIUM_BLOB || - field->type == MYSQL_TYPE_TINY_BLOB)) ? 1 : 0; + field->type == MYSQL_TYPE_TINY_BLOB || + field->type == MYSQL_TYPE_GEOMETRY)) ? 1 : 0; if (extended_insert && !opt_xml) { if (i == 0) diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 02251cc8c7c..0dbb17cdbed 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -5193,6 +5193,20 @@ slow_log CREATE TABLE `slow_log` ( SET @@global.log_output= @old_log_output_state; SET @@global.slow_query_log= @old_slow_query_log_state; SET @@global.general_log= @old_general_log_state; +# MDEV-5481 mysqldump fails to dump geometry types properly +create table t1 (g GEOMETRY) CHARSET koi8r; +create table t2 (g GEOMETRY) CHARSET koi8r; +insert into t1 values (point(1,1)), (point(2,2)); +################################################## +\0\0\0\0\0\0\0\0\0\0\0\0\0ð?\0\0\0\0\0\0ð? +\0\0\0\0\0\0\0\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@ +################################################## +LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/t1.txt' INTO TABLE t2 CHARACTER SET koi8r; +select astext(g) from t2; +astext(g) +POINT(1 1) +POINT(2 2) +drop table t1, t2; # # End of 5.1 tests # diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 76a17987fb6..ca47e8ed58d 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -2345,6 +2345,21 @@ SET @@global.log_output= @old_log_output_state; SET @@global.slow_query_log= @old_slow_query_log_state; SET @@global.general_log= @old_general_log_state; +--echo # MDEV-5481 mysqldump fails to dump geometry types properly + +create table t1 (g GEOMETRY) CHARSET koi8r; +create table t2 (g GEOMETRY) CHARSET koi8r; +insert into t1 values (point(1,1)), (point(2,2)); +--exec $MYSQL_DUMP --hex-blob --character-sets-dir=$MYSQL_SHAREDIR/charsets --tab=$MYSQLTEST_VARDIR/tmp/ test t1 +--echo ################################################## +--cat_file $file +--echo ################################################## +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval LOAD DATA INFILE '$file' INTO TABLE t2 CHARACTER SET koi8r +--remove_file $file +select astext(g) from t2; +drop table t1, t2; + --echo # --echo # End of 5.1 tests --echo # From 097b6440066cb29a7a4ca769a3717ea0ebde6329 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Wed, 19 Feb 2014 17:45:33 +0400 Subject: [PATCH 4/8] MDEV-5600: Wrong result on 2nd execution of PS depending on the length of the query - Item_direct_view_ref didn't clear its pointer to item_equal in ::cleanup. - Some Item_direct_view_ref objects have statement lifetime (i.e. they survive across multiple EXECUTE commands). Item_equal objects live only for the duration of one EXECUTE. This caused Item_direct_view_ref to have a stale pointer, which could cause all sorts of effects. (In this bug's testcase it was pointing to the wrong Item_equal, causing wrong query result) - Fixed by doing what Item_field::cleanup() does - don't keep item_equal pointer value. - There is no testcase because the only testcase I've got is highly fragile (e.g. the bug will not show up if @@datadir is of the wrong length). --- sql/item.h | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/item.h b/sql/item.h index 58abc42dd80..80f8ef966bb 100644 --- a/sql/item.h +++ b/sql/item.h @@ -3103,6 +3103,7 @@ public: void cleanup() { null_ref_table= NULL; + item_equal= NULL; Item_direct_ref::cleanup(); } }; From 260c802e7d66b30e5045bb82243b4d15c704e78c Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Wed, 19 Feb 2014 17:47:02 +0400 Subject: [PATCH 5/8] Add a debugger helper function that does this: (gdb) p dbug_print_table_row(table) $33 = "SUBQUERY2_t1(col_int_key,col_varchar_nokey)=(7,c)" --- sql/filesort.cc | 79 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/sql/filesort.cc b/sql/filesort.cc index d72e1c83355..7cb446a9b96 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -398,6 +398,84 @@ static uchar *read_buffpek_from_file(IO_CACHE *buffpek_pointers, uint count, } #ifndef DBUG_OFF + +/* Buffer where record is returned */ +char dbug_print_row_buff[512]; + +/* Temporary buffer for printing a column */ +char dbug_print_row_buff_tmp[512]; + +/* + Print table's current row into a buffer and return a pointer to it. + + This is intended to be used from gdb: + + (gdb) p dbug_print_table_row(table) + $33 = "SUBQUERY2_t1(col_int_key,col_varchar_nokey)=(7,c)" + (gdb) + + Only columns in table->read_set are printed +*/ + +const char* dbug_print_table_row(TABLE *table) +{ + Field **pfield; + String tmp(dbug_print_row_buff_tmp, + sizeof(dbug_print_row_buff_tmp),&my_charset_bin); + + String output(dbug_print_row_buff, sizeof(dbug_print_row_buff), + &my_charset_bin); + + output.length(0); + output.append(table->alias); + output.append("("); + bool first= true; + + for (pfield= table->field; *pfield ; pfield++) + { + if (table->read_set && !bitmap_is_set(table->read_set, (*pfield)->field_index)) + continue; + + if (first) + first= false; + else + output.append(","); + + output.append((*pfield)->field_name? (*pfield)->field_name: "NULL"); + } + + output.append(")=("); + + first= true; + for (pfield= table->field; *pfield ; pfield++) + { + Field *field= *pfield; + + if (table->read_set && !bitmap_is_set(table->read_set, (*pfield)->field_index)) + continue; + + if (first) + first= false; + else + output.append(","); + + if (field->is_null()) + output.append("NULL"); + else + { + if (field->type() == MYSQL_TYPE_BIT) + (void) field->val_int_as_str(&tmp, 1); + else + field->val_str(&tmp); + output.append(tmp.ptr(), tmp.length()); + } + } + output.append(")"); + + return output.c_ptr_safe(); +} + + /* Print a text, SQL-like record representation into dbug trace. @@ -446,6 +524,7 @@ static void dbug_print_record(TABLE *table, bool print_rowid) fprintf(DBUG_FILE, "\n"); DBUG_UNLOCK_FILE; } + #endif /** From ddc21f7977b47d8779b7f596b82798d222b1e808 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Wed, 19 Feb 2014 17:52:47 +0400 Subject: [PATCH 6/8] Fix compile failure: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In function ‘void* memset(void*, int, size_t)’, inlined from ‘void Lifo_buffer::set_buffer_space(uchar*, uchar*)’ at sql_lifo_buffer.h:70:5, inlined from ‘int DsMrr_impl::dsmrr_init(handler*, RANGE_SEQ_IF*, void*, uint, uint, HANDLER_BUFFER*)’ at multi_range_read.cc:895:62: /usr/include/i386-linux-gnu/bits/string3.h:82:32: error: call to ‘__warn_memset_zero_len’ declared with attribute warning: memset used with constant zero length parameter; this could be due to transposed parameters [-Werror] It was intentional that the buffer is set to zero length there. --- sql/sql_lifo_buffer.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/sql_lifo_buffer.h b/sql/sql_lifo_buffer.h index 34f9624436d..95fe02ecda7 100644 --- a/sql/sql_lifo_buffer.h +++ b/sql/sql_lifo_buffer.h @@ -67,7 +67,8 @@ public: { start= start_arg; end= end_arg; - TRASH(start, end - start); + if (end != start) + TRASH(start, end - start); reset(); } From 6ebaa4939e0a4e22491a4a251863f0b31af90829 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Wed, 19 Feb 2014 18:34:12 +0400 Subject: [PATCH 7/8] Backport the following from 5.5 to 5.3: MDEV-4556 Server crashes in SEL_ARG::rb_insert with index_merge+index_merge_sort_union, FORCE INDEX - merge_same_index_scans() may put the same SEL_ARG tree in multiple result plans. make it call incr_refs() on the SEL_ARG trees that it does key_or() on, because key_or(sel_arg_tree_1, sel_arg_tree_2) call may invalidate SEL_ARG trees pointed by sel_arg_tree_1 and sel_arg_tree_2. --- mysql-test/r/index_merge_myisam.result | 26 +++++++++++++++++++++++++ mysql-test/t/index_merge_myisam.test | 27 ++++++++++++++++++++++++++ sql/opt_range.cc | 2 ++ 3 files changed, 55 insertions(+) diff --git a/mysql-test/r/index_merge_myisam.result b/mysql-test/r/index_merge_myisam.result index 3616171ef58..e03adf36cc8 100644 --- a/mysql-test/r/index_merge_myisam.result +++ b/mysql-test/r/index_merge_myisam.result @@ -1617,4 +1617,30 @@ GROUP BY 2; COUNT(DISTINCT t2.b) CONCAT(t1.c) 2 0 DROP TABLE t1,t2,t3; +# +# MDEV-4556 Server crashes in SEL_ARG::rb_insert with index_merge+index_merge_sort_union, FORCE INDEX +# +CREATE TABLE t1 ( +pk int, +code char(2), +population_rate int, +area_rate int, +primary key (pk), +index (code), +key (population_rate), +key (area_rate) +); +INSERT INTO t1 VALUES (1,'WI',20, 23), (2, 'WA', 13, 18); +EXPLAIN +SELECT * FROM t1 FORCE INDEX ( PRIMARY, population_rate, area_rate, code ) +WHERE pk = 1 OR population_rate = 1 OR ( area_rate IN ( 1,2 ) OR area_rate IS NULL ) +AND (population_rate = 25 OR area_rate BETWEEN 2 AND 25 OR code BETWEEN 'MA' AND 'TX'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index_merge PRIMARY,code,population_rate,area_rate PRIMARY,population_rate,area_rate 4,5,5 NULL 2 Using sort_union(PRIMARY,population_rate,area_rate); Using where +SELECT * FROM t1 FORCE INDEX ( PRIMARY, population_rate, area_rate, code ) +WHERE pk = 1 OR population_rate = 1 OR ( area_rate IN ( 1,2 ) OR area_rate IS NULL ) +AND (population_rate = 25 OR area_rate BETWEEN 2 AND 25 OR code BETWEEN 'MA' AND 'TX'); +pk code population_rate area_rate +1 WI 20 23 +DROP TABLE t1; set optimizer_switch= @optimizer_switch_save; diff --git a/mysql-test/t/index_merge_myisam.test b/mysql-test/t/index_merge_myisam.test index 614c6595d61..07f83fa6713 100644 --- a/mysql-test/t/index_merge_myisam.test +++ b/mysql-test/t/index_merge_myisam.test @@ -149,5 +149,32 @@ GROUP BY 2; DROP TABLE t1,t2,t3; +--echo # +--echo # MDEV-4556 Server crashes in SEL_ARG::rb_insert with index_merge+index_merge_sort_union, FORCE INDEX +--echo # +CREATE TABLE t1 ( + pk int, + code char(2), + population_rate int, + area_rate int, + primary key (pk), + index (code), + key (population_rate), + key (area_rate) +); + +INSERT INTO t1 VALUES (1,'WI',20, 23), (2, 'WA', 13, 18); + +EXPLAIN +SELECT * FROM t1 FORCE INDEX ( PRIMARY, population_rate, area_rate, code ) +WHERE pk = 1 OR population_rate = 1 OR ( area_rate IN ( 1,2 ) OR area_rate IS NULL ) +AND (population_rate = 25 OR area_rate BETWEEN 2 AND 25 OR code BETWEEN 'MA' AND 'TX'); + +SELECT * FROM t1 FORCE INDEX ( PRIMARY, population_rate, area_rate, code ) +WHERE pk = 1 OR population_rate = 1 OR ( area_rate IN ( 1,2 ) OR area_rate IS NULL ) +AND (population_rate = 25 OR area_rate BETWEEN 2 AND 25 OR code BETWEEN 'MA' AND 'TX'); + +DROP TABLE t1; + set optimizer_switch= @optimizer_switch_save; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index a112f16dd3c..bbbfee2462d 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -4806,6 +4806,8 @@ TABLE_READ_PLAN *merge_same_index_scans(PARAM *param, SEL_IMERGE *imerge, bzero((*changed_tree)->keys, sizeof((*changed_tree)->keys[0])*param->keys); (*changed_tree)->keys_map.clear_all(); + key->incr_refs(); + (*tree)->keys[key_idx]->incr_refs(); if (((*changed_tree)->keys[key_idx]= key_or(param, key, (*tree)->keys[key_idx]))) (*changed_tree)->keys_map.set_bit(key_idx); From 3e03c9eae9089cd2cae0f378bd81ff29367f41eb Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Thu, 20 Feb 2014 21:27:33 -0800 Subject: [PATCH 8/8] After constant row substitution the optimizer should call the method update_used_tables for the the where condition to update cached indicators of constant subexpressions. It should be done before further possible simplification of the where condition. This change caused simplification of the executed where conditions in many test cases. --- mysql-test/r/derived_view.result | 2 +- mysql-test/r/func_compress.result | 1 - mysql-test/r/func_regexp.result | 2 +- mysql-test/r/join_outer.result | 2 +- mysql-test/r/join_outer_jcl6.result | 2 +- mysql-test/r/select.result | 6 +++--- mysql-test/r/select_jcl6.result | 6 +++--- mysql-test/r/select_pkeycache.result | 6 +++--- mysql-test/r/subselect.result | 2 +- mysql-test/r/subselect_extra.result | 4 ++-- mysql-test/r/subselect_no_mat.result | 2 +- mysql-test/r/subselect_no_opts.result | 2 +- mysql-test/r/subselect_no_scache.result | 2 +- mysql-test/r/subselect_no_semijoin.result | 2 +- mysql-test/r/type_datetime.result | 4 ++-- mysql-test/r/view.result | 2 +- sql/sql_select.cc | 1 + 17 files changed, 24 insertions(+), 24 deletions(-) diff --git a/mysql-test/r/derived_view.result b/mysql-test/r/derived_view.result index a37f9480e5c..acce2afb124 100644 --- a/mysql-test/r/derived_view.result +++ b/mysql-test/r/derived_view.result @@ -2243,7 +2243,7 @@ EXPLAIN EXTENDED SELECT a FROM v1 WHERE a > 100 ORDER BY b; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables Warnings: -Note 1003 select 4 AS `a` from `test`.`t1` where (4 > 100) order by 1 +Note 1003 select 4 AS `a` from `test`.`t1` where 0 order by 1 DROP VIEW v1; DROP TABLE t1; CREATE TABLE IF NOT EXISTS `galleries` ( diff --git a/mysql-test/r/func_compress.result b/mysql-test/r/func_compress.result index 786755f130c..37f7c475148 100644 --- a/mysql-test/r/func_compress.result +++ b/mysql-test/r/func_compress.result @@ -102,7 +102,6 @@ a foo Warnings: Error 1259 ZLIB: Input data corrupted -Error 1259 ZLIB: Input data corrupted explain select *, uncompress(a) from t1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 system NULL NULL NULL NULL 1 diff --git a/mysql-test/r/func_regexp.result b/mysql-test/r/func_regexp.result index 54aad23402f..4004520e47c 100644 --- a/mysql-test/r/func_regexp.result +++ b/mysql-test/r/func_regexp.result @@ -52,7 +52,7 @@ explain extended select * from t1 where xxx regexp('is a test of some long text id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00 Warnings: -Note 1003 select 'this is a test of some long text to see what happens' AS `xxx` from `test`.`t1` where ('this is a test of some long text to see what happens' regexp 'is a test of some long text to') +Note 1003 select 'this is a test of some long text to see what happens' AS `xxx` from `test`.`t1` where 1 select * from t1 where xxx regexp('is a test of some long text to '); xxx this is a test of some long text to see what happens diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result index 63d341d1c33..cce07b82688 100644 --- a/mysql-test/r/join_outer.result +++ b/mysql-test/r/join_outer.result @@ -1306,7 +1306,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00 1 SIMPLE t2 system NULL NULL NULL NULL 1 100.00 Warnings: -Note 1003 select 1 AS `f1`,NULL AS `f2`,3 AS `f3`,NULL AS `f1`,NULL AS `f2` from `test`.`t1` left join `test`.`t2` on(0) where ((coalesce(1,NULL),3) in ((1,3),(2,2))) +Note 1003 select 1 AS `f1`,NULL AS `f2`,3 AS `f3`,NULL AS `f1`,NULL AS `f2` from `test`.`t1` left join `test`.`t2` on(0) where 1 SELECT * FROM t1 LEFT JOIN t2 ON t1.f2 = t2.f2 WHERE (COALESCE(t1.f1, t2.f1), f3) IN ((1, 3), (2, 2)); f1 f2 f3 f1 f2 diff --git a/mysql-test/r/join_outer_jcl6.result b/mysql-test/r/join_outer_jcl6.result index eff47bf7c31..44dda3234df 100644 --- a/mysql-test/r/join_outer_jcl6.result +++ b/mysql-test/r/join_outer_jcl6.result @@ -1317,7 +1317,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00 1 SIMPLE t2 system NULL NULL NULL NULL 1 100.00 Warnings: -Note 1003 select 1 AS `f1`,NULL AS `f2`,3 AS `f3`,NULL AS `f1`,NULL AS `f2` from `test`.`t1` left join `test`.`t2` on(0) where ((coalesce(1,NULL),3) in ((1,3),(2,2))) +Note 1003 select 1 AS `f1`,NULL AS `f2`,3 AS `f3`,NULL AS `f1`,NULL AS `f2` from `test`.`t1` left join `test`.`t2` on(0) where 1 SELECT * FROM t1 LEFT JOIN t2 ON t1.f2 = t2.f2 WHERE (COALESCE(t1.f1, t2.f1), f3) IN ((1, 3), (2, 2)); f1 f2 f3 f1 f2 diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index e8bcba8043a..883deb95f43 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -5125,7 +5125,7 @@ SELECT * FROM t1 WHERE (1=2 OR t1.pk=2) AND t1.a <> 0; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables Warnings: -Note 1003 select 2 AS `pk`,0 AS `a` from `test`.`t1` where (0 <> 0) +Note 1003 select 2 AS `pk`,0 AS `a` from `test`.`t1` where 0 DROP TABLE t1; SELECT * FROM mysql.time_zone WHERE ( NOT (Use_leap_seconds <= Use_leap_seconds AND Time_zone_id != 1) @@ -5148,7 +5148,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 system idx NULL NULL NULL 1 100.00 1 SIMPLE t2 ref idx idx 5 const 1 100.00 Using index Warnings: -Note 1003 select 8 AS `a`,8 AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = 8) and (8 < 33)) +Note 1003 select 8 AS `a`,8 AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`c` = 8) SELECT * FROM t1 INNER JOIN t2 ON ( c = a ) WHERE 1 IS NULL OR b < 33 AND b = c; a b c @@ -5272,7 +5272,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 system PRIMARY NULL NULL NULL 1 100.00 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: -Note 1003 select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,1 AS `pk2`,1 AS `a2` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a1` = 1) and ((`test`.`t1`.`b1` = 6) or (1 > 4))) +Note 1003 select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,1 AS `pk2`,1 AS `a2` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a1` = 1) and (`test`.`t1`.`b1` = 6)) INSERT INTO t1 VALUES (3,1,6); SELECT * FROM t1, t2 WHERE a1 = pk2 AND ( ( b1 = 6 OR a2 > 4 ) AND pk2 = a2 OR pk1 IS NULL ); diff --git a/mysql-test/r/select_jcl6.result b/mysql-test/r/select_jcl6.result index c8d206e161d..b9af44089e5 100644 --- a/mysql-test/r/select_jcl6.result +++ b/mysql-test/r/select_jcl6.result @@ -5136,7 +5136,7 @@ SELECT * FROM t1 WHERE (1=2 OR t1.pk=2) AND t1.a <> 0; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables Warnings: -Note 1003 select 2 AS `pk`,0 AS `a` from `test`.`t1` where (0 <> 0) +Note 1003 select 2 AS `pk`,0 AS `a` from `test`.`t1` where 0 DROP TABLE t1; SELECT * FROM mysql.time_zone WHERE ( NOT (Use_leap_seconds <= Use_leap_seconds AND Time_zone_id != 1) @@ -5159,7 +5159,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 system idx NULL NULL NULL 1 100.00 1 SIMPLE t2 ref idx idx 5 const 1 100.00 Using index Warnings: -Note 1003 select 8 AS `a`,8 AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = 8) and (8 < 33)) +Note 1003 select 8 AS `a`,8 AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`c` = 8) SELECT * FROM t1 INNER JOIN t2 ON ( c = a ) WHERE 1 IS NULL OR b < 33 AND b = c; a b c @@ -5283,7 +5283,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 system PRIMARY NULL NULL NULL 1 100.00 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: -Note 1003 select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,1 AS `pk2`,1 AS `a2` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a1` = 1) and ((`test`.`t1`.`b1` = 6) or (1 > 4))) +Note 1003 select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,1 AS `pk2`,1 AS `a2` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a1` = 1) and (`test`.`t1`.`b1` = 6)) INSERT INTO t1 VALUES (3,1,6); SELECT * FROM t1, t2 WHERE a1 = pk2 AND ( ( b1 = 6 OR a2 > 4 ) AND pk2 = a2 OR pk1 IS NULL ); diff --git a/mysql-test/r/select_pkeycache.result b/mysql-test/r/select_pkeycache.result index e8bcba8043a..883deb95f43 100644 --- a/mysql-test/r/select_pkeycache.result +++ b/mysql-test/r/select_pkeycache.result @@ -5125,7 +5125,7 @@ SELECT * FROM t1 WHERE (1=2 OR t1.pk=2) AND t1.a <> 0; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables Warnings: -Note 1003 select 2 AS `pk`,0 AS `a` from `test`.`t1` where (0 <> 0) +Note 1003 select 2 AS `pk`,0 AS `a` from `test`.`t1` where 0 DROP TABLE t1; SELECT * FROM mysql.time_zone WHERE ( NOT (Use_leap_seconds <= Use_leap_seconds AND Time_zone_id != 1) @@ -5148,7 +5148,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 system idx NULL NULL NULL 1 100.00 1 SIMPLE t2 ref idx idx 5 const 1 100.00 Using index Warnings: -Note 1003 select 8 AS `a`,8 AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = 8) and (8 < 33)) +Note 1003 select 8 AS `a`,8 AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`c` = 8) SELECT * FROM t1 INNER JOIN t2 ON ( c = a ) WHERE 1 IS NULL OR b < 33 AND b = c; a b c @@ -5272,7 +5272,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 system PRIMARY NULL NULL NULL 1 100.00 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: -Note 1003 select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,1 AS `pk2`,1 AS `a2` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a1` = 1) and ((`test`.`t1`.`b1` = 6) or (1 > 4))) +Note 1003 select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,1 AS `pk2`,1 AS `a2` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a1` = 1) and (`test`.`t1`.`b1` = 6)) INSERT INTO t1 VALUES (3,1,6); SELECT * FROM t1, t2 WHERE a1 = pk2 AND ( ( b1 = 6 OR a2 > 4 ) AND pk2 = a2 OR pk1 IS NULL ); diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 19381353669..32a4d986c9c 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -5693,7 +5693,7 @@ FROM t1 AS sq4_alias1 WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR sq4_alias1.col_varchar_key = @var3; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +1 SIMPLE sq4_alias1 system NULL NULL NULL NULL 0 const row not found SELECT @var3:=12, sq4_alias1.* FROM t1 AS sq4_alias1 WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR diff --git a/mysql-test/r/subselect_extra.result b/mysql-test/r/subselect_extra.result index d29d57c764c..7310157eb6c 100644 --- a/mysql-test/r/subselect_extra.result +++ b/mysql-test/r/subselect_extra.result @@ -46,7 +46,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables Warnings: Note 1276 Field or reference 'test.t1.cur_date' of SELECT #2 was resolved in SELECT #1 -Note 1003 select 1 AS `id`,'2007-04-25 18:30:22' AS `cur_date` from `test`.`t1` semi join (`test`.`t1` `x1`) where ('2007-04-25 18:30:22' = 0) +Note 1003 select 1 AS `id`,'2007-04-25 18:30:22' AS `cur_date` from `test`.`t1` semi join (`test`.`t1` `x1`) where 0 select * from t1 where id in (select id from t1 as x1 where (t1.cur_date is null)); id cur_date @@ -57,7 +57,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables Warnings: Note 1276 Field or reference 'test.t2.cur_date' of SELECT #2 was resolved in SELECT #1 -Note 1003 select 1 AS `id`,'2007-04-25' AS `cur_date` from `test`.`t2` semi join (`test`.`t2` `x1`) where ('2007-04-25' = 0) +Note 1003 select 1 AS `id`,'2007-04-25' AS `cur_date` from `test`.`t2` semi join (`test`.`t2` `x1`) where 0 select * from t2 where id in (select id from t2 as x1 where (t2.cur_date is null)); id cur_date diff --git a/mysql-test/r/subselect_no_mat.result b/mysql-test/r/subselect_no_mat.result index 909185a28ea..dd9c48998a3 100644 --- a/mysql-test/r/subselect_no_mat.result +++ b/mysql-test/r/subselect_no_mat.result @@ -5692,7 +5692,7 @@ FROM t1 AS sq4_alias1 WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR sq4_alias1.col_varchar_key = @var3; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +1 SIMPLE sq4_alias1 system NULL NULL NULL NULL 0 const row not found SELECT @var3:=12, sq4_alias1.* FROM t1 AS sq4_alias1 WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR diff --git a/mysql-test/r/subselect_no_opts.result b/mysql-test/r/subselect_no_opts.result index 90820f09cab..beb2b317b4e 100644 --- a/mysql-test/r/subselect_no_opts.result +++ b/mysql-test/r/subselect_no_opts.result @@ -5688,7 +5688,7 @@ FROM t1 AS sq4_alias1 WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR sq4_alias1.col_varchar_key = @var3; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +1 SIMPLE sq4_alias1 system NULL NULL NULL NULL 0 const row not found SELECT @var3:=12, sq4_alias1.* FROM t1 AS sq4_alias1 WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR diff --git a/mysql-test/r/subselect_no_scache.result b/mysql-test/r/subselect_no_scache.result index 56962f584ee..3d251357bc4 100644 --- a/mysql-test/r/subselect_no_scache.result +++ b/mysql-test/r/subselect_no_scache.result @@ -5699,7 +5699,7 @@ FROM t1 AS sq4_alias1 WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR sq4_alias1.col_varchar_key = @var3; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +1 SIMPLE sq4_alias1 system NULL NULL NULL NULL 0 const row not found SELECT @var3:=12, sq4_alias1.* FROM t1 AS sq4_alias1 WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR diff --git a/mysql-test/r/subselect_no_semijoin.result b/mysql-test/r/subselect_no_semijoin.result index fd4de84664f..3554cd14f46 100644 --- a/mysql-test/r/subselect_no_semijoin.result +++ b/mysql-test/r/subselect_no_semijoin.result @@ -5688,7 +5688,7 @@ FROM t1 AS sq4_alias1 WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR sq4_alias1.col_varchar_key = @var3; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +1 SIMPLE sq4_alias1 system NULL NULL NULL NULL 0 const row not found SELECT @var3:=12, sq4_alias1.* FROM t1 AS sq4_alias1 WHERE (sq4_alias1.col_varchar_key + NULL) IS NULL OR diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result index 861ae974b9a..317af8d6b38 100644 --- a/mysql-test/r/type_datetime.result +++ b/mysql-test/r/type_datetime.result @@ -519,7 +519,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables Warnings: Note 1276 Field or reference 'test.t1.cur_date' of SELECT #2 was resolved in SELECT #1 -Note 1003 select 1 AS `id`,'2007-04-25 18:30:22' AS `cur_date` from `test`.`t1` semi join (`test`.`t1` `x1`) where ('2007-04-25 18:30:22' = 0) +Note 1003 select 1 AS `id`,'2007-04-25 18:30:22' AS `cur_date` from `test`.`t1` semi join (`test`.`t1` `x1`) where 0 select * from t1 where id in (select id from t1 as x1 where (t1.cur_date is null)); id cur_date @@ -530,7 +530,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables Warnings: Note 1276 Field or reference 'test.t2.cur_date' of SELECT #2 was resolved in SELECT #1 -Note 1003 select 1 AS `id`,'2007-04-25' AS `cur_date` from `test`.`t2` semi join (`test`.`t2` `x1`) where ('2007-04-25' = 0) +Note 1003 select 1 AS `id`,'2007-04-25' AS `cur_date` from `test`.`t2` semi join (`test`.`t2` `x1`) where 0 select * from t2 where id in (select id from t2 as x1 where (t2.cur_date is null)); id cur_date diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index cec6adafdce..8e5c082c6c1 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -4300,7 +4300,7 @@ WHERE f1<>0 OR f2<>0 AND f4='v' AND (f2<>0 OR f3<>0 AND f5<>0 OR f4 LIKE '%b%'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00 Warnings: -Note 1003 select 'r' AS `f4` from `test`.`t1` where (20 <> 0) +Note 1003 select 'r' AS `f4` from `test`.`t1` where 1 DROP VIEW v1; DROP TABLE t1; # diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 8d85d46f244..c7f31a9c956 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -3528,6 +3528,7 @@ make_join_statistics(JOIN *join, List &tables_list, join->impossible_where= false; if (conds && const_count) { + conds->update_used_tables(); conds= remove_eq_conds(join->thd, conds, &join->cond_value); join->select_lex->where= conds; if (join->cond_value == Item::COND_FALSE)