3#if !defined(ORG_FOSSIL_SCM_FSL_DB_H_INCLUDED)
4#define ORG_FOSSIL_SCM_FSL_DB_H_INCLUDED
28#if defined(__cplusplus)
38#if !defined(SQLITE_OK)
39typedef struct sqlite3 sqlite3;
148#define fsl_db_event_map(E) \
149 E(FSL_DB_EVENT_BEGIN, 0x01) \
150 E(FSL_DB_EVENT_COMMIT, 0x02) \
151 E(FSL_DB_EVENT_ROLLING_BACK, 0x04) \
152 E(FSL_DB_EVENT_ROLLED_BACK, 0x08) \
153 E(FSL_DB_EVENT_CLOSING, 0x10) \
154 E(FSL_DB_EVENT_TRACE_SQL, 0x20 \
155 | FSL_DB_EVENT_payload_buffer \
157 E(FSL_DB_EVENT_TRACE_SQLX, 0x40 \
158 | FSL_DB_EVENT_payload_buffer \
178 & (FSL_DB_EVENT_BEGIN | FSL_DB_EVENT_COMMIT
179 | FSL_DB_EVENT_ROLLING_BACK | FSL_DB_EVENT_ROLLED_BACK),
182 & (FSL_DB_EVENT_TRACE_SQL
183 | FSL_DB_EVENT_TRACE_SQLX)
441#define fsl_db_empty_m { \
443 .error = fsl_error_empty_m, \
448 .openStatementCount = 0, \
465 .buffer = fsl_buffer_empty_m, \
631#define fsl_stmt_empty_m { \
635 .sql = fsl_buffer_empty_m, \
714 char const * sql, ... );
720 char const * sql, va_list args );
804 char const * sql, ... );
810 char const * sql, va_list args );
906 void * callbackState );
1353 bool bubbleRollback);
1359#define fsl_db_txn_end(DB,DOROLLBACK) \
1360 fsl_db_txn_end_v2((DB), !(DOROLLBACK), !!(DOROLLBACK))
1399 char const * sql, ... );
1405 char const * sql, va_list args);
1413 int32_t defaultValue,
1414 char const * sql, ... );
1421 char const * sql, ... );
1427 char const * sql, va_list args);
1435 char const * sql, ... );
1443 char const * sql, ... );
1449 char const * sql, va_list args);
1457 char const * sql, ... );
1466 char const * sql, ... );
1472 char const * sql, va_list args);
1481 char const * sql, ... );
1489 char const * sql, ... );
1495 char const * sql, va_list args);
1503 char const * sql, ... );
1516 char const * sql, ... );
1522 char const * sql, va_list args );
1548 char const * sql, ... );
1555 char const * sql, va_list args );
1579 bool asBlob,
char const * sql,
1586 bool asBlob,
char const * sql,
1603 void * callbackState,
char const * sql, ... );
1609 void * callbackState,
char const * sql, va_list args );
1627 bool msPrecision,
bool localTime );
1783 char const *zTableName,
1784 char const *zColName );
1833 const char *zLabel);
1886 char const * fmt, ... );
1892 char const * fmt, va_list args );
1935 char const * zSchema, ... );
1964 const char *zTable);
2104#if defined(__cplusplus)
int32_t fsl_id_t
fsl_id_t is a signed integer type used to store database record IDs.
uint64_t fsl_size_t
fsl_size_t is an unsigned integer type used to denote absolute ranges and lengths.
int64_t fsl_time_t
The type used to represent type values.
uint32_t fsl_flag32_t
A 32-bit unsigned int type.
int64_t fsl_int_t
fsl_int_t is a signed integer type used to denote "relative" ranges and lengths, or to tell a routine...
This file declares the core SCM-related public APIs.
fsl_dbrole_e
This enum defines type ID tags with which the API tags fsl_db instances so that the library can figur...
FSL_EXPORT int fsl_db_exec_multiv(fsl_db *db, const char *sql, va_list args)
va_list counterpart of db_exec_multi().
FSL_EXPORT fsl_id_t fsl_db_last_insert_id(fsl_db *db)
Returns the row ID of the most recent insertion, or -1 if !db, db is not connected,...
FSL_EXPORT char * fsl_db_julian_to_iso8601(fsl_db *db, double j, bool msPrecision, bool localTime)
Returns the given Julian date value formatted as an ISO8601 string (with a fractional seconds part if...
FSL_EXPORT int fsl_stmt_bind_blob_name(fsl_stmt *stmt, char const *param, void const *v, fsl_int_t len, bool makeCopy)
Equivalent to fsl_stmt_bind_blob() but binds to a named parameter.
FSL_EXPORT int fsl_stmt_bind_int32(fsl_stmt *stmt, int index, int32_t v)
Binds v to the given 1-based parameter index.
FSL_EXPORT int fsl_db_get_int64v(fsl_db *db, int64_t *rv, char const *sql, va_list args)
va_list counterpart of fsl_db_get_int64().
FSL_EXPORT int fsl_stmt_reset(fsl_stmt *stmt)
Equivalent to fsl_stmt_reset2(stmt, false).
FSL_EXPORT int fsl_db_txn_level(fsl_db *db)
Returns the given db's current transaction depth.
FSL_EXPORT double fsl_db_g_double(fsl_db *db, double defaultValue, char const *sql,...)
Convenience form of fsl_db_get_double() which returns the value directly but provides no way of check...
FSL_EXPORT int fsl_db_err_get(fsl_db const *db, char const **msg, fsl_size_t *len)
Behaves like fsl_error_get(), using the db's underlying error state.
FSL_EXPORT int fsl_db_get_sizev(fsl_db *db, fsl_size_t *rv, char const *sql, va_list args)
va_list counterpart of fsl_db_get_size().
FSL_EXPORT int64_t fsl_db_g_int64(fsl_db *db, int64_t defaultValue, char const *sql,...)
Convenience form of fsl_db_get_int64() which returns the value directly but provides no way of checki...
FSL_EXPORT int fsl_stmt_each_f_dump(fsl_stmt *stmt, void *state)
A fsl_stmt_each_f() impl, intended primarily for debugging, which simply outputs row data in tabular ...
FSL_EXPORT int32_t fsl_stmt_g_int32(fsl_stmt *stmt, int index)
Convenience form of fsl_stmt_get_int32() which returns the value directly but cannot report errors.
FSL_EXPORT int fsl_db_prepare_cached(fsl_db *db, fsl_stmt **st, char const *sql,...)
A special-purpose variant of fsl_db_prepare() which caches statements based on their SQL code.
FSL_EXPORT int fsl_stmt_bind_fmtv(fsl_stmt *st, char const *fmt, va_list args)
Binds a series of values using a formatting string.
fsl_db_event_e
A flag type for use with fsl_db_event_f() implementations.
FSL_EXPORT int fsl_stmt_bind_fmt(fsl_stmt *st, char const *fmt,...)
The elipsis counterpart of fsl_stmt_bind_fmtv().
FSL_EXPORT double fsl_db_string_to_julian(fsl_db *db, char const *str)
Uses the given db to convert the given time string to Julian Day format.
FSL_EXPORT int fsl_stmt_get_int64(fsl_stmt *stmt, int index, int64_t *v)
Gets an integer value from the given 0-based result set column, assigns *v to that value,...
FSL_EXPORT int fsl_db_open(fsl_db *db, char const *dbFile, fsl_flag32_t openFlags)
Opens the given db file and populates db with its handle.
FSL_EXPORT int fsl_stmt_get_int32(fsl_stmt *stmt, int index, int32_t *v)
Gets an integer value from the given 0-based result set column, assigns *v to that value,...
FSL_EXPORT int fsl_db_get_textv(fsl_db *db, char **rv, fsl_size_t *rvLen, char const *sql, va_list args)
va_list counterpart of fsl_db_get_text().
FSL_EXPORT int fsl_stmt_bind_blob(fsl_stmt *stmt, int index, void const *v, fsl_size_t len, bool makeCopy)
Binds the first n bytes of v as a blob to the given 1-based bound parameter column in the given state...
FSL_EXPORT fsl_id_t fsl_db_g_id(fsl_db *db, fsl_id_t defaultValue, char const *sql,...)
Convenience form of fsl_db_get_id() which returns the value directly but provides no way of checking ...
FSL_EXPORT char const * fsl_stmt_col_name(fsl_stmt *stmt, int index)
Returns the name of the given 0-based result column index, or NULL if !stmt, stmt is not prepared,...
FSL_EXPORT const fsl_stmt fsl_stmt_empty
Empty-initialized fsl_stmt instance, intended for copy-constructing.
FSL_EXPORT void fsl_stmt_clear_bindings(fsl_stmt *stmt)
Clears memory associtated with any bindings on this statement.
FSL_EXPORT const char * fsl_db_role_name(enum fsl_dbrole_e r)
Returns a db name string for the given fsl_db_role value.
FSL_EXPORT int fsl_db_changes_recent(fsl_db *db)
Returns the "number of database rows that were changed or insertedor deleted by the most recently com...
FSL_EXPORT int fsl_stmt_bind_id_name(fsl_stmt *stmt, char const *param, fsl_id_t v)
Equivalent to fsl_stmt_bind_id() but binds to a named parameter.
FSL_EXPORT int fsl_stmt_bind_double(fsl_stmt *stmt, int index, double v)
Binds v to the given 1-based parameter index.
FSL_EXPORT const fsl_db fsl_db_empty
Empty-initialized fsl_db structure, intended for copy initialization.
FSL_EXPORT fsl_stmt * fsl_stmt_malloc(void)
Allocates a new, cleanly-initialized fsl_stmt instance using fsl_malloc().
FSL_EXPORT int fsl_db_get_id(fsl_db *db, fsl_id_t *rv, char const *sql,...)
The fsl_id_t counterpart of fsl_db_get_int32().
FSL_EXPORT void * fsl_db_g_blob(fsl_db *db, fsl_size_t *len, char const *sql,...)
Convenience form of fsl_db_get_blob() which returns the value directly but provides no way of checkin...
FSL_EXPORT int fsl_db_select_slistv(fsl_db *db, fsl_list *tgt, char const *fmt, va_list args)
The va_list counterpart of fsl_db_select_slist().
FSL_EXPORT char const * fsl_stmt_g_text(fsl_stmt *stmt, int index, fsl_size_t *outLen)
Convenience form of fsl_stmt_get_text() which returns the value directly but cannot report errors.
FSL_EXPORT int fsl_db_exec_multi(fsl_db *db, const char *sql,...)
Executes multiple SQL statements, ignoring any results they might collect.
FSL_EXPORT int fsl_db_get_blob(fsl_db *db, void **rv, fsl_size_t *len, char const *sql,...)
The Blob counterpart of fsl_db_get_text().
FSL_EXPORT char * fsl_db_random_hex(fsl_db *db, fsl_size_t n)
Returns n bytes of random lower-case hexidecimal characters using the given db as its data source,...
FSL_EXPORT int fsl_db_get_int32(fsl_db *db, int32_t *rv, char const *sql,...)
Runs a fetch-style SQL query against DB and returns the first column of the first result row via *rv.
int(* fsl_stmt_each_f)(fsl_stmt *stmt, void *state)
A callback interface for use with fsl_stmt_each() and fsl_db_each().
FSL_EXPORT int fsl_db_get_buffer(fsl_db *db, fsl_buffer *tgt, bool asBlob, char const *sql,...)
Similar to fsl_db_get_text() and fsl_db_get_blob(), but writes its result to tgt, appending its resul...
FSL_EXPORT int fsl_db_exec(fsl_db *db, char const *sql,...)
Executes a single SQL statement, skipping over any results it may have.
FSL_EXPORT bool fsl_db_existsv(fsl_db *db, char const *sql, va_list args)
va_list counterpart of fsl_db_exists().
FSL_EXPORT int fsl_stmt_bind_step_v2(fsl_stmt *st, char const *fmt,...)
The elipsis counterpart of fsl_stmt_bind_step_v2().
FSL_EXPORT int fsl_stmt_bind_text_name(fsl_stmt *stmt, char const *param, char const *v, fsl_int_t n, bool makeCopy)
Equivalent to fsl_stmt_bind_text() but binds to a named parameter.
FSL_EXPORT char const * fsl_stmt_sql(fsl_stmt *stmt, fsl_size_t *len)
Returns the SQL string used to prepare the given statement, or NULL if stmt has not been prepared.
FSL_EXPORT int fsl_db_changes_total(fsl_db *db)
Returns "the number of row changes caused by INSERT, UPDATE orDELETE statements since the database co...
FSL_EXPORT int fsl_db_get_blobv(fsl_db *db, void **rv, fsl_size_t *stmtLen, char const *sql, va_list args)
va_list counterpart of fsl_db_get_blob().
FSL_EXPORT int fsl_stmt_bind_id(fsl_stmt *stmt, int index, fsl_id_t v)
Binds v to the given 1-based parameter index.
FSL_EXPORT char const * fsl_db_name(fsl_db const *db)
If a db name has been associated with db then it is returned, otherwise NULL is returned.
FSL_EXPORT int fsl_stmt_bind_null_name(fsl_stmt *stmt, char const *param)
Equivalent to fsl_stmt_bind_null_name() but binds to a named parameter.
FSL_EXPORT void fsl_db_event_listener(fsl_db *db, fsl_db_event_f f, void *pState, fsl_flag32_t mask)
Sets the on-transaction hook for the given db, overwriting any prior one.
FSL_EXPORT int fsl_db_txn_end_v2(fsl_db *db, bool keepSavepoint, bool bubbleRollback)
Decrements the transaction counter incremented by fsl_db_txn_begin() and commits or rolls back the sa...
FSL_EXPORT int fsl_stmt_bind_int32_name(fsl_stmt *stmt, char const *param, int32_t v)
Equivalent to fsl_stmt_bind_int32() but binds to a named parameter.
FSL_EXPORT char const * fsl_db_filename(fsl_db const *db, fsl_size_t *len)
If db is not NULL then this function returns its name (the one used to fsl_db_open() it).
FSL_EXPORT int fsl_stmt_get_blob(fsl_stmt *stmt, int index, void const **out, fsl_size_t *outLen)
The Blob counterpart of fsl_stmt_get_text().
FSL_EXPORT int fsl_db_get_int32v(fsl_db *db, int32_t *rv, char const *sql, va_list args)
va_list counterpart of fsl_db_get_int32().
FSL_EXPORT fsl_size_t fsl_db_g_size(fsl_db *db, fsl_size_t defaultValue, char const *sql,...)
Convenience form of fsl_db_get_size() which returns the value directly but provides no way of checkin...
FSL_EXPORT int fsl_db_preparev(fsl_db *db, fsl_stmt *tgt, char const *sql, va_list args)
va_list counterpart of fsl_db_prepare().
FSL_EXPORT int fsl_stmt_bind_step(fsl_stmt *st, char const *fmt,...)
The elipsis counterpart of fsl_stmt_bind_step().
FSL_EXPORT int fsl_stmt_param_count(fsl_stmt const *stmt)
Returns the bound parameter count for the given statement, or -1 if !stmt or it has not been prepared...
FSL_EXPORT int fsl_db_attach(fsl_db *db, const char *zDbName, const char *zLabel)
ATTACHes the file zDbName to db using the database name zLabel (which gets quoted as an SQL identifie...
FSL_EXPORT int fsl_stmt_param_index(fsl_stmt *stmt, char const *param)
Returns the index of the given named parameter for the given statement, or -1 if !...
FSL_EXPORT int fsl_db_txn_begin(fsl_db *db)
Begins a transaction on the given db.
FSL_EXPORT int fsl_stmt_reset2(fsl_stmt *stmt, bool resetRowCounter)
Resets the given statement, analog to sqlite3_reset().
FSL_EXPORT bool fsl_db_table_has_column(fsl_db *db, char const *zTableName, char const *zColName)
Returns non-0 (true) if the database (which must be open) table identified by zTableName has a column...
FSL_EXPORT double fsl_stmt_g_double(fsl_stmt *stmt, int index)
Convenience form of fsl_stmt_get_double() which returns the value directly but cannot report errors.
FSL_EXPORT int fsl_db_each(fsl_db *db, fsl_stmt_each_f callback, void *callbackState, char const *sql,...)
Expects sql to be a SELECT-style query which (potentially) returns a result set.
FSL_EXPORT bool fsl_db_is_writeable(fsl_db *db, char const *zSchema)
Returns true if db is opened and sqlite3_db_readonly() returns 0 for it, else returns false.
FSL_EXPORT int fsl_stmt_get_double(fsl_stmt *stmt, int index, double *v)
Gets double value from the given 0-based result set column, assigns *v to that value,...
FSL_EXPORT int fsl_stmt_each(fsl_stmt *stmt, fsl_stmt_each_f callback, void *callbackState)
Calls the given callback one time for each result row in the given statement, iterating over stmt usi...
FSL_EXPORT int fsl_db_get_double(fsl_db *db, double *rv, char const *sql,...)
The double counterpart of fsl_db_get_int32().
FSL_EXPORT int fsl_db_txn_commit(fsl_db *db)
Equivalent to fsl_db_txn_end_v2(db, true, false).
FSL_EXPORT int fsl_db_detach(fsl_db *db, const char *zLabel)
The converse of fsl_db_detach().
FSL_EXPORT int fsl_db_get_idv(fsl_db *db, fsl_id_t *rv, char const *sql, va_list args)
va_list counterpart of fsl_db_get_id().
FSL_EXPORT int fsl_db_get_text(fsl_db *db, char **rv, fsl_size_t *rvLen, char const *sql,...)
The C-string counterpart of fsl_db_get_int32().
FSL_EXPORT int fsl_stmt_bind_text(fsl_stmt *stmt, int index, char const *v, fsl_int_t n, bool makeCopy)
Binds the first n bytes of v as text to the given 1-based bound parameter column in the given stateme...
FSL_EXPORT char * fsl_db_unix_to_iso8601(fsl_db *db, fsl_time_t j, bool localTime)
Returns the given Julian date value formatted as an ISO8601 string (with a fractional seconds part if...
int(* fsl_db_event_f)(fsl_db_event const *e)
An event callback for fsl_db objects, primarily for communicating on-transaction-start/end.
FSL_EXPORT int fsl_stmt_get_text(fsl_stmt *stmt, int index, char const **out, fsl_size_t *outLen)
Gets a string value from the given 0-based result set column, assigns *out (if out is not NULL) to th...
FSL_EXPORT int fsl_db_init(fsl_error *err, char const *zFilename, char const *zSchema,...)
Initializes the given database file.
FSL_EXPORT int fsl_stmt_step(fsl_stmt *stmt)
"Steps" the given SQL cursor one time.
FSL_EXPORT int fsl_db_txn_rollback(fsl_db *db)
Equivalent to fsl_db_txn_end_v2(db, false, true), noting that the final value of true there is for hi...
FSL_EXPORT int fsl_db_execv(fsl_db *db, char const *sql, va_list args)
va_list counterpart of fs_db_exec().
FSL_EXPORT int fsl_db_eachv(fsl_db *db, fsl_stmt_each_f callback, void *callbackState, char const *sql, va_list args)
va_list counterpart to fsl_db_each().
FSL_EXPORT fsl_id_t fsl_stmt_g_id(fsl_stmt *stmt, int index)
Convenience form of fsl_stmt_get_id() which returns the value directly but cannot report errors.
FSL_EXPORT void fsl_db_close(fsl_db *db)
Closes the given db handle and frees any resources owned by db.
FSL_EXPORT void fsl_db_sqltrace_enable(fsl_db *db, FILE *outStream, bool expandSql)
If db is an opened db handle, this registers a debugging function with the db which traces all SQL to...
FSL_EXPORT int fsl_stmt_bind_int64(fsl_stmt *stmt, int index, int64_t v)
Binds v to the given 1-based parameter index.
FSL_EXPORT int fsl_stmt_bind_stepv(fsl_stmt *st, char const *fmt, va_list args)
Works exactly like fsl_stmt_bind_stepv_v2() except that it returns 0 if stepping results in FSL_RC_ST...
FSL_EXPORT bool fsl_db_table_exists(fsl_db *db, fsl_dbrole_e whichDb, const char *zTable)
Returns true if the table name specified by the final argument exists in the fossil database specifie...
FSL_EXPORT int fsl_stmt_cached_yield(fsl_stmt *st)
"Yields" a statement which was prepared with fsl_db_prepare_cached(), such that that routine can once...
FSL_EXPORT double fsl_db_julian_now(fsl_db *db)
Returns the current time in Julian Date format.
FSL_EXPORT bool fsl_db_exists(fsl_db *db, char const *sql,...)
Runs the given SQL query on the given db and returns true if the query returns any rows,...
FSL_EXPORT int fsl_stmt_bind_stepv_v2(fsl_stmt *st, char const *fmt, va_list args)
Works like fsl_stmt_bind_fmt() but:
FSL_EXPORT char * fsl_db_g_text(fsl_db *db, fsl_size_t *len, char const *sql,...)
Convenience form of fsl_db_get_text() which returns the value directly but provides no way of checkin...
FSL_EXPORT void fsl_db_err_reset(fsl_db *db)
Resets any error state in db, but might keep the string memory allocated for later use.
FSL_EXPORT int fsl_stmt_get_id(fsl_stmt *stmt, int index, fsl_id_t *v)
The fsl_id_t counterpart of fsl_stmt_get_int32().
FSL_EXPORT int fsl_db_get_int64(fsl_db *db, int64_t *rv, char const *sql,...)
The int64 counterpart of fsl_db_get_int32().
FSL_EXPORT int fsl_stmt_bind_int64_name(fsl_stmt *stmt, char const *param, int64_t v)
Equivalent to fsl_stmt_bind_int64() but binds to a named parameter.
FSL_EXPORT fsl_db * fsl_db_malloc(void)
Allocates a new fsl_db instance().
FSL_EXPORT int32_t fsl_db_g_int32(fsl_db *db, int32_t defaultValue, char const *sql,...)
Convenience form of fsl_db_get_int32() which returns the value directly but provides no way of checki...
FSL_EXPORT int fsl_db_prepare(fsl_db *db, fsl_stmt *tgt, char const *sql,...)
Prepares an SQL statement for execution.
FSL_EXPORT int fsl_stmt_bind_double_name(fsl_stmt *stmt, char const *param, double v)
Equivalent to fsl_stmt_bind_double() but binds to a named parameter.
#define fsl_db_event_map(E)
A map of fsl_db_event types.
FSL_EXPORT int fsl_stmt_finalize(fsl_stmt *stmt)
Frees memory associated with stmt but does not free stmt unless it was allocated by fsl_stmt_malloc()...
sqlite3 fsl_db_t
A level of indirection to "hide" the actual db driver implementation from the public API.
fsl_db_open_flags_e
Flags for use with fsl_db_open() and friends.
@ FSL_DB_OPEN_RW
Flag for fsl_db_open() specifying that the db should be opened in read-write mode,...
@ FSL_DB_OPEN_NONE
The "no flags" value.
@ FSL_DB_OPEN_RO
Flag for fsl_db_open() specifying that the db should be opened in read-only mode.
@ FSL_DB_OPEN_TRACE_SQL
Used by fsl_db_open() to to tell the underlying db connection to trace all SQL to stdout.
@ FSL_DB_OPEN_SCHEMA_VALIDATE
Currently unused.
@ FSL_DB_OPEN_CREATE
Flag for fsl_db_open() specifying that the db should be opened in read-write mode,...
@ FSL_DB_OPEN_RWC
Shorthand for RW+CREATE flags.
FSL_EXPORT int fsl_db_get_size(fsl_db *db, fsl_size_t *rv, char const *sql,...)
The fsl_size_t counterpart of fsl_db_get_int32().
FSL_EXPORT int fsl_db_get_doublev(fsl_db *db, double *rv, char const *sql, va_list args)
va_list counterpart of fsl_db_get_double().
FSL_EXPORT int fsl_db_get_bufferv(fsl_db *db, fsl_buffer *tgt, bool asBlob, char const *sql, va_list args)
va_list counterpart of fsl_db_get_buffer().
FSL_EXPORT int fsl_stmt_bind_null(fsl_stmt *stmt, int index)
Binds NULL to the given 1-based parameter index.
fsl_db_event_mask2_e
Convenience FSL_DB_EVENT_... entries which cannot be defined until after fsl_db_event_e is.
@ FSL_DB_EVENT_group_txn
Mask of the IDs of transaction-specific events.
@ FSL_DB_EVENT_group_sql_trace
Mask of the IDs of SQL tracing events.
FSL_EXPORT int fsl_db_select_slist(fsl_db *db, fsl_list *tgt, char const *fmt,...)
Expects fmt to be a SELECT-style query.
FSL_EXPORT int64_t fsl_stmt_g_int64(fsl_stmt *stmt, int index)
Convenience form of fsl_stmt_get_int64() which returns the value directly but cannot report errors.
FSL_EXPORT fsl_db * fsl_stmt_db(fsl_stmt *stmt)
Returns the db handle which prepared the given statement, or NULL if stmt has not been prepared.
fsl_db_event_mask_e
Bitmasks for use with fsl_db_event_e.
@ FSL_DB_EVENT_mask_payload
Describes a data type for fsl_db_event::payload.
@ FSL_DB_EVENT_payload_buffer
(fsl_buffer const *) payload.
@ FSL_DB_EVENT_mask_id
All concrete message IDs are masked with this.
@ FSL_DB_EVENT_listen_all
Convenience entry for use with fsl_db_event_listener().
@ FSL_DB_EVENT_mask_reserved
FSL_EXPORT int fsl_db_preparev_cached(fsl_db *db, fsl_stmt **st, char const *sql, va_list args)
The va_list counterpart of fsl_db_prepare_cached().
FSL_EXPORT int fsl_stmt_col_count(fsl_stmt const *stmt)
Returns the result column count for the given statement, or -1 if !stmt or it has not been prepared.
A general-purpose buffer class, analog to Fossil's Blob class, but it is not called fsl_blob to avoid...
An "event" message type for use with fsl_db.
void * state
The event listener state.
fsl_db * db
The event-firing db.
fsl_db_event_e type
Event type.
void const * payload
A message-type-specific payload.
int savepointLevel
The db's current savepoint level (because most events deal with transactions and this info has proven...
struct fsl_db::@316105345303111027035325362263037170313261254037::@331140356012215264240306074346040363221336276352 txn
Transaction-related state.
sqlite3_stmt * sRelease
Prepared statements for SAVEPOINT RELEASE.
fsl_db_t * dbh
Underlying db driver handle.
int level
Counter for fsl_db_txn_begin/end().
char * filename
Holds the file name used when opening this db.
sqlite3_stmt * sRollback
Prepared statements for ROLLBACK TO SAVEPOINT.
int openStatementCount
Debugging/test counter.
fsl_buffer buffer
Internal buffer to reduce reallocations caused via fsl_db_prepare_cached(), fsl_db_see_check(),...
fsl_stmt * head
An internal cache of "static" queries - those which do not rely on call-time state unless that state ...
char * name
Holds the database name for use in creating queries.
fsl_error error
Holds error state from the underlying driver.
struct fsl_db::@316105345303111027035325362263037170313261254037::@265153334322072202076113040112070317014315122116 event
fsl_flag32_t flags
Internal flags.
fsl_db_event_f f
Event listener callback.
void const * allocStamp
A marker which tells fsl_db_close() whether or not fsl_db_malloc() allocated this instance (in which ...
fsl_flag16_t role
Describes what role(s) this db connection plays in fossil (if any).
fsl_flag32_t maskIds
The FSL_DB_EVENT_mask_id-masked part of event IDs to fire the callback for.
FILE * fpTrace
Older-style (pre-fsl_db_event) trace output channel.
struct fsl_db::@316105345303111027035325362263037170313261254037::@025146014153060240206145300313221172252240144027 stCache
State for use with fsl_db_prepare_cached().
void * state
Impl-specific state for f.
sqlite3_stmt * sSavepoint
Prepared statements for SAVEPOINT management.
struct fsl_db::@316105345303111027035325362263037170313261254037 impl
Private implementation details.
A container for storing generic error state.
Generic list container type.
Represents a prepared statement handle.
fsl_db * db
The db which prepared this statement.
fsl_flag16_t role
Describes the database(s) used by this statement handle, in the form of a bitmask of fsl_dbrole_e val...
fsl_stmt * next
For internal use in creating linked lists.
fsl_size_t rowCount
The number of times this statement has fetched a row via fsl_stmt_step().
fsl_stmt_t * stmt
Underlying db driver-level statement handle.
fsl_buffer sql
The SQL used to prepare this statement.
fsl_flag16_t flags
Internal state flags.
uint32_t cachedHits
Internal use only: counts the number of times this query has been resolved as cached via fsl_db_prepa...
void const * allocStamp
A marker which tells fsl_stmt_finalize() whether or not fsl_stmt_malloc() allocated this instance (in...
struct fsl_stmt::@241310320130362112273312176156263277022126132200 impl
Private implementation details.