From: Ole John Aske Date: October 11 2010 9:55am Subject: bzr push into mysql-5.1-telco-7.0-spj-scan-vs-scan branch (ole.john.aske:3306 to 3308) List-Archive: http://lists.mysql.com/commits/120481 Message-Id: <20101011095558.5F6B221D@fimafeng09.norway.sun.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8390685081330314894==" --===============8390685081330314894== MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline 3308 Ole John Aske 2010-10-11 spj-svs: Fixed an undefined memory read Fixed a situation where an empty 'm_spjProjection' will cause NdbQueryOperationDefImpl::appendChildProjection() to set the QueryTree flag 'NI_LINKED_ATTR' without appending a projection list to the serialized query tree. This fix will ensure that a serialized m_spjProjection list with size==0 will be included in these cases. No testcase as I can't think of any deterministic ways to make a testcase for an undefined memory read.... modified: storage/ndb/src/ndbapi/NdbQueryBuilder.cpp 3307 Ole John Aske 2010-10-11 spj-svs: Recommited after 'bzr pull' to clear merge conflicts Fixed incorrect usage of info in NdbRecord to find the NdbQueryOperand* which defined the value for a specific column in the partition key. Bug caused 'out of bound' read in m_bound.low[] and an assert when compiled with DEBUG. Includes testcase for the above. modified: mysql-test/suite/ndb/r/ndb_join_pushdown.result mysql-test/suite/ndb/t/ndb_join_pushdown.test storage/ndb/src/ndbapi/NdbQueryBuilder.cpp 3306 Jan Wedvik 2010-10-07 This commit adds methods for setting the parallelism for the root operation of a pushed scan query (to be less than the number of fragments). If you wish to test this, apply the patch below and run suitable SQL queries. -----------8<---------------- === modified file 'sql/ha_ndbcluster.cc' --- sql/ha_ndbcluster.cc 2010-10-07 11:21:35 +0000 +++ sql/ha_ndbcluster.cc 2010-10-07 10:56:58 +0000 @@ -5205,6 +5205,11 @@ int ha_ndbcluster::ordered_index_scan(co ERR_RETURN(query->getNdbError()); } + if (!sorted) + { + query->getQueryOperation(0U)->setParallelism(1); + } + if (pbound && query->setBound(key_rec, pbound)!=0) ERR_RETURN(query->getNdbError()); @@ -5393,6 +5398,7 @@ int ha_ndbcluster::full_table_scan(const m_thd_ndb->m_scan_count++; DBUG_ASSERT(!uses_blob_value(table->read_set)); // Can't have BLOB in pushed joins (yet) + m_active_query->getQueryOperation(0U)->setParallelism(1); } else // if (check_if_pushable(NdbQueryOperationDef::TableScan)) { -----------8<---------------- modified: storage/ndb/include/kernel/signaldata/ScanTab.hpp storage/ndb/include/ndbapi/NdbQueryOperation.hpp storage/ndb/src/kernel/blocks/dbtc/Dbtc.hpp storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp storage/ndb/src/ndbapi/NdbQueryBuilderImpl.hpp storage/ndb/src/ndbapi/NdbQueryOperation.cpp storage/ndb/src/ndbapi/NdbQueryOperationImpl.hpp storage/ndb/src/ndbapi/ndberror.c === modified file 'mysql-test/suite/ndb/r/ndb_join_pushdown.result' --- a/mysql-test/suite/ndb/r/ndb_join_pushdown.result 2010-09-30 14:20:12 +0000 +++ b/mysql-test/suite/ndb/r/ndb_join_pushdown.result 2010-10-11 09:48:36 +0000 @@ -3875,6 +3875,14 @@ d e f a b c d e f a b c 1 2 3 6 7 8 1 2 3 1 2 4 1 2 3 7 8 9 1 2 3 1 2 3 1 2 3 7 8 9 1 2 3 1 2 4 +alter table t1 drop primary key, add primary key using hash (d,b,a,c); +alter table t1 partition by key (b); +create index ix1 on t1(b,d,a); +explain +select straight_join * from t1 x, t1 y where y.a=x.d and y.b=x.e; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE x ALL PRIMARY NULL NULL NULL 8 Parent of 2 pushed join@1 +1 SIMPLE y ref ix1 ix1 4 test.x.e 1 Child of pushed join@1; Using where pruned 12 const_pruned @@ -4014,13 +4022,13 @@ LOCAL+REMOTE READS_SENT drop table spj_counts_at_startup; drop table spj_counts_at_end; scan_count -1975 +1985 pruned_scan_count 7 sorted_scan_count 44 pushed_queries_defined -333 +334 pushed_queries_dropped 11 pushed_queries_executed === modified file 'mysql-test/suite/ndb/t/ndb_join_pushdown.test' --- a/mysql-test/suite/ndb/t/ndb_join_pushdown.test 2010-09-30 14:20:12 +0000 +++ b/mysql-test/suite/ndb/t/ndb_join_pushdown.test 2010-10-11 09:48:36 +0000 @@ -2771,6 +2771,18 @@ select straight_join * from t1 x, t1 y w --sorted_result select straight_join * from t1 x, t1 y where y.a=x.d and y.b=2; +########## +# Test pruned scan using an index: +# Declaring PK as 'using hash' will prevent that PK is used as index +# Declare PK / ix1 with mismatching column order will test correct +# usage of NdbRecord::distkey_indexes[] +########## +alter table t1 drop primary key, add primary key using hash (d,b,a,c); +alter table t1 partition by key (b); +create index ix1 on t1(b,d,a); + +explain +select straight_join * from t1 x, t1 y where y.a=x.d and y.b=x.e; # Verify pruned execution by comparing the NDB$INFO counters --disable_query_log === modified file 'storage/ndb/src/ndbapi/NdbQueryBuilder.cpp' --- a/storage/ndb/src/ndbapi/NdbQueryBuilder.cpp 2010-09-24 07:29:43 +0000 +++ b/storage/ndb/src/ndbapi/NdbQueryBuilder.cpp 2010-10-11 09:55:24 +0000 @@ -1810,11 +1810,9 @@ public: m_pos(0), m_finished(false) { - if (size > 0) { - m_seq = buffer.alloc(1 + size/2); - assert (size <= 0xFFFF); - m_seq[0] = size; - } + m_seq = buffer.alloc(1 + size/2); + assert (size <= 0xFFFF); + m_seq[0] = size; } ~Uint16Sequence() @@ -2102,10 +2100,12 @@ NdbQueryIndexScanOperationDefImpl::appen for (unsigned i = 0; i < indexRecord->distkey_index_length; i++) { - unsigned keyNo = indexRecord->distkey_indexes[i]; - assert(keyNocolumns[keyNo].flags & NdbRecord::IsDistributionKey); - const NdbQueryOperandImpl* key = m_bound.low[keyNo]; + const unsigned keyNo = indexRecord->distkey_indexes[i]; + assert(keyNonoOfColumns); + const NdbRecord::Attr& indexAttr = indexRecord->columns[keyNo]; + assert(indexAttr.flags & NdbRecord::IsDistributionKey); + assert(indexAttr.index_attrIdgetKind()) { --===============8390685081330314894== MIME-Version: 1.0 Content-Type: text/bzr-bundle; charset="us-ascii"; name="bzr/ole.john.aske@stripped" Content-Transfer-Encoding: 7bit Content-Disposition: inline # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: ole.john.aske@stripped\ # c6k1ptd3zvc3ipl8 # target_branch: file:///net/fimafeng09/export/home/tmp/oleja/mysql\ # /mysql-5.1-telco-7.0-spj-scan-scan/ # testament_sha1: 0dcd3459f179802627180e5ec3426460b29f1605 # timestamp: 2010-10-11 11:55:58 +0200 # source_branch: bzr+ssh://oaske@stripped/bzrroot/server\ # /mysql-5.1-telco-7.0-spj/ # base_revision_id: jan.wedvik@stripped # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWS+VNDUABQNfgEUwWf///3+/ /iq////wYAun3mbtgAAaBy6yAAAAFAXWADDUyEyamnpNGU0M0mRhNNNGg0AaNMgaMjIEpUxT8Jqn tNU/Unij0mgAAANNAAAAAcNNMEMhppkZMIBpoAwmjTJgAQNBIpojUFGeqbKfqaR6npB6mRoMNIae kADQGgHDTTBDIaaZGTCAaaAMJo0yYAEDQSSBAAIBomRiAIUxhRobUnmqHpB6myl6CQgBCMk2HWel I7SsqRlXsaWhWZVosQjU0wtxcGAX0FCSVGPp8gINImkILibpBF5nFW/GZc0SAIoY0XCtIqTmImXF kABwyCLOpI4e1NbOunMXS9qZ6ITFMsytBr/4cILEGb6dOjPORaYsmIlr3w6A4wY222Nipq+oFaFT JuUc8j0sozcstnNWO9krKVpS2Q4nBMvXTNbl35BNfFvbciWAuSZVZRsbvLXXjYOgJBrNTzDp4E0d K66RkgW6WwcC3zbgU1YDZjA0sGMORGwoSYTTCasYpSYB9KCwsYKHsp3Vsad3MNF2LnS0FM8wPI6J H7HtRP5aJQwXMUSVjoSYYxloFB9GWXSARcy14E875GNZNJNCVmJUkAO0S0qDrC7C1jdtxTlG+s5R gRBQNmG6kBgnG1rpOnLD1an3wq4CIycINR7gYGPflhXq4/rIHs21xpGNIzNZ+PHp/Ph2FJ+xKguv dMaR5IYkOMaIuT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