Below is the list of changes that have just been committed into a local
5.1 repository of pekka. When pekka does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
storage/ndb/src/ndbapi/NdbOperationSearch.cpp
1.26 05/06/15 19:06:39 pekka@stripped +80 -36
re-order keyinfo in equal_impl
use method to compute NdbTableImpl aggregates
storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp
1.42 05/06/15 19:06:39 pekka@stripped +11 -1
re-order keyinfo in equal_impl
use method to compute NdbTableImpl aggregates
storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp
1.86 05/06/15 19:06:39 pekka@stripped +58 -37
re-order keyinfo in equal_impl
use method to compute NdbTableImpl aggregates
storage/ndb/src/ndbapi/NdbDictionary.cpp
1.44 05/06/15 19:06:39 pekka@stripped +3 -8
re-order keyinfo in equal_impl
use method to compute NdbTableImpl aggregates
storage/ndb/include/ndbapi/NdbOperation.hpp
1.33 05/06/15 19:06:39 pekka@stripped +1 -0
re-order keyinfo in equal_impl
use method to compute NdbTableImpl aggregates
ChangeSet
1.1910 05/06/15 18:52:33 pekka@stripped +5 -0
ndb - wl#1751 re-order keyinfo in ndb api to match kernel key order
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: pekka
# Host: tuna.ndb.mysql.com
# Root: /orca/space/pekka/ndb/version/my51-vs
--- 1.32/storage/ndb/include/ndbapi/NdbOperation.hpp 2005-06-14 10:41:57 +02:00
+++ 1.33/storage/ndb/include/ndbapi/NdbOperation.hpp 2005-06-15 19:06:39 +02:00
@@ -860,6 +860,7 @@
int insertKEYINFO(const char* aValue,
Uint32 aStartPosition,
Uint32 aKeyLenInByte);
+ void reorderKEYINFO();
virtual void setErrorCode(int aErrorCode);
virtual void setErrorCodeAbort(int aErrorCode);
--- 1.43/storage/ndb/src/ndbapi/NdbDictionary.cpp 2005-06-13 15:24:52 +02:00
+++ 1.44/storage/ndb/src/ndbapi/NdbDictionary.cpp 2005-06-15 19:06:39 +02:00
@@ -178,12 +178,12 @@
void
NdbDictionary::Column::setPartitionKey(bool val){
- m_impl.m_distributionKey = val;
+ m_impl.m_distributionKey = (val ? 2 : 0);
}
bool
NdbDictionary::Column::getPartitionKey() const{
- return m_impl.m_distributionKey;
+ return (bool)m_impl.m_distributionKey;
}
const NdbDictionary::Table *
@@ -317,12 +317,7 @@
NdbColumnImpl* col = new NdbColumnImpl;
(* col) = NdbColumnImpl::getImpl(c);
m_impl.m_columns.push_back(col);
- if(c.getPrimaryKey()){
- m_impl.m_noOfKeys++;
- }
- if (col->getBlobType()) {
- m_impl.m_noOfBlobs++;
- }
+ m_impl.computeAggregates();
m_impl.buildColumnHash();
}
--- 1.85/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp 2005-06-13 15:24:52 +02:00
+++ 1.86/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp 2005-06-15 19:06:39 +02:00
@@ -248,13 +248,11 @@
if(m_nullable != col.m_nullable){
DBUG_RETURN(false);
}
-#ifdef ndb_dictionary_dkey_fixed
- if(m_pk){
- if(m_distributionKey != col.m_distributionKey){
+ if (m_pk) {
+ if ((bool)m_distributionKey != (bool)col.m_distributionKey) {
DBUG_RETURN(false);
}
}
-#endif
if (m_precision != col.m_precision ||
m_scale != col.m_scale ||
m_length != col.m_length ||
@@ -482,6 +480,58 @@
return m_newExternalName.c_str();
}
+void
+NdbTableImpl::computeAggregates()
+{
+ m_noOfKeys = 0;
+ m_keyLenInWords = 0;
+ m_noOfDistributionKeys = 0;
+ m_noOfBlobs = 0;
+ Uint32 i, n;
+ for (i = 0; i < m_columns.size(); i++) {
+ NdbColumnImpl* col = m_columns[i];
+ if (col->m_pk) {
+ m_noOfKeys++;
+ m_keyLenInWords += (col->m_attrSize * col->m_arraySize + 3) / 4;
+ }
+ if (col->m_distributionKey == 2) // set by user
+ m_noOfDistributionKeys++;
+ if (col->getBlobType())
+ m_noOfBlobs++;
+ col->m_keyInfoPos = ~0;
+ }
+ if (m_noOfDistributionKeys == m_noOfKeys) {
+ // all is none!
+ m_noOfDistributionKeys = 0;
+ }
+ if (m_noOfDistributionKeys == 0) {
+ // none is all!
+ for (i = 0, n = m_noOfKeys; n != 0; i++) {
+ NdbColumnImpl* col = m_columns[i];
+ if (col->m_pk) {
+ col->m_distributionKey = true; // set by us
+ n--;
+ }
+ }
+ }
+ Uint32 keyInfoPos = 0;
+ for (i = 0, n = m_noOfKeys; n != 0; i++) {
+ NdbColumnImpl* col = m_columns[i];
+ if (col->m_pk) {
+ if (col->m_arrayType == NDB_ARRAYTYPE_FIXED)
+ col->m_keyInfoPos = keyInfoPos++;
+ n--;
+ }
+ }
+ for (i = 0, n = m_noOfKeys; n != 0; i++) {
+ NdbColumnImpl* col = m_columns[i];
+ if (col->m_pk) {
+ if (col->m_arrayType != NDB_ARRAYTYPE_FIXED)
+ col->m_keyInfoPos = keyInfoPos++;
+ n--;
+ }
+ }
+}
void
NdbTableImpl::buildColumnHash(){
@@ -1386,11 +1436,6 @@
impl->m_primaryTable.assign(externalPrimary);
}
- Uint32 keyInfoPos = 0;
- Uint32 keyCount = 0;
- Uint32 blobCount = 0;
- Uint32 distKeys = 0;
-
Uint32 i;
for(i = 0; i < tableDesc.NoOfAttributes; i++) {
DictTabInfo::Attribute attrDesc; attrDesc.init();
@@ -1442,33 +1487,18 @@
col->m_storageType = attrDesc.AttributeStorageType;
col->m_pk = attrDesc.AttributeKeyFlag;
- col->m_distributionKey = attrDesc.AttributeDKey;
+ col->m_distributionKey = (bool)attrDesc.AttributeDKey;
col->m_nullable = attrDesc.AttributeNullableFlag;
col->m_autoIncrement = (attrDesc.AttributeAutoIncrement ? true : false);
col->m_autoIncrementInitialValue = ~0;
col->m_defaultValue.assign(attrDesc.AttributeDefaultValue);
- if(attrDesc.AttributeKeyFlag){
- col->m_keyInfoPos = keyInfoPos + 1;
- keyInfoPos += ((col->m_attrSize * col->m_arraySize + 3) / 4);
- keyCount++;
-
- if(attrDesc.AttributeDKey)
- distKeys++;
- } else {
- col->m_keyInfoPos = 0;
- }
- if (col->getBlobType())
- blobCount++;
- col->m_column_no= impl->m_columns.size();
+ col->m_column_no = impl->m_columns.size();
impl->m_columns.push_back(col);
it.next();
}
- impl->m_noOfKeys = keyCount;
- impl->m_keyLenInWords = keyInfoPos;
- impl->m_noOfBlobs = blobCount;
- impl->m_noOfDistributionKeys = distKeys;
+ impl->computeAggregates();
if(tableDesc.FragmentDataLen > 0)
{
@@ -1498,15 +1528,6 @@
impl->m_hashpointerValue = 0;
}
- if(distKeys == 0)
- {
- for(i = 0; i < tableDesc.NoOfAttributes; i++)
- {
- if(impl->m_columns[i]->getPrimaryKey())
- impl->m_columns[i]->m_distributionKey = true;
- }
- }
-
impl->m_tablespace_id = tableDesc.TablespaceId;
impl->m_tablespace_version = tableDesc.TablespaceVersion;
@@ -1766,7 +1787,7 @@
tmpAttr.AttributeId = i;
tmpAttr.AttributeKeyFlag = col->m_pk;
tmpAttr.AttributeNullableFlag = col->m_nullable;
- tmpAttr.AttributeDKey = distKeys ? col->m_distributionKey : 0;
+ tmpAttr.AttributeDKey = distKeys ? (bool)col->m_distributionKey : 0;
tmpAttr.AttributeExtType = (Uint32)col->m_type;
tmpAttr.AttributeExtPrecision = ((unsigned)col->m_precision & 0xFFFF);
--- 1.41/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp 2005-06-14 18:22:00 +02:00
+++ 1.42/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp 2005-06-15 19:06:39 +02:00
@@ -67,7 +67,11 @@
CHARSET_INFO * m_cs; // not const in MySQL
bool m_pk;
- bool m_distributionKey;
+ /*
+ * Since "none" is "all" we distinguish between
+ * 1-set by us, 2-set by user
+ */
+ Uint32 m_distributionKey;
bool m_nullable;
bool m_autoIncrement;
Uint64 m_autoIncrementInitialValue;
@@ -81,6 +85,10 @@
Uint32 m_arraySize; // length or maxlength+1/2 for Var* types
Uint32 m_arrayType; // NDB_ARRAYTYPE_FIXED or _VAR
Uint32 m_storageType; // NDB_STORAGETYPE_MEMORY or _DISK
+ /*
+ * NdbTableImpl: if m_pk, 0-based index of key in m_attrId order
+ * NdbIndexImpl: m_column_no of primary table column
+ */
Uint32 m_keyInfoPos;
// TODO: use bits in attr desc 2
bool getInterpretableType() const ;
@@ -126,6 +134,7 @@
Uint32 m_columnHashMask;
Vector<Uint32> m_columnHash;
Vector<NdbColumnImpl *> m_columns;
+ void computeAggregates();
void buildColumnHash();
/**
@@ -159,6 +168,7 @@
* Aggregates
*/
Uint8 m_noOfKeys;
+ // if all pk = dk then this is zero!
Uint8 m_noOfDistributionKeys;
Uint8 m_noOfBlobs;
--- 1.25/storage/ndb/src/ndbapi/NdbOperationSearch.cpp 2005-06-14 18:22:01 +02:00
+++ 1.26/storage/ndb/src/ndbapi/NdbOperationSearch.cpp 2005-06-15 19:06:39 +02:00
@@ -61,10 +61,7 @@
tAttrInfo->m_name.c_str(), theOperationType,
aValuePassed));
- register Uint32 tAttrId;
-
Uint32 tData;
- Uint32 tKeyInfoPosition;
const char* aValue = aValuePassed;
Uint64 tempData[512];
@@ -79,10 +76,21 @@
* Finally check if all tuple key attributes have been defined. If
* this is true then set Operation state to tuple key defined.
*****************************************************************************/
- tAttrId = tAttrInfo->m_attrId;
- tKeyInfoPosition = tAttrInfo->m_keyInfoPos;
- bool tDistrKey = tAttrInfo->m_distributionKey;
+ /*
+ * For each call theTupleKeyDefined stores 3 items:
+ *
+ * [0] = m_column_no (external column id)
+ * [1] = 1-based index of first word of accumulating keyinfo
+ * [2] = number of words of keyinfo
+ *
+ * This is used to re-order keyinfo if not in m_attrId order.
+ *
+ * Note: No point to "clean up" this code. The upcoming
+ * record-based ndb api makes it obsolete.
+ */
+
+ Uint32 tAttrId = tAttrInfo->m_column_no; // not m_attrId;
Uint32 i = 0;
if (tAttrInfo->m_pk) {
Uint32 tKeyDefined = theTupleKeyDefined[0][2];
@@ -120,17 +128,18 @@
* We have to retrieve the size of the attribute in words and bits.
*************************************************************************/
keyEntryFound:
- theTupleKeyDefined[i][0] = tAttrId;
- theTupleKeyDefined[i][1] = tKeyInfoPosition;
- theTupleKeyDefined[i][2] = true;
-
- OperationType tOpType = theOperationType;
Uint32 sizeInBytes;
if (! tAttrInfo->get_var_length(aValue, sizeInBytes)) {
setErrorCodeAbort(4209);
DBUG_RETURN(-1);
}
+ Uint32 tKeyInfoPosition =
+ i == 0 ? 1 : theTupleKeyDefined[i-1][1] + theTupleKeyDefined[i-1][2];
+ theTupleKeyDefined[i][0] = tAttrId;
+ theTupleKeyDefined[i][1] = tKeyInfoPosition;
+ theTupleKeyDefined[i][2] = (sizeInBytes + 3) / 4;
+
{
/************************************************************************
* Check if the pointer of the value passed is aligned on a 4 byte
@@ -138,6 +147,7 @@
* aValue. If it is not aligned then we start by copying the value to
* tempData and use this as aValue instead.
***********************************************************************/
+ const bool tDistrKey = tAttrInfo->m_distributionKey;
const int attributeSize = sizeInBytes;
const int slack = sizeInBytes & 3;
const int align = UintPtr(aValue) & 7;
@@ -151,17 +161,7 @@
}
Uint32 totalSizeInWords = (sizeInBytes + 3)/4; // Inc. bits in last word
-
- if (true){ //tArraySize != 0) {
- Uint32 tTupKeyLen = theTupKeyLen;
-
- theTupKeyLen = tTupKeyLen + totalSizeInWords;
- if (true) {
- ;
- } else {
- goto equal_error3;
- }
- }
+ theTupKeyLen += totalSizeInWords;
#if 0
else {
/************************************************************************
@@ -190,26 +190,25 @@
* we also set the value in the stored part through putting the
* information in the ATTRINFO signals.
*************************************************************************/
+ OperationType tOpType = theOperationType;
if ((tOpType == InsertRequest) ||
(tOpType == WriteRequest)) {
Uint32 ahValue;
- const Uint32 sz = totalSizeInWords;
- // XXX
- if(m_accessTable == m_currentTable)
- {
- AttributeHeader::init(&ahValue, tAttrId, sz << 2);
- }
- else
- {
- assert(m_accessTable->m_index);
- int attr_id_current_table =
+ if(m_accessTable == m_currentTable) {
+ AttributeHeader::init(&ahValue, tAttrInfo->m_attrId, sizeInBytes);
+ } else {
+ assert(tOpType == WriteRequest && m_accessTable->m_index);
+ // use attrId of primary table column
+ int column_no_current_table =
m_accessTable->m_index->m_columns[tAttrId]->m_keyInfoPos;
- AttributeHeader::init(&ahValue, attr_id_current_table, sz << 2);
+ int attr_id_current_table =
+ m_currentTable->m_columns[column_no_current_table]->m_attrId;
+ AttributeHeader::init(&ahValue, attr_id_current_table, sizeInBytes);
}
insertATTRINFO( ahValue );
- insertATTRINFOloop((Uint32*)aValue, sz);
+ insertATTRINFOloop((Uint32*)aValue, totalSizeInWords);
}//if
/**************************************************************************
@@ -230,6 +229,19 @@
theErrorLine = tErrorLine;
if (tNoKeysDef == 0) {
+
+ // re-order keyinfo if not entered in order
+ if (m_accessTable->m_noOfKeys != 1) {
+ for (Uint32 i = 0; i < m_accessTable->m_noOfKeys; i++) {
+ Uint32 k = theTupleKeyDefined[i][0]; // column_no
+ if (m_accessTable->m_columns[k]->m_keyInfoPos != i) {
+ DBUG_PRINT("info", ("key disorder at %d", i));
+ reorderKEYINFO();
+ break;
+ }
+ }
+ }
+
if (tOpType == UpdateRequest) {
if (tInterpretInd == 1) {
theStatus = GetValue;
@@ -456,11 +468,43 @@
return 0;
}
+void
+NdbOperation::reorderKEYINFO()
+{
+ Uint32 data[4000];
+ getKeyFromTCREQ(data, 4000);
+ Uint32 pos = 1;
+ Uint32 k;
+ for (k = 0; k < m_accessTable->m_noOfKeys; k++) {
+ Uint32 i;
+ for (i = 0; i < m_accessTable->m_columns.size(); i++) {
+ NdbColumnImpl* col = m_accessTable->m_columns[i];
+ if (col->m_pk && col->m_keyInfoPos == k) {
+ Uint32 j;
+ for (j = 0; j < m_accessTable->m_noOfKeys; j++) {
+ if (theTupleKeyDefined[j][0] == i) {
+ Uint32 off = theTupleKeyDefined[j][1] - 1;
+ Uint32 len = theTupleKeyDefined[j][2];
+ assert(off < 4000 && off + len <= 4000);
+ int ret = insertKEYINFO((char*)&data[off], pos, len);
+ assert(ret == 0);
+ pos += len;
+ break;
+ }
+ }
+ assert(j < m_accessTable->m_columns.size());
+ break;
+ }
+ }
+ assert(i < m_accessTable->m_columns.size());
+ }
+}
+
int
NdbOperation::getKeyFromTCREQ(Uint32* data, unsigned size)
{
- assert(m_accessTable != 0 && m_accessTable->m_keyLenInWords != 0);
- assert(m_accessTable->m_keyLenInWords == size);
+ assert(size >= theTupKeyLen && theTupKeyLen > 0);
+ size = theTupKeyLen;
unsigned pos = 0;
while (pos < 8 && pos < size) {
data[pos] = theKEYINFOptr[pos];
| Thread |
|---|
| • bk commit into 5.1 tree (pekka:1.1910) | pekka | 15 Jun |