83 lines
3.1 KiB
Groff
83 lines
3.1 KiB
Groff
.Dd March 11, 2017
|
|
.Dt SQLITE3_TABLE_COLUMN_METADATA 3
|
|
.Os
|
|
.Sh NAME
|
|
.Nm sqlite3_table_column_metadata
|
|
.Nd Extract Metadata About A Column Of A Table
|
|
.Sh SYNOPSIS
|
|
.Ft int
|
|
.Fo sqlite3_table_column_metadata
|
|
.Fa "sqlite3 *db"
|
|
.Fa "const char *zDbName"
|
|
.Fa "const char *zTableName"
|
|
.Fa "const char *zColumnName"
|
|
.Fa "char const **pzDataType"
|
|
.Fa "char const **pzCollSeq"
|
|
.Fa "int *pNotNull"
|
|
.Fa "int *pPrimaryKey"
|
|
.Fa "int *pAutoinc "
|
|
.Fc
|
|
.Sh DESCRIPTION
|
|
The sqlite3_table_column_metadata(X,D,T,C,....) routine returns information
|
|
about column C of table T in database D on database connection
|
|
X.
|
|
The sqlite3_table_column_metadata() interface returns SQLITE_OK and
|
|
fills in the non-NULL pointers in the final five arguments with appropriate
|
|
values if the specified column exists.
|
|
The sqlite3_table_column_metadata() interface returns SQLITE_ERROR
|
|
and if the specified column does not exist.
|
|
If the column-name parameter to sqlite3_table_column_metadata() is
|
|
a NULL pointer, then this routine simply checks for the existence of
|
|
the table and returns SQLITE_OK if the table exists and SQLITE_ERROR
|
|
if it does not.
|
|
.Pp
|
|
The column is identified by the second, third and fourth parameters
|
|
to this function.
|
|
The second parameter is either the name of the database (i.e.
|
|
"main", "temp", or an attached database) containing the specified table
|
|
or NULL.
|
|
If it is NULL, then all attached databases are searched for the table
|
|
using the same algorithm used by the database engine to resolve unqualified
|
|
table references.
|
|
.Pp
|
|
The third and fourth parameters to this function are the table and
|
|
column name of the desired column, respectively.
|
|
.Pp
|
|
Metadata is returned by writing to the memory locations passed as the
|
|
5th and subsequent parameters to this function.
|
|
Any of these arguments may be NULL, in which case the corresponding
|
|
element of metadata is omitted.
|
|
.Bd -ragged
|
|
<table border="1"> <tr><th> Parameter <th> Output<br>Type <th> Description
|
|
.Pp
|
|
<tr><td> 5th <td> const char* <td> Data type <tr><td> 6th <td> const
|
|
char* <td> Name of default collation sequence <tr><td> 7th <td> int
|
|
<td> True if column has a NOT NULL constraint <tr><td> 8th <td> int
|
|
<td> True if column is part of the PRIMARY KEY <tr><td> 9th <td> int
|
|
<td> True if column is AUTOINCREMENT </table>
|
|
.Ed
|
|
.Pp
|
|
The memory pointed to by the character pointers returned for the declaration
|
|
type and collation sequence is valid until the next call to any SQLite
|
|
API function.
|
|
.Pp
|
|
If the specified table is actually a view, an error code
|
|
is returned.
|
|
.Pp
|
|
If the specified column is "rowid", "oid" or "_rowid_" and the table
|
|
is not a WITHOUT ROWID table and an INTEGER PRIMARY KEY
|
|
column has been explicitly declared, then the output parameters are
|
|
set for the explicitly declared column.
|
|
If there is no INTEGER PRIMARY KEY column, then
|
|
the outputs for the rowid are set as follows:
|
|
.Bd -literal
|
|
data type: "INTEGER" collation sequence: "BINARY" not null: 0 primary
|
|
key: 1 auto increment: 0
|
|
.Ed
|
|
.Pp
|
|
This function causes all database schemas to be read from disk and
|
|
parsed, if that has not already been done, and returns an error if
|
|
any errors are encountered while loading the schema.
|
|
.Sh SEE ALSO
|
|
.Xr sqlite3 3
|