2834 Jonas Oreland 2009-02-10 [merge]
merge 62 to 63
modified:
sql/ha_ndbcluster.cc
storage/ndb/include/ndbapi/NdbScanOperation.hpp
storage/ndb/src/ndbapi/NdbScanOperation.cpp
storage/ndb/src/ndbapi/ndberror.c
2833 Jonas Oreland 2009-02-06
dump version
modified:
configure.in
=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc 2009-01-31 09:12:30 +0000
+++ b/sql/ha_ndbcluster.cc 2009-02-10 06:53:05 +0000
@@ -2854,7 +2854,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;
@@ -10566,7 +10566,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 21:22:57 +0000
+++ b/storage/ndb/include/ndbapi/NdbScanOperation.hpp 2009-02-10 06:53:05 +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),
/*
@@ -395,12 +401,9 @@ protected:
int addInterpretedCode(Uint32 aTC_ConncetPtr,
Uint64 aTransId);
int handleScanOptions(const ScanOptions *options);
- int generatePackedReadAIs(const NdbRecord *reseult_record,
- bool needAllKeys,
- bool& haveBlob);
+ int generatePackedReadAIs(const NdbRecord *reseult_record, bool& haveBlob);
int scanImpl(const unsigned char* result_mask,
- const NdbScanOperation::ScanOptions *options,
- bool needAllKeys= false);
+ const NdbScanOperation::ScanOptions *options);
int scanTableImpl(const NdbRecord *result_record,
NdbOperation::LockMode lock_mode,
const unsigned char *result_mask,
=== modified file 'storage/ndb/src/ndbapi/NdbScanOperation.cpp'
--- a/storage/ndb/src/ndbapi/NdbScanOperation.cpp 2009-02-04 06:53:22 +0000
+++ b/storage/ndb/src/ndbapi/NdbScanOperation.cpp 2009-02-10 06:53:05 +0000
@@ -338,7 +338,6 @@ NdbScanOperation::handleScanOptions(cons
*/
int
NdbScanOperation::generatePackedReadAIs(const NdbRecord *result_record,
- bool needAllKeys,
bool& haveBlob)
{
Bitmask<MAXNROFATTRIBUTESINWORDS> readMask;
@@ -357,10 +356,7 @@ NdbScanOperation::generatePackedReadAIs(
/* Skip column if result_mask says so and we don't need
* to read it
*/
- if ((!BitmaskImpl::get(MAXNROFATTRIBUTESINWORDS,
- m_read_mask, attrId))
- &&
- !(needAllKeys && col->flags & NdbRecord::IsKey))
+ if (!BitmaskImpl::get(MAXNROFATTRIBUTESINWORDS, m_read_mask, attrId))
continue;
/* Blob reads are handled with a getValue() in NdbBlob.cpp. */
@@ -423,17 +419,14 @@ NdbScanOperation::generatePackedReadAIs(
*/
inline int
NdbScanOperation::scanImpl(const unsigned char *result_mask,
- const NdbScanOperation::ScanOptions *options,
- bool needAllKeys)
+ const NdbScanOperation::ScanOptions *options)
{
bool haveBlob= false;
m_attribute_record->copyMask(m_read_mask, result_mask);
/* Add AttrInfos for packed read of cols in result_record */
- if (generatePackedReadAIs(m_attribute_record,
- needAllKeys,
- haveBlob) != 0)
+ if (generatePackedReadAIs(m_attribute_record, haveBlob) != 0)
return -1;
theInitialReadSize= theTotalCurrAI_Len - AttrInfo::SectionSizeInfoLength;
@@ -867,7 +860,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.
@@ -875,19 +871,34 @@ NdbIndexScanOperation::scanIndexImpl(con
* So for each key column, check that it is included in the result
* NdbRecord.
*/
+ Uint32 keymask[MAXNROFATTRIBUTESINWORDS];
+ BitmaskImpl::clear(MAXNROFATTRIBUTESINWORDS, 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(MAXNROFATTRIBUTESINWORDS, keymask, attrId);
}
- }
+ if (scan_flags & NdbScanOperation::SF_OrderByFull)
+ {
+ BitmaskImpl::bitOR(MAXNROFATTRIBUTESINWORDS, m_read_mask, keymask);
+ }
+ else if (!BitmaskImpl::contains(MAXNROFATTRIBUTESINWORDS,
+ m_read_mask, keymask))
+ {
+ setErrorCodeAbort(4341);
+ return -1;
+ }
+ }
+
if (!(key_record->flags & NdbRecord::RecIsIndex))
{
setErrorCodeAbort(4283);
@@ -916,9 +927,8 @@ NdbIndexScanOperation::scanIndexImpl(con
theStatus= NdbOperation::UseNdbRecord;
/* Call generic scan code */
- res= scanImpl(result_mask,
- options,
- (scan_flags & NdbScanOperation::SF_OrderBy)); // needAllKeys
+ res= scanImpl(result_mask, options);
+
if (!res)
{
/*
@@ -961,6 +971,12 @@ NdbScanOperation::readTuples(NdbScanOper
m_savedParallelOldApi= parallel;
m_savedBatchOldApi= batch;
+ /**
+ * Old API always auto-added all key-colums
+ */
+ if (scan_flags & SF_OrderBy)
+ m_savedScanFlagsOldApi |= SF_OrderByFull;
+
return 0;
}
@@ -1015,7 +1031,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.
@@ -1809,7 +1825,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;
@@ -3058,7 +3074,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;
@@ -3555,7 +3571,7 @@ NdbIndexScanOperation::end_of_bound(Uint
* back then check that range numbers are strictly
* increasing
*/
- if ((m_savedScanFlagsOldApi & SF_OrderBy) &&
+ if ((m_savedScanFlagsOldApi & (SF_OrderBy | SF_OrderByFull)) &&
(m_savedScanFlagsOldApi & SF_ReadRangeNo))
{
Uint32 expectedNum= 0;
=== modified file 'storage/ndb/src/ndbapi/ndberror.c'
--- a/storage/ndb/src/ndbapi/ndberror.c 2009-01-13 08:50:14 +0000
+++ b/storage/ndb/src/ndbapi/ndberror.c 2009-02-10 06:53:05 +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" },
@@ -679,6 +679,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" },
| Thread |
|---|
| • bzr push into mysql-5.1-telco-6.3 branch (jonas:2833 to 2834) | Jonas Oreland | 10 Feb |