xref: /netbsd-src/external/public-domain/sqlite/man/sqlite3changegroup_add.3 (revision bdc22b2e01993381dcefeff2bc9b56ca75a4235c)
1.Dd March 11, 2017
2.Dt SQLITE3CHANGEGROUP_ADD 3
3.Os
4.Sh NAME
5.Nm sqlite3changegroup_add
6.Nd Add A Changeset To A Changegroup
7.Sh SYNOPSIS
8.Ft int
9.Fo sqlite3changegroup_add
10.Fa "sqlite3_changegroup*"
11.Fa "int nData"
12.Fa "void *pData"
13.Fc
14.Sh DESCRIPTION
15Add all changes within the changeset (or patchset) in buffer pData
16(size nData bytes) to the changegroup.
17.Pp
18If the buffer contains a patchset, then all prior calls to this function
19on the same changegroup object must also have specified patchsets.
20Or, if the buffer contains a changeset, so must have the earlier calls
21to this function.
22Otherwise, SQLITE_ERROR is returned and no changes are added to the
23changegroup.
24.Pp
25Rows within the changeset and changegroup are identified by the values
26in their PRIMARY KEY columns.
27A change in the changeset is considered to apply to the same row as
28a change already present in the changegroup if the two rows have the
29same primary key.
30.Pp
31Changes to rows that do not already appear in the changegroup are simply
32copied into it.
33Or, if both the new changeset and the changegroup contain changes that
34apply to a single row, the final contents of the changegroup depends
35on the type of each change, as follows:
36.Pp
37<table border=1 style="margin-left:8ex;margin-right:8ex"> <tr><th style="white-space:pre">Existing
38Change  </th> <th style="white-space:pre">New Change       </th> <th>Output
39Change <tr><td>INSERT <td>INSERT <td> The new change is ignored.
40This case does not occur if the new changeset was recorded immediately
41after the changesets already added to the changegroup.
42<tr><td>INSERT <td>UPDATE <td> The INSERT change remains in the changegroup.
43The values in the INSERT change are modified as if the row was inserted
44by the existing change and then updated according to the new change.
45<tr><td>INSERT <td>DELETE <td> The existing INSERT is removed from
46the changegroup.
47The DELETE is not added.
48<tr><td>UPDATE <td>INSERT <td> The new change is ignored.
49This case does not occur if the new changeset was recorded immediately
50after the changesets already added to the changegroup.
51<tr><td>UPDATE <td>UPDATE <td> The existing UPDATE remains within the
52changegroup.
53It is amended so that the accompanying values are as if the row was
54updated once by the existing change and then again by the new change.
55<tr><td>UPDATE <td>DELETE <td> The existing UPDATE is replaced by the
56new DELETE within the changegroup.
57<tr><td>DELETE <td>INSERT <td> If one or more of the column values
58in the row inserted by the new change differ from those in the row
59deleted by the existing change, the existing DELETE is replaced by
60an UPDATE within the changegroup.
61Otherwise, if the inserted row is exactly the same as the deleted row,
62the existing DELETE is simply discarded.
63<tr><td>DELETE <td>UPDATE <td> The new change is ignored.
64This case does not occur if the new changeset was recorded immediately
65after the changesets already added to the changegroup.
66<tr><td>DELETE <td>DELETE <td> The new change is ignored.
67This case does not occur if the new changeset was recorded immediately
68after the changesets already added to the changegroup.
69</table>
70.Pp
71If the new changeset contains changes to a table that is already present
72in the changegroup, then the number of columns and the position of
73the primary key columns for the table must be consistent.
74If this is not the case, this function fails with SQLITE_SCHEMA.
75If the input changeset appears to be corrupt and the corruption is
76detected, SQLITE_CORRUPT is returned.
77Or, if an out-of-memory condition occurs during processing, this function
78returns SQLITE_NOMEM.
79In all cases, if an error occurs the final contents of the changegroup
80is undefined.
81.Pp
82If no error occurs, SQLITE_OK is returned.
83