1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-21 09:00:59 +03:00

Add support for delete operations to the ota extension.

FossilOrigin-Name: f988234ba54d7c667f7deef1d04beed4e7fe6182
This commit is contained in:
dan
2014-09-06 20:19:38 +00:00
parent 4e9246e9db
commit 9295d21bfd
6 changed files with 304 additions and 61 deletions

View File

@@ -546,17 +546,23 @@ int sqlite3_index_writer(
sqlite3VdbeAddOp2(v, OP_Variable, i, i);
}
regRec = ++pParse->nMem;
sqlite3VdbeAddOp3(v, OP_MakeRecord, 1, pIdx->nColumn, regRec);
/* If this is a UNIQUE index, check the constraint. */
if( pIdx->onError ){
int addr = sqlite3VdbeAddOp4Int(v, OP_NoConflict, 0, 0, 1, pIdx->nKeyCol);
sqlite3UniqueConstraint(pParse, SQLITE_ABORT, pIdx);
sqlite3VdbeJumpHere(v, addr);
if( bDelete==0 ){
sqlite3VdbeAddOp3(v, OP_MakeRecord, 1, pIdx->nColumn, regRec);
/* If this is a UNIQUE index, check the constraint. */
if( pIdx->onError ){
int addr = sqlite3VdbeAddOp4Int(v, OP_NoConflict, 0, 0, 1, pIdx->nKeyCol);
sqlite3UniqueConstraint(pParse, SQLITE_ABORT, pIdx);
sqlite3VdbeJumpHere(v, addr);
}
/* Code the IdxInsert to write to the b-tree index. */
sqlite3VdbeAddOp2(v, OP_IdxInsert, 0, regRec);
}else{
/* Code the IdxDelete to remove the entry from the b-tree index. */
sqlite3VdbeAddOp3(v, OP_IdxDelete, 0, 1, pIdx->nColumn);
}
/* Code the IdxInsert to write to the b-tree index. */
sqlite3VdbeAddOp2(v, OP_IdxInsert, 0, regRec);
sqlite3FinishCoding(pParse);
index_writer_out: