aboutsummaryrefslogtreecommitdiff
path: root/src/insert.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2018-04-13 01:15:09 +0000
committerdrh <drh@noemail.net>2018-04-13 01:15:09 +0000
commit788d55aa772b9012f93283b4f3cd89aa9dbfe77d (patch)
tree2832fb097291e6642454586213d8f8ac14e44708 /src/insert.c
parentfcfd756fe32920c6495b1ae9c2092cc73c2fbcb1 (diff)
downloadsqlite-788d55aa772b9012f93283b4f3cd89aa9dbfe77d.tar.gz
sqlite-788d55aa772b9012f93283b4f3cd89aa9dbfe77d.zip
Begin adding upsert logic. This is an incremental check-in.
FossilOrigin-Name: 809696434097e62e8ef486c7478b5eb62c0cf1342522a5584939fade82821410
Diffstat (limited to 'src/insert.c')
-rw-r--r--src/insert.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/insert.c b/src/insert.c
index 4fc79c223..313434bad 100644
--- a/src/insert.c
+++ b/src/insert.c
@@ -804,6 +804,13 @@ void sqlite3Insert(
pParse->nMem += pIdx->nColumn;
}
}
+#ifndef SQLITE_OMIT_UPSERT
+ if( pUpsert ){
+ pTabList->a[0].iCursor = iDataCur;
+ sqlite3UpsertAnalyze(pParse, pTabList, pUpsert);
+ }
+#endif
+
/* This is the top of the main insertion loop */
if( useTempTable ){
@@ -1006,7 +1013,7 @@ void sqlite3Insert(
int isReplace; /* Set to true if constraints may cause a replace */
int bUseSeek; /* True to use OPFLAG_SEEKRESULT */
sqlite3GenerateConstraintChecks(pParse, pTab, aRegIdx, iDataCur, iIdxCur,
- regIns, 0, ipkColumn>=0, onError, endOfLoop, &isReplace, 0
+ regIns, 0, ipkColumn>=0, onError, endOfLoop, &isReplace, 0, pUpsert
);
sqlite3FkCheck(pParse, pTab, 0, regIns, 0, 0);
@@ -1242,7 +1249,8 @@ void sqlite3GenerateConstraintChecks(
u8 overrideError, /* Override onError to this if not OE_Default */
int ignoreDest, /* Jump to this label on an OE_Ignore resolution */
int *pbMayReplace, /* OUT: Set to true if constraint may cause a replace */
- int *aiChng /* column i is unchanged if aiChng[i]<0 */
+ int *aiChng, /* column i is unchanged if aiChng[i]<0 */
+ Upsert *pUpsert /* ON CONFLICT clauses, if any. NULL otherwise */
){
Vdbe *v; /* VDBE under constrution */
Index *pIdx; /* Pointer to one of the indices */