summaryrefslogtreecommitdiff
path: root/ndb
diff options
context:
space:
mode:
authorunknown <mskold@mysql.com>2004-08-13 13:51:18 +0200
committerunknown <mskold@mysql.com>2004-08-13 13:51:18 +0200
commit55cc6be43c85b40b0a9c510c9a6630c8df7d3137 (patch)
tree377d74e888b2ddaaeae15b47803bc328f3fe4ae3 /ndb
parentfedc787e53660491d59b94df7cc7f6dd92c8f28f (diff)
downloadmariadb-git-55cc6be43c85b40b0a9c510c9a6630c8df7d3137.tar.gz
Added support for NULL in unique index
Diffstat (limited to 'ndb')
-rw-r--r--ndb/src/kernel/blocks/dbdict/Dbdict.cpp10
-rw-r--r--ndb/src/kernel/blocks/dbtc/Dbtc.hpp1
-rw-r--r--ndb/src/kernel/blocks/dbtc/DbtcMain.cpp65
-rw-r--r--ndb/src/kernel/blocks/trix/Trix.cpp4
-rw-r--r--ndb/src/ndbapi/NdbDictionaryImpl.cpp7
5 files changed, 36 insertions, 51 deletions
diff --git a/ndb/src/kernel/blocks/dbdict/Dbdict.cpp b/ndb/src/kernel/blocks/dbdict/Dbdict.cpp
index 143a96e49d3..d7c4b8a2222 100644
--- a/ndb/src/kernel/blocks/dbdict/Dbdict.cpp
+++ b/ndb/src/kernel/blocks/dbdict/Dbdict.cpp
@@ -6255,16 +6255,6 @@ Dbdict::createIndex_toCreateTable(Signal* signal, OpCreateIndexPtr opPtr)
jam();
found = true;
const Uint32 a = aRec->attributeDescriptor;
- bool isNullable = AttributeDescriptor::getNullable(a);
- // We do not allow more than one NULLable attribute for hash index
- if (isNullable &&
- indexPtr.p->isHashIndex() &&
- (opPtr.p->m_attrList.sz > 1)) {
- jam();
- opPtr.p->m_errorCode = CreateIndxRef::AttributeNullable;
- opPtr.p->m_errorLine = __LINE__;
- return;
- }
if (indexPtr.p->isHashIndex()) {
const Uint32 s1 = AttributeDescriptor::getSize(a);
const Uint32 s2 = AttributeDescriptor::getArraySize(a);
diff --git a/ndb/src/kernel/blocks/dbtc/Dbtc.hpp b/ndb/src/kernel/blocks/dbtc/Dbtc.hpp
index 095ba9b0bbe..6e32216557c 100644
--- a/ndb/src/kernel/blocks/dbtc/Dbtc.hpp
+++ b/ndb/src/kernel/blocks/dbtc/Dbtc.hpp
@@ -139,6 +139,7 @@
#define ZNOT_FOUND 626
#define ZALREADYEXIST 630
#define ZINCONSISTENTHASHINDEX 892
+#define ZNOTUNIQUE 893
#endif
class Dbtc: public SimulatedBlock {
diff --git a/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp b/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp
index 3246fcc5e6f..3b708dbbb58 100644
--- a/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp
+++ b/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp
@@ -4925,7 +4925,9 @@ void Dbtc::execLQHKEYREF(Signal* signal)
// The operation executed an index trigger
const Uint32 opType = regTcPtr->operation;
- if (!(opType == ZDELETE && errCode == ZNOT_FOUND)) {
+ if (errCode == ZALREADYEXIST)
+ errCode = terrorCode = ZNOTUNIQUE;
+ else if (!(opType == ZDELETE && errCode == ZNOT_FOUND)) {
jam();
/**
* "Normal path"
@@ -12168,34 +12170,33 @@ void Dbtc::insertIntoIndexTable(Signal* signal,
// Calculate key length and renumber attribute id:s
AttributeBuffer::DataBufferPool & pool = c_theAttributeBufferPool;
LocalDataBuffer<11> afterValues(pool, firedTriggerData->afterValues);
+ bool skipNull = false;
for(bool moreKeyAttrs = afterValues.first(iter); moreKeyAttrs; attrId++) {
jam();
AttributeHeader* attrHeader = (AttributeHeader *) iter.data;
+ // Filter out NULL valued attributes
+ if (attrHeader->isNULL()) {
+ skipNull = true;
+ break;
+ }
attrHeader->setAttributeId(attrId);
keyLength += attrHeader->getDataSize();
hops = attrHeader->getHeaderSize() + attrHeader->getDataSize();
moreKeyAttrs = afterValues.next(iter, hops);
}
-
- // Filter out single NULL attributes
- if (attrId == 1) {
+ if (skipNull) {
jam();
- afterValues.first(iter);
- AttributeHeader* attrHeader = (AttributeHeader *) iter.data;
- if (attrHeader->isNULL() && !afterValues.next(iter)) {
- jam();
- opRecord->triggerExecutionCount--;
- if (opRecord->triggerExecutionCount == 0) {
- /*
- We have completed current trigger execution
- Continue triggering operation
- */
- jam();
- continueTriggeringOp(signal, opRecord);
- }//if
- return;
+ opRecord->triggerExecutionCount--;
+ if (opRecord->triggerExecutionCount == 0) {
+ /*
+ We have completed current trigger execution
+ Continue triggering operation
+ */
+ jam();
+ continueTriggeringOp(signal, opRecord);
}//if
+ return;
}//if
// Calculate total length of primary key to be stored in index table
@@ -12523,36 +12524,36 @@ void Dbtc::deleteFromIndexTable(Signal* signal,
// Calculate key length and renumber attribute id:s
AttributeBuffer::DataBufferPool & pool = c_theAttributeBufferPool;
LocalDataBuffer<11> beforeValues(pool, firedTriggerData->beforeValues);
+ bool skipNull = false;
for(bool moreKeyAttrs = beforeValues.first(iter);
(moreKeyAttrs);
attrId++) {
jam();
AttributeHeader* attrHeader = (AttributeHeader *) iter.data;
+ // Filter out NULL valued attributes
+ if (attrHeader->isNULL()) {
+ skipNull = true;
+ break;
+ }
attrHeader->setAttributeId(attrId);
keyLength += attrHeader->getDataSize();
hops = attrHeader->getHeaderSize() + attrHeader->getDataSize();
moreKeyAttrs = beforeValues.next(iter, hops);
}
- // Filter out single NULL attributes
- if (attrId == 1) {
+ if (skipNull) {
jam();
- beforeValues.first(iter);
- AttributeHeader* attrHeader = (AttributeHeader *) iter.data;
- if (attrHeader->isNULL() && !beforeValues.next(iter)) {
- jam();
- opRecord->triggerExecutionCount--;
- if (opRecord->triggerExecutionCount == 0) {
- /*
+ opRecord->triggerExecutionCount--;
+ if (opRecord->triggerExecutionCount == 0) {
+ /*
We have completed current trigger execution
Continue triggering operation
- */
- jam();
- continueTriggeringOp(signal, opRecord);
- }//if
- return;
+ */
+ jam();
+ continueTriggeringOp(signal, opRecord);
}//if
+ return;
}//if
TcKeyReq::setKeyLength(tcKeyRequestInfo, keyLength);
diff --git a/ndb/src/kernel/blocks/trix/Trix.cpp b/ndb/src/kernel/blocks/trix/Trix.cpp
index 6cbc7a9b371..4088d55c76d 100644
--- a/ndb/src/kernel/blocks/trix/Trix.cpp
+++ b/ndb/src/kernel/blocks/trix/Trix.cpp
@@ -814,8 +814,8 @@ void Trix::executeInsertTransaction(Signal* signal,
for(Uint32 i = 0; i < headerPtr.sz; i++) {
AttributeHeader* keyAttrHead = (AttributeHeader *) headerBuffer + i;
- // Filter out single NULL attributes
- if (keyAttrHead->isNULL() && (i == (Uint32)0) && (headerPtr.sz == (Uint32)2))
+ // Filter out NULL attributes
+ if (keyAttrHead->isNULL())
return;
if (i < subRec->noOfIndexColumns)
diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/ndb/src/ndbapi/NdbDictionaryImpl.cpp
index 6e95f5c5622..c4ea9909fcd 100644
--- a/ndb/src/ndbapi/NdbDictionaryImpl.cpp
+++ b/ndb/src/ndbapi/NdbDictionaryImpl.cpp
@@ -1851,13 +1851,6 @@ NdbDictInterface::createIndex(Ndb & ndb,
m_error.code = 4245;
return -1;
}
-
- if (it == DictTabInfo::UniqueHashIndex &&
- (col->m_nullable) && (attributeList.sz > 1)) {
- // We only support one NULL attribute
- m_error.code = 4246;
- return -1;
- }
attributeList.id[i] = col->m_attrId;
}
if (it == DictTabInfo::UniqueHashIndex) {