From: Date: February 10 2009 5:23pm Subject: bzr commit into mysql-5.1-telco-6.2 branch (Martin.Skold:2814) Bug#32662 Bug#42591 List-Archive: http://lists.mysql.com/commits/65774 X-Bug: 32662,42591 Message-Id: <200902101623.n1AGNMCY013528@quadfish.liljeholmen.mysql.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit #At file:///home/marty/MySQL/mysql-5.1-telco-6.2/ 2814 Martin Skold 2009-02-10 [merge] Merge modified: sql/ha_ndbcluster.cc storage/ndb/include/ndbapi/NdbScanOperation.hpp storage/ndb/src/ndbapi/NdbScanOperation.cpp storage/ndb/src/ndbapi/ndberror.c === modified file 'sql/ha_ndbcluster.cc' --- a/sql/ha_ndbcluster.cc 2009-02-10 12:47:54 +0000 +++ b/sql/ha_ndbcluster.cc 2009-02-10 16:23:13 +0000 @@ -2594,7 +2594,7 @@ int ha_ndbcluster::ordered_index_scan(co if (lm == NdbOperation::LM_Read) options.scan_flags|= NdbScanOperation::SF_KeyInfo; if (sorted) - options.scan_flags|= NdbScanOperation::SF_OrderBy; + options.scan_flags|= NdbScanOperation::SF_OrderByFull; if (descending) options.scan_flags|= NdbScanOperation::SF_Descending; const NdbRecord *key_rec= m_index[active_index].ndb_record_key; @@ -9319,7 +9319,7 @@ ha_ndbcluster::read_multi_range_first(KE if (lm == NdbOperation::LM_Read) options.scan_flags|= NdbScanOperation::SF_KeyInfo; if (sorted) - options.scan_flags|= NdbScanOperation::SF_OrderBy; + options.scan_flags|= NdbScanOperation::SF_OrderByFull; options.parallel=parallelism; === modified file 'storage/ndb/include/ndbapi/NdbScanOperation.hpp' --- a/storage/ndb/include/ndbapi/NdbScanOperation.hpp 2008-11-08 20:40:15 +0000 +++ b/storage/ndb/include/ndbapi/NdbScanOperation.hpp 2009-02-09 13:28:30 +0000 @@ -54,6 +54,12 @@ public: each fragment, to get a single sorted result set. */ SF_OrderBy = (1 << 24), + /** + * Same as order by, except that it will automatically + * add all key columns into the read-mask + */ + SF_OrderByFull = (16 << 24), + /* Index scan in descending order, instead of default ascending. */ SF_Descending = (2 << 24), /* === modified file 'storage/ndb/src/ndbapi/NdbScanOperation.cpp' --- a/storage/ndb/src/ndbapi/NdbScanOperation.cpp 2009-02-04 06:52:21 +0000 +++ b/storage/ndb/src/ndbapi/NdbScanOperation.cpp 2009-02-10 08:05:16 +0000 @@ -788,7 +788,10 @@ NdbIndexScanOperation::scanIndexImpl(con return -1; } - if (scan_flags & NdbScanOperation::SF_OrderBy) + result_record->copyMask(m_read_mask, result_mask); + + if (scan_flags & (NdbScanOperation::SF_OrderBy | + NdbScanOperation::SF_OrderByFull)) { /** * For ordering, we need all keys in the result row. @@ -796,19 +799,34 @@ NdbIndexScanOperation::scanIndexImpl(con * So for each key column, check that it is included in the result * NdbRecord. */ +#define MASKSZ ((NDB_MAX_ATTRIBUTES_IN_TABLE+31)>>5) + Uint32 keymask[MASKSZ]; + BitmaskImpl::clear(MASKSZ, keymask); + for (i = 0; i < key_record->key_index_length; i++) { - const NdbRecord::Attr *key_col = - &key_record->columns[key_record->key_indexes[i]]; - if (key_col->attrId >= result_record->m_attrId_indexes_length || - result_record->m_attrId_indexes[key_col->attrId] < 0) + Uint32 attrId = key_record->columns[key_record->key_indexes[i]].attrId; + if (attrId >= result_record->m_attrId_indexes_length || + result_record->m_attrId_indexes[attrId] < 0) { setErrorCodeAbort(4292); return -1; } + + BitmaskImpl::set(MASKSZ, keymask, attrId); } - } + if (scan_flags & NdbScanOperation::SF_OrderByFull) + { + BitmaskImpl::bitOR(MASKSZ, m_read_mask, keymask); + } + else if (!BitmaskImpl::contains(MASKSZ, m_read_mask, keymask)) + { + setErrorCodeAbort(4341); + return -1; + } + } + if (!(key_record->flags & NdbRecord::RecIsIndex)) { setErrorCodeAbort(4283); @@ -833,8 +851,6 @@ NdbIndexScanOperation::scanIndexImpl(con if (res==-1) return -1; - result_record->copyMask(m_read_mask, result_mask); - /* Fix theStatus as set in processIndexScanDefs(). */ theStatus= NdbOperation::UseNdbRecord; @@ -853,11 +869,8 @@ NdbIndexScanOperation::scanIndexImpl(con But cannot mask pseudo columns, nor key columns in ordered scans. */ attrId= col->attrId; - if ( result_mask && - !(attrId & AttributeHeader::PSEUDO) && - !( (scan_flags & NdbScanOperation::SF_OrderBy) && - (col->flags & NdbRecord::IsKey) ) && - !(result_mask[attrId>>3] & (1<<(attrId & 7))) ) + if ( !(attrId & AttributeHeader::PSEUDO) && + !BitmaskImpl::get(MASKSZ, m_read_mask, attrId)) { continue; } @@ -1022,7 +1035,7 @@ NdbScanOperation::processTableScanDefs(N tupScan = false; } - if (rangeScan && (scan_flags & SF_OrderBy)) + if (rangeScan && (scan_flags & (SF_OrderBy | SF_OrderByFull))) parallel = fragCount; // Note we assume fragcount of base table== // fragcount of index. @@ -1826,7 +1839,7 @@ int NdbScanOperation::finaliseScanOldApi * don't */ const unsigned char * resultMask= - ((m_savedScanFlagsOldApi & SF_OrderBy) !=0) ? + ((m_savedScanFlagsOldApi & (SF_OrderBy | SF_OrderByFull)) !=0) ? m_accessTable->m_pkMask : emptyMask; @@ -3017,7 +3030,7 @@ NdbIndexScanOperation::processIndexScanD Uint32 parallel, Uint32 batch) { - const bool order_by = scan_flags & SF_OrderBy; + const bool order_by = scan_flags & (SF_OrderBy | SF_OrderByFull); const bool order_desc = scan_flags & SF_Descending; const bool read_range_no = scan_flags & SF_ReadRangeNo; m_multi_range = scan_flags & SF_MultiRange; === modified file 'storage/ndb/src/ndbapi/ndberror.c' --- a/storage/ndb/src/ndbapi/ndberror.c 2009-01-13 08:39:34 +0000 +++ b/storage/ndb/src/ndbapi/ndberror.c 2009-02-09 13:28:30 +0000 @@ -365,7 +365,7 @@ ErrorBundle ErrorCodes[] = { { 708, DMEC, SE, "No more attribute metadata records (increase MaxNoOfAttributes)" }, { 709, HA_ERR_NO_SUCH_TABLE, SE, "No such table existed" }, { 710, DMEC, SE, "Internal: Get by table name not supported, use table id." }, - { 721, HA_ERR_TABLE_EXIST, OE, "Table or index with given name already exists" }, + { 721, HA_ERR_TABLE_EXIST, OE, "Schema object with given name already exists" }, { 723, HA_ERR_NO_SUCH_TABLE, SE, "No such table existed" }, { 736, DMEC, SE, "Unsupported array size" }, { 737, HA_WRONG_CREATE_OPTION, SE, "Attribute array size too big" }, @@ -678,6 +678,7 @@ ErrorBundle ErrorCodes[] = { { 4290, DMEC, AE, "Missing column specification in NdbDictionary::RecordSpecification" }, { 4291, DMEC, AE, "Duplicate column specification in NdbDictionary::RecordSpecification" }, { 4292, DMEC, AE, "NdbRecord for tuple access is not an index key NdbRecord" }, + { 4341, DMEC, AE, "Not all keys read when using option SF_OrderBy" }, { 4293, DMEC, AE, "Error returned from application scanIndex() callback" }, { 4294, DMEC, AE, "Scan filter is too large, discarded" }, { 4295, DMEC, AE, "Column is NULL in Get/SetValueSpec structure" },