diff options
author | mskold/marty@mysql.com/linux.site <> | 2007-02-07 12:33:36 +0100 |
---|---|---|
committer | mskold/marty@mysql.com/linux.site <> | 2007-02-07 12:33:36 +0100 |
commit | 77ab74831f6681da93435cd18d4ba289d8ebd910 (patch) | |
tree | 95b1c230a42cd9c98465cfb7b0c6b399526d4eec | |
parent | 8d5ce41010b2da139ad3f6551aecf94a0dea19ae (diff) | |
parent | 5df38bfc3ecd2894eef8a545686c17b68e5be02a (diff) | |
download | mariadb-git-77ab74831f6681da93435cd18d4ba289d8ebd910.tar.gz |
Merge mskold@bk-internal.mysql.com:/home/bk/mysql-5.0-ndb
into mysql.com:/windows/Linux_space/MySQL/mysql-5.0-ndb
-rw-r--r-- | mysql-test/r/ndb_read_multi_range.result | 7 | ||||
-rw-r--r-- | mysql-test/t/ndb_read_multi_range.test | 9 | ||||
-rw-r--r-- | ndb/include/ndbapi/NdbIndexScanOperation.hpp | 6 | ||||
-rw-r--r-- | ndb/include/ndbapi/NdbScanOperation.hpp | 8 | ||||
-rw-r--r-- | ndb/src/ndbapi/NdbScanOperation.cpp | 15 | ||||
-rw-r--r-- | sql/ha_ndbcluster.cc | 8 |
6 files changed, 40 insertions, 13 deletions
diff --git a/mysql-test/r/ndb_read_multi_range.result b/mysql-test/r/ndb_read_multi_range.result index d279485e48e..64a6749bed1 100644 --- a/mysql-test/r/ndb_read_multi_range.result +++ b/mysql-test/r/ndb_read_multi_range.result @@ -398,3 +398,10 @@ INSERT INTO t1 VALUES (1,1),(2,2),(3,3); UPDATE t1 SET var2 = 9 WHERE var1 IN(1,2,3); DROP TRIGGER testtrigger; DROP TABLE t1, t2; +create table t2 (a int, b int, primary key (a), key ab (a,b)) engine=ndbcluster; +insert into t2 values (1,1), (10,10); +select * from t2 use index (ab) where a in(1,10) order by a; +a b +1 1 +10 10 +drop table t2; diff --git a/mysql-test/t/ndb_read_multi_range.test b/mysql-test/t/ndb_read_multi_range.test index cfbf0561d1e..e1f1dfc1150 100644 --- a/mysql-test/t/ndb_read_multi_range.test +++ b/mysql-test/t/ndb_read_multi_range.test @@ -282,3 +282,12 @@ UPDATE t1 SET var2 = 9 WHERE var1 IN(1,2,3); DROP TRIGGER testtrigger; DROP TABLE t1, t2; + +#bug#25821 +create table t2 (a int, b int, primary key (a), key ab (a,b)) engine=ndbcluster; + +insert into t2 values (1,1), (10,10); + +select * from t2 use index (ab) where a in(1,10) order by a; + +drop table t2; diff --git a/ndb/include/ndbapi/NdbIndexScanOperation.hpp b/ndb/include/ndbapi/NdbIndexScanOperation.hpp index 550f4201b71..8c20fd58f43 100644 --- a/ndb/include/ndbapi/NdbIndexScanOperation.hpp +++ b/ndb/include/ndbapi/NdbIndexScanOperation.hpp @@ -63,12 +63,14 @@ public: bool order_by, bool order_desc = false, bool read_range_no = false, - bool keyinfo = false) { + bool keyinfo = false, + bool multi_range = false) { Uint32 scan_flags = (SF_OrderBy & -(Int32)order_by) | (SF_Descending & -(Int32)order_desc) | (SF_ReadRangeNo & -(Int32)read_range_no) | - (SF_KeyInfo & -(Int32)keyinfo); + (SF_KeyInfo & -(Int32)keyinfo) | + (SF_MultiRange & -(Int32)multi_range); return readTuples(lock_mode, scan_flags, parallel, batch); } diff --git a/ndb/include/ndbapi/NdbScanOperation.hpp b/ndb/include/ndbapi/NdbScanOperation.hpp index 749c91ab765..c84e12bfe7b 100644 --- a/ndb/include/ndbapi/NdbScanOperation.hpp +++ b/ndb/include/ndbapi/NdbScanOperation.hpp @@ -37,13 +37,15 @@ class NdbScanOperation : public NdbOperation { public: /** * Scan flags. OR-ed together and passed as second argument to - * readTuples. + * readTuples. Note that SF_MultiRange has to be set if several + * ranges (bounds) are to be passed. */ enum ScanFlag { SF_TupScan = (1 << 16), // scan TUP SF_OrderBy = (1 << 24), // index scan in order SF_Descending = (2 << 24), // index scan in descending order SF_ReadRangeNo = (4 << 24), // enable @ref get_range_no + SF_MultiRange = (8 << 24), // scan is part of multi-range scan SF_KeyInfo = 1 // request KeyInfo to be sent back }; @@ -70,7 +72,8 @@ public: */ #ifdef ndb_readtuples_impossible_overload int readTuples(LockMode lock_mode = LM_Read, - Uint32 batch = 0, Uint32 parallel = 0, bool keyinfo = false); + Uint32 batch = 0, Uint32 parallel = 0, + bool keyinfo = false, bool multi_range = false); #endif inline int readTuples(int parallell){ @@ -262,6 +265,7 @@ protected: bool m_descending; Uint32 m_read_range_no; NdbRecAttr *m_curr_row; // Pointer to last returned row + bool m_multi_range; // Mark if operation is part of multi-range scan }; inline diff --git a/ndb/src/ndbapi/NdbScanOperation.cpp b/ndb/src/ndbapi/NdbScanOperation.cpp index 30046978542..ef5c58fb4f4 100644 --- a/ndb/src/ndbapi/NdbScanOperation.cpp +++ b/ndb/src/ndbapi/NdbScanOperation.cpp @@ -1188,7 +1188,7 @@ NdbIndexScanOperation::setBound(const NdbColumnImpl* tAttrInfo, * so it's safe to use [tIndexAttrId] * (instead of looping as is NdbOperation::equal_impl) */ - if(type == BoundEQ && tDistrKey) + if(type == BoundEQ && tDistrKey && !m_multi_range) { theNoOfTupKeyLeft--; return handle_distribution_key((Uint64*)aValue, sizeInWords); @@ -1249,7 +1249,8 @@ NdbIndexScanOperation::readTuples(LockMode lm, const bool order_by = scan_flags & SF_OrderBy; const bool order_desc = scan_flags & SF_Descending; const bool read_range_no = scan_flags & SF_ReadRangeNo; - + m_multi_range = scan_flags & SF_MultiRange; + int res = NdbScanOperation::readTuples(lm, scan_flags, parallel, batch); if(!res && read_range_no) { @@ -1716,6 +1717,12 @@ NdbIndexScanOperation::reset_bounds(bool forceSend){ int NdbIndexScanOperation::end_of_bound(Uint32 no) { + DBUG_ENTER("end_of_bound"); + DBUG_PRINT("info", ("Range number %u", no)); + /* Check that SF_MultiRange has been specified if more + than one range is specified */ + if (no > 0 && !m_multi_range) + DBUG_RETURN(-1); if(no < (1 << 13)) // Only 12-bits no of ranges { Uint32 bound_head = * m_first_bound_word; @@ -1724,9 +1731,9 @@ NdbIndexScanOperation::end_of_bound(Uint32 no) m_first_bound_word = theKEYINFOptr + theTotalNrOfKeyWordInSignal;; m_this_bound_start = theTupKeyLen; - return 0; + DBUG_RETURN(0); } - return -1; + DBUG_RETURN(-1); } int diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 8ba7f664512..13270cdb30a 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -1995,8 +1995,7 @@ int ha_ndbcluster::set_bounds(NdbIndexScanOperation *op, DBUG_PRINT("error", ("key %d unknown flag %d", j, p.key->flag)); DBUG_ASSERT(FALSE); // Stop setting bounds but continue with what we have - op->end_of_bound(range_no); - DBUG_RETURN(0); + DBUG_RETURN(op->end_of_bound(range_no)); } } } @@ -2043,8 +2042,7 @@ int ha_ndbcluster::set_bounds(NdbIndexScanOperation *op, tot_len+= part_store_len; } - op->end_of_bound(range_no); - DBUG_RETURN(0); + DBUG_RETURN(op->end_of_bound(range_no)); } /* @@ -6364,7 +6362,7 @@ ha_ndbcluster::read_multi_range_first(KEY_MULTI_RANGE **found_range_p, } else if ((scanOp= m_active_trans->getNdbIndexScanOperation(idx, tab)) &&!scanOp->readTuples(lm, 0, parallelism, sorted, - FALSE, TRUE, need_pk) + FALSE, TRUE, need_pk, TRUE) &&!generate_scan_filter(m_cond_stack, scanOp) &&!define_read_attrs(end_of_buffer-reclength, scanOp)) { |