From: Ole John Aske Date: May 3 2012 1:55pm Subject: bzr push into mysql-trunk-cluster branch (ole.john.aske:3490 to 3491) List-Archive: http://lists.mysql.com/commits/143737 Message-Id: <20120503135555.AA598242@fimafeng09.norway.sun.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3491 Ole John Aske 2012-05-03 [merge] Merge mysql-5.5-cluster-7.3 -> mysql-trunk-cluster. modified: mysql-test/suite/ndb/r/ndb_blob.result mysql-test/suite/ndb/r/ndb_dd_sql_features.result mysql-test/suite/ndb/r/ndb_join_pushdown_default.result mysql-test/suite/ndb/r/ndb_join_pushdown_nobnl.result mysql-test/suite/ndb/r/ndb_join_pushdown_none.result sql/ha_ndbcluster.cc sql/ha_ndbcluster.h sql/ha_ndbcluster_push.cc sql/handler.h sql/sql_executor.cc sql/sql_optimizer.cc sql/sql_select.cc storage/ndb/memcache/src/ndb_engine.c 3490 magnus.blaudd@stripped 2012-05-02 WL#6224 Adapt MySQL Cluster to 5.6 - Handle new datatypes MYSQL_TYPE_TIMESTAMP2(not used), MYSQL_TYPE_TIME2 and MYSQL_TYPE_DATE2 in condition pushown code. - Update .result file for EXPLAIN which now always uses NULL for empty Extra column - Update .result file for removed colon after text "Using where with pushed condition" for Extra column modified: mysql-test/suite/ndb/r/ndb_condition_pushdown.result sql/ha_ndbcluster_cond.cc === modified file 'mysql-test/suite/ndb/r/ndb_blob.result' --- a/mysql-test/suite/ndb/r/ndb_blob.result 2012-03-12 08:56:56 +0000 +++ b/mysql-test/suite/ndb/r/ndb_blob.result 2012-05-03 13:54:29 +0000 @@ -40,7 +40,7 @@ insert into t1 values(2,@b2,222,@d2); commit; explain select * from t1 where a = 1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 const PRIMARY PRIMARY 4 const # NULL +1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 const # NULL select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) from t1 where a=1; a length(b) substr(b,1+2*900,2) length(d) substr(d,1+3*900,3) @@ -89,7 +89,7 @@ replace t1 set a=2,b=@b2,c=222,d=@d2; commit; explain select * from t1 where a = 1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 const PRIMARY PRIMARY 4 const # NULL +1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 const # NULL select a,length(b),substr(b,1+2*900,2),length(d),substr(d,1+3*900,3) from t1 where a=1; a length(b) substr(b,1+2*900,2) length(d) substr(d,1+3*900,3) === modified file 'mysql-test/suite/ndb/r/ndb_dd_sql_features.result' --- a/mysql-test/suite/ndb/r/ndb_dd_sql_features.result 2012-03-12 08:56:56 +0000 +++ b/mysql-test/suite/ndb/r/ndb_dd_sql_features.result 2012-05-03 13:54:29 +0000 @@ -441,7 +441,7 @@ INSERT INTO test.t1 values(1,@vc1,@d1); INSERT INTO test.t1 values(2,@vc2,@d2); explain SELECT * from test.t1 WHERE a1 = 1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 const PRIMARY PRIMARY 4 const # NULL +1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 const # NULL SELECT a1,length(a2),substr(a2,1+2*900,2),length(a3),substr(a3,1+3*900,3) FROM test.t1 WHERE a1=1 ORDER BY a1; a1 length(a2) substr(a2,1+2*900,2) length(a3) substr(a3,1+3*900,3) === modified file 'mysql-test/suite/ndb/r/ndb_join_pushdown_default.result' --- a/mysql-test/suite/ndb/r/ndb_join_pushdown_default.result 2012-05-02 19:09:22 +0000 +++ b/mysql-test/suite/ndb/r/ndb_join_pushdown_default.result 2012-05-03 13:54:29 +0000 @@ -3447,11 +3447,11 @@ from t1, t2 where t2.a = t1.b and t1.a = 2; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 100.00 NULL -1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 const 1 100.00 Using where with pushed condition (`test`.`t1`.`b` is not null) +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 NULL Warnings: -Note 9999 Table 't1' was optimized away, or const'ified by optimizer -Note 1003 /* select#1 */ select '2' AS `a`,'1' AS `b`,'kalle' AS `c`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = '1')) +Note 9999 Table 't1' is not pushable: select list can't contain BLOB columns +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = 2) and (`test`.`t2`.`a` = `test`.`t1`.`b`)) select * from t1, t2 where t2.a = t1.b @@ -4871,11 +4871,12 @@ on table3.u = table1.u where table2.pk = 3; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE table1 ALL NULL NULL NULL NULL 13 100.00 NULL -1 SIMPLE table2 eq_ref PRIMARY,ix2 PRIMARY 4 const 1 100.00 Parent of 2 pushed join@1; Using where with pushed condition (`test`.`table2`.`a` is not null) -1 SIMPLE table3 ref ix2 ix2 9 test.table2.a,test.table1.u 1 100.00 Child of 'table2' in pushed join@1 +1 SIMPLE table2 eq_ref PRIMARY,ix2 PRIMARY 4 const 1 100.00 Using where with pushed condition (`test`.`table2`.`a` is not null) +1 SIMPLE table3 ref ix2 ix2 9 test.table2.a,test.table1.u 1 100.00 NULL Warnings: Note 9999 Can't push table 'table2' as child of 'table1', their dependency is 'const' Note 9999 Can't push table 'table3' as child of 'table1', column 'table2.a' is outside scope of pushable join +Note 9999 Cannot push table 'table3' as child of 'table2', since it referes to column 'table1.u' prior to a potential 'const' root. Note 1003 /* select#1 */ select straight_join `test`.`table1`.`pk` AS `pk`,`test`.`table1`.`u` AS `u`,`test`.`table1`.`a` AS `a`,`test`.`table1`.`b` AS `b`,`test`.`table2`.`pk` AS `pk`,`test`.`table2`.`u` AS `u`,`test`.`table2`.`a` AS `a`,`test`.`table2`.`b` AS `b`,`test`.`table3`.`pk` AS `pk`,`test`.`table3`.`u` AS `u`,`test`.`table3`.`a` AS `a`,`test`.`table3`.`b` AS `b` from `test`.`t1` `table1` join `test`.`t1` `table2` join `test`.`t1` `table3` where ((`test`.`table3`.`a` = `test`.`table2`.`a`) and (`test`.`table3`.`u` = `test`.`table1`.`u`) and (`test`.`table2`.`pk` = 3)) select straight_join * from t1 as table1 join @@ -5700,7 +5701,7 @@ CONST_PRUNED_RANGE_SCANS_RECEIVED 8 LOCAL_TABLE_SCANS_SENT 256 PRUNED_RANGE_SCANS_RECEIVED 27 RANGE_SCANS_RECEIVED 728 -READS_RECEIVED 56 +READS_RECEIVED 43 TABLE_SCANS_RECEIVED 256 drop table spj_counts_at_startup; drop table spj_counts_at_end; @@ -5711,9 +5712,9 @@ where new.variable_name = old.variable_n order by new.variable_name; variable_name new.variable_value - old.variable_value NDB_PRUNED_SCAN_COUNT 8 -NDB_PUSHED_QUERIES_DEFINED 403 +NDB_PUSHED_QUERIES_DEFINED 401 NDB_PUSHED_QUERIES_DROPPED 7 -NDB_PUSHED_QUERIES_EXECUTED 547 +NDB_PUSHED_QUERIES_EXECUTED 534 NDB_SORTED_SCAN_COUNT 11 drop table server_counts_at_startup; set ndb_join_pushdown = @save_ndb_join_pushdown; === modified file 'mysql-test/suite/ndb/r/ndb_join_pushdown_nobnl.result' --- a/mysql-test/suite/ndb/r/ndb_join_pushdown_nobnl.result 2012-05-02 19:09:22 +0000 +++ b/mysql-test/suite/ndb/r/ndb_join_pushdown_nobnl.result 2012-05-03 13:54:29 +0000 @@ -3444,11 +3444,11 @@ from t1, t2 where t2.a = t1.b and t1.a = 2; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 100.00 NULL -1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 const 1 100.00 Using where with pushed condition (`test`.`t1`.`b` is not null) +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 NULL Warnings: -Note 9999 Table 't1' was optimized away, or const'ified by optimizer -Note 1003 /* select#1 */ select '2' AS `a`,'1' AS `b`,'kalle' AS `c`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = '1')) +Note 9999 Table 't1' is not pushable: select list can't contain BLOB columns +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = 2) and (`test`.`t2`.`a` = `test`.`t1`.`b`)) select * from t1, t2 where t2.a = t1.b @@ -4868,11 +4868,12 @@ on table3.u = table1.u where table2.pk = 3; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE table1 ALL NULL NULL NULL NULL 13 100.00 NULL -1 SIMPLE table2 eq_ref PRIMARY,ix2 PRIMARY 4 const 1 100.00 Parent of 2 pushed join@1; Using where with pushed condition (`test`.`table2`.`a` is not null) -1 SIMPLE table3 ref ix2 ix2 9 test.table2.a,test.table1.u 1 100.00 Child of 'table2' in pushed join@1 +1 SIMPLE table2 eq_ref PRIMARY,ix2 PRIMARY 4 const 1 100.00 Using where with pushed condition (`test`.`table2`.`a` is not null) +1 SIMPLE table3 ref ix2 ix2 9 test.table2.a,test.table1.u 1 100.00 NULL Warnings: Note 9999 Can't push table 'table2' as child of 'table1', their dependency is 'const' Note 9999 Can't push table 'table3' as child of 'table1', column 'table2.a' is outside scope of pushable join +Note 9999 Cannot push table 'table3' as child of 'table2', since it referes to column 'table1.u' prior to a potential 'const' root. Note 1003 /* select#1 */ select straight_join `test`.`table1`.`pk` AS `pk`,`test`.`table1`.`u` AS `u`,`test`.`table1`.`a` AS `a`,`test`.`table1`.`b` AS `b`,`test`.`table2`.`pk` AS `pk`,`test`.`table2`.`u` AS `u`,`test`.`table2`.`a` AS `a`,`test`.`table2`.`b` AS `b`,`test`.`table3`.`pk` AS `pk`,`test`.`table3`.`u` AS `u`,`test`.`table3`.`a` AS `a`,`test`.`table3`.`b` AS `b` from `test`.`t1` `table1` join `test`.`t1` `table2` join `test`.`t1` `table3` where ((`test`.`table3`.`a` = `test`.`table2`.`a`) and (`test`.`table3`.`u` = `test`.`table1`.`u`) and (`test`.`table2`.`pk` = 3)) select straight_join * from t1 as table1 join @@ -5695,7 +5696,7 @@ CONST_PRUNED_RANGE_SCANS_RECEIVED 8 LOCAL_TABLE_SCANS_SENT 298 PRUNED_RANGE_SCANS_RECEIVED 27 RANGE_SCANS_RECEIVED 734 -READS_RECEIVED 56 +READS_RECEIVED 43 TABLE_SCANS_RECEIVED 298 drop table spj_counts_at_startup; drop table spj_counts_at_end; @@ -5706,9 +5707,9 @@ where new.variable_name = old.variable_n order by new.variable_name; variable_name new.variable_value - old.variable_value NDB_PRUNED_SCAN_COUNT 8 -NDB_PUSHED_QUERIES_DEFINED 411 +NDB_PUSHED_QUERIES_DEFINED 409 NDB_PUSHED_QUERIES_DROPPED 7 -NDB_PUSHED_QUERIES_EXECUTED 571 +NDB_PUSHED_QUERIES_EXECUTED 558 NDB_SORTED_SCAN_COUNT 11 drop table server_counts_at_startup; set ndb_join_pushdown = @save_ndb_join_pushdown; === modified file 'mysql-test/suite/ndb/r/ndb_join_pushdown_none.result' --- a/mysql-test/suite/ndb/r/ndb_join_pushdown_none.result 2012-05-02 19:09:22 +0000 +++ b/mysql-test/suite/ndb/r/ndb_join_pushdown_none.result 2012-05-03 13:54:29 +0000 @@ -3447,11 +3447,11 @@ from t1, t2 where t2.a = t1.b and t1.a = 2; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 100.00 NULL -1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 const 1 100.00 NULL +1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 const 1 100.00 Using where with pushed condition (`test`.`t1`.`b` is not null) +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 100.00 NULL Warnings: -Note 9999 Table 't1' was optimized away, or const'ified by optimizer -Note 1003 /* select#1 */ select '2' AS `a`,'1' AS `b`,'kalle' AS `c`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = '1')) +Note 9999 Table 't1' is not pushable: select list can't contain BLOB columns +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a` = 2) and (`test`.`t2`.`a` = `test`.`t1`.`b`)) select * from t1, t2 where t2.a = t1.b @@ -4871,11 +4871,12 @@ on table3.u = table1.u where table2.pk = 3; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE table1 ALL NULL NULL NULL NULL 13 100.00 NULL -1 SIMPLE table2 eq_ref PRIMARY,ix2 PRIMARY 4 const 1 100.00 Parent of 2 pushed join@1; Using where with pushed condition (`test`.`table2`.`a` is not null) -1 SIMPLE table3 ref ix2 ix2 9 test.table2.a,test.table1.u 1 100.00 Child of 'table2' in pushed join@1 +1 SIMPLE table2 eq_ref PRIMARY,ix2 PRIMARY 4 const 1 100.00 Using where with pushed condition (`test`.`table2`.`a` is not null) +1 SIMPLE table3 ref ix2 ix2 9 test.table2.a,test.table1.u 1 100.00 NULL Warnings: Note 9999 Can't push table 'table2' as child of 'table1', their dependency is 'const' Note 9999 Can't push table 'table3' as child of 'table1', column 'table2.a' is outside scope of pushable join +Note 9999 Cannot push table 'table3' as child of 'table2', since it referes to column 'table1.u' prior to a potential 'const' root. Note 1003 /* select#1 */ select straight_join `test`.`table1`.`pk` AS `pk`,`test`.`table1`.`u` AS `u`,`test`.`table1`.`a` AS `a`,`test`.`table1`.`b` AS `b`,`test`.`table2`.`pk` AS `pk`,`test`.`table2`.`u` AS `u`,`test`.`table2`.`a` AS `a`,`test`.`table2`.`b` AS `b`,`test`.`table3`.`pk` AS `pk`,`test`.`table3`.`u` AS `u`,`test`.`table3`.`a` AS `a`,`test`.`table3`.`b` AS `b` from `test`.`t1` `table1` join `test`.`t1` `table2` join `test`.`t1` `table3` where ((`test`.`table3`.`a` = `test`.`table2`.`a`) and (`test`.`table3`.`u` = `test`.`table1`.`u`) and (`test`.`table2`.`pk` = 3)) select straight_join * from t1 as table1 join @@ -5700,7 +5701,7 @@ CONST_PRUNED_RANGE_SCANS_RECEIVED 8 LOCAL_TABLE_SCANS_SENT 254 PRUNED_RANGE_SCANS_RECEIVED 27 RANGE_SCANS_RECEIVED 735 -READS_RECEIVED 60 +READS_RECEIVED 47 TABLE_SCANS_RECEIVED 254 drop table spj_counts_at_startup; drop table spj_counts_at_end; @@ -5711,9 +5712,9 @@ where new.variable_name = old.variable_n order by new.variable_name; variable_name new.variable_value - old.variable_value NDB_PRUNED_SCAN_COUNT 11 -NDB_PUSHED_QUERIES_DEFINED 403 +NDB_PUSHED_QUERIES_DEFINED 401 NDB_PUSHED_QUERIES_DROPPED 11 -NDB_PUSHED_QUERIES_EXECUTED 555 +NDB_PUSHED_QUERIES_EXECUTED 542 NDB_SORTED_SCAN_COUNT 11 drop table server_counts_at_startup; set ndb_join_pushdown = @save_ndb_join_pushdown; === modified file 'sql/ha_ndbcluster.cc' --- a/sql/ha_ndbcluster.cc 2012-05-02 19:09:22 +0000 +++ b/sql/ha_ndbcluster.cc 2012-05-03 13:54:29 +0000 @@ -6554,46 +6554,6 @@ int ha_ndbcluster::index_read_last(uchar } -/** - Read first row (only) from a table. - - This is actually (yet) never called for ndbcluster tables, as these table types - does not set HA_STATS_RECORDS_IS_EXACT. - - UPDATE: Might be called if the predicate contain ' IS NULL', and - is defined as 'NOT NULL' (or is part of primary key) - - Implemented regardless of this as the default implememtation would break - any pushed joins as it calls ha_rnd_end() / ha_index_end() at end of execution. - */ -int ha_ndbcluster::read_first_row(uchar * buf, uint primary_key) -{ - register int error; - DBUG_ENTER("ha_ndbcluster::read_first_row"); - - ha_statistic_increment(&SSV::ha_read_first_count); - - /* - If there is very few deleted rows in the table, find the first row by - scanning the table. - TODO remove the test for HA_READ_ORDER - */ - if (stats.deleted < 10 || primary_key >= MAX_KEY || - !(index_flags(primary_key, 0, 0) & HA_READ_ORDER)) - { - (void) ha_rnd_init(1); - while ((error= rnd_next(buf)) == HA_ERR_RECORD_DELETED) ; - } - else - { - /* Find the first row through the primary key */ - (void) ha_index_init(primary_key, 0); - error=index_first(buf); - } - DBUG_RETURN(error); -} - - int ha_ndbcluster::read_range_first_to_buf(const key_range *start_key, const key_range *end_key, bool desc, bool sorted, @@ -12414,6 +12374,19 @@ ulonglong ha_ndbcluster::table_flags(voi */ if (thd->variables.binlog_format == BINLOG_FORMAT_STMT) f= (f | HA_BINLOG_STMT_CAPABLE) & ~HA_HAS_OWN_BINLOGGING; + + /** + * To maximize join pushability we want const-table optimization + * blocked if table is possibly pushable, that is: + * - Variable 'ndb_join_pushdown= on' + * - Lock mode is LM_CommittedRead + */ + if (THDVAR(thd, join_pushdown) && + get_ndb_lock_mode(m_lock.type) == NdbOperation::LM_CommittedRead) + { + f= f | HA_BLOCK_CONST_TABLE; + } + return f; } @@ -14987,57 +14960,6 @@ ha_ndbcluster::parent_of_pushed_join() c return NULL; } -bool -ha_ndbcluster::test_push_flag(enum ha_push_flag flag) const -{ - DBUG_ENTER("test_push_flag"); - switch (flag) { - case HA_PUSH_BLOCK_CONST_TABLE: - { - /** - * We don't support join push down if... - * - not LM_CommittedRead - * - uses blobs - */ - THD *thd= current_thd; - if (unlikely(!THDVAR(thd, join_pushdown))) - DBUG_RETURN(false); - - if (table->read_set != NULL && uses_blob_value(table->read_set)) - { - DBUG_RETURN(false); - } - - NdbOperation::LockMode lm= get_ndb_lock_mode(m_lock.type); - - if (lm != NdbOperation::LM_CommittedRead) - { - DBUG_RETURN(false); - } - - DBUG_RETURN(true); - } - case HA_PUSH_MULTIPLE_DEPENDENCY: - /** - * If any child operation within this pushed join refer - * column values (paramValues), the pushed join has dependencies - * in addition to the root operation itself. - */ - if (m_pushed_join_operation==PUSHED_ROOT && - m_pushed_join_member->get_field_referrences_count() > 0) // Childs has field refs - { - DBUG_RETURN(true); - } - DBUG_RETURN(false); - - default: - DBUG_ASSERT(0); - DBUG_RETURN(false); - } - DBUG_RETURN(false); -} - - /** @param[in] comment table comment defined by user === modified file 'sql/ha_ndbcluster.h' --- a/sql/ha_ndbcluster.h 2012-05-02 19:09:22 +0000 +++ b/sql/ha_ndbcluster.h 2012-05-03 13:54:29 +0000 @@ -180,7 +180,6 @@ class ha_ndbcluster: public handler int rnd_next(uchar *buf); int rnd_pos(uchar *buf, uchar *pos); void position(const uchar *record); - int read_first_row(uchar *buf, uint primary_key); virtual int cmp_ref(const uchar * ref1, const uchar * ref2); int read_range_first(const key_range *start_key, const key_range *end_key, @@ -338,15 +337,6 @@ static void set_tabname(const char *path bool maybe_pushable_join(const char*& reason) const; int assign_pushed_join(const ndb_pushed_join* pushed_join); -#ifdef NDB_WITHOUT_JOIN_PUSHDOWN - enum ha_push_flag { - HA_PUSH_BLOCK_CONST_TABLE, - HA_PUSH_MULTIPLE_DEPENDENCY, - HA_PUSH_NO_ORDERED_INDEX - }; -#endif - bool test_push_flag(enum ha_push_flag flag) const; - uint number_of_pushed_joins() const; const TABLE* root_of_pushed_join() const; const TABLE* parent_of_pushed_join() const; === modified file 'sql/ha_ndbcluster_push.cc' --- a/sql/ha_ndbcluster_push.cc 2012-05-02 19:09:22 +0000 +++ b/sql/ha_ndbcluster_push.cc 2012-05-03 13:54:29 +0000 @@ -958,12 +958,38 @@ bool ndb_pushed_builder_ctx::is_field_it // This key item is const. and did not cause the set of possible parents // to be recalculated. Reuse what we had before this key item. DBUG_ASSERT(field_parents.is_clear_all()); - /** - * Scan queries cannot be pushed if the pushed query may refer column - * values (paramValues) from rows stored in a join cache. + + /** + * Field referrence is a 'paramValue' to a column value evaluated + * prior to the root of this pushed join candidate. Some restrictions + * applies to when a field reference is allowed in a pushed join: */ - if (!ndbcluster_is_lookup_operation(m_join_root->get_access_type())) + if (ndbcluster_is_lookup_operation(m_join_root->get_access_type())) { + /** + * The 'eq_ref' access function join_read_key(), may optimize away + * key reads if the key for a requested row is the same as the + * previous. Thus, iff this is the root of a pushed lookup join + * we do not want it to contain childs with references to columns + * 'outside' the the pushed joins, as these may still change + * between calls to join_read_key() independent of the root key + * itself being the same. + */ + EXPLAIN_NO_PUSH("Cannot push table '%s' as child of '%s', since " + "it referes to column '%s.%s' prior to a " + "potential 'const' root.", + table->get_table()->alias, + m_join_root->get_table()->alias, + get_referred_table_access_name(key_item_field), + get_referred_field_name(key_item_field)); + DBUG_RETURN(false); + } + else + { + /** + * Scan queries cannot be pushed if the pushed query may refer column + * values (paramValues) from rows stored in a join cache. + */ const TABLE* const referred_tab = key_item_field->field->table; uint access_no = tab_no; do === modified file 'sql/handler.h' --- a/sql/handler.h 2012-05-02 19:09:22 +0000 +++ b/sql/handler.h 2012-05-03 13:54:29 +0000 @@ -189,6 +189,14 @@ enum enum_alter_inplace_result { */ #define HA_READ_BEFORE_WRITE_REMOVAL (LL(1) << 38) +#ifndef MCP_WL4784 +/* + The handler don't want accesses to this table to + be const-table optimized +*/ +#define HA_BLOCK_CONST_TABLE (LL(1) << 39) +#endif + /* bits in index_flags(index_number) for what you can do with index */ #define HA_READ_NEXT 1 /* TODO really use this flag */ #define HA_READ_PREV 2 /* supports ::index_prev */ @@ -424,21 +432,6 @@ typedef ulonglong my_xid; // this line i namespace AQP { class Join_plan; }; - -/* Flag used for for test_push_flag() */ -enum ha_push_flag { - - /* Handler want to block const table optimization */ - HA_PUSH_BLOCK_CONST_TABLE - - /* Handler reports a pushed join as having multiple dependencies - if its results does not only depend on the root operation: - ie. results from some child operations does not only depend - on results from the root operation and/or other child operations - within this pushed join - */ - ,HA_PUSH_MULTIPLE_DEPENDENCY -}; #endif /** @@ -2521,11 +2514,6 @@ public: virtual const TABLE* parent_of_pushed_join() const { return NULL; } - virtual bool test_push_flag(enum ha_push_flag flag) const - { - return FALSE; - } - virtual int index_read_pushed(uchar * buf, const uchar * key, key_part_map keypart_map) { return HA_ERR_WRONG_COMMAND; } === modified file 'sql/sql_executor.cc' --- a/sql/sql_executor.cc 2012-04-11 12:33:47 +0000 +++ b/sql/sql_executor.cc 2012-05-03 13:54:29 +0000 @@ -3120,21 +3120,8 @@ join_read_last_key(JOIN_TAB *tab) /* ARGSUSED */ static int -join_no_more_records(READ_RECORD *info) +join_no_more_records(READ_RECORD *info __attribute__((unused))) { -#ifndef MCP_WL4784 - /** - * When a pushed join completes, and its results did not only depend on - * the key of this root operations: ('tab->ref.key_buff') - * Results from this pushed join can not be reused - * for later queries having the same root key. - * (ref: join_read_key(), join_read_const() & join_read_system() - */ - if (info->table->file->test_push_flag(HA_PUSH_MULTIPLE_DEPENDENCY)) - { - info->table->status= STATUS_GARBAGE; - } -#endif return -1; } === modified file 'sql/sql_optimizer.cc' --- a/sql/sql_optimizer.cc 2012-04-11 12:33:47 +0000 +++ b/sql/sql_optimizer.cc 2012-05-03 13:54:29 +0000 @@ -3049,16 +3049,6 @@ make_join_statistics(JOIN *join, TABLE_L */ extract_method= extract_no_table; } -#ifndef MCP_WL4784 - else if (table->file->test_push_flag(HA_PUSH_BLOCK_CONST_TABLE)) - { - /* - Handler implements pushed joins, and prefer const tables to - be pushed together with rest of the pushed query. - */ - extract_method= extract_no_table; - } -#endif else if (*s->on_expr_ref) { /* s is the only inner table of an outer join, extract empty tables */ @@ -3243,7 +3233,7 @@ const_table_extraction_done: !(tl->embedding && tl->embedding->sj_on_expr) && // 3 #ifndef MCP_WL4784 !(*s->on_expr_ref && (*s->on_expr_ref)->is_expensive()) &&// 4 - !table->file->test_push_flag(HA_PUSH_BLOCK_CONST_TABLE)) // 5 + !(table->file->ha_table_flags() & HA_BLOCK_CONST_TABLE)) // 5 #else !(*s->on_expr_ref && (*s->on_expr_ref)->is_expensive())) // 4 #endif === modified file 'sql/sql_select.cc' --- a/sql/sql_select.cc 2012-05-02 19:09:22 +0000 +++ b/sql/sql_select.cc 2012-05-03 13:54:29 +0000 @@ -1511,7 +1511,7 @@ bool create_ref_for_key(JOIN *join, JOIN } #ifndef MCP_WL4784 else if (keyuse_uses_no_tables && - !table->file->test_push_flag(HA_PUSH_BLOCK_CONST_TABLE)) + !(table->file->ha_table_flags() & HA_BLOCK_CONST_TABLE)) #else else if (keyuse_uses_no_tables) #endif @@ -3312,6 +3312,7 @@ const_expression_in_where(Item *cond, It } + /** Test if one can use the key to resolve ORDER BY. === modified file 'storage/ndb/memcache/src/ndb_engine.c' --- a/storage/ndb/memcache/src/ndb_engine.c 2012-04-24 01:41:51 +0000 +++ b/storage/ndb/memcache/src/ndb_engine.c 2012-05-02 03:01:21 +0000 @@ -28,6 +28,7 @@ #include #include +#include #include #include "ndb_engine.h" @@ -93,7 +94,7 @@ ENGINE_ERROR_CODE create_instance(uint64 return ENGINE_ENOMEM; } - logger = get_stderr_logger(); + logger = api->extension->get_extension(EXTENSION_LOGGER); ndb_eng->npipelines = 0; ndb_eng->connected = false; @@ -364,6 +365,7 @@ static ENGINE_ERROR_CODE ndb_remove(ENGI return_status = ENGINE_KEY_ENOENT; hash_item *it = item_get(def_eng, key, nkey); if (it != NULL) { + // ACTUALLY NO??? /* In the binary protocol there is such a thing as a CAS delete. This is the CAS check. If we will also be deleting from the database, there are two possibilities: No bundle (reason: useless for push emails).