aboutsummaryrefslogtreecommitdiff
path: root/src/sqliteInt.h
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/sqliteInt.h
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/sqliteInt.h')
-rw-r--r--src/sqliteInt.h19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/sqliteInt.h b/src/sqliteInt.h
index bb23e25b4..b1e412fcb 100644
--- a/src/sqliteInt.h
+++ b/src/sqliteInt.h
@@ -2713,11 +2713,27 @@ struct NameContext {
** An instance of the following object describes a single ON CONFLICT
** clause in an upsert. A list of these objects may be attached to
** an INSERT statement in order to form an upsert.
+**
+** The pUpsertTarget field is only set if the ON CONFLICT clause includes
+** conflict-target clause. (In "ON CONFLICT(a,b)" the "(a,b)" is the
+** conflict-target clause.)
+**
+** pUpsertSet is the list of column=expr terms of the UPDATE statement.
+** The pUpsertSet field is NULL for a ON CONFLICT DO NOTHING. The
+** pUpsertWhere is the WHERE clause for the UPDATE and is NULL if the
+** WHERE clause is omitted.
+**
+** The pUpsertIdx is a transient pointer to the unique index described
+** by pUpsertTarget. If pUpsertTarget describes the rowid, then pUpsertIdx
+** will be NULL. pUpsertIdx does not own the Index object it points to.
+** Care must be taken to ensure that the Index object does not expire while
+** the pointer is valid.
*/
struct Upsert {
ExprList *pUpsertTarget; /* Optional description of conflicting index */
ExprList *pUpsertSet; /* The SET clause from an ON CONFLICT UPDATE */
Expr *pUpsertWhere; /* WHERE clause for the ON CONFLICT UPDATE */
+ Index *pUpsertIdx; /* UNIQUE index referenced by pUpsertTarget */
Upsert *pUpsertNext; /* Next ON CONFLICT clause in the list */
};
@@ -3877,7 +3893,7 @@ void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*, int);
int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*,Index*,int);
void sqlite3ResolvePartIdxLabel(Parse*,int);
void sqlite3GenerateConstraintChecks(Parse*,Table*,int*,int,int,int,int,
- u8,u8,int,int*,int*);
+ u8,u8,int,int*,int*,Upsert*);
#ifdef SQLITE_ENABLE_NULL_TRIM
void sqlite3SetMakeRecordP5(Vdbe*,Table*);
#else
@@ -4274,6 +4290,7 @@ const char *sqlite3JournalModename(int);
Upsert *sqlite3UpsertNew(sqlite3*,Upsert*,ExprList*,ExprList*,Expr*);
void sqlite3UpsertDelete(sqlite3*,Upsert*);
Upsert *sqlite3UpsertDup(sqlite3*,Upsert*);
+ int sqlite3UpsertAnalyze(Parse*,SrcList*,Upsert*);
#else
#define sqlite3UpsertNew(x,y,z,w) ((Upsert*)0)
#define sqlite3UpsertDelete(x,y)