mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Add the sqlite3changeset_apply() function. Does not yet handle all cases.
FossilOrigin-Name: 2b19be7bf753c7dd12e1c3b384981a3ea1bc8145
This commit is contained in:
@ -112,6 +112,21 @@ int sqlite3changeset_new(
|
||||
int iVal,
|
||||
sqlite3_value **ppValue /* OUT: New value (or NULL pointer) */
|
||||
);
|
||||
/*
|
||||
** This function is only usable with sqlite3_changeset_iter objects passed
|
||||
** to the xConflict callback by sqlite3changeset_apply(). It cannot be used
|
||||
** with iterators created using sqlite3changeset_start().
|
||||
**
|
||||
** It is used to access the "conflicting row" information available to the
|
||||
** conflict handler if the second argument is either SQLITE_CHANGESET_DATA
|
||||
** or SQLITE_CHANGESET_CONFLICT.
|
||||
*/
|
||||
int sqlite3changeset_conflict(
|
||||
sqlite3_changeset_iter *pIter,
|
||||
int iVal,
|
||||
sqlite3_value **ppValue /* OUT: Value from conflicting row */
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
** Finalize an iterator allocated with sqlite3changeset_start().
|
||||
@ -129,6 +144,36 @@ int sqlite3changeset_invert(
|
||||
int *pnOut, void **ppOut /* OUT: Inverse of input */
|
||||
);
|
||||
|
||||
/*
|
||||
** Apply a changeset to a database.
|
||||
**
|
||||
** It is safe to execute SQL statements, including those that write to the
|
||||
** table that the callback related to, from within the xConflict callback.
|
||||
** This can be used to further customize the applications conflict
|
||||
** resolution strategy.
|
||||
*/
|
||||
int sqlite3changeset_apply(
|
||||
sqlite3 *db,
|
||||
int nChangeset,
|
||||
void *pChangeset,
|
||||
int(*xConflict)(
|
||||
void *pCtx, /* Copy of fifth arg to _apply() */
|
||||
int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
|
||||
sqlite3_changeset_iter *p /* Handle describing change and conflict */
|
||||
),
|
||||
void *pCtx
|
||||
);
|
||||
|
||||
/* Values passed as the second argument to a conflict-handler */
|
||||
#define SQLITE_CHANGESET_DATA 1
|
||||
#define SQLITE_CHANGESET_NOTFOUND 2
|
||||
#define SQLITE_CHANGESET_CONFLICT 3
|
||||
#define SQLITE_CHANGESET_CONSTRAINT 4
|
||||
|
||||
/* Valid return values from a conflict-handler */
|
||||
#define SQLITE_CHANGESET_OMIT 0
|
||||
#define SQLITE_CHANGESET_REPLACE 1
|
||||
#define SQLITE_CHANGESET_ABORT 2
|
||||
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user