1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-11 01:42:22 +03:00

Replace the OP_IsUnique opcode with OP_NoConflict. This code simplification

might be useful to move onto trunk even if this branch is never merged.

FossilOrigin-Name: e6650e16dd11327afd25961b2feb29ec8778c2ca
This commit is contained in:
drh
2013-10-26 13:36:51 +00:00
parent d82b50212e
commit 6f225d0d7f
6 changed files with 51 additions and 122 deletions

View File

@@ -1392,13 +1392,12 @@ void sqlite3GenerateConstraintChecks(
for(iCur=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, iCur++){
int regIdx;
int regR;
int addrSkipRow = 0;
int addrSkipRow = sqlite3VdbeMakeLabel(v);
if( aRegIdx[iCur]==0 ) continue; /* Skip unused indices */
if( pIdx->pPartIdxWhere ){
sqlite3VdbeAddOp2(v, OP_Null, 0, aRegIdx[iCur]);
addrSkipRow = sqlite3VdbeMakeLabel(v);
pParse->ckBase = regData;
sqlite3ExprIfFalse(pParse, pIdx->pPartIdxWhere, addrSkipRow,
SQLITE_JUMPIFNULL);
@@ -1438,8 +1437,10 @@ void sqlite3GenerateConstraintChecks(
/* Check to see if the new index entry will be unique */
regR = sqlite3GetTempReg(pParse);
sqlite3VdbeAddOp2(v, OP_SCopy, regOldRowid, regR);
j3 = sqlite3VdbeAddOp4Int(v, OP_IsUnique, baseCur+iCur+1, 0, regR, regIdx);
sqlite3VdbeAddOp4Int(v, OP_NoConflict, baseCur+iCur+1, addrSkipRow,
regIdx, pIdx->nKeyCol);
sqlite3VdbeAddOp2(v, OP_IdxRowid, baseCur+iCur+1, regR);
sqlite3VdbeAddOp3(v, OP_Eq, regR, addrSkipRow, regOldRowid);
sqlite3ReleaseTempRange(pParse, regIdx, pIdx->nKeyCol+1);
/* Generate code that executes if the new index entry is not unique */
@@ -1490,7 +1491,6 @@ void sqlite3GenerateConstraintChecks(
break;
}
}
sqlite3VdbeJumpHere(v, j3);
sqlite3VdbeResolveLabel(v, addrSkipRow);
sqlite3ReleaseTempReg(pParse, regR);
}