aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordan <dan@noemail.net>2014-09-06 20:19:38 +0000
committerdan <dan@noemail.net>2014-09-06 20:19:38 +0000
commit9295d21bfd8bb3c1f9fcc70ca9f7764c61d70d79 (patch)
tree46515671e2f047c8915ab6adb886a18c480014a5 /src
parent4e9246e9dbf69ff8771a2121782e69b7ad445ead (diff)
downloadsqlite-9295d21bfd8bb3c1f9fcc70ca9f7764c61d70d79.tar.gz
sqlite-9295d21bfd8bb3c1f9fcc70ca9f7764c61d70d79.zip
Add support for delete operations to the ota extension.
FossilOrigin-Name: f988234ba54d7c667f7deef1d04beed4e7fe6182
Diffstat (limited to 'src')
-rw-r--r--src/delete.c3
-rw-r--r--src/vdbeblob.c24
2 files changed, 18 insertions, 9 deletions
diff --git a/src/delete.c b/src/delete.c
index af83903c4..19c1ed01a 100644
--- a/src/delete.c
+++ b/src/delete.c
@@ -730,6 +730,9 @@ void sqlite3GenerateRowIndexDelete(
Vdbe *v; /* The prepared statement under construction */
Index *pPk; /* PRIMARY KEY index, or NULL for rowid tables */
+ /* Skip this if we are in OTA mode */
+ if( pParse->db->flags & SQLITE_OtaMode ) return;
+
v = pParse->pVdbe;
pPk = HasRowid(pTab) ? 0 : sqlite3PrimaryKeyIndex(pTab);
for(i=0, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){
diff --git a/src/vdbeblob.c b/src/vdbeblob.c
index 11e018e19..5e809fc78 100644
--- a/src/vdbeblob.c
+++ b/src/vdbeblob.c
@@ -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);
+ /* 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);
+ }
sqlite3FinishCoding(pParse);
index_writer_out: