.Dd January 24, 2024
.Dt SQLITE3CHANGESET_PK 3
.Os
.Sh NAME
.Nm sqlite3changeset_pk
.Nd obtain the primary key definition of a table
.Sh SYNOPSIS
.In sqlite3.h
.Ft int
.Fo sqlite3changeset_pk
.Fa "sqlite3_changeset_iter *pIter"
.Fa "unsigned char **pabPK"
.Fa "int *pnCol"
.Fc
.Sh DESCRIPTION
For each modified table, a changeset includes the following:
.Bl -bullet
.It
The number of columns in the table, and
.It
Which of those columns make up the tables PRIMARY KEY.
.El
.Pp
This function is used to find which columns comprise the PRIMARY KEY
of the table modified by the change that iterator pIter currently points
to.
If successful, *pabPK is set to point to an array of nCol entries,
where nCol is the number of columns in the table.
Elements of *pabPK are set to 0x01 if the corresponding column is part
of the tables primary key, or 0x00 if it is not.
.Pp
If argument pnCol is not NULL, then *pnCol is set to the number of
columns in the table.
.Pp
If this function is called when the iterator does not point to a valid
entry, SQLITE_MISUSE is returned and the output variables zeroed.
Otherwise, SQLITE_OK is returned and the output variables populated
as described above.
.Sh IMPLEMENTATION NOTES
These declarations were extracted from the
interface documentation at line 11567.
.Bd -literal
SQLITE_API int sqlite3changeset_pk(
  sqlite3_changeset_iter *pIter,  /* Iterator object */
  unsigned char **pabPK,          /* OUT: Array of boolean - true for PK cols */
  int *pnCol                      /* OUT: Number of entries in output array */
);
.Ed