ndb - bug#34118 - hash index trigger vs. disk

parent 86ccc887
...@@ -501,6 +501,18 @@ f1 f2 ...@@ -501,6 +501,18 @@ f1 f2
111111 aaaaaa 111111 aaaaaa
222222 bbbbbb 222222 bbbbbb
drop table test.t1; drop table test.t1;
CREATE TABLE t1 (
id int unsigned NOT NULL,
c1 int unsigned NOT NULL,
c2 int DEFAULT NULL,
PRIMARY KEY using hash (id),
UNIQUE KEY c1 using hash (c1))
TABLESPACE ts1 STORAGE DISK ENGINE=ndbcluster;
insert into t1 values(1, 1, 3);
insert into t1 values(2, 2, 3);
update t1 set c1 = 1 where id = 2;
ERROR 23000: Duplicate entry '1' for key 'c1'
drop table t1;
ALTER TABLESPACE ts1 ALTER TABLESPACE ts1
DROP DATAFILE 'datafile.dat' DROP DATAFILE 'datafile.dat'
ENGINE = NDB; ENGINE = NDB;
......
...@@ -439,6 +439,21 @@ select f2 from test.t1 order by f2; ...@@ -439,6 +439,21 @@ select f2 from test.t1 order by f2;
select f1,f2 from test.t1 order by f1; select f1,f2 from test.t1 order by f1;
drop table test.t1; drop table test.t1;
# bug#34118 hash index trigger and do not update any disk attr
CREATE TABLE t1 (
id int unsigned NOT NULL,
c1 int unsigned NOT NULL,
c2 int DEFAULT NULL,
PRIMARY KEY using hash (id),
UNIQUE KEY c1 using hash (c1))
TABLESPACE ts1 STORAGE DISK ENGINE=ndbcluster;
insert into t1 values(1, 1, 3);
insert into t1 values(2, 2, 3);
--error ER_DUP_ENTRY
update t1 set c1 = 1 where id = 2;
drop table t1;
################### ###################
# Test Cleanup # Test Cleanup
################### ###################
......
...@@ -2202,17 +2202,20 @@ private: ...@@ -2202,17 +2202,20 @@ private:
void void
checkImmediateTriggersAfterInsert(KeyReqStruct *req_struct, checkImmediateTriggersAfterInsert(KeyReqStruct *req_struct,
Operationrec* regOperPtr, Operationrec* regOperPtr,
Tablerec* tablePtr); Tablerec* tablePtr,
bool disk);
void void
checkImmediateTriggersAfterUpdate(KeyReqStruct *req_struct, checkImmediateTriggersAfterUpdate(KeyReqStruct *req_struct,
Operationrec* regOperPtr, Operationrec* regOperPtr,
Tablerec* tablePtr); Tablerec* tablePtr,
bool disk);
void void
checkImmediateTriggersAfterDelete(KeyReqStruct *req_struct, checkImmediateTriggersAfterDelete(KeyReqStruct *req_struct,
Operationrec* regOperPtr, Operationrec* regOperPtr,
Tablerec* tablePtr); Tablerec* tablePtr,
bool disk);
#if 0 #if 0
void checkDeferredTriggers(Signal* signal, void checkDeferredTriggers(Signal* signal,
...@@ -2226,7 +2229,8 @@ private: ...@@ -2226,7 +2229,8 @@ private:
void fireImmediateTriggers(KeyReqStruct *req_struct, void fireImmediateTriggers(KeyReqStruct *req_struct,
DLList<TupTriggerData>& triggerList, DLList<TupTriggerData>& triggerList,
Operationrec* regOperPtr); Operationrec* regOperPtr,
bool disk);
void fireDeferredTriggers(KeyReqStruct *req_struct, void fireDeferredTriggers(KeyReqStruct *req_struct,
DLList<TupTriggerData>& triggerList, DLList<TupTriggerData>& triggerList,
...@@ -2239,12 +2243,13 @@ private: ...@@ -2239,12 +2243,13 @@ private:
void executeTriggers(KeyReqStruct *req_struct, void executeTriggers(KeyReqStruct *req_struct,
DLList<TupTriggerData>& triggerList, DLList<TupTriggerData>& triggerList,
Operationrec* regOperPtr); Operationrec* regOperPtr,
bool disk);
void executeTrigger(KeyReqStruct *req_struct, void executeTrigger(KeyReqStruct *req_struct,
TupTriggerData* trigPtr, TupTriggerData* trigPtr,
Operationrec* regOperPtr, Operationrec* regOperPtr,
bool disk = true); bool disk);
bool readTriggerInfo(TupTriggerData* trigPtr, bool readTriggerInfo(TupTriggerData* trigPtr,
Operationrec* regOperPtr, Operationrec* regOperPtr,
......
...@@ -749,7 +749,8 @@ void Dbtup::execTUPKEYREQ(Signal* signal) ...@@ -749,7 +749,8 @@ void Dbtup::execTUPKEYREQ(Signal* signal)
} }
checkImmediateTriggersAfterInsert(&req_struct, checkImmediateTriggersAfterInsert(&req_struct,
regOperPtr, regOperPtr,
regTabPtr); regTabPtr,
disk_page != RNIL);
set_change_mask_state(regOperPtr, SET_ALL_MASK); set_change_mask_state(regOperPtr, SET_ALL_MASK);
sendTUPKEYCONF(signal, &req_struct, regOperPtr); sendTUPKEYCONF(signal, &req_struct, regOperPtr);
return; return;
...@@ -782,7 +783,8 @@ void Dbtup::execTUPKEYREQ(Signal* signal) ...@@ -782,7 +783,8 @@ void Dbtup::execTUPKEYREQ(Signal* signal)
} }
checkImmediateTriggersAfterUpdate(&req_struct, checkImmediateTriggersAfterUpdate(&req_struct,
regOperPtr, regOperPtr,
regTabPtr); regTabPtr,
disk_page != RNIL);
// XXX use terrorCode for now since all methods are void // XXX use terrorCode for now since all methods are void
if (terrorCode != 0) if (terrorCode != 0)
{ {
...@@ -813,7 +815,8 @@ void Dbtup::execTUPKEYREQ(Signal* signal) ...@@ -813,7 +815,8 @@ void Dbtup::execTUPKEYREQ(Signal* signal)
*/ */
checkImmediateTriggersAfterDelete(&req_struct, checkImmediateTriggersAfterDelete(&req_struct,
regOperPtr, regOperPtr,
regTabPtr); regTabPtr,
disk_page != RNIL);
set_change_mask_state(regOperPtr, DELETE_CHANGES); set_change_mask_state(regOperPtr, DELETE_CHANGES);
sendTUPKEYCONF(signal, &req_struct, regOperPtr); sendTUPKEYCONF(signal, &req_struct, regOperPtr);
return; return;
......
...@@ -369,7 +369,8 @@ Dbtup::dropTrigger(Tablerec* table, const DropTrigReq* req, BlockNumber sender) ...@@ -369,7 +369,8 @@ Dbtup::dropTrigger(Tablerec* table, const DropTrigReq* req, BlockNumber sender)
void void
Dbtup::checkImmediateTriggersAfterInsert(KeyReqStruct *req_struct, Dbtup::checkImmediateTriggersAfterInsert(KeyReqStruct *req_struct,
Operationrec *regOperPtr, Operationrec *regOperPtr,
Tablerec *regTablePtr) Tablerec *regTablePtr,
bool disk)
{ {
if(refToBlock(req_struct->TC_ref) != DBTC) { if(refToBlock(req_struct->TC_ref) != DBTC) {
return; return;
...@@ -380,14 +381,16 @@ Dbtup::checkImmediateTriggersAfterInsert(KeyReqStruct *req_struct, ...@@ -380,14 +381,16 @@ Dbtup::checkImmediateTriggersAfterInsert(KeyReqStruct *req_struct,
jam(); jam();
fireImmediateTriggers(req_struct, fireImmediateTriggers(req_struct,
regTablePtr->afterInsertTriggers, regTablePtr->afterInsertTriggers,
regOperPtr); regOperPtr,
disk);
} }
} }
void void
Dbtup::checkImmediateTriggersAfterUpdate(KeyReqStruct *req_struct, Dbtup::checkImmediateTriggersAfterUpdate(KeyReqStruct *req_struct,
Operationrec* regOperPtr, Operationrec* regOperPtr,
Tablerec* regTablePtr) Tablerec* regTablePtr,
bool disk)
{ {
if(refToBlock(req_struct->TC_ref) != DBTC) { if(refToBlock(req_struct->TC_ref) != DBTC) {
return; return;
...@@ -398,21 +401,24 @@ Dbtup::checkImmediateTriggersAfterUpdate(KeyReqStruct *req_struct, ...@@ -398,21 +401,24 @@ Dbtup::checkImmediateTriggersAfterUpdate(KeyReqStruct *req_struct,
jam(); jam();
fireImmediateTriggers(req_struct, fireImmediateTriggers(req_struct,
regTablePtr->afterUpdateTriggers, regTablePtr->afterUpdateTriggers,
regOperPtr); regOperPtr,
disk);
} }
if ((regOperPtr->op_struct.primary_replica) && if ((regOperPtr->op_struct.primary_replica) &&
(!(regTablePtr->constraintUpdateTriggers.isEmpty()))) { (!(regTablePtr->constraintUpdateTriggers.isEmpty()))) {
jam(); jam();
fireImmediateTriggers(req_struct, fireImmediateTriggers(req_struct,
regTablePtr->constraintUpdateTriggers, regTablePtr->constraintUpdateTriggers,
regOperPtr); regOperPtr,
disk);
} }
} }
void void
Dbtup::checkImmediateTriggersAfterDelete(KeyReqStruct *req_struct, Dbtup::checkImmediateTriggersAfterDelete(KeyReqStruct *req_struct,
Operationrec* regOperPtr, Operationrec* regOperPtr,
Tablerec* regTablePtr) Tablerec* regTablePtr,
bool disk)
{ {
if(refToBlock(req_struct->TC_ref) != DBTC) { if(refToBlock(req_struct->TC_ref) != DBTC) {
return; return;
...@@ -423,7 +429,8 @@ Dbtup::checkImmediateTriggersAfterDelete(KeyReqStruct *req_struct, ...@@ -423,7 +429,8 @@ Dbtup::checkImmediateTriggersAfterDelete(KeyReqStruct *req_struct,
jam(); jam();
executeTriggers(req_struct, executeTriggers(req_struct,
regTablePtr->afterDeleteTriggers, regTablePtr->afterDeleteTriggers,
regOperPtr); regOperPtr,
disk);
} }
} }
...@@ -547,7 +554,8 @@ void Dbtup::checkDetachedTriggers(KeyReqStruct *req_struct, ...@@ -547,7 +554,8 @@ void Dbtup::checkDetachedTriggers(KeyReqStruct *req_struct,
void void
Dbtup::fireImmediateTriggers(KeyReqStruct *req_struct, Dbtup::fireImmediateTriggers(KeyReqStruct *req_struct,
DLList<TupTriggerData>& triggerList, DLList<TupTriggerData>& triggerList,
Operationrec* const regOperPtr) Operationrec* const regOperPtr,
bool disk)
{ {
TriggerPtr trigPtr; TriggerPtr trigPtr;
triggerList.first(trigPtr); triggerList.first(trigPtr);
...@@ -558,7 +566,8 @@ Dbtup::fireImmediateTriggers(KeyReqStruct *req_struct, ...@@ -558,7 +566,8 @@ Dbtup::fireImmediateTriggers(KeyReqStruct *req_struct,
jam(); jam();
executeTrigger(req_struct, executeTrigger(req_struct,
trigPtr.p, trigPtr.p,
regOperPtr); regOperPtr,
disk);
}//if }//if
triggerList.next(trigPtr); triggerList.next(trigPtr);
}//while }//while
...@@ -621,7 +630,8 @@ Dbtup::fireDetachedTriggers(KeyReqStruct *req_struct, ...@@ -621,7 +630,8 @@ Dbtup::fireDetachedTriggers(KeyReqStruct *req_struct,
void Dbtup::executeTriggers(KeyReqStruct *req_struct, void Dbtup::executeTriggers(KeyReqStruct *req_struct,
DLList<TupTriggerData>& triggerList, DLList<TupTriggerData>& triggerList,
Operationrec* regOperPtr) Operationrec* regOperPtr,
bool disk)
{ {
TriggerPtr trigPtr; TriggerPtr trigPtr;
triggerList.first(trigPtr); triggerList.first(trigPtr);
...@@ -629,7 +639,8 @@ void Dbtup::executeTriggers(KeyReqStruct *req_struct, ...@@ -629,7 +639,8 @@ void Dbtup::executeTriggers(KeyReqStruct *req_struct,
jam(); jam();
executeTrigger(req_struct, executeTrigger(req_struct,
trigPtr.p, trigPtr.p,
regOperPtr); regOperPtr,
disk);
triggerList.next(trigPtr); triggerList.next(trigPtr);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment