diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/insert.c | 14 | ||||
-rw-r--r-- | src/sqliteInt.h | 1 | ||||
-rw-r--r-- | src/upsert.c | 17 |
3 files changed, 31 insertions, 1 deletions
diff --git a/src/insert.c b/src/insert.c index fb4f442e9..c794b1ad7 100644 --- a/src/insert.c +++ b/src/insert.c @@ -1484,6 +1484,12 @@ void sqlite3GenerateConstraintChecks( seenReplace = 1; break; } +#ifndef SQLITE_OMIT_UPSERT + case OE_Update: { + sqlite3UpsertDoUpdate(pParse, pUpsert, pTab, 0, iDataCur, 0); + /* Fall through */ + } +#endif case OE_Ignore: { sqlite3VdbeGoto(v, ignoreDest); break; @@ -1666,7 +1672,7 @@ void sqlite3GenerateConstraintChecks( /* Generate code that executes if the new index entry is not unique */ assert( onError==OE_Rollback || onError==OE_Abort || onError==OE_Fail - || onError==OE_Ignore || onError==OE_Replace ); + || onError==OE_Ignore || onError==OE_Replace || onError==OE_Update ); switch( onError ){ case OE_Rollback: case OE_Abort: @@ -1674,6 +1680,12 @@ void sqlite3GenerateConstraintChecks( sqlite3UniqueConstraint(pParse, onError, pIdx); break; } +#ifndef SQLITE_OMIT_UPSERT + case OE_Update: { + sqlite3UpsertDoUpdate(pParse, pUpsert, pTab, pIdx, iDataCur, iIdxCur); + /* Fall through */ + } +#endif case OE_Ignore: { sqlite3VdbeGoto(v, ignoreDest); break; diff --git a/src/sqliteInt.h b/src/sqliteInt.h index d611f4913..8936345d5 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -4284,6 +4284,7 @@ const char *sqlite3JournalModename(int); void sqlite3UpsertDelete(sqlite3*,Upsert*); Upsert *sqlite3UpsertDup(sqlite3*,Upsert*); int sqlite3UpsertAnalyzeTarget(Parse*,SrcList*,Upsert*); + void sqlite3UpsertDoUpdate(Parse*,Upsert*,Table*,Index*,int,int); #else #define sqlite3UpsertNew(x,y,z,w) ((Upsert*)0) #define sqlite3UpsertDelete(x,y) diff --git a/src/upsert.c b/src/upsert.c index d98a82743..5c37d4c12 100644 --- a/src/upsert.c +++ b/src/upsert.c @@ -180,4 +180,21 @@ int sqlite3UpsertAnalyzeTarget( return SQLITE_ERROR; } +/* +** Generate bytecode that does an UPDATE as part of an upsert. +*/ +void sqlite3UpsertDoUpdate( + Parse *pParse, /* The parsing and code-generating context */ + Upsert *pUpsert, /* The ON CONFLICT clause for the upsert */ + Table *pTab, /* The table being updated */ + Index *pIdx, /* The UNIQUE constraint that failed */ + int iDataCur, /* Cursor for the pTab, table being updated */ + int iIdxCur /* Cursor for the pIdx */ +){ + Vdbe *v = pParse->pVdbe; + assert( v!=0 ); + VdbeNoopComment((v, "Begin DO UPDATE of UPSERT")); + VdbeNoopComment((v, "End DO UPDATE of UPSERT")); +} + #endif /* SQLITE_OMIT_UPSERT */ |