Loading mysql-test/r/ndb_condition_pushdown.result +398 −8 Original line number Diff line number Diff line Loading @@ -278,6 +278,35 @@ pk1 attr1 attr2 attr3 attr4 pk1 attr1 attr2 attr3 attr4 3 3 9223372036854775805 3 d 3 3 9223372036854775805 3 d 4 4 9223372036854775806 4 e 4 4 9223372036854775806 4 e set engine_condition_pushdown = on; explain select auto from t1 where string = "aaaa" and vstring = "aaaa" and bin = 0xAAAA and vbin = 0xAAAA and tiny = -1 and short = -1 and medium = -1 and long_int = -1 and longlong = -1 and real_float > 1.0 and real_float < 2.0 and real_double > 1.0 and real_double < 2.0 and real_decimal > 1.0 and real_decimal < 2.0 and utiny = 1 and ushort = 1 and umedium = 1 and ulong = 1 and ulonglong = 1 and /* bits = b'001' and */ options = 'one' and flags = 'one' and date_field = '1901-01-01' and year_field = '1901' and time_field = '01:01:01' and date_time = '1901-01-01 01:01:01' order by auto; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where with pushed condition; Using filesort select auto from t1 where string = "aaaa" and vstring = "aaaa" and Loading Loading @@ -306,6 +335,35 @@ date_time = '1901-01-01 01:01:01' order by auto; auto 1 explain select auto from t1 where string != "aaaa" and vstring != "aaaa" and bin != 0xAAAA and vbin != 0xAAAA and tiny != -1 and short != -1 and medium != -1 and long_int != -1 and longlong != -1 and (real_float < 1.0 or real_float > 2.0) and (real_double < 1.0 or real_double > 2.0) and (real_decimal < 1.0 or real_decimal > 2.0) and utiny != 1 and ushort != 1 and umedium != 1 and ulong != 1 and ulonglong != 1 and /* bits != b'001' and */ options != 'one' and flags != 'one' and date_field != '1901-01-01' and year_field != '1901' and time_field != '01:01:01' and date_time != '1901-01-01 01:01:01' order by auto; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where with pushed condition; Using filesort select auto from t1 where string != "aaaa" and vstring != "aaaa" and Loading Loading @@ -336,6 +394,35 @@ auto 2 3 4 explain select auto from t1 where string > "aaaa" and vstring > "aaaa" and bin > 0xAAAA and vbin > 0xAAAA and tiny < -1 and short < -1 and medium < -1 and long_int < -1 and longlong < -1 and real_float > 1.1 and real_double > 1.1 and real_decimal > 1.1 and utiny > 1 and ushort > 1 and umedium > 1 and ulong > 1 and ulonglong > 1 and /* bits > b'001' and */ (options = 'two' or options = 'three' or options = 'four') and (flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and date_field > '1901-01-01' and year_field > '1901' and time_field > '01:01:01' and date_time > '1901-01-01 01:01:01' order by auto; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where with pushed condition; Using filesort select auto from t1 where string > "aaaa" and vstring > "aaaa" and Loading Loading @@ -366,6 +453,35 @@ auto 2 3 4 explain select auto from t1 where string >= "aaaa" and vstring >= "aaaa" and bin >= 0xAAAA and vbin >= 0xAAAA and tiny <= -1 and short <= -1 and medium <= -1 and long_int <= -1 and longlong <= -1 and real_float >= 1.0 and real_double >= 1.0 and real_decimal >= 1.0 and utiny >= 1 and ushort >= 1 and umedium >= 1 and ulong >= 1 and ulonglong >= 1 and /* bits >= b'001' and */ (options = 'one' or options = 'two' or options = 'three' or options = 'four') and (flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and date_field >= '1901-01-01' and year_field >= '1901' and time_field >= '01:01:01' and date_time >= '1901-01-01 01:01:01' order by auto; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where with pushed condition; Using filesort select auto from t1 where string >= "aaaa" and vstring >= "aaaa" and Loading Loading @@ -397,6 +513,35 @@ auto 2 3 4 explain select auto from t1 where string < "dddd" and vstring < "dddd" and bin < 0xDDDD and vbin < 0xDDDD and tiny > -4 and short > -4 and medium > -4 and long_int > -4 and longlong > -4 and real_float < 4.4 and real_double < 4.4 and real_decimal < 4.4 and utiny < 4 and ushort < 4 and umedium < 4 and ulong < 4 and ulonglong < 4 and /* bits < b'100' and */ (options = 'one' or options = 'two' or options = 'three') and (flags = 'one' or flags = 'one,two' or flags = 'one,two,three') and date_field < '1904-01-01' and year_field < '1904' and time_field < '04:04:04' and date_time < '1904-04-04 04:04:04' order by auto; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where with pushed condition; Using filesort select auto from t1 where string < "dddd" and vstring < "dddd" and Loading Loading @@ -427,6 +572,35 @@ auto 1 2 3 explain select auto from t1 where string <= "dddd" and vstring <= "dddd" and bin <= 0xDDDD and vbin <= 0xDDDD and tiny >= -4 and short >= -4 and medium >= -4 and long_int >= -4 and longlong >= -4 and real_float <= 4.5 and real_double <= 4.5 and real_decimal <= 4.5 and utiny <= 4 - 1 + 1 and /* Checking function composition */ ushort <= 4 and umedium <= 4 and ulong <= 4 and ulonglong <= 4 and /* bits <= b'100' and */ (options = 'one' or options = 'two' or options = 'three' or options = 'four') and (flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and date_field <= '1904-04-04' and year_field <= '1904' and time_field <= '04:04:04' and date_time <= '1904-04-04 04:04:04' order by auto; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where with pushed condition; Using filesort select auto from t1 where string <= "dddd" and vstring <= "dddd" and Loading Loading @@ -459,6 +633,35 @@ auto 3 4 create index medium_index on t1(medium); explain select auto from t1 where string = "aaaa" and vstring = "aaaa" and bin = 0xAAAA and vbin = 0xAAAA and tiny = -1 and short = -1 and medium = -1 and long_int = -1 and longlong = -1 and real_float > 1.0 and real_float < 2.0 and real_double > 1.0 and real_double < 2.0 and real_decimal > 1.0 and real_decimal < 2.0 and utiny = 1 and ushort = 1 and umedium = 1 and ulong = 1 and ulonglong = 1 and /* bits = b'001' and */ options = 'one' and flags = 'one' and date_field = '1901-01-01' and year_field = '1901' and time_field = '01:01:01' and date_time = '1901-01-01 01:01:01' order by auto; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref medium_index medium_index 3 const 10 Using where with pushed condition; Using filesort select auto from t1 where string = "aaaa" and vstring = "aaaa" and Loading Loading @@ -487,6 +690,35 @@ date_time = '1901-01-01 01:01:01' order by auto; auto 1 explain select auto from t1 where string != "aaaa" and vstring != "aaaa" and bin != 0xAAAA and vbin != 0xAAAA and tiny != -1 and short != -1 and medium != -1 and long_int != -1 and longlong != -1 and (real_float < 1.0 or real_float > 2.0) and (real_double < 1.0 or real_double > 2.0) and (real_decimal < 1.0 or real_decimal > 2.0) and utiny != 1 and ushort != 1 and umedium != 1 and ulong != 1 and ulonglong != 1 and /* bits != b'001' and */ options != 'one' and flags != 'one' and date_field != '1901-01-01' and year_field != '1901' and time_field != '01:01:01' and date_time != '1901-01-01 01:01:01' order by auto; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range medium_index medium_index 3 NULL 20 Using where with pushed condition; Using filesort select auto from t1 where string != "aaaa" and vstring != "aaaa" and Loading Loading @@ -517,6 +749,35 @@ auto 2 3 4 explain select auto from t1 where string > "aaaa" and vstring > "aaaa" and bin > 0xAAAA and vbin > 0xAAAA and tiny < -1 and short < -1 and medium < -1 and long_int < -1 and longlong < -1 and real_float > 1.1 and real_double > 1.1 and real_decimal > 1.1 and utiny > 1 and ushort > 1 and umedium > 1 and ulong > 1 and ulonglong > 1 and /* bits > b'001' and */ (options = 'two' or options = 'three' or options = 'four') and (flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and date_field > '1901-01-01' and year_field > '1901' and time_field > '01:01:01' and date_time > '1901-01-01 01:01:01' order by auto; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range medium_index medium_index 3 NULL 10 Using where with pushed condition; Using filesort select auto from t1 where string > "aaaa" and vstring > "aaaa" and Loading Loading @@ -547,6 +808,35 @@ auto 2 3 4 explain select auto from t1 where string >= "aaaa" and vstring >= "aaaa" and bin >= 0xAAAA and vbin >= 0xAAAA and tiny <= -1 and short <= -1 and medium <= -1 and long_int <= -1 and longlong <= -1 and real_float >= 1.0 and real_double >= 1.0 and real_decimal >= 1.0 and utiny >= 1 and ushort >= 1 and umedium >= 1 and ulong >= 1 and ulonglong >= 1 and /* bits >= b'001' and */ (options = 'one' or options = 'two' or options = 'three' or options = 'four') and (flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and date_field >= '1901-01-01' and year_field >= '1901' and time_field >= '01:01:01' and date_time >= '1901-01-01 01:01:01' order by auto; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range medium_index medium_index 3 NULL 10 Using where with pushed condition; Using filesort select auto from t1 where string >= "aaaa" and vstring >= "aaaa" and Loading Loading @@ -578,6 +868,35 @@ auto 2 3 4 explain select auto from t1 where string < "dddd" and vstring < "dddd" and bin < 0xDDDD and vbin < 0xDDDD and tiny > -4 and short > -4 and medium > -4 and long_int > -4 and longlong > -4 and real_float < 4.4 and real_double < 4.4 and real_decimal < 4.4 and utiny < 4 and ushort < 4 and umedium < 4 and ulong < 4 and ulonglong < 4 and /* bits < b'100' and */ (options = 'one' or options = 'two' or options = 'three') and (flags = 'one' or flags = 'one,two' or flags = 'one,two,three') and date_field < '1904-01-01' and year_field < '1904' and time_field < '04:04:04' and date_time < '1904-04-04 04:04:04' order by auto; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range medium_index medium_index 3 NULL 10 Using where with pushed condition; Using filesort select auto from t1 where string < "dddd" and vstring < "dddd" and Loading Loading @@ -608,6 +927,35 @@ auto 1 2 3 explain select auto from t1 where string <= "dddd" and vstring <= "dddd" and bin <= 0xDDDD and vbin <= 0xDDDD and tiny >= -4 and short >= -4 and medium >= -4 and long_int >= -4 and longlong >= -4 and real_float <= 4.5 and real_double <= 4.5 and real_decimal <= 4.5 and utiny <= 4 - 1 + 1 and /* Checking function composition */ ushort <= 4 and umedium <= 4 and ulong <= 4 and ulonglong <= 4 and /* bits <= b'100' and */ (options = 'one' or options = 'two' or options = 'three' or options = 'four') and (flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and date_field <= '1904-04-04' and year_field <= '1904' and time_field <= '04:04:04' and date_time <= '1904-04-04 04:04:04' order by auto; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range medium_index medium_index 3 NULL 10 Using where with pushed condition; Using filesort select auto from t1 where string <= "dddd" and vstring <= "dddd" and Loading Loading @@ -639,6 +987,15 @@ auto 2 3 4 explain select auto from t1 where string like "b%" and vstring like "b%" and bin like concat(0xBB, '%') and vbin like concat(0xBB, '%') order by auto; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where with pushed condition; Using filesort select auto from t1 where string like "b%" and vstring like "b%" and Loading @@ -647,6 +1004,15 @@ vbin like concat(0xBB, '%') order by auto; auto 2 explain select auto from t1 where string not like "b%" and vstring not like "b%" and bin not like concat(0xBB, '%') and vbin not like concat(0xBB, '%') order by auto; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where with pushed condition; Using filesort select auto from t1 where string not like "b%" and vstring not like "b%" and Loading @@ -657,41 +1023,65 @@ auto 1 3 4 explain select * from t2 where attr3 is null or attr1 > 2 and pk1= 3 order by pk1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 6 Using where with pushed condition; Using filesort select * from t2 where attr3 is null or attr1 > 2 and pk1= 3 order by pk1; pk1 attr1 attr2 attr3 2 2 NULL NULL 3 3 3 d explain select * from t2 where attr3 is not null and attr1 > 2 order by pk1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where with pushed condition; Using filesort select * from t2 where attr3 is not null and attr1 > 2 order by pk1; pk1 attr1 attr2 attr3 3 3 3 d 4 4 4 e 5 5 5 f explain select * from t3 where attr2 > 9223372036854775803 and attr3 != 3 order by pk1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t3 ALL NULL NULL NULL NULL 6 Using where with pushed condition; Using filesort select * from t3 where attr2 > 9223372036854775803 and attr3 != 3 order by pk1; pk1 attr1 attr2 attr3 attr4 2 2 9223372036854775804 2 c 4 4 9223372036854775806 4 e 5 5 9223372036854775807 5 f explain select * from t2,t3 where t2.attr1 < 1 and t2.attr2 = t3.attr2 and t3.attr1 < 5 order by t2.pk1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where with pushed condition; Using temporary; Using filesort 1 SIMPLE t3 ALL NULL NULL NULL NULL 6 Using where with pushed condition select * from t2,t3 where t2.attr1 < 1 and t2.attr2 = t3.attr2 and t3.attr1 < 5 order by t2.pk1; pk1 attr1 attr2 attr3 pk1 attr1 attr2 attr3 attr4 0 0 0 a 0 0 0 0 a explain select * from t4 where attr1 < 5 and attr2 > 9223372036854775803 and attr3 != 3 order by t4.pk1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t4 range attr1 attr1 4 NULL 10 Using where with pushed condition; Using filesort select * from t4 where attr1 < 5 and attr2 > 9223372036854775803 and attr3 != 3 order by t4.pk1; pk1 attr1 attr2 attr3 attr4 2 2 9223372036854775804 2 c 4 4 9223372036854775806 4 e explain select * from t3,t4 where t4.attr1 > 1 and t4.attr2 = t3.attr2 and t4.attr3 < 5 order by t4.pk1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t4 range attr1 attr1 4 NULL 10 Using where with pushed condition; Using temporary; Using filesort 1 SIMPLE t3 ALL NULL NULL NULL NULL 6 Using where select * from t3,t4 where t4.attr1 > 1 and t4.attr2 = t3.attr2 and t4.attr3 < 5 order by t4.pk1; pk1 attr1 attr2 attr3 attr4 pk1 attr1 attr2 attr3 attr4 2 2 9223372036854775804 2 c 2 2 9223372036854775804 2 c 3 3 9223372036854775805 3 d 3 3 9223372036854775805 3 d 4 4 9223372036854775806 4 e 4 4 9223372036854775806 4 e explain select auto from t1 where string = "aaaa" collate latin1_general_ci order by auto; auto 1 id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where; Using filesort explain select * from t2 where (attr1 < 2) = (attr2 < 2) order by pk1; pk1 attr1 attr2 attr3 0 0 0 a 1 1 1 b 3 3 3 d 4 4 4 e 5 5 5 f id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using filesort set engine_condition_pushdown = @old_ecpd; DROP TABLE t1,t2,t3,t4; mysql-test/t/ndb_condition_pushdown.test +371 −0 File changed.Preview size limit exceeded, changes collapsed. Show changes sql/set_var.cc +2 −0 Original line number Diff line number Diff line Loading @@ -1319,10 +1319,12 @@ static void fix_thd_mem_root(THD *thd, enum_var_type type) static void fix_trans_mem_root(THD *thd, enum_var_type type) { #ifdef USING_TRANSACTIONS if (type != OPT_GLOBAL) reset_root_defaults(&thd->transaction.mem_root, thd->variables.trans_alloc_block_size, thd->variables.trans_prealloc_size); #endif } Loading sql/sql_select.cc +17 −3 Original line number Diff line number Diff line Loading @@ -5305,7 +5305,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) if (!(tmp= add_found_match_trig_cond(first_inner_tab, tmp, 0))) DBUG_RETURN(1); tab->select_cond=sel->cond=tmp; if (current_thd->variables.engine_condition_pushdown) if (join->thd->variables.engine_condition_pushdown) { tab->table->file->pushed_cond= NULL; /* Push condition to handler */ Loading Loading @@ -5433,7 +5433,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) join->thd->memdup((gptr) sel, sizeof(SQL_SELECT)); tab->cache.select->cond=tmp; tab->cache.select->read_tables=join->const_table_map; if (current_thd->variables.engine_condition_pushdown && if (join->thd->variables.engine_condition_pushdown && (!tab->table->file->pushed_cond)) { /* Push condition to handler */ Loading Loading @@ -13008,8 +13008,22 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, extra.append(')'); } else if (tab->select->cond) { const COND *pushed_cond= tab->table->file->pushed_cond; if (thd->variables.engine_condition_pushdown && pushed_cond) { extra.append("; Using where with pushed condition"); if (thd->lex->describe & DESCRIBE_EXTENDED) { extra.append(": "); ((COND *)pushed_cond)->print(&extra); } } else extra.append("; Using where"); } } if (key_read) { if (quick_type == QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX) Loading Loading
mysql-test/r/ndb_condition_pushdown.result +398 −8 Original line number Diff line number Diff line Loading @@ -278,6 +278,35 @@ pk1 attr1 attr2 attr3 attr4 pk1 attr1 attr2 attr3 attr4 3 3 9223372036854775805 3 d 3 3 9223372036854775805 3 d 4 4 9223372036854775806 4 e 4 4 9223372036854775806 4 e set engine_condition_pushdown = on; explain select auto from t1 where string = "aaaa" and vstring = "aaaa" and bin = 0xAAAA and vbin = 0xAAAA and tiny = -1 and short = -1 and medium = -1 and long_int = -1 and longlong = -1 and real_float > 1.0 and real_float < 2.0 and real_double > 1.0 and real_double < 2.0 and real_decimal > 1.0 and real_decimal < 2.0 and utiny = 1 and ushort = 1 and umedium = 1 and ulong = 1 and ulonglong = 1 and /* bits = b'001' and */ options = 'one' and flags = 'one' and date_field = '1901-01-01' and year_field = '1901' and time_field = '01:01:01' and date_time = '1901-01-01 01:01:01' order by auto; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where with pushed condition; Using filesort select auto from t1 where string = "aaaa" and vstring = "aaaa" and Loading Loading @@ -306,6 +335,35 @@ date_time = '1901-01-01 01:01:01' order by auto; auto 1 explain select auto from t1 where string != "aaaa" and vstring != "aaaa" and bin != 0xAAAA and vbin != 0xAAAA and tiny != -1 and short != -1 and medium != -1 and long_int != -1 and longlong != -1 and (real_float < 1.0 or real_float > 2.0) and (real_double < 1.0 or real_double > 2.0) and (real_decimal < 1.0 or real_decimal > 2.0) and utiny != 1 and ushort != 1 and umedium != 1 and ulong != 1 and ulonglong != 1 and /* bits != b'001' and */ options != 'one' and flags != 'one' and date_field != '1901-01-01' and year_field != '1901' and time_field != '01:01:01' and date_time != '1901-01-01 01:01:01' order by auto; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where with pushed condition; Using filesort select auto from t1 where string != "aaaa" and vstring != "aaaa" and Loading Loading @@ -336,6 +394,35 @@ auto 2 3 4 explain select auto from t1 where string > "aaaa" and vstring > "aaaa" and bin > 0xAAAA and vbin > 0xAAAA and tiny < -1 and short < -1 and medium < -1 and long_int < -1 and longlong < -1 and real_float > 1.1 and real_double > 1.1 and real_decimal > 1.1 and utiny > 1 and ushort > 1 and umedium > 1 and ulong > 1 and ulonglong > 1 and /* bits > b'001' and */ (options = 'two' or options = 'three' or options = 'four') and (flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and date_field > '1901-01-01' and year_field > '1901' and time_field > '01:01:01' and date_time > '1901-01-01 01:01:01' order by auto; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where with pushed condition; Using filesort select auto from t1 where string > "aaaa" and vstring > "aaaa" and Loading Loading @@ -366,6 +453,35 @@ auto 2 3 4 explain select auto from t1 where string >= "aaaa" and vstring >= "aaaa" and bin >= 0xAAAA and vbin >= 0xAAAA and tiny <= -1 and short <= -1 and medium <= -1 and long_int <= -1 and longlong <= -1 and real_float >= 1.0 and real_double >= 1.0 and real_decimal >= 1.0 and utiny >= 1 and ushort >= 1 and umedium >= 1 and ulong >= 1 and ulonglong >= 1 and /* bits >= b'001' and */ (options = 'one' or options = 'two' or options = 'three' or options = 'four') and (flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and date_field >= '1901-01-01' and year_field >= '1901' and time_field >= '01:01:01' and date_time >= '1901-01-01 01:01:01' order by auto; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where with pushed condition; Using filesort select auto from t1 where string >= "aaaa" and vstring >= "aaaa" and Loading Loading @@ -397,6 +513,35 @@ auto 2 3 4 explain select auto from t1 where string < "dddd" and vstring < "dddd" and bin < 0xDDDD and vbin < 0xDDDD and tiny > -4 and short > -4 and medium > -4 and long_int > -4 and longlong > -4 and real_float < 4.4 and real_double < 4.4 and real_decimal < 4.4 and utiny < 4 and ushort < 4 and umedium < 4 and ulong < 4 and ulonglong < 4 and /* bits < b'100' and */ (options = 'one' or options = 'two' or options = 'three') and (flags = 'one' or flags = 'one,two' or flags = 'one,two,three') and date_field < '1904-01-01' and year_field < '1904' and time_field < '04:04:04' and date_time < '1904-04-04 04:04:04' order by auto; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where with pushed condition; Using filesort select auto from t1 where string < "dddd" and vstring < "dddd" and Loading Loading @@ -427,6 +572,35 @@ auto 1 2 3 explain select auto from t1 where string <= "dddd" and vstring <= "dddd" and bin <= 0xDDDD and vbin <= 0xDDDD and tiny >= -4 and short >= -4 and medium >= -4 and long_int >= -4 and longlong >= -4 and real_float <= 4.5 and real_double <= 4.5 and real_decimal <= 4.5 and utiny <= 4 - 1 + 1 and /* Checking function composition */ ushort <= 4 and umedium <= 4 and ulong <= 4 and ulonglong <= 4 and /* bits <= b'100' and */ (options = 'one' or options = 'two' or options = 'three' or options = 'four') and (flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and date_field <= '1904-04-04' and year_field <= '1904' and time_field <= '04:04:04' and date_time <= '1904-04-04 04:04:04' order by auto; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where with pushed condition; Using filesort select auto from t1 where string <= "dddd" and vstring <= "dddd" and Loading Loading @@ -459,6 +633,35 @@ auto 3 4 create index medium_index on t1(medium); explain select auto from t1 where string = "aaaa" and vstring = "aaaa" and bin = 0xAAAA and vbin = 0xAAAA and tiny = -1 and short = -1 and medium = -1 and long_int = -1 and longlong = -1 and real_float > 1.0 and real_float < 2.0 and real_double > 1.0 and real_double < 2.0 and real_decimal > 1.0 and real_decimal < 2.0 and utiny = 1 and ushort = 1 and umedium = 1 and ulong = 1 and ulonglong = 1 and /* bits = b'001' and */ options = 'one' and flags = 'one' and date_field = '1901-01-01' and year_field = '1901' and time_field = '01:01:01' and date_time = '1901-01-01 01:01:01' order by auto; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ref medium_index medium_index 3 const 10 Using where with pushed condition; Using filesort select auto from t1 where string = "aaaa" and vstring = "aaaa" and Loading Loading @@ -487,6 +690,35 @@ date_time = '1901-01-01 01:01:01' order by auto; auto 1 explain select auto from t1 where string != "aaaa" and vstring != "aaaa" and bin != 0xAAAA and vbin != 0xAAAA and tiny != -1 and short != -1 and medium != -1 and long_int != -1 and longlong != -1 and (real_float < 1.0 or real_float > 2.0) and (real_double < 1.0 or real_double > 2.0) and (real_decimal < 1.0 or real_decimal > 2.0) and utiny != 1 and ushort != 1 and umedium != 1 and ulong != 1 and ulonglong != 1 and /* bits != b'001' and */ options != 'one' and flags != 'one' and date_field != '1901-01-01' and year_field != '1901' and time_field != '01:01:01' and date_time != '1901-01-01 01:01:01' order by auto; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range medium_index medium_index 3 NULL 20 Using where with pushed condition; Using filesort select auto from t1 where string != "aaaa" and vstring != "aaaa" and Loading Loading @@ -517,6 +749,35 @@ auto 2 3 4 explain select auto from t1 where string > "aaaa" and vstring > "aaaa" and bin > 0xAAAA and vbin > 0xAAAA and tiny < -1 and short < -1 and medium < -1 and long_int < -1 and longlong < -1 and real_float > 1.1 and real_double > 1.1 and real_decimal > 1.1 and utiny > 1 and ushort > 1 and umedium > 1 and ulong > 1 and ulonglong > 1 and /* bits > b'001' and */ (options = 'two' or options = 'three' or options = 'four') and (flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and date_field > '1901-01-01' and year_field > '1901' and time_field > '01:01:01' and date_time > '1901-01-01 01:01:01' order by auto; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range medium_index medium_index 3 NULL 10 Using where with pushed condition; Using filesort select auto from t1 where string > "aaaa" and vstring > "aaaa" and Loading Loading @@ -547,6 +808,35 @@ auto 2 3 4 explain select auto from t1 where string >= "aaaa" and vstring >= "aaaa" and bin >= 0xAAAA and vbin >= 0xAAAA and tiny <= -1 and short <= -1 and medium <= -1 and long_int <= -1 and longlong <= -1 and real_float >= 1.0 and real_double >= 1.0 and real_decimal >= 1.0 and utiny >= 1 and ushort >= 1 and umedium >= 1 and ulong >= 1 and ulonglong >= 1 and /* bits >= b'001' and */ (options = 'one' or options = 'two' or options = 'three' or options = 'four') and (flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and date_field >= '1901-01-01' and year_field >= '1901' and time_field >= '01:01:01' and date_time >= '1901-01-01 01:01:01' order by auto; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range medium_index medium_index 3 NULL 10 Using where with pushed condition; Using filesort select auto from t1 where string >= "aaaa" and vstring >= "aaaa" and Loading Loading @@ -578,6 +868,35 @@ auto 2 3 4 explain select auto from t1 where string < "dddd" and vstring < "dddd" and bin < 0xDDDD and vbin < 0xDDDD and tiny > -4 and short > -4 and medium > -4 and long_int > -4 and longlong > -4 and real_float < 4.4 and real_double < 4.4 and real_decimal < 4.4 and utiny < 4 and ushort < 4 and umedium < 4 and ulong < 4 and ulonglong < 4 and /* bits < b'100' and */ (options = 'one' or options = 'two' or options = 'three') and (flags = 'one' or flags = 'one,two' or flags = 'one,two,three') and date_field < '1904-01-01' and year_field < '1904' and time_field < '04:04:04' and date_time < '1904-04-04 04:04:04' order by auto; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range medium_index medium_index 3 NULL 10 Using where with pushed condition; Using filesort select auto from t1 where string < "dddd" and vstring < "dddd" and Loading Loading @@ -608,6 +927,35 @@ auto 1 2 3 explain select auto from t1 where string <= "dddd" and vstring <= "dddd" and bin <= 0xDDDD and vbin <= 0xDDDD and tiny >= -4 and short >= -4 and medium >= -4 and long_int >= -4 and longlong >= -4 and real_float <= 4.5 and real_double <= 4.5 and real_decimal <= 4.5 and utiny <= 4 - 1 + 1 and /* Checking function composition */ ushort <= 4 and umedium <= 4 and ulong <= 4 and ulonglong <= 4 and /* bits <= b'100' and */ (options = 'one' or options = 'two' or options = 'three' or options = 'four') and (flags = 'one' or flags = 'one,two' or flags = 'one,two,three' or flags = 'one,two,three,four') and date_field <= '1904-04-04' and year_field <= '1904' and time_field <= '04:04:04' and date_time <= '1904-04-04 04:04:04' order by auto; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range medium_index medium_index 3 NULL 10 Using where with pushed condition; Using filesort select auto from t1 where string <= "dddd" and vstring <= "dddd" and Loading Loading @@ -639,6 +987,15 @@ auto 2 3 4 explain select auto from t1 where string like "b%" and vstring like "b%" and bin like concat(0xBB, '%') and vbin like concat(0xBB, '%') order by auto; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where with pushed condition; Using filesort select auto from t1 where string like "b%" and vstring like "b%" and Loading @@ -647,6 +1004,15 @@ vbin like concat(0xBB, '%') order by auto; auto 2 explain select auto from t1 where string not like "b%" and vstring not like "b%" and bin not like concat(0xBB, '%') and vbin not like concat(0xBB, '%') order by auto; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where with pushed condition; Using filesort select auto from t1 where string not like "b%" and vstring not like "b%" and Loading @@ -657,41 +1023,65 @@ auto 1 3 4 explain select * from t2 where attr3 is null or attr1 > 2 and pk1= 3 order by pk1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 6 Using where with pushed condition; Using filesort select * from t2 where attr3 is null or attr1 > 2 and pk1= 3 order by pk1; pk1 attr1 attr2 attr3 2 2 NULL NULL 3 3 3 d explain select * from t2 where attr3 is not null and attr1 > 2 order by pk1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where with pushed condition; Using filesort select * from t2 where attr3 is not null and attr1 > 2 order by pk1; pk1 attr1 attr2 attr3 3 3 3 d 4 4 4 e 5 5 5 f explain select * from t3 where attr2 > 9223372036854775803 and attr3 != 3 order by pk1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t3 ALL NULL NULL NULL NULL 6 Using where with pushed condition; Using filesort select * from t3 where attr2 > 9223372036854775803 and attr3 != 3 order by pk1; pk1 attr1 attr2 attr3 attr4 2 2 9223372036854775804 2 c 4 4 9223372036854775806 4 e 5 5 9223372036854775807 5 f explain select * from t2,t3 where t2.attr1 < 1 and t2.attr2 = t3.attr2 and t3.attr1 < 5 order by t2.pk1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where with pushed condition; Using temporary; Using filesort 1 SIMPLE t3 ALL NULL NULL NULL NULL 6 Using where with pushed condition select * from t2,t3 where t2.attr1 < 1 and t2.attr2 = t3.attr2 and t3.attr1 < 5 order by t2.pk1; pk1 attr1 attr2 attr3 pk1 attr1 attr2 attr3 attr4 0 0 0 a 0 0 0 0 a explain select * from t4 where attr1 < 5 and attr2 > 9223372036854775803 and attr3 != 3 order by t4.pk1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t4 range attr1 attr1 4 NULL 10 Using where with pushed condition; Using filesort select * from t4 where attr1 < 5 and attr2 > 9223372036854775803 and attr3 != 3 order by t4.pk1; pk1 attr1 attr2 attr3 attr4 2 2 9223372036854775804 2 c 4 4 9223372036854775806 4 e explain select * from t3,t4 where t4.attr1 > 1 and t4.attr2 = t3.attr2 and t4.attr3 < 5 order by t4.pk1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t4 range attr1 attr1 4 NULL 10 Using where with pushed condition; Using temporary; Using filesort 1 SIMPLE t3 ALL NULL NULL NULL NULL 6 Using where select * from t3,t4 where t4.attr1 > 1 and t4.attr2 = t3.attr2 and t4.attr3 < 5 order by t4.pk1; pk1 attr1 attr2 attr3 attr4 pk1 attr1 attr2 attr3 attr4 2 2 9223372036854775804 2 c 2 2 9223372036854775804 2 c 3 3 9223372036854775805 3 d 3 3 9223372036854775805 3 d 4 4 9223372036854775806 4 e 4 4 9223372036854775806 4 e explain select auto from t1 where string = "aaaa" collate latin1_general_ci order by auto; auto 1 id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where; Using filesort explain select * from t2 where (attr1 < 2) = (attr2 < 2) order by pk1; pk1 attr1 attr2 attr3 0 0 0 a 1 1 1 b 3 3 3 d 4 4 4 e 5 5 5 f id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using filesort set engine_condition_pushdown = @old_ecpd; DROP TABLE t1,t2,t3,t4;
mysql-test/t/ndb_condition_pushdown.test +371 −0 File changed.Preview size limit exceeded, changes collapsed. Show changes
sql/set_var.cc +2 −0 Original line number Diff line number Diff line Loading @@ -1319,10 +1319,12 @@ static void fix_thd_mem_root(THD *thd, enum_var_type type) static void fix_trans_mem_root(THD *thd, enum_var_type type) { #ifdef USING_TRANSACTIONS if (type != OPT_GLOBAL) reset_root_defaults(&thd->transaction.mem_root, thd->variables.trans_alloc_block_size, thd->variables.trans_prealloc_size); #endif } Loading
sql/sql_select.cc +17 −3 Original line number Diff line number Diff line Loading @@ -5305,7 +5305,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) if (!(tmp= add_found_match_trig_cond(first_inner_tab, tmp, 0))) DBUG_RETURN(1); tab->select_cond=sel->cond=tmp; if (current_thd->variables.engine_condition_pushdown) if (join->thd->variables.engine_condition_pushdown) { tab->table->file->pushed_cond= NULL; /* Push condition to handler */ Loading Loading @@ -5433,7 +5433,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) join->thd->memdup((gptr) sel, sizeof(SQL_SELECT)); tab->cache.select->cond=tmp; tab->cache.select->read_tables=join->const_table_map; if (current_thd->variables.engine_condition_pushdown && if (join->thd->variables.engine_condition_pushdown && (!tab->table->file->pushed_cond)) { /* Push condition to handler */ Loading Loading @@ -13008,8 +13008,22 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, extra.append(')'); } else if (tab->select->cond) { const COND *pushed_cond= tab->table->file->pushed_cond; if (thd->variables.engine_condition_pushdown && pushed_cond) { extra.append("; Using where with pushed condition"); if (thd->lex->describe & DESCRIBE_EXTENDED) { extra.append(": "); ((COND *)pushed_cond)->print(&extra); } } else extra.append("; Using where"); } } if (key_read) { if (quick_type == QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX) Loading