Name

sqlite3_set_authorizer() — Register an authorization callback

Definition

int sqlite3_set_authorizer( sqlite3* db, auth_callback, void* udp );

int auth_callback( void* udp, int action_code,
                     const char* param1,  const char* param2,
                     const char* db_name, const char* trigger_name );
db

A database connection.

auth_callback

An application-defined authorization callback function.

udp

An application-defined user-data pointer. This value is made available to the authorization callback.

action_code

A code indicating which database operation requires authorization.

param1, param2

Two data values related to the authorization action. The specific meaning of these parameters depends on the value of the action_code parameter.

db_name

The logical name of the database being affected by the action in question. This value is valid for many, but not all, action_code values.

trigger_name

If the action in question comes from a trigger, the name of the lowest-level trigger. If the action comes from a bare SQL statement, this parameter will be NULL.

Returns (sqlite3_set_authorizer())

An SQLite result code.

Returns (auth_func())

An SQLite result code. The code SQLITE_OK indicates that the action is allowed. The code SQLITE_IGNORE denies the specific action, but allows the SQL statement to continue. The code SQLITE_DENY causes the whole SQL statement to be rejected.

Description

This function registers an authorization callback. The callback is called when SQL statements are prepared, allowing the application to allow or deny specific actions. This is useful when processing SQL statements from external sources (including the application user). The authorization function must not utilize the database connection.

For a full description of the currently supported action codes, see http://www.sqlite.org/c3ref/c_alter_table.html.

See Also

sqlite3_prepare_xxx(), sqlite3_limit()