Sq3LiteC - various functions to perform misc operations … More...
Macros | |
#define | Sq3Fupu_Sq3LiteAutovacuumPages_arg1_ret MK_U32 |
#define | Sq3Fupu_Sq3LiteAutovacuumPages_arg1_args MK_PTR arg0, MK_STRN arg1, MK_U32 arg2, MK_U32 arg3, MK_U32 arg4 |
#define | Sq3Fupu_Sq3LiteAutovacuumPages_arg3_ret void |
#define | Sq3Fupu_Sq3LiteAutovacuumPages_arg3_args MK_PTR arg0 |
#define | Sq3Fupu_Sq3LiteCreateCollation_xCompare_ret MK_I32 |
#define | Sq3Fupu_Sq3LiteCreateCollation_xCompare_args MK_PTR arg0, MK_I32 arg1, MK_PTRN arg2, MK_I32 arg3, MK_PTRN arg4 |
#define | Sq3LiteVtabConfig(sq3lite, op, ...) |
Virtual Table Interface Configuration … | |
Functions | |
void | Sq3LiteLog_RT (MK_RT mkrt, SQ3_LITEN const lite, MK_OBJN fmtobj, MK_DBG const debug, MK_STRN const callfunc, MK_I32 const lvl) |
log the lite … | |
static enum MkErrorE | Sq3LiteAutovacuumPages (SQ3_LITE db, Sq3Fupu_Sq3LiteAutovacuumPages_arg1 arg1, MK_PTR arg2, Sq3Fupu_Sq3LiteAutovacuumPages_arg3 arg3) |
Autovacuum Compaction Amount Callback … | |
static enum MkErrorE | Sq3LiteCreateCollation (SQ3_LITE sq3lite, MK_STRN zName, MK_I32 eTextRep, MK_PTR pArg, Sq3Fupu_Sq3LiteCreateCollation_xCompare xCompare) |
Define New Collating Sequences … | |
static enum MkErrorE | Sq3LiteDbCacheflush (SQ3_LITE sq3lite) |
Flush caches to disk mid-transaction … | |
static SQ3_FILENAME | Sq3LiteDbFilename (SQ3_LITE db, MK_STRN zDbName) |
Return The Filename For A Database Connection … | |
static MK_STRN | Sq3LiteDbName (SQ3_LITE db, MK_I32 N) |
Return The Schema Name For A Database Connection … | |
static enum MkErrorE | Sq3LiteDbReadonly (SQ3_LITE db, MK_STRN zDbName) |
Determine if a database is read-only … | |
static enum MkErrorE | Sq3LiteDbReleaseMemory (SQ3_LITE sq3lite) |
Free Memory Used By A Database Connection … | |
static enum MkErrorE | Sq3LiteDeserializeHide (SQ3_LITE db, MK_STRN zSchema, MK_BIN pData, MK_I64 szDb, MK_I64 szBuf, enum Sq3DeSerializeEF mFlags) |
Deserialize a database … | |
static enum MkErrorE | Sq3LiteDropModulesHide (SQ3_LITE db, MK_STRN *azKeep) |
Remove Unnecessary Virtual Table Implementations … | |
static enum MkErrorE | Sq3LiteFileControl (SQ3_LITE sq3lite, MK_STRN zDbName, enum Sq3TestCtrlE op, MK_PTR arg3) |
Low-Level Control Of Database Files … | |
static enum MkErrorE | Sq3LiteOverloadFunction (SQ3_LITE sq3lite, MK_STRN zFuncName, MK_I32 nArg) |
Overload A Function For A Virtual Table … | |
static enum MkErrorE | Sq3LiteDbStatus (SQ3_LITE sq3lite, enum Sq3DbStatusE op, MK_I32 *pCur, MK_I32 *pHiwtr, MK_BOOL resetFlg) |
Database Connection Status … | |
static MK_BIN | Sq3LiteSerializeHide (SQ3_LITE db, MK_STRN zSchema, MK_I64 *piSize, enum Sq3SerializeE mFlags) |
Serialize a database … | |
static enum MkErrorE | Sq3LiteTableColumnMetadata (SQ3_LITE db, MK_STRN zDbName, MK_STRN zTableName, MK_STRN zColumnName, MK_STRN *pzDataType, MK_STRN *pzCollSeq, MK_I32 *pNotNull, MK_I32 *pPrimaryKey, MK_I32 *pAutoinc) |
Extract Metadata About A Column Of A Table … | |
static MkBinaryR | Sq3LiteSerialize (SQ3_LITE sq3lite, MK_STRN zSchema, enum Sq3SerializeE mFlags) |
Serialize a database … | |
static enum MkErrorE | Sq3LiteDeserialize_RT (MK_RT mkrt, SQ3_LITE sq3lite, MK_STRN zSchema, MkBinaryR pData, enum Sq3DeSerializeEF mFlags) |
Deserialize a database … | |
enum MkErrorE | Sq3LiteVtabConfig (SQ3_LITE sq3lite, Sq3VtabE op,...) |
This function may be called by either the [xConnect] or [xCreate] method of a [virtual table] implementation to configure various facets of the virtual table interface. | |
static enum MkErrorE | Sq3LiteDbStatusBFL_RT (MK_RT mkrt, SQ3_LITE sq3lite, enum Sq3DbStatusE op, MK_BFL *val_out, MK_BOOL resetFlg) |
Database Connection Status … | |
enum MkErrorE | Sq3LiteDropModules_RT (MK_RT mkrt, SQ3_LITE sq3lite, MK_BFL azKeepBfl) |
Remove Unnecessary Virtual Table Implementations … | |
Sq3LiteC - various functions to perform misc operations …
#define Sq3Fupu_Sq3LiteAutovacuumPages_arg1_args MK_PTR arg0, MK_STRN arg1, MK_U32 arg2, MK_U32 arg3, MK_U32 arg4 |
Definition at line 104 of file Sq3LiteC_sq3.h.
#define Sq3Fupu_Sq3LiteAutovacuumPages_arg1_ret MK_U32 |
Definition at line 103 of file Sq3LiteC_sq3.h.
#define Sq3Fupu_Sq3LiteAutovacuumPages_arg3_args MK_PTR arg0 |
Definition at line 111 of file Sq3LiteC_sq3.h.
#define Sq3Fupu_Sq3LiteAutovacuumPages_arg3_ret void |
Definition at line 110 of file Sq3LiteC_sq3.h.
#define Sq3Fupu_Sq3LiteCreateCollation_xCompare_args MK_PTR arg0, MK_I32 arg1, MK_PTRN arg2, MK_I32 arg3, MK_PTRN arg4 |
Definition at line 118 of file Sq3LiteC_sq3.h.
#define Sq3Fupu_Sq3LiteCreateCollation_xCompare_ret MK_I32 |
Definition at line 117 of file Sq3LiteC_sq3.h.
#define Sq3LiteAutovacuumPages_C | ( | ... | ) |
Definition at line 432 of file sqlite3_overload_sq3.h.
#define Sq3LiteAutovacuumPages_E | ( | ... | ) |
Definition at line 431 of file sqlite3_overload_sq3.h.
#define Sq3LiteCreateCollation_C | ( | ... | ) |
Definition at line 434 of file sqlite3_overload_sq3.h.
#define Sq3LiteCreateCollation_E | ( | ... | ) |
Definition at line 433 of file sqlite3_overload_sq3.h.
#define Sq3LiteDbCacheflush_C | ( | ... | ) |
Definition at line 436 of file sqlite3_overload_sq3.h.
#define Sq3LiteDbCacheflush_E | ( | ... | ) |
Definition at line 435 of file sqlite3_overload_sq3.h.
#define Sq3LiteDbReadonly_C | ( | ... | ) |
Definition at line 438 of file sqlite3_overload_sq3.h.
#define Sq3LiteDbReadonly_E | ( | ... | ) |
Definition at line 437 of file sqlite3_overload_sq3.h.
#define Sq3LiteDbReleaseMemory_C | ( | ... | ) |
Definition at line 440 of file sqlite3_overload_sq3.h.
#define Sq3LiteDbReleaseMemory_E | ( | ... | ) |
Definition at line 439 of file sqlite3_overload_sq3.h.
#define Sq3LiteDbStatus_C | ( | ... | ) |
Definition at line 469 of file sqlite3_overload_sq3.h.
#define Sq3LiteDbStatus_E | ( | ... | ) |
Definition at line 468 of file sqlite3_overload_sq3.h.
#define Sq3LiteDbStatusBFL | ( | ... | ) |
Definition at line 426 of file sqlite3_overload_sq3.h.
#define Sq3LiteDbStatusBFL_C | ( | ... | ) |
Definition at line 428 of file sqlite3_overload_sq3.h.
#define Sq3LiteDbStatusBFL_E | ( | ... | ) |
Definition at line 427 of file sqlite3_overload_sq3.h.
#define Sq3LiteDbStatusBFL_NULL | ( | ... | ) |
Definition at line 425 of file sqlite3_overload_sq3.h.
#define Sq3LiteDeserialize | ( | ... | ) |
Definition at line 442 of file sqlite3_overload_sq3.h.
#define Sq3LiteDeserialize_C | ( | ... | ) |
Definition at line 444 of file sqlite3_overload_sq3.h.
#define Sq3LiteDeserialize_E | ( | ... | ) |
Definition at line 443 of file sqlite3_overload_sq3.h.
#define Sq3LiteDeserialize_NULL | ( | ... | ) |
Definition at line 441 of file sqlite3_overload_sq3.h.
#define Sq3LiteDeserializeHide_5 | ( | db, | |
zSchema, | |||
pData, | |||
szDb, | |||
szBuf ) |
Definition at line 445 of file sqlite3_overload_sq3.h.
#define Sq3LiteDeserializeHide_C | ( | ... | ) |
Definition at line 447 of file sqlite3_overload_sq3.h.
#define Sq3LiteDeserializeHide_E | ( | ... | ) |
Definition at line 446 of file sqlite3_overload_sq3.h.
#define Sq3LiteDropModules | ( | ... | ) |
Definition at line 449 of file sqlite3_overload_sq3.h.
#define Sq3LiteDropModules_C | ( | ... | ) |
Definition at line 451 of file sqlite3_overload_sq3.h.
#define Sq3LiteDropModules_E | ( | ... | ) |
Definition at line 450 of file sqlite3_overload_sq3.h.
#define Sq3LiteDropModules_NULL | ( | ... | ) |
Definition at line 448 of file sqlite3_overload_sq3.h.
#define Sq3LiteDropModulesHide_C | ( | ... | ) |
Definition at line 453 of file sqlite3_overload_sq3.h.
#define Sq3LiteDropModulesHide_E | ( | ... | ) |
Definition at line 452 of file sqlite3_overload_sq3.h.
#define Sq3LiteFileControl_C | ( | ... | ) |
Definition at line 455 of file sqlite3_overload_sq3.h.
#define Sq3LiteFileControl_E | ( | ... | ) |
Definition at line 454 of file sqlite3_overload_sq3.h.
#define Sq3LiteLog | ( | ... | ) |
Definition at line 457 of file sqlite3_overload_sq3.h.
#define Sq3LiteLog_1 | ( | lite | ) |
Definition at line 461 of file sqlite3_overload_sq3.h.
#define Sq3LiteLog_2 | ( | lite, | |
fmtobj ) |
Definition at line 460 of file sqlite3_overload_sq3.h.
#define Sq3LiteLog_3 | ( | lite, | |
fmtobj, | |||
debug ) |
Definition at line 459 of file sqlite3_overload_sq3.h.
#define Sq3LiteLog_4 | ( | lite, | |
fmtobj, | |||
debug, | |||
callfunc ) |
Definition at line 458 of file sqlite3_overload_sq3.h.
#define Sq3LiteLog_NULL | ( | ... | ) |
Definition at line 456 of file sqlite3_overload_sq3.h.
#define Sq3LiteOverloadFunction_C | ( | ... | ) |
Definition at line 463 of file sqlite3_overload_sq3.h.
#define Sq3LiteOverloadFunction_E | ( | ... | ) |
Definition at line 462 of file sqlite3_overload_sq3.h.
#define Sq3LiteSerializeHide_2 | ( | db, | |
zSchema ) |
Definition at line 471 of file sqlite3_overload_sq3.h.
#define Sq3LiteSerializeHide_3 | ( | db, | |
zSchema, | |||
piSize ) |
Definition at line 470 of file sqlite3_overload_sq3.h.
#define Sq3LiteTableColumnMetadata_C | ( | ... | ) |
Definition at line 473 of file sqlite3_overload_sq3.h.
#define Sq3LiteTableColumnMetadata_E | ( | ... | ) |
Definition at line 472 of file sqlite3_overload_sq3.h.
#define Sq3LiteVtabConfig | ( | sq3lite, | |
op, | |||
... ) |
Virtual Table Interface Configuration …
This function may be called by either the xConnect or xCreate method of a virtual table implementation to configure various facets of the virtual table interface.
If this interface is invoked outside the context of an xConnect or xCreate virtual table method then the behavior is undefined.
In the call Sq3LiteVtabConfig(D,C,...) the D parameter is the database connection in which the virtual table is being created and which is passed in as the first argument to the xConnect or xCreate method that is invoking Sq3LiteVtabConfig(). The C parameter is one of the virtual table configuration options. The presence and meaning of parameters after C depend on which virtual table configuration option is used.
Reference code from sqlite3:
Definition at line 635 of file Sq3LiteC_sq3.h.
#define Sq3LiteVtabConfig_C | ( | ... | ) |
Definition at line 465 of file sqlite3_overload_sq3.h.
#define Sq3LiteVtabConfig_E | ( | ... | ) |
Definition at line 464 of file sqlite3_overload_sq3.h.
typedef Sq3Fupu_Sq3LiteAutovacuumPages_arg1_ret(* Sq3Fupu_Sq3LiteAutovacuumPages_arg1) (Sq3Fupu_Sq3LiteAutovacuumPages_arg1_args) |
Definition at line 105 of file Sq3LiteC_sq3.h.
typedef Sq3Fupu_Sq3LiteAutovacuumPages_arg3_ret(* Sq3Fupu_Sq3LiteAutovacuumPages_arg3) (Sq3Fupu_Sq3LiteAutovacuumPages_arg3_args) |
Definition at line 112 of file Sq3LiteC_sq3.h.
typedef Sq3Fupu_Sq3LiteCreateCollation_xCompare_ret(* Sq3Fupu_Sq3LiteCreateCollation_xCompare) (Sq3Fupu_Sq3LiteCreateCollation_xCompare_args) |
Definition at line 119 of file Sq3LiteC_sq3.h.
|
inlinestatic |
Autovacuum Compaction Amount Callback …
The Sq3LiteAutovacuumPages(D,C,P,X) interface registers a callback function C that is invoked prior to each autovacuum of the database file. The callback is passed a copy of the generic data pointer (P), the schema-name of the attached database that is being autovacuumed, the size of the database file in pages, the number of free pages, and the number of bytes per page, respectively. The callback should return the number of free pages that should be removed by the autovacuum. If the callback returns zero, then no autovacuum happens. If the value returned is greater than or equal to the number of free pages, then a complete autovacuum happens.
If there are multiple ATTACH-ed database files that are being modified as part of a transaction commit, then the autovacuum pages callback is invoked separately for each file.
The callback is not reentrant. The callback function should not attempt to invoke any other SQLite interface. If it does, bad things may happen, including segmentation faults and corrupt database files. The callback function should be a simple function that does some arithmetic on its input parameters and returns a result.
The X parameter to Sq3LiteAutovacuumPages(D,C,P,X) is an optional destructor for the P parameter. If X is not NULL, then X(P) is invoked whenever the database connection closes or when the callback is overwritten by another invocation of Sq3LiteAutovacuumPages().
There is only one autovacuum pages callback per database connection. Each call to the Sq3LiteAutovacuumPages() interface overrides all previous invocations for that database connection. If the callback argument (C) to Sq3LiteAutovacuumPages(D,C,P,X) is a NULL pointer, then the autovacuum steps callback is canceled. The return value from Sq3LiteAutovacuumPages() is normally SQ3_RESULT_OK, but might be some other error code if something goes wrong. The current implementation will only return SQ3_RESULT_OK or SQ3_RESULT_MISUSE, but other return codes might be added in future releases.
If no autovacuum pages callback is specified (the usual case) or a NULL pointer is provided for the callback, then the default behavior is to vacuum all free pages. So, in other words, the default behavior is the same as if the callback function were something like this:
unsigned int demonstration_autovac_pages_callback( void *pClientData, const char *zSchema, unsigned int nDbPage, unsigned int nFreePage, unsigned int nBytePerPage ){ return nFreePage; }
Reference code from sqlite3:
Definition at line 321 of file Sq3LiteC_sq3.h.
enum MkErrorE Sq3LiteAutovacuumPagesP | ( | SQ3_LITE | db, |
Sq3Fupu_Sq3LiteAutovacuumPages_arg1 | arg1, | ||
MK_PTR | arg2, | ||
Sq3Fupu_Sq3LiteAutovacuumPages_arg3 | arg3 ) |
Non-inline replacement for Sq3LiteAutovacuumPages …
|
inlinestatic |
Define New Collating Sequences …
These functions add, remove, or modify a collation associated with the database connection specified as the first argument.
The name of the collation is a UTF-8 string for Sq3LiteCreateCollation() and sqlite3_create_collation_v2() and a UTF-16 string in native byte order for sqlite3_create_collation16(). Collation names that compare equal according to Sq3StrNicmp () are considered to be the same name.
The third argument (eTextRep) must be one of the constants:
The eTextRep argument determines the encoding of strings passed to the collating function callback, xCompare. The SQ3_TEXT_UTF16 and SQ3_TEXT_UTF16_ALIGNED values for eTextRep force strings to be UTF16 with native byte order. The SQ3_TEXT_UTF16_ALIGNED value for eTextRep forces strings to begin on an even byte address.
The fourth argument, pArg, is an application data pointer that is passed through as the first argument to the collating function callback.
The fifth argument, xCompare, is a pointer to the collating function. Multiple collating functions can be registered using the same name but with different eTextRep parameters and SQLite will use whichever function requires the least amount of data transformation. If the xCompare argument is NULL then the collating function is deleted. When all collating functions having the same name are deleted, that collation is no longer usable.
The collating function callback is invoked with a copy of the pArg application data pointer and with two strings in the encoding specified by the eTextRep argument. The two integer parameters to the collating function callback are the length of the two strings, in bytes. The collating function must return an integer that is negative, zero, or positive if the first string is less than, equal to, or greater than the second, respectively. A collating function must always return the same answer given the same inputs. If two or more collating functions are registered to the same collation name (using different eTextRep values) then all must give an equivalent answer when invoked with equivalent strings. The collating function must obey the following properties for all strings A, B, and C:
If a collating function fails any of the above constraints and that collating function is registered and used, then the behavior of SQLite is undefined.
The sqlite3_create_collation_v2() works like Sq3LiteCreateCollation() with the addition that the xDestroy callback is invoked on pArg when the collating function is deleted. Collating functions are deleted when they are overridden by later calls to the collation creation functions or when the database connection is closed using sqlite3_close ().
The xDestroy callback is not called if the sqlite3_create_collation_v2() function fails. Applications that invoke sqlite3_create_collation_v2() with a non-NULL xDestroy argument should check the return code and dispose of the application data pointer themselves rather than expecting SQLite to deal with it for them. This is different from every other SQLite interface. The inconsistency is unfortunate but cannot be changed without breaking backwards compatibility.
See also: sqlite3_collation_needed () and sqlite3_collation_needed16 ().
Reference code from sqlite3:
Definition at line 331 of file Sq3LiteC_sq3.h.
enum MkErrorE Sq3LiteCreateCollationP | ( | SQ3_LITE | sq3lite, |
MK_STRN | zName, | ||
MK_I32 | eTextRep, | ||
MK_PTR | pArg, | ||
Sq3Fupu_Sq3LiteCreateCollation_xCompare | xCompare ) |
Non-inline replacement for Sq3LiteCreateCollation …
Flush caches to disk mid-transaction …
If a write-transaction is open on database connection D when the Sq3LiteDbCacheflush (D) interface invoked, any dirty pages in the pager-cache that are not currently in use are written out to disk. A dirty page may be in use if a database cursor created by an active SQL statement is reading from it, or if it is page 1 of a database file (page 1 is always "in use"). The Sq3LiteDbCacheflush (D) interface flushes caches for all schemas - "main", "temp", and any attached databases.
If this function needs to obtain extra database locks before dirty pages can be flushed to disk, it does so. If those locks cannot be obtained immediately and there is a busy-handler callback configured, it is invoked in the usual manner. If the required lock still cannot be obtained, then the database is skipped and an attempt made to flush any dirty pages belonging to the next (if any) database. If any databases are skipped because locks cannot be obtained, but no other error occurs, this function returns SQ3_RESULT_BUSY.
If any other error occurs while flushing dirty pages to disk (for example an IO error or out-of-memory condition), then processing is abandoned and an SQLite error code is returned to the caller immediately.
Otherwise, if no error occurs, Sq3LiteDbCacheflush () returns SQ3_RESULT_OK.
This function does not set the database handle error code or message returned by the Sq3LiteErrCode () and Sq3LiteErrMsg () functions.
Reference code from sqlite3:
Definition at line 341 of file Sq3LiteC_sq3.h.
Non-inline replacement for Sq3LiteDbCacheflush …
Return The Filename For A Database Connection …
The Sq3LiteDbFilename(D,N) interface returns a pointer to the filename associated with database N of connection D. If there is no attached database N on the database connection D, or if database N is a temporary or in-memory database, then this function will return either a NULL pointer or an empty string.
The string value returned by this routine is owned and managed by the database connection. The value will be valid until the database N is DETACH-ed or until the database connection closes.
The filename returned by this function is the output of the xFullPathname method of the VFS. In other words, the filename will be an absolute pathname, even if the filename used to open the database originally was a URI or relative pathname.
If the filename pointer returned by this routine is not NULL, then it can be used as the filename input parameter to these routines:
Reference code from sqlite3:
Definition at line 351 of file Sq3LiteC_sq3.h.
Non-inline replacement for Sq3LiteDbFilename …
Return The Schema Name For A Database Connection …
The Sq3LiteDbName(D,N) interface returns a pointer to the schema name for the N-th database on database connection D, or a NULL pointer of N is out of range. An N value of 0 means the main database file. An N of 1 is the "temp" schema. Larger values of N correspond to various ATTACH-ed databases.
Space to hold the string that is returned by Sq3LiteDbName() is managed by SQLite itself. The string might be deallocated by any operation that changes the schema, including ATTACH or DETACH or calls to Sq3LiteSerialize () or Sq3LiteDeserialize (), even operations that occur on a different thread. Applications that need to remember the string long-term should make their own copy. Applications that are accessing the same database connection simultaneously on multiple threads should mutex-protect calls to this API and should make their own private copy of the result prior to releasing the mutex.
Reference code from sqlite3:
Definition at line 358 of file Sq3LiteC_sq3.h.
Non-inline replacement for Sq3LiteDbName …
Determine if a database is read-only …
The Sq3LiteDbReadonly(D,N) interface returns 1 if the database N of connection D is read-only, 0 if it is read/write, or -1 if N is not the name of a database on connection D.
Reference code from sqlite3:
Definition at line 365 of file Sq3LiteC_sq3.h.
Non-inline replacement for Sq3LiteDbReadonly …
Free Memory Used By A Database Connection …
The Sq3LiteDbReleaseMemory(D) interface attempts to free as much heap memory as possible from database connection D. Unlike the Sq3ReleaseMemory () interface, this interface is in effect even when the SQLITE_ENABLE_MEMORY_MANAGEMENT compile-time option is omitted.
See also: Sq3ReleaseMemory ()
Reference code from sqlite3:
Definition at line 375 of file Sq3LiteC_sq3.h.
Non-inline replacement for Sq3LiteDbReleaseMemory …
|
inlinestatic |
Database Connection Status …
This interface is used to retrieve runtime status information about a single database connection. The first argument is the database connection object to be interrogated. The second argument is an integer constant, taken from the set of SQ3_DBSTATUS options, that determines the parameter to interrogate. The set of SQ3_DBSTATUS options is likely to grow in future releases of SQLite.
The current value of the requested parameter is written into *pCur and the highest instantaneous value is written into *pHiwtr. If the resetFlg is true, then the highest instantaneous value is reset back down to the current value.
The Sq3LiteDbStatus() routine returns SQ3_RESULT_OK on success and a non-zero error code on failure.
See also: Sq3Status () and Sq3StmtStatus ().
Reference code from sqlite3:
Definition at line 427 of file Sq3LiteC_sq3.h.
|
inlinestatic |
Database Connection Status …
This interface is used to retrieve runtime status information about a single database connection. The first argument is the database connection object to be interrogated. The second argument is an integer constant, taken from the set of SQ3_DBSTATUS options, that determines the parameter to interrogate. The set of SQ3_DBSTATUS options is likely to grow in future releases of SQLite.
The current value of the requested parameter is written into *pCur and the highest instantaneous value is written into *pHiwtr. If the resetFlg is true, then the highest instantaneous value is reset back down to the current value.
The Sq3LiteDbStatus() routine returns SQ3_RESULT_OK on success and a non-zero error code on failure.
See also: Sq3Status () and Sq3StmtStatus ().
Reference code from sqlite3:
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | sq3lite | the Sq3LiteC instance to work on a database |
[in] | op | a value from the enum Sq3DbStatusE |
[out] | val_out | The return-value have to be none null. |
[in] | resetFlg | If the resetFlg is true, then the highest instantaneous value is reset back down to the current value. |
MkExceptionC | → The default-exception from the Programming-Language-Micro-Kernel (PLMK) |
Definition at line 658 of file Sq3LiteC_sq3.h.
enum MkErrorE Sq3LiteDbStatusBFLP | ( | MK_RT | mkrt, |
SQ3_LITE | sq3lite, | ||
enum Sq3DbStatusE | op, | ||
MK_BFL * | val_out, | ||
MK_BOOL | resetFlg ) |
Non-inline replacement for Sq3LiteDbStatusBFL …
enum MkErrorE Sq3LiteDbStatusP | ( | SQ3_LITE | sq3lite, |
enum Sq3DbStatusE | op, | ||
MK_I32 * | pCur, | ||
MK_I32 * | pHiwtr, | ||
MK_BOOL | resetFlg ) |
Non-inline replacement for Sq3LiteDbStatus …
|
inlinestatic |
Deserialize a database …
This is an enhanced version of Sq3LiteDeserializeHide, the return value changed to MkBinaryR.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | sq3lite | the Sq3LiteC instance to work on a database |
[in] | zSchema | Which DB to reopen with the deserialization |
[in] | pData | The serialized database content |
[in] | mFlags | Zero or more Sq3SerializeE flags |
MkExceptionC | → The default-exception from the Programming-Language-Micro-Kernel (PLMK) |
Definition at line 601 of file Sq3LiteC_sq3.h.
|
inlinestatic |
Deserialize a database …
The Sq3LiteDeserialize(D,S,P,N,M,F) interface causes the database connection D to disconnect from database S and then reopen S as an in-memory database based on the serialization contained in P. The serialized database P is N bytes in size. M is the size of the buffer P, which might be larger than N. If M is larger than N, and the SQ3_DESERIALIZE_READONLY bit is not set in F, then SQLite is permitted to add content to the in-memory database as long as the total size does not exceed M bytes.
If the SQ3_DESERIALIZE_FREEONCLOSE bit is set in F, then SQLite will invoke Sq3Free() on the serialization buffer when the database connection closes. If the SQ3_DESERIALIZE_RESIZEABLE bit is set, then SQLite will try to increase the buffer size using Sq3Realloc64() if writes on the database cause it to grow larger than M bytes.
Applications must not modify the buffer P or invalidate it before the database connection D is closed.
The Sq3LiteDeserialize() interface will fail with SQ3_RESULT_BUSY if the database is currently in a read transaction or is involved in a backup operation.
It is not possible to deserialized into the TEMP database. If the S argument to Sq3LiteDeserialize(D,S,P,N,M,F) is "temp" then the function returns SQ3_RESULT_ERROR.
The deserialized database should not be in WAL mode. If the database is in WAL mode, then any attempt to use the database file will result in an SQ3_RESULT_CANTOPEN error. The application can set the file format version numbers (bytes 18 and 19) of the input database P to 0x01 prior to invoking Sq3LiteDeserialize(D,S,P,N,M,F) to force the database file into rollback mode and work around this limitation.
If Sq3LiteDeserialize(D,S,P,N,M,F) fails for any reason and if the SQ3_DESERIALIZE_FREEONCLOSE bit is set in argument F, then Sq3Free () is invoked on argument P prior to returning.
This interface is omitted if SQLite is compiled with the SQLITE_OMIT_DESERIALIZE option.
Reference code from sqlite3:
Definition at line 385 of file Sq3LiteC_sq3.h.
enum MkErrorE Sq3LiteDeserializeHideP | ( | SQ3_LITE | db, |
MK_STRN | zSchema, | ||
MK_BIN | pData, | ||
MK_I64 | szDb, | ||
MK_I64 | szBuf, | ||
enum Sq3DeSerializeEF | mFlags ) |
Non-inline replacement for Sq3LiteDeserializeHide …
enum MkErrorE Sq3LiteDeserializeP | ( | MK_RT | mkrt, |
SQ3_LITE | sq3lite, | ||
MK_STRN | zSchema, | ||
MkBinaryR | pData, | ||
enum Sq3DeSerializeEF | mFlags ) |
Non-inline replacement for Sq3LiteDeserialize …
Remove Unnecessary Virtual Table Implementations …
This is an enhanced version of Sq3LiteDropModulesHide.
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | sq3lite | the Sq3LiteC instance to work on a database |
azKeepBfl | The MkBufferListC list of modules to drop |
MkExceptionC | → The default-exception from the Programming-Language-Micro-Kernel (PLMK) |
Remove Unnecessary Virtual Table Implementations …
The Sq3LiteDropModules(D,L) interface removes all virtual table modules from database connection D except those named on list L. The L parameter must be either NULL or a pointer to an array of pointers to strings where the array is terminated by a single NULL pointer. If the L parameter is NULL, then all virtual table modules are removed.
See also: sqlite3_create_module ()
Reference code from sqlite3:
Definition at line 395 of file Sq3LiteC_sq3.h.
Non-inline replacement for Sq3LiteDropModulesHide …
|
inlinestatic |
Low-Level Control Of Database Files …
The Sq3LiteFileControl () interface makes a direct call to the xFileControl method for the sqlite3_io_methods object associated with a particular database identified by the second argument. The name of the database is "main" for the main database or "temp" for the TEMP database, or the name that appears after the AS keyword for databases that are added using the ATTACH SQL command. A NULL pointer can be used in place of "main" to refer to the main database file. The third and fourth parameters to this routine are passed directly through to the second and third parameters of the xFileControl method. The return value of the xFileControl method becomes the return value of this routine.
A few opcodes for Sq3LiteFileControl () are handled directly by the SQLite core and never invoke the sqlite3_io_methods.xFileControl method. The SQ3_FCNTL_FILE_POINTER value for the op parameter causes a pointer to the underlying Sq3FileC object to be written into the space pointed to by the 4th parameter. The SQ3_FCNTL_JOURNAL_POINTER works similarly except that it returns the Sq3FileC object associated with the journal file instead of the main database. The SQ3_FCNTL_VFS_POINTER opcode returns a pointer to the underlying sqlite3_vfs object for the file. The SQ3_FCNTL_DATA_VERSION returns the data version counter from the pager.
If the second parameter (zDbName) does not match the name of any open database file, then SQ3_RESULT_ERROR is returned. This error code is not remembered and will not be recalled by Sq3LiteErrCode () or Sq3LiteErrMsg (). The underlying xFileControl method might also return SQ3_RESULT_ERROR. There is no way to distinguish between an incorrect zDbName and an SQ3_RESULT_ERROR return from the underlying xFileControl method.
See also: file control opcodes
Reference code from sqlite3:
Definition at line 405 of file Sq3LiteC_sq3.h.
enum MkErrorE Sq3LiteFileControlP | ( | SQ3_LITE | sq3lite, |
MK_STRN | zDbName, | ||
enum Sq3TestCtrlE | op, | ||
MK_PTR | arg3 ) |
Non-inline replacement for Sq3LiteFileControl …
void Sq3LiteLog_RT | ( | MK_RT | mkrt, |
SQ3_LITEN const | lite, | ||
MK_OBJN | fmtobj, | ||
MK_DBG const | debug, | ||
MK_STRN const | callfunc, | ||
MK_I32 const | lvl ) |
log the lite …
[in] | mkrt | the MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only) |
[in] | lite | Programming-Language-Micro-Kernel (PLMK) instance from libsqlite3 |
[in] | fmtobj | managed object used to format the log-message (default=null → use default-format) |
[in] | debug | the debug level from MkRuntimeS::debug, use 0 <= debug <= 9 (default=0 ) |
[in] | callfunc | a user-defined postfix to identify the calling function or the environment (default=name-of-function ) |
[in] | lvl | a user-defined prefix starting with "" for lvl=0 and increase with " " for lvl+1 (default=0 ) |
|
inlinestatic |
Overload A Function For A Virtual Table …
Virtual tables can provide alternative implementations of functions using the xFindFunction method of the virtual table module. But global versions of those functions must exist in order to be overloaded.
This API makes sure a global version of a function with a particular name and number of parameters exists. If no such function exists before this API is called, a new function is created. The implementation of the new function always causes an exception to be thrown. So the new function is not good for anything by itself. Its only purpose is to be a placeholder function that can be overloaded by a virtual table.
Reference code from sqlite3:
Definition at line 415 of file Sq3LiteC_sq3.h.
Non-inline replacement for Sq3LiteOverloadFunction …
|
inlinestatic |
Serialize a database …
This is an enhanced version of Sq3LiteSerializeHide, the return value changed to MkBinaryR.
[in] | sq3lite | the Sq3LiteC instance to work on a database |
[in] | zSchema | Which DB to serialize. ex: "main", "temp", ... |
[in] | mFlags | Zero or more Sq3SerializeE flags |
Definition at line 579 of file Sq3LiteC_sq3.h.
|
inlinestatic |
Serialize a database …
The Sq3LiteSerialize(D,S,P,F) interface returns a pointer to memory that is a serialization of the S database on database connection D. If P is not a NULL pointer, then the size of the database in bytes is written into *P.
For an ordinary on-disk database file, the serialization is just a copy of the disk file. For an in-memory database or a "TEMP" database, the serialization is the same sequence of bytes which would be written to disk if that database where backed up to disk.
The usual case is that Sq3LiteSerialize() copies the serialization of the database into memory obtained from Sq3Malloc64 () and returns a pointer to that memory. The caller is responsible for freeing the returned value to avoid a memory leak. However, if the F argument contains the SQ3_SERIALIZE_NOCOPY bit, then no memory allocations are made, and the Sq3LiteSerialize() function will return a pointer to the contiguous memory representation of the database that SQLite is currently using for that database, or NULL if the no such contiguous memory representation of the database exists. A contiguous memory representation of the database will usually only exist if there has been a prior call to Sq3LiteDeserialize (D,S,...) with the same values of D and S. The size of the database is written into *P even if the SQ3_SERIALIZE_NOCOPY bit is set but no contiguous copy of the database exists.
After the call, if the SQ3_SERIALIZE_NOCOPY bit had been set, the returned buffer content will remain accessible and unchanged until either the next write operation on the connection or when the connection is closed, and applications must not modify the buffer. If the bit had been clear, the returned buffer will not be accessed by SQLite after the call.
A call to Sq3LiteSerialize(D,S,P,F) might return NULL even if the SQ3_SERIALIZE_NOCOPY bit is omitted from argument F if a memory allocation error occurs.
This interface is omitted if SQLite is compiled with the SQLITE_OMIT_DESERIALIZE option.
Reference code from sqlite3:
Definition at line 437 of file Sq3LiteC_sq3.h.
MK_BIN Sq3LiteSerializeHideP | ( | SQ3_LITE | db, |
MK_STRN | zSchema, | ||
MK_I64 * | piSize, | ||
enum Sq3SerializeE | mFlags ) |
Non-inline replacement for Sq3LiteSerializeHide …
MkBinaryR Sq3LiteSerializeP | ( | SQ3_LITE | sq3lite, |
MK_STRN | zSchema, | ||
enum Sq3SerializeE | mFlags ) |
Non-inline replacement for Sq3LiteSerialize …
|
inlinestatic |
Extract Metadata About A Column Of A Table …
The Sq3LiteTableColumnMetadata(X,D,T,C,....) routine returns information about column C of table T in database D on database connection X. The Sq3LiteTableColumnMetadata() interface returns SQ3_RESULT_OK and fills in the non-NULL pointers in the final five arguments with appropriate values if the specified column exists. The Sq3LiteTableColumnMetadata() interface returns SQ3_RESULT_ERROR if the specified column does not exist. If the column-name parameter to Sq3LiteTableColumnMetadata() is a NULL pointer, then this routine simply checks for the existence of the table and returns SQ3_RESULT_OK if the table exists and SQ3_RESULT_ERROR if it does not. If the table name parameter T in a call to Sq3LiteTableColumnMetadata(X,D,T,C,...) is NULL then the result is undefined behavior.
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.
The third and fourth parameters to this function are the table and column name of the desired column, respectively.
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.
Parameter Output
TypeDescription
5th const char* Data type 6th const char* Name of default collation sequence 7th int True if column has a NOT NULL constraint 8th int True if column is part of the PRIMARY KEY 9th int True if column is AUTOINCREMENT
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.
If the specified table is actually a view, an error code is returned.
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:
data type: "INTEGER" collation sequence: "BINARY" not null: 0 primary key: 1 auto increment: 0
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.
Reference code from sqlite3:
Definition at line 443 of file Sq3LiteC_sq3.h.
enum MkErrorE Sq3LiteTableColumnMetadataP | ( | SQ3_LITE | db, |
MK_STRN | zDbName, | ||
MK_STRN | zTableName, | ||
MK_STRN | zColumnName, | ||
MK_STRN * | pzDataType, | ||
MK_STRN * | pzCollSeq, | ||
MK_I32 * | pNotNull, | ||
MK_I32 * | pPrimaryKey, | ||
MK_I32 * | pAutoinc ) |
Non-inline replacement for Sq3LiteTableColumnMetadata …
This function may be called by either the [xConnect] or [xCreate] method of a [virtual table] implementation to configure various facets of the virtual table interface.
If this interface is invoked outside the context of an xConnect or xCreate virtual table method then the behavior is undefined.
In the call sqlite3_vtab_config(D,C,...) the D parameter is the [database connection] in which the virtual table is being created and which is passed in as the first argument to the [xConnect] or [xCreate] method that is invoking sqlite3_vtab_config(). The C parameter is one of the [virtual table configuration options]. The presence and meaning of parameters after C depend on which [virtual table configuration option] is used.
[in] | sq3lite | the Sq3LiteC instance to work on a database |
[in] | op | configuration option to set |
MkExceptionC | → The default-exception from the Programming-Language-Micro-Kernel (PLMK) |