theSq3Lite 10.0 NHI1 - theKernel - theLink - theConfig - theSq3Lite - theCompiler - theBrain - theGuard
c - tcl - py - rb - jv - cc
Loading...
Searching...
No Matches
libsq3lite

Support the libsqlite3 native library.

SYNOPSIS

The libsq3lite package is a library for using the sqlite3 database

link: -Lpath -lsq3lite or automake: LDADD = libsq3lite.la

The libsq3lite package is a composition of multiple classes defining the Programming-Language-Micro-Kernel (PLMK) :

object description
Sq3 the namespace with all libsq3lite specific definitions
Sq3Attribute(…) the interface to access the package specific attribute
Sq3ClassAttribute(…) the interface to access the class specific attribute
Sq3ClassAttribute(Instance,…) the interface to access the instance specific attribute

To access all features without Sq3 prefix use:

#include "LibSq3Lite_lc.h"

Using the libsq3lite package ...

Using automake/libtool the libsq3lite library have to be linked with the executable/library, this is done with:

‍LDADD = path/to/libsq3lite.la

or

‍mylib_la_LIBADD = path/to/libsq3lite.la

Example from acmds/Makefile.am using libmkkernel.la and libmqmsgque.la:
atool_SOURCES = atool.c ajoin.c acut.c asort.c asplit.c optionL.c optionL.h
atool_CPPFLAGS = $(libmqmsgque_CPPFLAGS)
atool_CFLAGS = $(libmqmsgque_CFLAGS)
atool_LDFLAGS = @noversion_LDFLAGS@
atool_LDADD = $(libmqmsgque_LIBADD_shared)

TABLE OF CONTENTS

PACKAGE
Philosophy ,
CLASS
Sq3Lite PACKAGE , Sq3LiteC , Sq3ValueC , Sq3StmtC , Sq3BlobC , Sq3FileC ,
MISC
Examples

INTRODUCTION

C-API: SQ3_C_API - The Sq3Lite API.

SQLite is an in-process library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine.

License

The code for SQLite is in the public domain and is thus free for use for any purpose, commercial or private.


Sq3Lite PACKAGE

Sq3Lite SETUP

libsq3lite META - Setup und Cleanup the Meta Library libsq3lite
libsqlite3

NATIVE - Initialize The SQLite Library libsqlite3

Sq3Lite ENUM

enum Sq3VtabE Virtual Table Configuration Options.
enum Sq3TypeE Fundamental Datatypes.
enum Sq3TxnE Allowed return values from sqlite3_txn_state()
enum Sq3TraceEF SQL Trace Event Codes.
enum Sq3TextE Text Encodings.
enum Sq3TestCtrlE Testing Interface Operation Codes.
enum Sq3SyncEF Synchronization Type Flags.
enum Sq3StmtStatusE Status Parameters for prepared statements.
enum Sq3StatusE Status Parameters.
enum Sq3ShmLockE Flags for the xShmLock VFS method.
enum Sq3SessionObjConfigE Options for sqlite3session_object_config.
enum Sq3SerializeE Flags for sqlite3_serialize.
enum Sq3ScanStatE Prepared Statement Scan Status Opcodes.
enum Sq3PrepareEF Prepare Flags.
enum Sq3OpenEF Flags For File Open Operations.
enum Sq3MutexE Mutex Types.
enum Sq3LockE File Locking Levels.
enum Sq3LimitE Run-Time Limit Categories.
enum Sq3IoCapEF Device Characteristics.
enum Sq3IndexConstraintEF Virtual Table Constraint Operator Codes.
enum Sq3FunctionEF Function Flags.
enum Sq3FcntlE Standard File Control Opcodes.
enum Sq3ExtendetResultCodesE Extended Result Codes.
enum Sq3ErrorE Result Codes.
enum Sq3DeSerializeEF Flags for sqlite3_deserialize()
enum Sq3DbStatusE Status Parameters for database connections.
enum Sq3DbConfigE Database Connection Configuration Options.
enum Sq3ConflictResolutionE Conflict resolution modes.
enum Sq3ConfigE Configuration Options.
enum Sq3CheckpointE Checkpoint Mode Values.
enum Sq3ChangesetE Constants Passed To The Conflict Handler.
enum Sq3ChangeSetConflictE Constants Returned By The Conflict Handler.
enum Sq3AuthReturnE Authorizer Return Codes.
enum Sq3AuthActionE Authorizer Action Codes.
enum Sq3AccessE

Flags for the xAccess VFS method.

Sq3Lite CONFIG

CompileOptionGet Run-Time Library Compilation Options Diagnostics …
CompileOptionUsed Run-Time Library Compilation Options Diagnostics …
ProgressHandler Query Progress Callbacks …
SetAuthorizer Compile-Time Authorization Callbacks …
MemoryHighwater Memory Allocator Statistics …
MemoryUsed Memory Allocator Statistics …
Randomness Pseudo-Random Number Generator …
SetupThreadCallback Initialize a callback which is called at runtime-setup
Threadsafe

Test To See If The Library Is Threadsafe …

Sq3Lite INFO

Complete Determine If An SQL Statement Is Complete …
KeywordCheck SQL Keyword Checking …
KeywordCount SQL Keyword Checking …
KeywordName SQL Keyword Checking …
KeywordNameBUF SQL Keyword Checking …
Status SQLite Runtime Status …
Status64

SQLite Runtime Status …

Sq3Lite INTERNAL

Alloc Memory Allocation Subsystem …
Memory Sq3Lite PACKAGE - functions related to index 'Internal' and doc 'Memory' …
String

Sq3Lite PACKAGE - functions related to index 'Internal' and doc 'String' …

Sq3Lite VERSION

Libversion Run-Time Library Version Numbers …
LibversionNumber Run-Time Library Version Numbers …
Sourceid

Run-Time Library Version Numbers …

Sq3Lite VFS

CreateFilename Create and Destroy VFS Filenames …
FilenameDatabase Translate filenames …
FilenameJournal Translate filenames …
FilenameWal Translate filenames …
FreeFilename Create and Destroy VFS Filenames …
UriBoolean Obtain Values For URI Parameters …
UriInt64 Obtain Values For URI Parameters …
UriKey Obtain Values For URI Parameters …
UriParameter

Obtain Values For URI Parameters …

Sq3Lite ERROR

ErrorCheckI check if ret signal an error
ErrorToMQ

if a libsq3lite funtion return a MkErrorE use this function to convert the libsq3lite-error into the libmkkernel-error

Sq3Lite DETAIL

C-API: Sq3Lite_C_API - Sq3Lite PACKAGE - toplevel package of the Programming-Language-Micro-Kernel (PLMK)

The libsq3lite package is loaded with:

link: -Lpath -lsq3lite or automake: LDADD = libsq3lite.la

and is a composition of one or more package-item and exact one package-main.

The libsq3lite package add the following classes into MkObjectC_C_API :

Object C-Short Description
Sq3LiteC SQ3_LITE Sq3LiteC - the class known as sq3lite or Lite defined by Sq3LiteS
Sq3ValueC SQ3_VAL Sq3ValueC - the class known as sq3val or Value define by Sq3ValueS
Sq3BlobC SQ3_BLOB Sq3BlobC - the class known as sq3blob or Blob define by Sq3BlobS
Sq3FileC SQ3_FILE Sq3FileC - the class known as sq3file or File defined by Sq3FileS
Sq3StmtC SQ3_STMT Sq3StmtC - the class known as sq3stmt or Statement defined by Sq3StmtS

The libsq3lite package add the following types into MkObjectC_C_API :

    ABSTRACT: MkTypeSTT (TypeTypeType = type of a TypeType)
    |
    |- ABSTRACT: MkSuperTypeSTT (TypeType = type of a Type)
       |
       |- Sq3LiteST, Sq3ValueST, Sq3BlobST, Sq3FileST, Sq3StmtST

Sq3Lite SETUP

NAVI: top, up

Sq3Lite SETUP LIBSQ3LITE

Cleanup cleanup libsq3lite internal memory …
Setup

setup libsq3lite internal memory …

Sq3Lite SETUP LIBSQLITE3

Initialize Initialize The SQLite Library …
OsEnd Initialize The SQLite Library …
OsInit Initialize The SQLite Library …
Shutdown

Initialize The SQLite Library …

Sq3Lite SETUP DETAILS

C-API: Sq3Lite_Setup_C_API - Sq3Lite PACKAGE - setup library and Programming-Language-Micro-Kernel (PLMK)

Sq3Lite SETUP LIBSQ3LITE

C-API: Sq3Lite_Setup_libsq3lite_C_API - META - Setup und Cleanup the Meta Library libsq3lite

For details about Setup and Cleanup usage refer to MkKernel_Setup_libmkkernel_C_API

(static) void Sq3Cleanup()

top cleanup libsq3lite internal memory … → API: Sq3Cleanup

MkCleanup can only be called once and will be ignored if not called in the same thread as Sq3Setup. after a call to Sq3Setup the call to MkCleanup is possible again.

Attention
during cleanup objects will be deleted too -> the language interpreter have to be active

(static) void Sq3Setup()

top setup libsq3lite internal memory … → API: Sq3Setup

Sq3Setup can only be called once, additional call's will be ignored until a Sq3Cleanup is called.

Sq3Lite SETUP LIBSQLITE3

C-API: Sq3Lite_Setup_libsqlite3_C_API - NATIVE - Initialize The SQLite Library libsqlite3

Initialize The SQLite Library …

The Sq3Initialize() routine initializes the SQLite library. The Sq3Shutdown() routine deallocates any resources that were allocated by Sq3Initialize(). These routines are designed to aid in process initialization and shutdown on embedded systems. Workstation applications using SQLite normally do not need to invoke either of these routines.

A call to Sq3Initialize() is an "effective" call if it is the first time Sq3Initialize() is invoked during the lifetime of the process, or if it is the first time Sq3Initialize() is invoked following a call to Sq3Shutdown(). Only an effective call of Sq3Initialize() does any initialization. All other calls are harmless no-ops.

A call to Sq3Shutdown() is an "effective" call if it is the first call to Sq3Shutdown() since the last Sq3Initialize(). Only an effective call to Sq3Shutdown() does any deinitialization. All other valid calls to Sq3Shutdown() are harmless no-ops.

The Sq3Initialize() interface is threadsafe, but Sq3Shutdown() is not. The Sq3Shutdown() interface must only be called from a single thread. All open database connections must be closed and all other SQLite resources must be deallocated prior to invoking Sq3Shutdown().

Among other things, Sq3Initialize() will invoke Sq3OsInit(). Similarly, Sq3Shutdown() will invoke Sq3OsEnd().

The Sq3Initialize() routine returns SQ3_RESULT_OK on success. If for some reason, Sq3Initialize() is unable to initialize the library (perhaps it is unable to allocate a needed resource such as a mutex) it returns an error code other than SQ3_RESULT_OK.

The Sq3Initialize() routine is called internally by many other SQLite interfaces so that an application usually does not need to invoke Sq3Initialize() directly. For example, sqlite3_open () calls Sq3Initialize() so the SQLite library will be automatically initialized when sqlite3_open () is called if it has not be initialized already. However, if SQLite is compiled with the SQLITE_OMIT_AUTOINIT compile-time option, then the automatic calls to Sq3Initialize() are omitted and the application must call Sq3Initialize() directly prior to using any other SQLite interface. For maximum portability, it is recommended that applications always invoke Sq3Initialize() directly prior to using any other SQLite interface. Future releases of SQLite may require this. In other words, the behavior exhibited when SQLite is compiled with SQLITE_OMIT_AUTOINIT might become the default behavior in some future release of SQLite.

The Sq3OsInit() routine does operating-system specific initialization of the SQLite library. The Sq3OsEnd() routine undoes the effect of Sq3OsInit(). Typical tasks performed by these routines include allocation or deallocation of static resources, initialization of global variables, setting up a default sqlite3_vfs module, or setting up a default configuration using sqlite3_config ().

The application should never invoke either Sq3OsInit() or Sq3OsEnd() directly. The application should only invoke Sq3Initialize() and Sq3Shutdown(). The Sq3OsInit() interface is called automatically by Sq3Initialize() and Sq3OsEnd() is called by Sq3Shutdown(). Appropriate implementations for Sq3OsInit() and Sq3OsEnd() are built into SQLite when it is compiled for Unix, Windows, or OS/2. When built for other platforms (using the SQLITE_OS_OTHER=1 compile-time option) the application must supply a suitable implementation for Sq3OsInit() and Sq3OsEnd(). An application-supplied implementation of Sq3OsInit() or Sq3OsEnd() must return SQ3_RESULT_OK on success and some other error code upon failure.

Reference code from sqlite3:

#define SQLITE_API
SQLITE_API int sqlite3_os_end(void)
SQLITE_API int sqlite3_initialize(void)
SQLITE_API int sqlite3_os_init(void)
SQLITE_API int sqlite3_shutdown(void)

(static) enum MkErrorE Sq3Initialize()

top Initialize The SQLite Library … → API: Sq3Initialize

read more at 'Sq3Lite_Setup_libsqlite3_C_API'

(static) enum MkErrorE Sq3OsEnd()

top Initialize The SQLite Library … → API: Sq3OsEnd

read more at 'Sq3Lite_Setup_libsqlite3_C_API'

(static) enum MkErrorE Sq3OsInit()

top Initialize The SQLite Library … → API: Sq3OsInit

read more at 'Sq3Lite_Setup_libsqlite3_C_API'

(static) enum MkErrorE Sq3Shutdown()

top Initialize The SQLite Library … → API: Sq3Shutdown

read more at 'Sq3Lite_Setup_libsqlite3_C_API'

Sq3Lite ENUM

C-API: Sq3Lite_Enum_C_API - Sq3Lite PACKAGE - definition of the enum type …

read more at: MkKernel_Enum_C_API

enum Sq3AccessE

top Flags for the xAccess VFS method. → API: Sq3AccessE

Flags for the xAccess VFS method …

These integer constants can be used as the third parameter to the xAccess method of an sqlite3_vfs object. They determine what kind of permissions the xAccess method is looking for. With SQ3_ACCESS_EXISTS, the xAccess method simply checks whether the file exists. With SQ3_ACCESS_READWRITE, the xAccess method checks whether the named directory is both readable and writable (in other words, if files can be added, removed, and renamed within the directory). The SQ3_ACCESS_READWRITE constant is currently used only by the temp_store_directory pragma, though this could change in a future release of SQLite. With SQ3_ACCESS_READ, the xAccess method checks whether the file is readable. The SQ3_ACCESS_READ constant is currently unused, though it might be used in a future release of SQLite.

Reference code from sqlite3:

#define SQLITE_ACCESS_EXISTS 0
#define SQLITE_ACCESS_READWRITE 1 // Used by PRAGMA temp_store_directory
#define SQLITE_ACCESS_READ 2 // Unused

(static) enum MkErrorE Sq3AccessE_FromInt(MK_I32 const value, enum Sq3AccessE *value_out)

top return the Sq3AccessE from integer … → API: Sq3AccessE_FromInt

(static) MK_I32 Sq3AccessE_ToInt(enum Sq3AccessE value)

top return the Sq3AccessE as integer … → API: Sq3AccessE_ToInt

(static) MK_STRN Sq3AccessE_ToString(enum Sq3AccessE value)

top return the Sq3AccessE as string … → API: Sq3AccessE_ToString


enum Sq3AuthActionE

top Authorizer Action Codes. → API: Sq3AuthActionE

Authorizer Action Codes …

The Sq3LiteSetAuthorizer () interface registers a callback function that is invoked to authorize certain SQL statement actions. The second parameter to the callback is an integer code that specifies what action is being authorized. These are the integer action codes that the authorizer callback may be passed.

These action code values signify what kind of operation is to be authorized. The 3rd and 4th parameters to the authorization callback function will be parameters or NULL depending on which of these codes is used as the second parameter. The 5th parameter to the authorizer callback is the name of the database ("main", "temp", etc.) if applicable. The 6th parameter to the authorizer callback is the name of the inner-most trigger or view that is responsible for the access attempt or NULL if this access attempt is directly from top-level SQL code.

Reference code from sqlite3:

//****************************************** 3rd ************ 4th **********
#define SQLITE_CREATE_INDEX 1 // Index Name Table Name
#define SQLITE_CREATE_TABLE 2 // Table Name NULL
#define SQLITE_CREATE_TEMP_INDEX 3 // Index Name Table Name
#define SQLITE_CREATE_TEMP_TABLE 4 // Table Name NULL
#define SQLITE_CREATE_TEMP_TRIGGER 5 // Trigger Name Table Name
#define SQLITE_CREATE_TEMP_VIEW 6 // View Name NULL
#define SQLITE_CREATE_TRIGGER 7 // Trigger Name Table Name
#define SQLITE_CREATE_VIEW 8 // View Name NULL
#define SQLITE_DELETE 9 // Table Name NULL
#define SQLITE_DROP_INDEX 10 // Index Name Table Name
#define SQLITE_DROP_TABLE 11 // Table Name NULL
#define SQLITE_DROP_TEMP_INDEX 12 // Index Name Table Name
#define SQLITE_DROP_TEMP_TABLE 13 // Table Name NULL
#define SQLITE_DROP_TEMP_TRIGGER 14 // Trigger Name Table Name
#define SQLITE_DROP_TEMP_VIEW 15 // View Name NULL
#define SQLITE_DROP_TRIGGER 16 // Trigger Name Table Name
#define SQLITE_DROP_VIEW 17 // View Name NULL
#define SQLITE_INSERT 18 // Table Name NULL
#define SQLITE_PRAGMA 19 // Pragma Name 1st arg or NULL
#define SQLITE_READ 20 // Table Name Column Name
#define SQLITE_SELECT 21 // NULL NULL
#define SQLITE_TRANSACTION 22 // Operation NULL
#define SQLITE_UPDATE 23 // Table Name Column Name
#define SQLITE_ATTACH 24 // Filename NULL
#define SQLITE_DETACH 25 // Database Name NULL
#define SQLITE_ALTER_TABLE 26 // Database Name Table Name
#define SQLITE_REINDEX 27 // Index Name NULL
#define SQLITE_ANALYZE 28 // Table Name NULL
#define SQLITE_CREATE_VTABLE 29 // Table Name Module Name
#define SQLITE_DROP_VTABLE 30 // Table Name Module Name
#define SQLITE_FUNCTION 31 // NULL Function Name
#define SQLITE_SAVEPOINT 32 // Operation Savepoint Name
#define SQLITE_COPY 0 // No longer used
#define SQLITE_RECURSIVE 33 // NULL NULL

(static) enum MkErrorE Sq3AuthActionE_FromInt(MK_I32 const value, enum Sq3AuthActionE *value_out)

top return the Sq3AuthActionE from integer … → API: Sq3AuthActionE_FromInt

(static) MK_I32 Sq3AuthActionE_ToInt(enum Sq3AuthActionE value)

top return the Sq3AuthActionE as integer … → API: Sq3AuthActionE_ToInt

(static) MK_STRN Sq3AuthActionE_ToString(enum Sq3AuthActionE value)

top return the Sq3AuthActionE as string … → API: Sq3AuthActionE_ToString


enum Sq3AuthReturnE

top Authorizer Return Codes. → API: Sq3AuthReturnE

Authorizer Return Codes …

The authorizer callback function must return either SQ3_RESULT_OK or one of these two constants in order to signal SQLite whether or not the action is permitted. See the authorizer documentation for additional information.

Note that SQ3_AUTHRETURN_IGNORE is also used as a conflict resolution mode returned from the Sq3LiteVtabOnConflict () interface.

Reference code from sqlite3:

#define SQLITE_DENY 1 // Abort the SQL statement with an error
#define SQLITE_IGNORE 2 // Don't allow access, but don't generate an error

(static) enum MkErrorE Sq3AuthReturnE_FromInt(MK_I32 const value, enum Sq3AuthReturnE *value_out)

top return the Sq3AuthReturnE from integer … → API: Sq3AuthReturnE_FromInt

(static) MK_I32 Sq3AuthReturnE_ToInt(enum Sq3AuthReturnE value)

top return the Sq3AuthReturnE as integer … → API: Sq3AuthReturnE_ToInt

(static) MK_STRN Sq3AuthReturnE_ToString(enum Sq3AuthReturnE value)

top return the Sq3AuthReturnE as string … → API: Sq3AuthReturnE_ToString


enum Sq3ChangeSetConflictE

top Constants Returned By The Conflict Handler. → API: Sq3ChangeSetConflictE

Constants Returned By The Conflict Handler …

A conflict handler callback must return one of the following three values.

SQ3_CHANGESET_CONFLICT_OMIT

If a conflict handler returns this value no special action is taken. The change that caused the conflict is not applied. The session module continues to the next change in the changeset.

SQ3_CHANGESET_CONFLICT_REPLACE

This value may only be returned if the second argument to the conflict handler was SQ3_CHANGESET_DATA or SQ3_CHANGESET_CONFLICT. If this is not the case, any changes applied so far are rolled back and the call to sqlite3changeset_apply() returns SQ3_RESULT_MISUSE.

If CHANGESET_REPLACE is returned by an SQ3_CHANGESET_DATA conflict handler, then the conflicting row is either updated or deleted, depending on the type of change.

If CHANGESET_REPLACE is returned by an SQ3_CHANGESET_CONFLICT conflict handler, then the conflicting row is removed from the database and a second attempt to apply the change is made. If this second attempt fails, the original row is restored to the database before continuing.

SQ3_CHANGESET_CONFLICT_ABORT
If this value is returned, any changes applied so far are rolled back and the call to sqlite3changeset_apply() returns SQ3_RESULT_ABORT.

Reference code from sqlite3:

#define SQLITE_CHANGESET_OMIT 0
#define SQLITE_CHANGESET_REPLACE 1
#define SQLITE_CHANGESET_ABORT 2

(static) enum MkErrorE Sq3ChangeSetConflictE_FromInt(MK_I32 const value, enum Sq3ChangeSetConflictE *value_out)

top return the Sq3ChangeSetConflictE from integer … → API: Sq3ChangeSetConflictE_FromInt

(static) MK_I32 Sq3ChangeSetConflictE_ToInt(enum Sq3ChangeSetConflictE value)

top return the Sq3ChangeSetConflictE as integer … → API: Sq3ChangeSetConflictE_ToInt

(static) MK_STRN Sq3ChangeSetConflictE_ToString(enum Sq3ChangeSetConflictE value)

top return the Sq3ChangeSetConflictE as string … → API: Sq3ChangeSetConflictE_ToString


enum Sq3ChangesetE

top Constants Passed To The Conflict Handler. → API: Sq3ChangesetE

Constants Passed To The Conflict Handler …

Values that may be passed as the second argument to a conflict-handler.

SQ3_CHANGESET_DATA

The conflict handler is invoked with CHANGESET_DATA as the second argument when processing a DELETE or UPDATE change if a row with the required PRIMARY KEY fields is present in the database, but one or more other (non primary-key) fields modified by the update do not contain the expected "before" values.

The conflicting row, in this case, is the database row with the matching primary key.

SQ3_CHANGESET_NOTFOUND

The conflict handler is invoked with CHANGESET_NOTFOUND as the second argument when processing a DELETE or UPDATE change if a row with the required PRIMARY KEY fields is not present in the database.

There is no conflicting row in this case. The results of invoking the sqlite3changeset_conflict() API are undefined.

SQ3_CHANGESET_CONFLICT

CHANGESET_CONFLICT is passed as the second argument to the conflict handler while processing an INSERT change if the operation would result in duplicate primary key values.

The conflicting row in this case is the database row with the matching primary key.

SQ3_CHANGESET_FOREIGN_KEY

If foreign key handling is enabled, and applying a changeset leaves the database in a state containing foreign key violations, the conflict handler is invoked with CHANGESET_FOREIGN_KEY as the second argument exactly once before the changeset is committed. If the conflict handler returns CHANGESET_OMIT, the changes, including those that caused the foreign key constraint violation, are committed. Or, if it returns CHANGESET_ABORT, the changeset is rolled back.

No current or conflicting row information is provided. The only function it is possible to call on the supplied sqlite3_changeset_iter handle is sqlite3changeset_fk_conflicts().

SQ3_CHANGESET_CONSTRAINT

If any other constraint violation occurs while applying a change (i.e. a UNIQUE, CHECK or NOT NULL constraint), the conflict handler is invoked with CHANGESET_CONSTRAINT as the second argument.

There is no conflicting row in this case. The results of invoking the sqlite3changeset_conflict() API are undefined.

Reference code from sqlite3:

#define SQLITE_CHANGESET_DATA 1
#define SQLITE_CHANGESET_NOTFOUND 2
#define SQLITE_CHANGESET_CONFLICT 3
#define SQLITE_CHANGESET_CONSTRAINT 4
#define SQLITE_CHANGESET_FOREIGN_KEY 5

(static) enum MkErrorE Sq3ChangesetE_FromInt(MK_I32 const value, enum Sq3ChangesetE *value_out)

top return the Sq3ChangesetE from integer … → API: Sq3ChangesetE_FromInt

(static) MK_I32 Sq3ChangesetE_ToInt(enum Sq3ChangesetE value)

top return the Sq3ChangesetE as integer … → API: Sq3ChangesetE_ToInt

(static) MK_STRN Sq3ChangesetE_ToString(enum Sq3ChangesetE value)

top return the Sq3ChangesetE as string … → API: Sq3ChangesetE_ToString


enum Sq3CheckpointE

top Checkpoint Mode Values. → API: Sq3CheckpointE

Checkpoint Mode Values …

These constants define all valid values for the "checkpoint mode" passed as the third parameter to the Sq3LiteWalCheckpointV2 () interface. See the Sq3LiteWalCheckpointV2 () documentation for details on the meaning of each of these checkpoint modes.

Reference code from sqlite3:

#define SQLITE_CHECKPOINT_PASSIVE 0 // Do as much as possible w/o blocking
#define SQLITE_CHECKPOINT_FULL 1 // Wait for writers, then checkpoint
#define SQLITE_CHECKPOINT_RESTART 2 // Like FULL but wait for readers
#define SQLITE_CHECKPOINT_TRUNCATE 3 // Like RESTART but also truncate WAL

(static) enum MkErrorE Sq3CheckpointE_FromInt(MK_I32 const value, enum Sq3CheckpointE *value_out)

top return the Sq3CheckpointE from integer … → API: Sq3CheckpointE_FromInt

(static) MK_I32 Sq3CheckpointE_ToInt(enum Sq3CheckpointE value)

top return the Sq3CheckpointE as integer … → API: Sq3CheckpointE_ToInt

(static) MK_STRN Sq3CheckpointE_ToString(enum Sq3CheckpointE value)

top return the Sq3CheckpointE as string … → API: Sq3CheckpointE_ToString


enum Sq3ConfigE

top Configuration Options. → API: Sq3ConfigE

Configuration Options …

These constants are the available integer configuration options that can be passed as the first argument to the sqlite3_config () interface.

Most of the configuration options for sqlite3_config() will only work if invoked prior to Sq3Initialize () or after Sq3Shutdown (). The few exceptions to this rule are called "anytime configuration options". Calling sqlite3_config () with a first argument that is not an anytime configuration option in between calls to Sq3Initialize () and Sq3Shutdown () is a no-op that returns SQ3_RESULT_MISUSE.

The set of anytime configuration options can change (by insertions and/or deletions) from one release of SQLite to the next. As of SQLite version 3.42.0, the complete set of anytime configuration options is:

  • SQ3_CONFIG_LOG
  • SQ3_CONFIG_PCACHE_HDRSZ

New configuration options may be added in future releases of SQLite. Existing configuration options might be discontinued. Applications should check the return code from sqlite3_config () to make sure that the call worked. The sqlite3_config () interface will return a non-zero error code if a discontinued or unsupported configuration option is invoked.

SQ3_CONFIG_SINGLETHREAD

There are no arguments to this option. This option sets the threading mode to Single-thread. In other words, it disables all mutexing and puts SQLite into a mode where it can only be used by a single thread. If SQLite is compiled with the SQLITE_THREADSAFE=0 compile-time option then it is not possible to change the threading mode from its default value of Single-thread and so sqlite3_config () will return SQ3_RESULT_ERROR if called with the SQ3_CONFIG_SINGLETHREAD configuration option.

SQ3_CONFIG_MULTITHREAD

There are no arguments to this option. This option sets the threading mode to Multi-thread. In other words, it disables mutexing on database connection and prepared statement objects. The application is responsible for serializing access to database connections and prepared statements. But other mutexes are enabled so that SQLite will be safe to use in a multi-threaded environment as long as no two threads attempt to use the same database connection at the same time. If SQLite is compiled with the SQLITE_THREADSAFE=0 compile-time option then it is not possible to set the Multi-thread threading mode and sqlite3_config () will return SQ3_RESULT_ERROR if called with the SQ3_CONFIG_MULTITHREAD configuration option.

SQ3_CONFIG_SERIALIZED

There are no arguments to this option. This option sets the threading mode to Serialized. In other words, this option enables all mutexes including the recursive mutexes on database connection and prepared statement objects. In this mode (which is the default when SQLite is compiled with SQLITE_THREADSAFE=1) the SQLite library will itself serialize access to database connections and prepared statements so that the application is free to use the same database connection or the same prepared statement in different threads at the same time. If SQLite is compiled with the SQLITE_THREADSAFE=0 compile-time option then it is not possible to set the Serialized threading mode and sqlite3_config () will return SQ3_RESULT_ERROR if called with the SQ3_CONFIG_SERIALIZED configuration option.

SQ3_CONFIG_MALLOC

The SQ3_CONFIG_MALLOC option takes a single argument which is a pointer to an instance of the sqlite3_mem_methods structure. The argument specifies alternative low-level memory allocation routines to be used in place of the memory allocation routines built into SQLite. SQLite makes its own private copy of the content of the sqlite3_mem_methods structure before the sqlite3_config () call returns.

SQ3_CONFIG_GETMALLOC

The SQ3_CONFIG_GETMALLOC option takes a single argument which is a pointer to an instance of the sqlite3_mem_methods structure. The sqlite3_mem_methods structure is filled with the currently defined memory allocation routines. This option can be used to overload the default memory allocation routines with a wrapper that simulations memory allocation failure or tracks memory usage, for example.

SQ3_CONFIG_SMALL_MALLOC

The SQ3_CONFIG_SMALL_MALLOC option takes single argument of type int, interpreted as a boolean, which if true provides a hint to SQLite that it should avoid large memory allocations if possible. SQLite will run faster if it is free to make large memory allocations, but some application might prefer to run slower in exchange for guarantees about memory fragmentation that are possible if large allocations are avoided. This hint is normally off.

SQ3_CONFIG_MEMSTATUS

The SQ3_CONFIG_MEMSTATUS option takes single argument of type int, interpreted as a boolean, which enables or disables the collection of memory allocation statistics. When memory allocation statistics are disabled, the following SQLite interfaces become non-operational:

Memory allocation statistics are enabled by default unless SQLite is compiled with SQLITE_DEFAULT_MEMSTATUS=0 in which case memory allocation statistics are disabled by default.

SQ3_CONFIG_SCRATCH

The SQ3_CONFIG_SCRATCH option is no longer used.

SQ3_CONFIG_PAGECACHE

The SQ3_CONFIG_PAGECACHE option specifies a memory pool that SQLite can use for the database page cache with the default page cache implementation. This configuration option is a no-op if an application-defined page cache implementation is loaded using the SQ3_CONFIG_PCACHE2. There are three arguments to SQ3_CONFIG_PAGECACHE: A pointer to 8-byte aligned memory (pMem), the size of each page cache line (sz), and the number of cache lines (N). The sz argument should be the size of the largest database page (a power of two between 512 and 65536) plus some extra bytes for each page header. The number of extra bytes needed by the page header can be determined using SQ3_CONFIG_PCACHE_HDRSZ. It is harmless, apart from the wasted memory, for the sz parameter to be larger than necessary. The pMem argument must be either a NULL pointer or a pointer to an 8-byte aligned block of memory of at least sz*N bytes, otherwise subsequent behavior is undefined. When pMem is not NULL, SQLite will strive to use the memory provided to satisfy page cache needs, falling back to Sq3Malloc () if a page cache line is larger than sz bytes or if all of the pMem buffer is exhausted. If pMem is NULL and N is non-zero, then each database connection does an initial bulk allocation for page cache memory from Sq3Malloc () sufficient for N cache lines if N is positive or of -1024*N bytes if N is negative, . If additional page cache memory is needed beyond what is provided by the initial allocation, then SQLite goes to Sq3Malloc () separately for each additional cache line.

SQ3_CONFIG_HEAP

The SQ3_CONFIG_HEAP option specifies a static memory buffer that SQLite will use for all of its dynamic memory allocation needs beyond those provided for by SQ3_CONFIG_PAGECACHE. The SQ3_CONFIG_HEAP option is only available if SQLite is compiled with either SQLITE_ENABLE_MEMSYS3 or SQLITE_ENABLE_MEMSYS5 and returns SQ3_RESULT_ERROR if invoked otherwise. There are three arguments to SQ3_CONFIG_HEAP: An 8-byte aligned pointer to the memory, the number of bytes in the memory buffer, and the minimum allocation size. If the first pointer (the memory pointer) is NULL, then SQLite reverts to using its default memory allocator (the system malloc() implementation), undoing any prior invocation of SQ3_CONFIG_MALLOC. If the memory pointer is not NULL then the alternative memory allocator is engaged to handle all of SQLites memory allocation needs. The first pointer (the memory pointer) must be aligned to an 8-byte boundary or subsequent behavior of SQLite will be undefined. The minimum allocation size is capped at 2**12. Reasonable values for the minimum allocation size are 2**5 through 2**8.

SQ3_CONFIG_MUTEX

The SQ3_CONFIG_MUTEX option takes a single argument which is a pointer to an instance of the sqlite3_mutex_methods structure. The argument specifies alternative low-level mutex routines to be used in place the mutex routines built into SQLite. SQLite makes a copy of the content of the sqlite3_mutex_methods structure before the call to sqlite3_config () returns. If SQLite is compiled with the SQLITE_THREADSAFE=0 compile-time option then the entire mutexing subsystem is omitted from the build and hence calls to sqlite3_config () with the SQ3_CONFIG_MUTEX configuration option will return SQ3_RESULT_ERROR.

SQ3_CONFIG_GETMUTEX

The SQ3_CONFIG_GETMUTEX option takes a single argument which is a pointer to an instance of the sqlite3_mutex_methods structure. The sqlite3_mutex_methods structure is filled with the currently defined mutex routines. This option can be used to overload the default mutex allocation routines with a wrapper used to track mutex usage for performance profiling or testing, for example. If SQLite is compiled with the SQLITE_THREADSAFE=0 compile-time option then the entire mutexing subsystem is omitted from the build and hence calls to sqlite3_config () with the SQ3_CONFIG_GETMUTEX configuration option will return SQ3_RESULT_ERROR.

SQ3_CONFIG_LOOKASIDE

The SQ3_CONFIG_LOOKASIDE option takes two arguments that determine the default size of lookaside memory on each database connection. The first argument is the size of each lookaside buffer slot and the second is the number of slots allocated to each database connection. SQ3_CONFIG_LOOKASIDE sets the default lookaside size. The SQ3_DBCONFIG_LOOKASIDE option to sqlite3_db_config () can be used to change the lookaside configuration on individual connections.

SQ3_CONFIG_PCACHE2

The SQ3_CONFIG_PCACHE2 option takes a single argument which is a pointer to an sqlite3_pcache_methods2 object. This object specifies the interface to a custom page cache implementation. SQLite makes a copy of the sqlite3_pcache_methods2 object.

SQ3_CONFIG_GETPCACHE2

The SQ3_CONFIG_GETPCACHE2 option takes a single argument which is a pointer to an sqlite3_pcache_methods2 object. SQLite copies of the current page cache implementation into that object.

SQ3_CONFIG_LOG

The SQ3_CONFIG_LOG option is used to configure the SQLite global error log. (The SQ3_CONFIG_LOG option takes two arguments: a pointer to a function with a call signature of void(*)(void*,int,const char*), and a pointer to void. If the function pointer is not NULL, it is invoked by sqlite3_log () to process each logging event. If the function pointer is NULL, the sqlite3_log () interface becomes a no-op. The void pointer that is the second argument to SQ3_CONFIG_LOG is passed through as the first parameter to the application-defined logger function whenever that function is invoked. The second parameter to the logger function is a copy of the first parameter to the corresponding sqlite3_log () call and is intended to be a result code or an extended result code. The third parameter passed to the logger is log message after formatting via sqlite3_snprintf (). The SQLite logging interface is not reentrant; the logger function supplied by the application must not invoke any SQLite interface. In a multi-threaded application, the application-defined logger function must be threadsafe.

SQ3_CONFIG_URI

The SQ3_CONFIG_URI option takes a single argument of type int. If non-zero, then URI handling is globally enabled. If the parameter is zero, then URI handling is globally disabled. If URI handling is globally enabled, all filenames passed to sqlite3_open (), Sq3LiteOpenV2 (), sqlite3_open16 () or specified as part of ATTACH commands are interpreted as URIs, regardless of whether or not the SQ3_OPEN_URI flag is set when the database connection is opened. If it is globally disabled, filenames are only interpreted as URIs if the SQ3_OPEN_URI flag is set when the database connection is opened. By default, URI handling is globally disabled. The default value may be changed by compiling with the SQLITE_USE_URI symbol defined.

SQ3_CONFIG_COVERING_INDEX_SCAN

The SQ3_CONFIG_COVERING_INDEX_SCAN option takes a single integer argument which is interpreted as a boolean in order to enable or disable the use of covering indices for full table scans in the query optimizer. The default setting is determined by the SQLITE_ALLOW_COVERING_INDEX_SCAN compile-time option, or is "on" if that compile-time option is omitted. The ability to disable the use of covering indices for full table scans is because some incorrectly coded legacy applications might malfunction when the optimization is enabled. Providing the ability to disable the optimization allows the older, buggy application code to work without change even with newer versions of SQLite.

SQ3_CONFIG_PCACHE and SQ3_CONFIG_GETPCACHE

These options are obsolete and should not be used by new code. They are retained for backwards compatibility but are now no-ops.

SQ3_CONFIG_SQLLOG

This option is only available if sqlite is compiled with the SQLITE_ENABLE_SQLLOG pre-processor macro defined. The first argument should be a pointer to a function of type void(*)(void*,Sq3LiteC*,const char*, int). The second should be of type (void*). The callback is invoked by the library in three separate circumstances, identified by the value passed as the fourth parameter. If the fourth parameter is 0, then the database connection passed as the second argument has just been opened. The third argument points to a buffer containing the name of the main database file. If the fourth parameter is 1, then the SQL statement that the third parameter points to has just been executed. Or, if the fourth parameter is 2, then the connection being passed as the second parameter is being closed. The third parameter is passed NULL In this case. An example of using this configuration option can be seen in the "test_sqllog.c" source file in the canonical SQLite source tree.

SQ3_CONFIG_MMAP_SIZE

SQ3_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values that are the default mmap size limit (the default setting for PRAGMA mmap_size) and the maximum allowed mmap size limit. The default setting can be overridden by each database connection using either the PRAGMA mmap_size command, or by using the SQ3_FCNTL_MMAP_SIZE file control. The maximum allowed mmap size will be silently truncated if necessary so that it does not exceed the compile-time maximum mmap size set by the SQLITE_MAX_MMAP_SIZE compile-time option. If either argument to this option is negative, then that argument is changed to its compile-time default.

SQ3_CONFIG_WIN32_HEAPSIZE

The SQ3_CONFIG_WIN32_HEAPSIZE option is only available if SQLite is compiled for Windows with the SQLITE_WIN32_MALLOC pre-processor macro defined. SQ3_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value that specifies the maximum size of the created heap.

SQ3_CONFIG_PCACHE_HDRSZ

The SQ3_CONFIG_PCACHE_HDRSZ option takes a single parameter which is a pointer to an integer and writes into that integer the number of extra bytes per page required for each page in SQ3_CONFIG_PAGECACHE. The amount of extra space required can change depending on the compiler, target platform, and SQLite version.

SQ3_CONFIG_PMASZ

The SQ3_CONFIG_PMASZ option takes a single parameter which is an unsigned integer and sets the "Minimum PMA Size" for the multithreaded sorter to that integer. The default minimum PMA Size is set by the SQLITE_SORTER_PMASZ compile-time option. New threads are launched to help with sort operations when multithreaded sorting is enabled (using the PRAGMA threads command) and the amount of content to be sorted exceeds the page size times the minimum of the PRAGMA cache_size setting and this value.

SQ3_CONFIG_STMTJRNL_SPILL

The SQ3_CONFIG_STMTJRNL_SPILL option takes a single parameter which becomes the statement journal spill-to-disk threshold. Statement journals are held in memory until their size (in bytes) exceeds this threshold, at which point they are written to disk. Or if the threshold is -1, statement journals are always held exclusively in memory. Since many statement journals never become large, setting the spill threshold to a value such as 64KiB can greatly reduce the amount of I/O required to support statement rollback. The default value for this setting is controlled by the SQLITE_STMTJRNL_SPILL compile-time option.

SQ3_CONFIG_SORTERREF_SIZE

The SQ3_CONFIG_SORTERREF_SIZE option accepts a single parameter of type (int) - the new value of the sorter-reference size threshold. Usually, when SQLite uses an external sort to order records according to an ORDER BY clause, all fields required by the caller are present in the sorted records. However, if SQLite determines based on the declared type of a table column that its values are likely to be very large - larger than the configured sorter-reference size threshold - then a reference is stored in each sorted record and the required column values loaded from the database as records are returned in sorted order. The default value for this option is to never use this optimization. Specifying a negative value for this option restores the default behavior. This option is only available if SQLite is compiled with the SQLITE_ENABLE_SORTER_REFERENCES compile-time option.

SQ3_CONFIG_MEMDB_MAXSIZE
The SQ3_CONFIG_MEMDB_MAXSIZE option accepts a single parameter sqlite3_int64 parameter which is the default maximum size for an in-memory database created using Sq3LiteDeserialize (). This default maximum size can be adjusted up or down for individual databases using the SQ3_FCNTL_SIZE_LIMIT file-control. If this configuration setting is never used, then the default maximum is determined by the SQLITE_MEMDB_DEFAULT_MAXSIZE compile-time option. If that compile-time option is not set, then the default maximum is 1073741824.

Reference code from sqlite3:

#define SQLITE_CONFIG_SINGLETHREAD 1 // nil
#define SQLITE_CONFIG_MULTITHREAD 2 // nil
#define SQLITE_CONFIG_SERIALIZED 3 // nil
#define SQLITE_CONFIG_MALLOC 4 // sqlite3_mem_methods*
#define SQLITE_CONFIG_GETMALLOC 5 // sqlite3_mem_methods*
#define SQLITE_CONFIG_SCRATCH 6 // No longer used
#define SQLITE_CONFIG_PAGECACHE 7 // void*, int sz, int N
#define SQLITE_CONFIG_HEAP 8 // void*, int nByte, int min
#define SQLITE_CONFIG_MEMSTATUS 9 // boolean
#define SQLITE_CONFIG_MUTEX 10 // sqlite3_mutex_methods*
#define SQLITE_CONFIG_GETMUTEX 11 // sqlite3_mutex_methods*
// previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused.
#define SQLITE_CONFIG_LOOKASIDE 13 // int int
#define SQLITE_CONFIG_PCACHE 14 // no-op
#define SQLITE_CONFIG_GETPCACHE 15 // no-op
#define SQLITE_CONFIG_LOG 16 // xFunc, void*
#define SQLITE_CONFIG_URI 17 // int
#define SQLITE_CONFIG_PCACHE2 18 // sqlite3_pcache_methods2*
#define SQLITE_CONFIG_GETPCACHE2 19 // sqlite3_pcache_methods2*
#define SQLITE_CONFIG_COVERING_INDEX_SCAN 20 // int
#define SQLITE_CONFIG_SQLLOG 21 // xSqllog, void*
#define SQLITE_CONFIG_MMAP_SIZE 22 // sqlite3_int64, sqlite3_int64
#define SQLITE_CONFIG_WIN32_HEAPSIZE 23 // int nByte
#define SQLITE_CONFIG_PCACHE_HDRSZ 24 // int *psz
#define SQLITE_CONFIG_PMASZ 25 // unsigned int szPma
#define SQLITE_CONFIG_STMTJRNL_SPILL 26 // int nByte
#define SQLITE_CONFIG_SMALL_MALLOC 27 // boolean
#define SQLITE_CONFIG_SORTERREF_SIZE 28 // int nByte
#define SQLITE_CONFIG_MEMDB_MAXSIZE 29 // sqlite3_int64

(static) enum MkErrorE Sq3ConfigE_FromInt(MK_I32 const value, enum Sq3ConfigE *value_out)

top return the Sq3ConfigE from integer … → API: Sq3ConfigE_FromInt

(static) MK_I32 Sq3ConfigE_ToInt(enum Sq3ConfigE value)

top return the Sq3ConfigE as integer … → API: Sq3ConfigE_ToInt

(static) MK_STRN Sq3ConfigE_ToString(enum Sq3ConfigE value)

top return the Sq3ConfigE as string … → API: Sq3ConfigE_ToString


enum Sq3ConflictResolutionE

top Conflict resolution modes. → API: Sq3ConflictResolutionE

Conflict resolution modes …

These constants are returned by Sq3LiteVtabOnConflict () to inform a virtual table implementation what the ON CONFLICT mode is for the SQL statement being evaluated.

Note that the SQ3_AUTHRETURN_IGNORE constant is also used as a potential return value from the Sq3LiteSetAuthorizer () callback and that SQ3_RESULT_ABORT is also a result code.

Reference code from sqlite3:

#define SQLITE_ROLLBACK 1
// #define SQLITE_IGNORE 2 // Also used by sqlite3_authorizer() callback
#define SQLITE_FAIL 3
// #define SQLITE_ABORT 4 // Also an error code
#define SQLITE_REPLACE 5

(static) enum MkErrorE Sq3ConflictResolutionE_FromInt(MK_I32 const value, enum Sq3ConflictResolutionE *value_out)

top return the Sq3ConflictResolutionE from integer … → API: Sq3ConflictResolutionE_FromInt

(static) MK_I32 Sq3ConflictResolutionE_ToInt(enum Sq3ConflictResolutionE value)

top return the Sq3ConflictResolutionE as integer … → API: Sq3ConflictResolutionE_ToInt

(static) MK_STRN Sq3ConflictResolutionE_ToString(enum Sq3ConflictResolutionE value)

top return the Sq3ConflictResolutionE as string … → API: Sq3ConflictResolutionE_ToString


enum Sq3DbConfigE

top Database Connection Configuration Options. → API: Sq3DbConfigE

Database Connection Configuration Options …

These constants are the available integer configuration options that can be passed as the second argument to the sqlite3_db_config () interface.

New configuration options may be added in future releases of SQLite. Existing configuration options might be discontinued. Applications should check the return code from sqlite3_db_config () to make sure that the call worked. The sqlite3_db_config () interface will return a non-zero error code if a discontinued or unsupported configuration option is invoked.

SQ3_DBCONFIG_LOOKASIDE

This option takes three additional arguments that determine the lookaside memory allocator configuration for the database connection. The first argument (the third parameter to sqlite3_db_config () is a pointer to a memory buffer to use for lookaside memory. The first argument after the SQ3_DBCONFIG_LOOKASIDE verb may be NULL in which case SQLite will allocate the lookaside buffer itself using Sq3Malloc (). The second argument is the size of each lookaside buffer slot. The third argument is the number of slots. The size of the buffer in the first argument must be greater than or equal to the product of the second and third arguments. The buffer must be aligned to an 8-byte boundary. If the second argument to SQ3_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally rounded down to the next smaller multiple of 8. The lookaside memory configuration for a database connection can only be changed when that connection is not currently using lookaside memory, or in other words when the "current value" returned by Sq3LiteDbStatus(D,SQ3_DBSTATUS_LOOKASIDE_USED,...) is zero. Any attempt to change the lookaside memory configuration when lookaside memory is in use leaves the configuration unchanged and returns SQ3_RESULT_BUSY.

SQ3_DBCONFIG_ENABLE_FKEY

This option is used to enable or disable the enforcement of foreign key constraints. There should be two additional arguments. The first argument is an integer which is 0 to disable FK enforcement, positive to enable FK enforcement or negative to leave FK enforcement unchanged. The second parameter is a pointer to an integer into which is written 0 or 1 to indicate whether FK enforcement is off or on following this call. The second parameter may be a NULL pointer, in which case the FK enforcement setting is not reported back.

SQ3_DBCONFIG_ENABLE_TRIGGER

This option is used to enable or disable triggers. There should be two additional arguments. The first argument is an integer which is 0 to disable triggers, positive to enable triggers or negative to leave the setting unchanged. The second parameter is a pointer to an integer into which is written 0 or 1 to indicate whether triggers are disabled or enabled following this call. The second parameter may be a NULL pointer, in which case the trigger setting is not reported back.

Originally this option disabled all triggers. However, since SQLite version 3.35.0, TEMP triggers are still allowed even if this option is off. So, in other words, this option now only disables triggers in the main database schema or in the schemas of ATTACH-ed databases.

SQ3_DBCONFIG_ENABLE_VIEW

This option is used to enable or disable views. There should be two additional arguments. The first argument is an integer which is 0 to disable views, positive to enable views or negative to leave the setting unchanged. The second parameter is a pointer to an integer into which is written 0 or 1 to indicate whether views are disabled or enabled following this call. The second parameter may be a NULL pointer, in which case the view setting is not reported back.

Originally this option disabled all views. However, since SQLite version 3.35.0, TEMP views are still allowed even if this option is off. So, in other words, this option now only disables views in the main database schema or in the schemas of ATTACH-ed databases.

SQ3_DBCONFIG_ENABLE_FTS3_TOKENIZER

This option is used to enable or disable the fts3_tokenizer () function which is part of the FTS3 full-text search engine extension. There should be two additional arguments. The first argument is an integer which is 0 to disable fts3_tokenizer() or positive to enable fts3_tokenizer() or negative to leave the setting unchanged. The second parameter is a pointer to an integer into which is written 0 or 1 to indicate whether fts3_tokenizer is disabled or enabled following this call. The second parameter may be a NULL pointer, in which case the new setting is not reported back.

SQ3_DBCONFIG_ENABLE_LOAD_EXTENSION

This option is used to enable or disable the Sq3LiteLoadExtension () interface independently of the load_extension () SQL function. The Sq3LiteEnableLoadExtension () API enables or disables both the C-API Sq3LiteLoadExtension () and the SQL function load_extension (). There should be two additional arguments. When the first argument to this interface is 1, then only the C-API is enabled and the SQL function remains disabled. If the first argument to this interface is 0, then both the C-API and the SQL function are disabled. If the first argument is -1, then no changes are made to state of either the C-API or the SQL function. The second parameter is a pointer to an integer into which is written 0 or 1 to indicate whether Sq3LiteLoadExtension () interface is disabled or enabled following this call. The second parameter may be a NULL pointer, in which case the new setting is not reported back.

SQ3_DBCONFIG_MAINDBNAME

This option is used to change the name of the "main" database schema. The sole argument is a pointer to a constant UTF8 string which will become the new schema name in place of "main". SQLite does not make a copy of the new main schema name string, so the application must ensure that the argument passed into this DBCONFIG option is unchanged until after the database connection closes.

SQ3_DBCONFIG_NO_CKPT_ON_CLOSE

Usually, when a database in wal mode is closed or detached from a database handle, SQLite checks if this will mean that there are now no connections at all to the database. If so, it performs a checkpoint operation before closing the connection. This option may be used to override this behavior. The first parameter passed to this operation is an integer - positive to disable checkpoints-on-close, or zero (the default) to enable them, and negative to leave the setting unchanged. The second parameter is a pointer to an integer into which is written 0 or 1 to indicate whether checkpoints-on-close have been disabled - 0 if they are not disabled, 1 if they are.

SQ3_DBCONFIG_ENABLE_QPSG

The SQ3_DBCONFIG_ENABLE_QPSG option activates or deactivates the query planner stability guarantee (QPSG). When the QPSG is active, a single SQL query statement will always use the same algorithm regardless of values of bound parameters. The QPSG disables some query optimizations that look at the values of bound parameters, which can make some queries slower. But the QPSG has the advantage of more predictable behavior. With the QPSG active, SQLite will always use the same query plan in the field as was used during testing in the lab. The first argument to this setting is an integer which is 0 to disable the QPSG, positive to enable QPSG, or negative to leave the setting unchanged. The second parameter is a pointer to an integer into which is written 0 or 1 to indicate whether the QPSG is disabled or enabled following this call.

SQ3_DBCONFIG_TRIGGER_EQP

By default, the output of EXPLAIN QUERY PLAN commands does not include output for any operations performed by trigger programs. This option is used to set or clear (the default) a flag that governs this behavior. The first parameter passed to this operation is an integer - positive to enable output for trigger programs, or zero to disable it, or negative to leave the setting unchanged. The second parameter is a pointer to an integer into which is written 0 or 1 to indicate whether output-for-triggers has been disabled - 0 if it is not disabled, 1 if it is.

SQ3_DBCONFIG_RESET_DATABASE

Set the SQ3_DBCONFIG_RESET_DATABASE flag and then run VACUUM in order to reset a database back to an empty database with no schema and no content. The following process works even for a badly corrupted database file:

  1. If the database connection is newly opened, make sure it has read the database schema by preparing then discarding some query against the database, or calling Sq3LiteTableColumnMetadata(), ignoring any errors. This step is only necessary if the application desires to keep the database in WAL mode after the reset if it was in WAL mode before the reset.
  2. sqlite3_db_config(db, SQ3_DBCONFIG_RESET_DATABASE, 1, 0);
  3. Sq3LiteExec(db, "<a href="https://www.sqlite.org/lang_vacuum.html">VACUUM</a>", 0, 0, 0);
  4. sqlite3_db_config(db, SQ3_DBCONFIG_RESET_DATABASE, 0, 0);

Because resetting a database is destructive and irreversible, the process requires the use of this obscure API and multiple steps to help ensure that it does not happen by accident. Because this feature must be capable of resetting corrupt databases, and shutting down virtual tables may require access to that corrupt storage, the library must abandon any installed virtual tables without calling their xDestroy() methods.

SQ3_DBCONFIG_DEFENSIVE

The SQ3_DBCONFIG_DEFENSIVE option activates or deactivates the "defensive" flag for a database connection. When the defensive flag is enabled, language features that allow ordinary SQL to deliberately corrupt the database file are disabled. The disabled features include but are not limited to the following:

SQ3_DBCONFIG_WRITABLE_SCHEMA

The SQ3_DBCONFIG_WRITABLE_SCHEMA option activates or deactivates the "writable_schema" flag. This has the same effect and is logically equivalent to setting PRAGMA writable_schema=ON or PRAGMA writable_schema=OFF. The first argument to this setting is an integer which is 0 to disable the writable_schema, positive to enable writable_schema, or negative to leave the setting unchanged. The second parameter is a pointer to an integer into which is written 0 or 1 to indicate whether the writable_schema is enabled or disabled following this call.

SQ3_DBCONFIG_LEGACY_ALTER_TABLE

The SQ3_DBCONFIG_LEGACY_ALTER_TABLE option activates or deactivates the legacy behavior of the ALTER TABLE RENAME command such it behaves as it did prior to version 3.24.0 (2018-06-04). See the "Compatibility Notice" on the ALTER TABLE RENAME documentation for additional information. This feature can also be turned on and off using the PRAGMA legacy_alter_table statement.

SQ3_DBCONFIG_DQS_DML

The SQ3_DBCONFIG_DQS_DML option activates or deactivates the legacy double-quoted string literal misfeature for DML statements only, that is DELETE, INSERT, SELECT, and UPDATE statements. The default value of this setting is determined by the -DSQLITE_DQS compile-time option.

SQ3_DBCONFIG_DQS_DDL

The SQ3_DBCONFIG_DQS_DDL option activates or deactivates the legacy double-quoted string literal misfeature for DDL statements, such as CREATE TABLE and CREATE INDEX. The default value of this setting is determined by the -DSQLITE_DQS compile-time option.

SQ3_DBCONFIG_TRUSTED_SCHEMA

The SQ3_DBCONFIG_TRUSTED_SCHEMA option tells SQLite to assume that database schemas are untainted by malicious content. When the SQ3_DBCONFIG_TRUSTED_SCHEMA option is disabled, SQLite takes additional defensive steps to protect the application from harm including:

  • Prohibit the use of SQL functions inside triggers, views, CHECK constraints, DEFAULT clauses, expression indexes, partial indexes, or generated columns unless those functions are tagged with SQ3_FUNCTION_INNOCUOUS.
  • Prohibit the use of virtual tables inside of triggers or views unless those virtual tables are tagged with SQ3_VTAB_INNOCUOUS.

This setting defaults to "on" for legacy compatibility, however all applications are advised to turn it off if possible. This setting can also be controlled using the PRAGMA trusted_schema statement.

SQ3_DBCONFIG_LEGACY_FILE_FORMAT

The SQ3_DBCONFIG_LEGACY_FILE_FORMAT option activates or deactivates the legacy file format flag. When activated, this flag causes all newly created database file to have a schema format version number (the 4-byte integer found at offset 44 into the database header) of 1. This in turn means that the resulting database file will be readable and writable by any SQLite version back to 3.0.0 (dateof:3.0.0). Without this setting, newly created databases are generally not understandable by SQLite versions prior to 3.3.0 (dateof:3.3.0). As these words are written, there is now scarcely any need to generate database files that are compatible all the way back to version 3.0.0, and so this setting is of little practical use, but is provided so that SQLite can continue to claim the ability to generate new database files that are compatible with version 3.0.0.

Note that when the SQ3_DBCONFIG_LEGACY_FILE_FORMAT setting is on, the VACUUM command will fail with an obscure error when attempting to process a table with generated columns and a descending index. This is not considered a bug since SQLite versions 3.3.0 and earlier do not support either generated columns or descending indexes.

SQ3_DBCONFIG_STMT_SCANSTATUS

The SQ3_DBCONFIG_STMT_SCANSTATUS option is only useful in SQLITE_ENABLE_STMT_SCANSTATUS builds. In this case, it sets or clears a flag that enables collection of the sqlite3_stmt_scanstatus_v2() statistics. For statistics to be collected, the flag must be set on the database handle both when the SQL statement is prepared and when it is stepped. The flag is set (collection of statistics is enabled) by default. This option takes two arguments: an integer and a pointer to an integer.. The first argument is 1, 0, or -1 to enable, disable, or leave unchanged the statement scanstatus option. If the second argument is not NULL, then the value of the statement scanstatus setting after processing the first argument is written into the integer that the second argument points to.

SQ3_DBCONFIG_REVERSE_SCANORDER
The SQ3_DBCONFIG_REVERSE_SCANORDER option changes the default order in which tables and indexes are scanned so that the scans start at the end and work toward the beginning rather than starting at the beginning and working toward the end. Setting SQ3_DBCONFIG_REVERSE_SCANORDER is the same as setting PRAGMA reverse_unordered_selects. This option takes two arguments which are an integer and a pointer to an integer. The first argument is 1, 0, or -1 to enable, disable, or leave unchanged the reverse scan order flag, respectively. If the second argument is not NULL, then 0 or 1 is written into the integer that the second argument points to depending on if the reverse scan order flag is set after processing the first argument.

Reference code from sqlite3:

#define SQLITE_DBCONFIG_MAINDBNAME 1000 // const char*
#define SQLITE_DBCONFIG_LOOKASIDE 1001 // void* int int
#define SQLITE_DBCONFIG_ENABLE_FKEY 1002 // int int*
#define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 // int int*
#define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 // int int*
#define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 // int int*
#define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 // int int*
#define SQLITE_DBCONFIG_ENABLE_QPSG 1007 // int int*
#define SQLITE_DBCONFIG_TRIGGER_EQP 1008 // int int*
#define SQLITE_DBCONFIG_RESET_DATABASE 1009 // int int*
#define SQLITE_DBCONFIG_DEFENSIVE 1010 // int int*
#define SQLITE_DBCONFIG_WRITABLE_SCHEMA 1011 // int int*
#define SQLITE_DBCONFIG_LEGACY_ALTER_TABLE 1012 // int int*
#define SQLITE_DBCONFIG_DQS_DML 1013 // int int*
#define SQLITE_DBCONFIG_DQS_DDL 1014 // int int*
#define SQLITE_DBCONFIG_ENABLE_VIEW 1015 // int int*
#define SQLITE_DBCONFIG_LEGACY_FILE_FORMAT 1016 // int int*
#define SQLITE_DBCONFIG_TRUSTED_SCHEMA 1017 // int int*
#define SQLITE_DBCONFIG_STMT_SCANSTATUS 1018 // int int*
#define SQLITE_DBCONFIG_REVERSE_SCANORDER 1019 // int int*
#define SQLITE_DBCONFIG_MAX 1019 // Largest DBCONFIG

(static) enum MkErrorE Sq3DbConfigE_FromInt(MK_I32 const value, enum Sq3DbConfigE *value_out)

top return the Sq3DbConfigE from integer … → API: Sq3DbConfigE_FromInt

(static) MK_I32 Sq3DbConfigE_ToInt(enum Sq3DbConfigE value)

top return the Sq3DbConfigE as integer … → API: Sq3DbConfigE_ToInt

(static) MK_STRN Sq3DbConfigE_ToString(enum Sq3DbConfigE value)

top return the Sq3DbConfigE as string … → API: Sq3DbConfigE_ToString


enum Sq3DbStatusE

top Status Parameters for database connections. → API: Sq3DbStatusE

Status Parameters for database connections …

These constants are the available integer "verbs" that can be passed as the second argument to the Sq3LiteDbStatus () interface.

New verbs may be added in future releases of SQLite. Existing verbs might be discontinued. Applications should check the return code from Sq3LiteDbStatus () to make sure that the call worked. The Sq3LiteDbStatus () interface will return a non-zero error code if a discontinued or unsupported verb is invoked.

SQ3_DBSTATUS_LOOKASIDE_USED

This parameter returns the number of lookaside memory slots currently checked out.

SQ3_DBSTATUS_LOOKASIDE_HIT

This parameter returns the number of malloc attempts that were satisfied using lookaside memory. Only the high-water value is meaningful; the current value is always zero.

SQ3_DBSTATUS_LOOKASIDE_MISS_SIZE

This parameter returns the number malloc attempts that might have been satisfied using lookaside memory but failed due to the amount of memory requested being larger than the lookaside slot size. Only the high-water value is meaningful; the current value is always zero.

SQ3_DBSTATUS_LOOKASIDE_MISS_FULL

This parameter returns the number malloc attempts that might have been satisfied using lookaside memory but failed due to all lookaside memory already being in use. Only the high-water value is meaningful; the current value is always zero.

SQ3_DBSTATUS_CACHE_USED

This parameter returns the approximate number of bytes of heap memory used by all pager caches associated with the database connection. The highwater mark associated with SQ3_DBSTATUS_CACHE_USED is always 0.

SQ3_DBSTATUS_CACHE_USED_SHARED

This parameter is similar to DBSTATUS_CACHE_USED, except that if a pager cache is shared between two or more connections the bytes of heap memory used by that pager cache is divided evenly between the attached connections. In other words, if none of the pager caches associated with the database connection are shared, this request returns the same value as DBSTATUS_CACHE_USED. Or, if one or more or the pager caches are shared, the value returned by this call will be smaller than that returned by DBSTATUS_CACHE_USED. The highwater mark associated with SQ3_DBSTATUS_CACHE_USED_SHARED is always 0.

SQ3_DBSTATUS_SCHEMA_USED

This parameter returns the approximate number of bytes of heap memory used to store the schema for all databases associated with the connection - main, temp, and any ATTACH-ed databases. The full amount of memory used by the schemas is reported, even if the schema memory is shared with other database connections due to shared cache mode being enabled. The highwater mark associated with SQ3_DBSTATUS_SCHEMA_USED is always 0.

SQ3_DBSTATUS_STMT_USED

This parameter returns the approximate number of bytes of heap and lookaside memory used by all prepared statements associated with the database connection. The highwater mark associated with SQ3_DBSTATUS_STMT_USED is always 0.

SQ3_DBSTATUS_CACHE_HIT

This parameter returns the number of pager cache hits that have occurred. The highwater mark associated with SQ3_DBSTATUS_CACHE_HIT is always 0.

SQ3_DBSTATUS_CACHE_MISS

This parameter returns the number of pager cache misses that have occurred. The highwater mark associated with SQ3_DBSTATUS_CACHE_MISS is always 0.

SQ3_DBSTATUS_CACHE_WRITE

This parameter returns the number of dirty cache entries that have been written to disk. Specifically, the number of pages written to the wal file in wal mode databases, or the number of pages written to the database file in rollback mode databases. Any pages written as part of transaction rollback or database recovery operations are not included. If an IO or other error occurs while writing a page to disk, the effect on subsequent SQ3_DBSTATUS_CACHE_WRITE requests is undefined. The highwater mark associated with SQ3_DBSTATUS_CACHE_WRITE is always 0.

SQ3_DBSTATUS_CACHE_SPILL

This parameter returns the number of dirty cache entries that have been written to disk in the middle of a transaction due to the page cache overflowing. Transactions are more efficient if they are written to disk all at once. When pages spill mid-transaction, that introduces additional overhead. This parameter can be used help identify inefficiencies that can be resolved by increasing the cache size.

SQ3_DBSTATUS_DEFERRED_FKS
This parameter returns zero for the current value if and only if all foreign key constraints (deferred or immediate) have been resolved. The highwater mark is always 0.

Reference code from sqlite3:

#define SQLITE_DBSTATUS_LOOKASIDE_USED 0
#define SQLITE_DBSTATUS_CACHE_USED 1
#define SQLITE_DBSTATUS_SCHEMA_USED 2
#define SQLITE_DBSTATUS_STMT_USED 3
#define SQLITE_DBSTATUS_LOOKASIDE_HIT 4
#define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5
#define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6
#define SQLITE_DBSTATUS_CACHE_HIT 7
#define SQLITE_DBSTATUS_CACHE_MISS 8
#define SQLITE_DBSTATUS_CACHE_WRITE 9
#define SQLITE_DBSTATUS_DEFERRED_FKS 10
#define SQLITE_DBSTATUS_CACHE_USED_SHARED 11
#define SQLITE_DBSTATUS_CACHE_SPILL 12
#define SQLITE_DBSTATUS_MAX 12 // Largest defined DBSTATUS

(static) enum MkErrorE Sq3DbStatusE_FromInt(MK_I32 const value, enum Sq3DbStatusE *value_out)

top return the Sq3DbStatusE from integer … → API: Sq3DbStatusE_FromInt

(static) MK_I32 Sq3DbStatusE_ToInt(enum Sq3DbStatusE value)

top return the Sq3DbStatusE as integer … → API: Sq3DbStatusE_ToInt

(static) MK_STRN Sq3DbStatusE_ToString(enum Sq3DbStatusE value)

top return the Sq3DbStatusE as string … → API: Sq3DbStatusE_ToString


enum Sq3DeSerializeEF

top Flags for sqlite3_deserialize() → API: Sq3DeSerializeEF

Flags for sqlite3_deserialize()

__parser__(enum-is-flag)
typedef enum Sq3DeSerializeEF {
#ifdef META_COMPILE_AS_CC
{
return static_cast<Sq3DeSerializeEF>(static_cast<int>(a) | static_cast<int>(b));
}
#endif

The following are allowed values for 6th argument (the F argument) to the Sq3LiteDeserialize (D,S,P,N,M,F) interface.

The SQ3_DESERIALIZE_FREEONCLOSE means that the database serialization in the P argument is held in memory obtained from Sq3Malloc64 () and that SQLite should take ownership of this memory and automatically free it when it has finished using it. Without this flag, the caller is responsible for freeing any dynamically allocated memory.

The SQ3_DESERIALIZE_RESIZEABLE flag means that SQLite is allowed to grow the size of the database using calls to Sq3Realloc64 (). This flag should only be used if SQ3_DESERIALIZE_FREEONCLOSE is also used. Without this flag, the deserialized database cannot increase in size beyond the number of bytes specified by the M parameter.

The SQ3_DESERIALIZE_READONLY flag means that the deserialized database should be treated as read-only.

Reference code from sqlite3:

#define SQLITE_DESERIALIZE_FREEONCLOSE 1 // Call sqlite3_free() on close
#define SQLITE_DESERIALIZE_RESIZEABLE 2 // Resize using sqlite3_realloc64()
#define SQLITE_DESERIALIZE_READONLY 4 // Database is read-only

(static) enum MkErrorE Sq3DeSerializeEF_FromInt(MK_I32 const value, enum Sq3DeSerializeEF *value_out)

top return the Sq3DeSerializeEF from integer … → API: Sq3DeSerializeEF_FromInt

(static) MK_I32 Sq3DeSerializeEF_ToInt(enum Sq3DeSerializeEF value)

top return the Sq3DeSerializeEF as integer … → API: Sq3DeSerializeEF_ToInt

(static) MK_STRN Sq3DeSerializeEF_ToString(enum Sq3DeSerializeEF value)

top return the Sq3DeSerializeEF as string … → API: Sq3DeSerializeEF_ToString


enum Sq3ErrorE

top Result Codes. → API: Sq3ErrorE

Result Codes …

Many SQLite functions return an integer result code from the set shown here in order to indicate success or failure.

New error codes may be added in future versions of SQLite.

See also: extended result code definitions

Reference code from sqlite3:

#define SQLITE_OK 0 // Successful result
// beginning-of-error-codes
#define SQLITE_ERROR 1 // Generic error
#define SQLITE_INTERNAL 2 // Internal logic error in SQLite
#define SQLITE_PERM 3 // Access permission denied
#define SQLITE_ABORT 4 // Callback routine requested an abort
#define SQLITE_BUSY 5 // The database file is locked
#define SQLITE_LOCKED 6 // A table in the database is locked
#define SQLITE_NOMEM 7 // A malloc() failed
#define SQLITE_READONLY 8 // Attempt to write a readonly database
#define SQLITE_INTERRUPT 9 // Operation terminated by sqlite3_interrupt()
#define SQLITE_IOERR 10 // Some kind of disk I/O error occurred
#define SQLITE_CORRUPT 11 // The database disk image is malformed
#define SQLITE_NOTFOUND 12 // Unknown opcode in sqlite3_file_control()
#define SQLITE_FULL 13 // Insertion failed because database is full
#define SQLITE_CANTOPEN 14 // Unable to open the database file
#define SQLITE_PROTOCOL 15 // Database lock protocol error
#define SQLITE_EMPTY 16 // Internal use only
#define SQLITE_SCHEMA 17 // The database schema changed
#define SQLITE_TOOBIG 18 // String or BLOB exceeds size limit
#define SQLITE_CONSTRAINT 19 // Abort due to constraint violation
#define SQLITE_MISMATCH 20 // Data type mismatch
#define SQLITE_MISUSE 21 // Library used incorrectly
#define SQLITE_NOLFS 22 // Uses OS features not supported on host
#define SQLITE_AUTH 23 // Authorization denied
#define SQLITE_FORMAT 24 // Not used
#define SQLITE_RANGE 25 // 2nd parameter to sqlite3_bind out of range
#define SQLITE_NOTADB 26 // File opened that is not a database file
#define SQLITE_NOTICE 27 // Notifications from sqlite3_log()
#define SQLITE_WARNING 28 // Warnings from sqlite3_log()
#define SQLITE_ROW 100 // sqlite3_step() has another row ready
#define SQLITE_DONE 101 // sqlite3_step() has finished executing
// end-of-error-codes

(static) enum MkErrorE Sq3ErrorE_FromInt(MK_I32 const value, enum Sq3ErrorE *value_out)

top return the Sq3ErrorE from integer … → API: Sq3ErrorE_FromInt

(static) MK_I32 Sq3ErrorE_ToInt(enum Sq3ErrorE value)

top return the Sq3ErrorE as integer … → API: Sq3ErrorE_ToInt

(static) MK_STRN Sq3ErrorE_ToString(enum Sq3ErrorE value)

top return the Sq3ErrorE as string … → API: Sq3ErrorE_ToString


enum Sq3ExtendetResultCodesE

top Extended Result Codes. → API: Sq3ExtendetResultCodesE

Extended Result Codes …

SQ3_EXTRESULT_ERROR_RETRY = (1 | (2<<8)) ,
SQ3_EXTRESULT_IOERR_READ = (10 | (1<<8)) ,
SQ3_EXTRESULT_IOERR_WRITE = (10 | (3<<8)) ,
SQ3_EXTRESULT_IOERR_FSYNC = (10 | (4<<8)) ,
SQ3_EXTRESULT_IOERR_TRUNCATE = (10 | (6<<8)) ,
SQ3_EXTRESULT_IOERR_FSTAT = (10 | (7<<8)) ,
SQ3_EXTRESULT_IOERR_UNLOCK = (10 | (8<<8)) ,
SQ3_EXTRESULT_IOERR_RDLOCK = (10 | (9<<8)) ,
SQ3_EXTRESULT_IOERR_DELETE = (10 | (10<<8)) ,
SQ3_EXTRESULT_IOERR_BLOCKED = (10 | (11<<8)) ,
SQ3_EXTRESULT_IOERR_NOMEM = (10 | (12<<8)) ,
SQ3_EXTRESULT_IOERR_ACCESS = (10 | (13<<8)) ,
SQ3_EXTRESULT_IOERR_LOCK = (10 | (15<<8)) ,
SQ3_EXTRESULT_IOERR_CLOSE = (10 | (16<<8)) ,
SQ3_EXTRESULT_IOERR_DIR_CLOSE = (10 | (17<<8)) ,
SQ3_EXTRESULT_IOERR_SHMOPEN = (10 | (18<<8)) ,
SQ3_EXTRESULT_IOERR_SHMSIZE = (10 | (19<<8)) ,
SQ3_EXTRESULT_IOERR_SHMLOCK = (10 | (20<<8)) ,
SQ3_EXTRESULT_IOERR_SHMMAP = (10 | (21<<8)) ,
SQ3_EXTRESULT_IOERR_SEEK = (10 | (22<<8)) ,
SQ3_EXTRESULT_IOERR_MMAP = (10 | (24<<8)) ,
SQ3_EXTRESULT_IOERR_CONVPATH = (10 | (26<<8)) ,
SQ3_EXTRESULT_IOERR_VNODE = (10 | (27<<8)) ,
SQ3_EXTRESULT_IOERR_AUTH = (10 | (28<<8)) ,
SQ3_EXTRESULT_IOERR_DATA = (10 | (32<<8)) ,
SQ3_EXTRESULT_IOERR_CORRUPTFS = (10 | (33<<8)) ,
SQ3_EXTRESULT_IOERR_IN_PAGE = (10 | (34<<8)) ,
SQ3_EXTRESULT_LOCKED_VTAB = (6 | (2<<8)) ,
SQ3_EXTRESULT_BUSY_RECOVERY = (5 | (1<<8)) ,
SQ3_EXTRESULT_BUSY_SNAPSHOT = (5 | (2<<8)) ,
SQ3_EXTRESULT_BUSY_TIMEOUT = (5 | (3<<8)) ,
SQ3_EXTRESULT_CANTOPEN_ISDIR = (14 | (2<<8)) ,
SQ3_EXTRESULT_CORRUPT_VTAB = (11 | (1<<8)) ,
SQ3_EXTRESULT_CORRUPT_INDEX = (11 | (3<<8)) ,
SQ3_EXTRESULT_NOTICE_RBU = (27 | (3<<8)) ,
SQ3_EXTRESULT_AUTH_USER = (23 | (1<<8)) ,
SQ3_EXTRESULT_OK_SYMLINK = (0 | (2<<8)) ,

In its default configuration, SQLite API routines return one of 30 integer result codes. However, experience has shown that many of these result codes are too coarse-grained. They do not provide as much information about problems as programmers might like. In an effort to address this, newer versions of SQLite (version 3.3.8 dateof:3.3.8 and later) include support for additional result codes that provide more detailed information about errors. These extended result codes are enabled or disabled on a per database connection basis using the Sq3LiteExtendedResultCodes () API. Or, the extended code for the most recent error can be obtained using Sq3LiteExtendetErrCode ().

Reference code from sqlite3:

#define SQLITE_ERROR_MISSING_COLLSEQ (SQLITE_ERROR | (1<<8))
#define SQLITE_ERROR_RETRY (SQLITE_ERROR | (2<<8))
#define SQLITE_ERROR_SNAPSHOT (SQLITE_ERROR | (3<<8))
#define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8))
#define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8))
#define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8))
#define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8))
#define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8))
#define SQLITE_IOERR_TRUNCATE (SQLITE_IOERR | (6<<8))
#define SQLITE_IOERR_FSTAT (SQLITE_IOERR | (7<<8))
#define SQLITE_IOERR_UNLOCK (SQLITE_IOERR | (8<<8))
#define SQLITE_IOERR_RDLOCK (SQLITE_IOERR | (9<<8))
#define SQLITE_IOERR_DELETE (SQLITE_IOERR | (10<<8))
#define SQLITE_IOERR_BLOCKED (SQLITE_IOERR | (11<<8))
#define SQLITE_IOERR_NOMEM (SQLITE_IOERR | (12<<8))
#define SQLITE_IOERR_ACCESS (SQLITE_IOERR | (13<<8))
#define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8))
#define SQLITE_IOERR_LOCK (SQLITE_IOERR | (15<<8))
#define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8))
#define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8))
#define SQLITE_IOERR_SHMOPEN (SQLITE_IOERR | (18<<8))
#define SQLITE_IOERR_SHMSIZE (SQLITE_IOERR | (19<<8))
#define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
#define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
#define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
#define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
#define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
#define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8))
#define SQLITE_IOERR_CONVPATH (SQLITE_IOERR | (26<<8))
#define SQLITE_IOERR_VNODE (SQLITE_IOERR | (27<<8))
#define SQLITE_IOERR_AUTH (SQLITE_IOERR | (28<<8))
#define SQLITE_IOERR_BEGIN_ATOMIC (SQLITE_IOERR | (29<<8))
#define SQLITE_IOERR_COMMIT_ATOMIC (SQLITE_IOERR | (30<<8))
#define SQLITE_IOERR_ROLLBACK_ATOMIC (SQLITE_IOERR | (31<<8))
#define SQLITE_IOERR_DATA (SQLITE_IOERR | (32<<8))
#define SQLITE_IOERR_CORRUPTFS (SQLITE_IOERR | (33<<8))
#define SQLITE_IOERR_IN_PAGE (SQLITE_IOERR | (34<<8))
#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
#define SQLITE_LOCKED_VTAB (SQLITE_LOCKED | (2<<8))
#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
#define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
#define SQLITE_BUSY_TIMEOUT (SQLITE_BUSY | (3<<8))
#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
#define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
#define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
#define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8))
#define SQLITE_CANTOPEN_DIRTYWAL (SQLITE_CANTOPEN | (5<<8)) // Not Used
#define SQLITE_CANTOPEN_SYMLINK (SQLITE_CANTOPEN | (6<<8))
#define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
#define SQLITE_CORRUPT_SEQUENCE (SQLITE_CORRUPT | (2<<8))
#define SQLITE_CORRUPT_INDEX (SQLITE_CORRUPT | (3<<8))
#define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
#define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
#define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8))
#define SQLITE_READONLY_DBMOVED (SQLITE_READONLY | (4<<8))
#define SQLITE_READONLY_CANTINIT (SQLITE_READONLY | (5<<8))
#define SQLITE_READONLY_DIRECTORY (SQLITE_READONLY | (6<<8))
#define SQLITE_ABORT_ROLLBACK (SQLITE_ABORT | (2<<8))
#define SQLITE_CONSTRAINT_CHECK (SQLITE_CONSTRAINT | (1<<8))
#define SQLITE_CONSTRAINT_COMMITHOOK (SQLITE_CONSTRAINT | (2<<8))
#define SQLITE_CONSTRAINT_FOREIGNKEY (SQLITE_CONSTRAINT | (3<<8))
#define SQLITE_CONSTRAINT_FUNCTION (SQLITE_CONSTRAINT | (4<<8))
#define SQLITE_CONSTRAINT_NOTNULL (SQLITE_CONSTRAINT | (5<<8))
#define SQLITE_CONSTRAINT_PRIMARYKEY (SQLITE_CONSTRAINT | (6<<8))
#define SQLITE_CONSTRAINT_TRIGGER (SQLITE_CONSTRAINT | (7<<8))
#define SQLITE_CONSTRAINT_UNIQUE (SQLITE_CONSTRAINT | (8<<8))
#define SQLITE_CONSTRAINT_VTAB (SQLITE_CONSTRAINT | (9<<8))
#define SQLITE_CONSTRAINT_ROWID (SQLITE_CONSTRAINT |(10<<8))
#define SQLITE_CONSTRAINT_PINNED (SQLITE_CONSTRAINT |(11<<8))
#define SQLITE_CONSTRAINT_DATATYPE (SQLITE_CONSTRAINT |(12<<8))
#define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8))
#define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
#define SQLITE_NOTICE_RBU (SQLITE_NOTICE | (3<<8))
#define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
#define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
#define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8))
#define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8)) // internal use only

(static) enum MkErrorE Sq3ExtendetResultCodesE_FromInt(MK_I32 const value, enum Sq3ExtendetResultCodesE *value_out)

top return the Sq3ExtendetResultCodesE from integer … → API: Sq3ExtendetResultCodesE_FromInt

(static) MK_I32 Sq3ExtendetResultCodesE_ToInt(enum Sq3ExtendetResultCodesE value)

top return the Sq3ExtendetResultCodesE as integer … → API: Sq3ExtendetResultCodesE_ToInt

(static) MK_STRN Sq3ExtendetResultCodesE_ToString(enum Sq3ExtendetResultCodesE value)

top return the Sq3ExtendetResultCodesE as string … → API: Sq3ExtendetResultCodesE_ToString


enum Sq3FcntlE

top Standard File Control Opcodes. → API: Sq3FcntlE

Standard File Control Opcodes …

These integer constants are opcodes for the xFileControl method of the sqlite3_io_methods object and for the Sq3LiteFileControl () interface.

  • The SQ3_FCNTL_LOCKSTATE opcode is used for debugging. This opcode causes the xFileControl method to write the current state of the lock (one of SQ3_LOCK_NONE, SQ3_LOCK_SHARED, SQ3_LOCK_RESERVED, SQ3_LOCK_PENDING, or SQ3_LOCK_EXCLUSIVE) into an integer that the pArg argument points to. This capability is only available if SQLite is compiled with SQLITE_DEBUG.

  • The SQ3_FCNTL_SIZE_HINT opcode is used by SQLite to give the VFS layer a hint of how large the database file will grow to be during the current transaction. This hint is not guaranteed to be accurate but it is often close. The underlying VFS might choose to preallocate database file space based on this hint in order to help writes to the database file run faster.

  • The SQ3_FCNTL_SIZE_LIMIT opcode is used by in-memory VFS that implements Sq3LiteDeserialize () to set an upper bound on the size of the in-memory database. The argument is a pointer to a sqlite3_int64. If the integer pointed to is negative, then it is filled in with the current limit. Otherwise the limit is set to the larger of the value of the integer pointed to and the current database size. The integer pointed to is set to the new limit.

  • The SQ3_FCNTL_CHUNK_SIZE opcode is used to request that the VFS extends and truncates the database file in chunks of a size specified by the user. The fourth argument to Sq3LiteFileControl () should point to an integer (type int) containing the new chunk-size to use for the nominated database. Allocating database file space in large chunks (say 1MB at a time), may reduce file-system fragmentation and improve performance on some systems.

  • The SQ3_FCNTL_FILE_POINTER opcode is used to obtain a pointer to the Sq3FileC object associated with a particular database connection. See also SQ3_FCNTL_JOURNAL_POINTER.

  • The SQ3_FCNTL_JOURNAL_POINTER opcode is used to obtain a pointer to the Sq3FileC object associated with the journal file (either the rollback journal or the write-ahead log) for a particular database connection. See also SQ3_FCNTL_FILE_POINTER.

  • No longer in use.

  • The SQ3_FCNTL_SYNC opcode is generated internally by SQLite and sent to the VFS immediately before the xSync method is invoked on a database file descriptor. Or, if the xSync method is not invoked because the user has configured SQLite with PRAGMA synchronous=OFF it is invoked in place of the xSync method. In most cases, the pointer argument passed with this file-control is NULL. However, if the database file is being synced as part of a multi-database commit, the argument points to a nul-terminated string containing the transactions super-journal file name. VFSes that do not need this signal should silently ignore this opcode. Applications should not call Sq3LiteFileControl () with this opcode as doing so may disrupt the operation of the specialized VFSes that do require it.

  • The SQ3_FCNTL_COMMIT_PHASETWO opcode is generated internally by SQLite and sent to the VFS after a transaction has been committed immediately but before the database is unlocked. VFSes that do not need this signal should silently ignore this opcode. Applications should not call Sq3LiteFileControl () with this opcode as doing so may disrupt the operation of the specialized VFSes that do require it.

  • The SQ3_FCNTL_WIN32_AV_RETRY opcode is used to configure automatic retry counts and intervals for certain disk I/O operations for the windows VFS in order to provide robustness in the presence of anti-virus programs. By default, the windows VFS will retry file read, file write, and file delete operations up to 10 times, with a delay of 25 milliseconds before the first retry and with the delay increasing by an additional 25 milliseconds with each subsequent retry. This opcode allows these two values (10 retries and 25 milliseconds of delay) to be adjusted. The values are changed for all database connections within the same process. The argument is a pointer to an array of two integers where the first integer is the new retry count and the second integer is the delay. If either integer is negative, then the setting is not changed but instead the prior value of that setting is written into the array entry, allowing the current retry settings to be interrogated. The zDbName parameter is ignored.

  • The SQ3_FCNTL_PERSIST_WAL opcode is used to set or query the persistent Write Ahead Log setting. By default, the auxiliary write ahead log (WAL file) and shared memory files used for transaction control are automatically deleted when the latest connection to the database closes. Setting persistent WAL mode causes those files to persist after close. Persisting the files is useful when other processes that do not have write permission on the directory containing the database file want to read the database file, as the WAL and shared memory files must exist in order for the database to be readable. The fourth parameter to Sq3LiteFileControl () for this opcode should be a pointer to an integer. That integer is 0 to disable persistent WAL mode or 1 to enable persistent WAL mode. If the integer is -1, then it is overwritten with the current WAL persistence setting.

  • The SQ3_FCNTL_POWERSAFE_OVERWRITE opcode is used to set or query the persistent "powersafe-overwrite" or "PSOW" setting. The PSOW setting determines the SQ3_IOCAP_POWERSAFE_OVERWRITE bit of the xDeviceCharacteristics methods. The fourth parameter to Sq3LiteFileControl () for this opcode should be a pointer to an integer. That integer is 0 to disable zero-damage mode or 1 to enable zero-damage mode. If the integer is -1, then it is overwritten with the current zero-damage mode setting.

  • The SQ3_FCNTL_OVERWRITE opcode is invoked by SQLite after opening a write transaction to indicate that, unless it is rolled back for some reason, the entire database file will be overwritten by the current transaction. This is used by VACUUM operations.

  • The SQ3_FCNTL_VFSNAME opcode can be used to obtain the names of all VFSes in the VFS stack. The names are of all VFS shims and the final bottom-level VFS are written into memory obtained from Sq3Malloc () and the result is stored in the char* variable that the fourth parameter of Sq3LiteFileControl () points to. The caller is responsible for freeing the memory when done. As with all file-control actions, there is no guarantee that this will actually do anything. Callers should initialize the char* variable to a NULL pointer in case this file-control is not implemented. This file-control is intended for diagnostic use only.

  • The SQ3_FCNTL_VFS_POINTER opcode finds a pointer to the top-level VFSes currently in use. The argument X in Sq3LiteFileControl(db,SQ3_FCNTL_VFS_POINTER,X) must be of type "<a href="https://www.sqlite.org/c3ref/vfs.html">sqlite3_vfs</a> **". This opcodes will set *X to a pointer to the top-level VFS. When there are multiple VFS shims in the stack, this opcode finds the upper-most shim only.

  • Whenever a PRAGMA statement is parsed, an SQ3_FCNTL_PRAGMA file control is sent to the open Sq3FileC object corresponding to the database file to which the pragma statement refers. The argument to the SQ3_FCNTL_PRAGMA file control is an array of pointers to strings (char**) in which the second element of the array is the name of the pragma and the third element is the argument to the pragma or NULL if the pragma has no argument. The handler for an SQ3_FCNTL_PRAGMA file control can optionally make the first element of the char** argument point to a string obtained from sqlite3_mprintf () or the equivalent and that string will become the result of the pragma or the error message if the pragma fails. If the SQ3_FCNTL_PRAGMA file control returns SQ3_RESULT_NOTFOUND, then normal PRAGMA processing continues. If the SQ3_FCNTL_PRAGMA file control returns SQ3_RESULT_OK, then the parser assumes that the VFS has handled the PRAGMA itself and the parser generates a no-op prepared statement if result string is NULL, or that returns a copy of the result string if the string is non-NULL. If the SQ3_FCNTL_PRAGMA file control returns any result code other than SQ3_RESULT_OK or SQ3_RESULT_NOTFOUND, that means that the VFS encountered an error while handling the PRAGMA and the compilation of the PRAGMA fails with an error. The SQ3_FCNTL_PRAGMA file control occurs at the beginning of pragma statement analysis and so it is able to override built-in PRAGMA statements.

  • The SQ3_FCNTL_BUSYHANDLER file-control may be invoked by SQLite on the database file handle shortly after it is opened in order to provide a custom VFS with access to the connection's busy-handler callback. The argument is of type (void**)

    • an array of two (void *) values. The first (void *) actually points to a function of type (int (*)(void *)). In order to invoke the connection's busy-handler, this function should be invoked with the second (void *) in the array as the only argument. If it returns non-zero, then the operation should be retried. If it returns zero, the custom VFS should abandon the current operation.

  • Applications can invoke the SQ3_FCNTL_TEMPFILENAME file-control to have SQLite generate a temporary filename using the same algorithm that is followed to generate temporary filenames for TEMP tables and other internal uses. The argument should be a char** which will be filled with the filename written into memory obtained from Sq3Malloc (). The caller should invoke Sq3Free () on the result to avoid a memory leak.

  • The SQ3_FCNTL_MMAP_SIZE file control is used to query or set the maximum number of bytes that will be used for memory-mapped I/O. The argument is a pointer to a value of type sqlite3_int64 that is an advisory maximum number of bytes in the file to memory map. The pointer is overwritten with the old value. The limit is not changed if the value originally pointed to is negative, and so the current limit can be queried by passing in a pointer to a negative number. This file-control is used internally to implement PRAGMA mmap_size.

  • The SQ3_FCNTL_TRACE file control provides advisory information to the VFS about what the higher layers of the SQLite stack are doing. This file control is used by some VFS activity tracing shims. The argument is a zero-terminated string. Higher layers in the SQLite stack may generate instances of this file control if the SQLITE_USE_FCNTL_TRACE compile-time option is enabled.

  • The SQ3_FCNTL_HAS_MOVED file control interprets its argument as a pointer to an integer and it writes a boolean into that integer depending on whether or not the file has been renamed, moved, or deleted since it was first opened.

  • The SQ3_FCNTL_WIN32_GET_HANDLE opcode can be used to obtain the underlying native file handle associated with a file handle. This file control interprets its argument as a pointer to a native file handle and writes the resulting value there.

  • The SQ3_FCNTL_WIN32_SET_HANDLE opcode is used for debugging. This opcode causes the xFileControl method to swap the file handle with the one pointed to by the pArg argument. This capability is used during testing and only needs to be supported when SQLITE_TEST is defined.

  • The SQ3_FCNTL_WAL_BLOCK is a signal to the VFS layer that it might be advantageous to block on the next WAL lock if the lock is not immediately available. The WAL subsystem issues this signal during rare circumstances in order to fix a problem with priority inversion. Applications should not use this file-control.

  • The SQ3_FCNTL_ZIPVFS opcode is implemented by zipvfs only. All other VFS should return SQ3_RESULT_NOTFOUND for this opcode.

  • The SQ3_FCNTL_RBU opcode is implemented by the special VFS used by the RBU extension only. All other VFS should return SQ3_RESULT_NOTFOUND for this opcode.

  • If the SQ3_FCNTL_BEGIN_ATOMIC_WRITE opcode returns SQ3_RESULT_OK, then the file descriptor is placed in "batch write mode", which means all subsequent write operations will be deferred and done atomically at the next SQ3_FCNTL_COMMIT_ATOMIC_WRITE. Systems that do not support batch atomic writes will return SQ3_RESULT_NOTFOUND. Following a successful SQ3_FCNTL_BEGIN_ATOMIC_WRITE and prior to the closing SQ3_FCNTL_COMMIT_ATOMIC_WRITE or SQ3_FCNTL_ROLLBACK_ATOMIC_WRITE, SQLite will make no VFS interface calls on the same Sq3FileC file descriptor except for calls to the xWrite method and the xFileControl method with SQ3_FCNTL_SIZE_HINT.

  • The SQ3_FCNTL_COMMIT_ATOMIC_WRITE opcode causes all write operations since the previous successful call to SQ3_FCNTL_BEGIN_ATOMIC_WRITE to be performed atomically. This file control returns SQ3_RESULT_OK if and only if the writes were all performed successfully and have been committed to persistent storage. Regardless of whether or not it is successful, this file control takes the file descriptor out of batch write mode so that all subsequent write operations are independent. SQLite will never invoke SQ3_FCNTL_COMMIT_ATOMIC_WRITE without a prior successful call to SQ3_FCNTL_BEGIN_ATOMIC_WRITE.

  • The SQ3_FCNTL_ROLLBACK_ATOMIC_WRITE opcode causes all write operations since the previous successful call to SQ3_FCNTL_BEGIN_ATOMIC_WRITE to be rolled back. This file control takes the file descriptor out of batch write mode so that all subsequent write operations are independent. SQLite will never invoke SQ3_FCNTL_ROLLBACK_ATOMIC_WRITE without a prior successful call to SQ3_FCNTL_BEGIN_ATOMIC_WRITE.

  • The SQ3_FCNTL_LOCK_TIMEOUT opcode is used to configure a VFS to block for up to M milliseconds before failing when attempting to obtain a file lock using the xLock or xShmLock methods of the VFS. The parameter is a pointer to a 32-bit signed integer that contains the value that M is to be set to. Before returning, the 32-bit signed integer is overwritten with the previous value of M.

  • The SQ3_FCNTL_DATA_VERSION opcode is used to detect changes to a database file. The argument is a pointer to a 32-bit unsigned integer. The "data version" for the pager is written into the pointer. The "data version" changes whenever any change occurs to the corresponding database file, either through SQL statements on the same database connection or through transactions committed by separate database connections possibly in other processes. The Sq3LiteTotalChanges () interface can be used to find if any database on the connection has changed, but that interface responds to changes on TEMP as well as MAIN and does not provide a mechanism to detect changes to MAIN only. Also, the Sq3LiteTotalChanges () interface responds to internal changes only and omits changes made by other database connections. The PRAGMA data_version command provides a mechanism to detect changes to a single attached database that occur due to other database connections, but omits changes implemented by the database connection on which it is called. This file control is the only mechanism to detect changes that happen either internally or externally and that are associated with a particular attached database.

  • The SQ3_FCNTL_CKPT_START opcode is invoked from within a checkpoint in wal mode before the client starts to copy pages from the wal file to the database file.

  • The SQ3_FCNTL_CKPT_DONE opcode is invoked from within a checkpoint in wal mode after the client has finished copying pages from the wal file to the database file, but before the *-shm file is updated to record the fact that the pages have been checkpointed.

  • The EXPERIMENTAL SQ3_FCNTL_EXTERNAL_READER opcode is used to detect whether or not there is a database client in another process with a wal-mode transaction open on the database or not. It is only available on unix.The (void*) argument passed with this file-control should be a pointer to a value of type (int). The integer value is set to 1 if the database is a wal mode database and there exists at least one client in another process that currently has an SQL transaction open on the database. It is set to 0 if the database is not a wal-mode db, or if there is no such connection in any other process. This opcode cannot be used to detect transactions opened by clients within the current process, only within other processes.

  • The SQ3_FCNTL_CKSM_FILE opcode is for use internally by the checksum VFS shim only.

  • If there is currently no transaction open on the database, and the database is not a temp db, then the SQ3_FCNTL_RESET_CACHE file-control purges the contents of the in-memory page cache. If there is an open transaction, or if the db is a temp-db, this opcode is a no-op, not an error.

Reference code from sqlite3:

#define SQLITE_FCNTL_LOCKSTATE 1
#define SQLITE_FCNTL_GET_LOCKPROXYFILE 2
#define SQLITE_FCNTL_SET_LOCKPROXYFILE 3
#define SQLITE_FCNTL_LAST_ERRNO 4
#define SQLITE_FCNTL_SIZE_HINT 5
#define SQLITE_FCNTL_CHUNK_SIZE 6
#define SQLITE_FCNTL_FILE_POINTER 7
#define SQLITE_FCNTL_SYNC_OMITTED 8
#define SQLITE_FCNTL_WIN32_AV_RETRY 9
#define SQLITE_FCNTL_PERSIST_WAL 10
#define SQLITE_FCNTL_OVERWRITE 11
#define SQLITE_FCNTL_VFSNAME 12
#define SQLITE_FCNTL_POWERSAFE_OVERWRITE 13
#define SQLITE_FCNTL_PRAGMA 14
#define SQLITE_FCNTL_BUSYHANDLER 15
#define SQLITE_FCNTL_TEMPFILENAME 16
#define SQLITE_FCNTL_MMAP_SIZE 18
#define SQLITE_FCNTL_TRACE 19
#define SQLITE_FCNTL_HAS_MOVED 20
#define SQLITE_FCNTL_SYNC 21
#define SQLITE_FCNTL_COMMIT_PHASETWO 22
#define SQLITE_FCNTL_WIN32_SET_HANDLE 23
#define SQLITE_FCNTL_WAL_BLOCK 24
#define SQLITE_FCNTL_ZIPVFS 25
#define SQLITE_FCNTL_RBU 26
#define SQLITE_FCNTL_VFS_POINTER 27
#define SQLITE_FCNTL_JOURNAL_POINTER 28
#define SQLITE_FCNTL_WIN32_GET_HANDLE 29
#define SQLITE_FCNTL_PDB 30
#define SQLITE_FCNTL_BEGIN_ATOMIC_WRITE 31
#define SQLITE_FCNTL_COMMIT_ATOMIC_WRITE 32
#define SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE 33
#define SQLITE_FCNTL_LOCK_TIMEOUT 34
#define SQLITE_FCNTL_DATA_VERSION 35
#define SQLITE_FCNTL_SIZE_LIMIT 36
#define SQLITE_FCNTL_CKPT_DONE 37
#define SQLITE_FCNTL_RESERVE_BYTES 38
#define SQLITE_FCNTL_CKPT_START 39
#define SQLITE_FCNTL_EXTERNAL_READER 40
#define SQLITE_FCNTL_CKSM_FILE 41
#define SQLITE_FCNTL_RESET_CACHE 42

(static) enum MkErrorE Sq3FcntlE_FromInt(MK_I32 const value, enum Sq3FcntlE *value_out)

top return the Sq3FcntlE from integer … → API: Sq3FcntlE_FromInt

(static) MK_I32 Sq3FcntlE_ToInt(enum Sq3FcntlE value)

top return the Sq3FcntlE as integer … → API: Sq3FcntlE_ToInt

(static) MK_STRN Sq3FcntlE_ToString(enum Sq3FcntlE value)

top return the Sq3FcntlE as string … → API: Sq3FcntlE_ToString


enum Sq3FunctionEF

top Function Flags. → API: Sq3FunctionEF

Function Flags …

__parser__(enum-is-flag)
typedef enum Sq3FunctionEF {
SQ3_FUNCTION_DIRECTONLY = 0x000080000 ,
SQ3_FUNCTION_SUBTYPE = 0x000100000 ,
SQ3_FUNCTION_INNOCUOUS = 0x000200000 ,
#ifdef META_COMPILE_AS_CC
{
return static_cast<Sq3FunctionEF>(static_cast<int>(a) | static_cast<int>(b));
}
#endif

These constants may be ORed together with the preferred text encoding as the fourth argument to sqlite3_create_function (), sqlite3_create_function16 (), or Sq3LiteCreateFunctionV2 ().

SQ3_FUNCTION_DETERMINISTIC

The SQ3_FUNCTION_DETERMINISTIC flag means that the new function always gives the same output when the input parameters are the same. The abs() function is deterministic, for example, but randomblob() is not. Functions must be deterministic in order to be used in certain contexts such as with the WHERE clause of partial indexes or in generated columns. SQLite might also optimize deterministic functions by factoring them out of inner loops.

SQ3_FUNCTION_DIRECTONLY

The SQ3_FUNCTION_DIRECTONLY flag means that the function may only be invoked from top-level SQL, and cannot be used in VIEWs or TRIGGERs nor in schema structures such as CHECK constraints, DEFAULT clauses, expression indexes, partial indexes, or generated columns.

The SQ3_FUNCTION_DIRECTONLY flag is recommended for any application-defined SQL function that has side-effects or that could potentially leak sensitive information. This will prevent attacks in which an application is tricked into using a database file that has had its schema surreptitiously modified to invoke the application-defined function in ways that are harmful.

Some people say it is good practice to set SQ3_FUNCTION_DIRECTONLY on all application-defined SQL functions, regardless of whether or not they are security sensitive, as doing so prevents those functions from being used inside of the database schema, and thus ensures that the database can be inspected and modified using generic tools (such as the CLI) that do not have access to the application-defined functions.

SQ3_FUNCTION_INNOCUOUS

The SQ3_FUNCTION_INNOCUOUS flag means that the function is unlikely to cause problems even if misused. An innocuous function should have no side effects and should not depend on any values other than its input parameters. The abs() function is an example of an innocuous function. The load_extension() SQL function is not innocuous because of its side effects.

SQ3_FUNCTION_INNOCUOUS is similar to SQ3_FUNCTION_DETERMINISTIC, but is not exactly the same. The random() function is an example of a function that is innocuous but not deterministic.

Some heightened security settings (SQ3_DBCONFIG_TRUSTED_SCHEMA and PRAGMA trusted_schema=OFF) disable the use of SQL functions inside views and triggers and in schema structures such as CHECK constraints, DEFAULT clauses, expression indexes, partial indexes, and generated columns unless the function is tagged with SQ3_FUNCTION_INNOCUOUS. Most built-in functions are innocuous. Developers are advised to avoid using the SQ3_FUNCTION_INNOCUOUS flag for application-defined functions unless the function has been carefully audited and found to be free of potentially security-adverse side-effects and information-leaks.

SQ3_FUNCTION_SUBTYPE

The SQ3_FUNCTION_SUBTYPE flag indicates to SQLite that a function might call Sq3ValueSubType () to inspect the sub-types of its arguments. This flag instructs SQLite to omit some corner-case optimizations that might disrupt the operation of the Sq3ValueSubType () function, causing it to return zero rather than the correct subtype(). SQL functions that invokes Sq3ValueSubType () should have this property. If the SQ3_FUNCTION_SUBTYPE property is omitted, then the return value from Sq3ValueSubType () might sometimes be zero even though a non-zero subtype was specified by the function argument expression.

SQ3_FUNCTION_RESULT_SUBTYPE
The SQ3_FUNCTION_RESULT_SUBTYPE flag indicates to SQLite that a function might call sqlite3_result_subtype () to cause a sub-type to be associated with its result. Every function that invokes sqlite3_result_subtype () should have this property. If it does not, then the call to sqlite3_result_subtype () might become a no-op if the function is used as term in an expression index. On the other hand, SQL functions that never invoke sqlite3_result_subtype () should avoid setting this property, as the purpose of this property is to disable certain optimizations that are incompatible with subtypes.

Reference code from sqlite3:

#define SQLITE_DETERMINISTIC 0x000000800
#define SQLITE_DIRECTONLY 0x000080000
#define SQLITE_SUBTYPE 0x000100000
#define SQLITE_INNOCUOUS 0x000200000
#define SQLITE_RESULT_SUBTYPE 0x001000000

(static) enum MkErrorE Sq3FunctionEF_FromInt(MK_I32 const value, enum Sq3FunctionEF *value_out)

top return the Sq3FunctionEF from integer … → API: Sq3FunctionEF_FromInt

(static) MK_I32 Sq3FunctionEF_ToInt(enum Sq3FunctionEF value)

top return the Sq3FunctionEF as integer … → API: Sq3FunctionEF_ToInt

(static) MK_STRN Sq3FunctionEF_ToString(enum Sq3FunctionEF value)

top return the Sq3FunctionEF as string … → API: Sq3FunctionEF_ToString


enum Sq3IndexConstraintEF

top Virtual Table Constraint Operator Codes. → API: Sq3IndexConstraintEF

Virtual Table Constraint Operator Codes …

These macros define the allowed values for the sqlite3_index_info.aConstraint[].op field. Each value represents an operator that is part of a constraint term in the WHERE clause of a query that uses a virtual table.

The left-hand operand of the operator is given by the corresponding aConstraint[].iColumn field. An iColumn of -1 indicates the left-hand operand is the rowid. The SQ3_INDEX_CONSTRAINT_LIMIT and SQ3_INDEX_CONSTRAINT_OFFSET operators have no left-hand operand, and so for those operators the corresponding aConstraint[].iColumn is meaningless and should not be used.

All operator values from SQ3_INDEX_CONSTRAINT_FUNCTION through value 255 are reserved to represent functions that are overloaded by the xFindFunction method of the virtual table implementation.

The right-hand operands for each constraint might be accessible using the sqlite3_vtab_rhs_value () interface. Usually the right-hand operand is only available if it appears as a single constant literal in the input SQL. If the right-hand operand is another column or an expression (even a constant expression) or a parameter, then the sqlite3_vtab_rhs_value() probably will not be able to extract it. The SQ3_INDEX_CONSTRAINT_ISNULL and SQ3_INDEX_CONSTRAINT_ISNOTNULL operators have no right-hand operand and hence calls to sqlite3_vtab_rhs_value() for those operators will always return SQ3_RESULT_NOTFOUND.

The collating sequence to be used for comparison can be found using the sqlite3_vtab_collation () interface. For most real-world virtual tables, the collating sequence of constraints does not matter (for example because the constraints are numeric) and so the sqlite3_vtab_collation() interface is not commonly needed.

Reference code from sqlite3:

#define SQLITE_INDEX_CONSTRAINT_EQ 2
#define SQLITE_INDEX_CONSTRAINT_GT 4
#define SQLITE_INDEX_CONSTRAINT_LE 8
#define SQLITE_INDEX_CONSTRAINT_LT 16
#define SQLITE_INDEX_CONSTRAINT_GE 32
#define SQLITE_INDEX_CONSTRAINT_MATCH 64
#define SQLITE_INDEX_CONSTRAINT_LIKE 65
#define SQLITE_INDEX_CONSTRAINT_GLOB 66
#define SQLITE_INDEX_CONSTRAINT_REGEXP 67
#define SQLITE_INDEX_CONSTRAINT_NE 68
#define SQLITE_INDEX_CONSTRAINT_ISNOT 69
#define SQLITE_INDEX_CONSTRAINT_ISNOTNULL 70
#define SQLITE_INDEX_CONSTRAINT_ISNULL 71
#define SQLITE_INDEX_CONSTRAINT_IS 72
#define SQLITE_INDEX_CONSTRAINT_LIMIT 73
#define SQLITE_INDEX_CONSTRAINT_OFFSET 74
#define SQLITE_INDEX_CONSTRAINT_FUNCTION 150

(static) enum MkErrorE Sq3IndexConstraintEF_FromInt(MK_I32 const value, enum Sq3IndexConstraintEF *value_out)

top return the Sq3IndexConstraintEF from integer … → API: Sq3IndexConstraintEF_FromInt

(static) MK_I32 Sq3IndexConstraintEF_ToInt(enum Sq3IndexConstraintEF value)

top return the Sq3IndexConstraintEF as integer … → API: Sq3IndexConstraintEF_ToInt

(static) MK_STRN Sq3IndexConstraintEF_ToString(enum Sq3IndexConstraintEF value)

top return the Sq3IndexConstraintEF as string … → API: Sq3IndexConstraintEF_ToString


enum Sq3IoCapEF

top Device Characteristics. → API: Sq3IoCapEF

Device Characteristics …

__parser__(enum-is-flag)
typedef enum Sq3IoCapEF {
SQ3_IOCAP_ATOMIC = 0x00000001 ,
SQ3_IOCAP_ATOMIC512 = 0x00000002 ,
SQ3_IOCAP_ATOMIC1K = 0x00000004 ,
SQ3_IOCAP_ATOMIC2K = 0x00000008 ,
SQ3_IOCAP_ATOMIC4K = 0x00000010 ,
SQ3_IOCAP_ATOMIC8K = 0x00000020 ,
SQ3_IOCAP_ATOMIC16K = 0x00000040 ,
SQ3_IOCAP_ATOMIC32K = 0x00000080 ,
SQ3_IOCAP_ATOMIC64K = 0x00000100 ,
SQ3_IOCAP_SAFE_APPEND = 0x00000200 ,
SQ3_IOCAP_SEQUENTIAL = 0x00000400 ,
SQ3_IOCAP_IMMUTABLE = 0x00002000 ,
SQ3_IOCAP_BATCH_ATOMIC = 0x00004000 ,
#ifdef META_COMPILE_AS_CC
inline Sq3IoCapEF operator|(Sq3IoCapEF a, Sq3IoCapEF b)
{
return static_cast<Sq3IoCapEF>(static_cast<int>(a) | static_cast<int>(b));
}
#endif

The xDeviceCharacteristics method of the sqlite3_io_methods object returns an integer which is a vector of these bit values expressing I/O characteristics of the mass storage device that holds the file that the sqlite3_io_methods refers to.

The SQ3_IOCAP_ATOMIC property means that all writes of any size are atomic. The SQ3_IOCAP_ATOMICnnn values mean that writes of blocks that are nnn bytes in size and are aligned to an address which is an integer multiple of nnn are atomic. The SQ3_IOCAP_SAFE_APPEND value means that when data is appended to a file, the data is appended first then the size of the file is extended, never the other way around. The SQ3_IOCAP_SEQUENTIAL property means that information is written to disk in the same order as calls to xWrite(). The SQ3_IOCAP_POWERSAFE_OVERWRITE property means that after reboot following a crash or power loss, the only bytes in a file that were written at the application level might have changed and that adjacent bytes, even bytes within the same sector are guaranteed to be unchanged. The SQ3_IOCAP_UNDELETABLE_WHEN_OPEN flag indicates that a file cannot be deleted when open. The SQ3_IOCAP_IMMUTABLE flag indicates that the file is on read-only media and cannot be changed even by processes with elevated privileges.

The SQ3_IOCAP_BATCH_ATOMIC property means that the underlying filesystem supports doing multiple write operations atomically when those write operations are bracketed by SQ3_FCNTL_BEGIN_ATOMIC_WRITE and SQ3_FCNTL_COMMIT_ATOMIC_WRITE.

Reference code from sqlite3:

#define SQLITE_IOCAP_ATOMIC 0x00000001
#define SQLITE_IOCAP_ATOMIC512 0x00000002
#define SQLITE_IOCAP_ATOMIC1K 0x00000004
#define SQLITE_IOCAP_ATOMIC2K 0x00000008
#define SQLITE_IOCAP_ATOMIC4K 0x00000010
#define SQLITE_IOCAP_ATOMIC8K 0x00000020
#define SQLITE_IOCAP_ATOMIC16K 0x00000040
#define SQLITE_IOCAP_ATOMIC32K 0x00000080
#define SQLITE_IOCAP_ATOMIC64K 0x00000100
#define SQLITE_IOCAP_SAFE_APPEND 0x00000200
#define SQLITE_IOCAP_SEQUENTIAL 0x00000400
#define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN 0x00000800
#define SQLITE_IOCAP_POWERSAFE_OVERWRITE 0x00001000
#define SQLITE_IOCAP_IMMUTABLE 0x00002000
#define SQLITE_IOCAP_BATCH_ATOMIC 0x00004000

(static) enum MkErrorE Sq3IoCapEF_FromInt(MK_I32 const value, enum Sq3IoCapEF *value_out)

top return the Sq3IoCapEF from integer … → API: Sq3IoCapEF_FromInt

(static) MK_I32 Sq3IoCapEF_ToInt(enum Sq3IoCapEF value)

top return the Sq3IoCapEF as integer … → API: Sq3IoCapEF_ToInt

(static) MK_STRN Sq3IoCapEF_ToString(enum Sq3IoCapEF value)

top return the Sq3IoCapEF as string … → API: Sq3IoCapEF_ToString


enum Sq3LimitE

top Run-Time Limit Categories. → API: Sq3LimitE

Run-Time Limit Categories …

These constants define various performance limits that can be lowered at run-time using Sq3LiteLimit (). The synopsis of the meanings of the various limits is shown below. Additional information is available at Limits in SQLite.

SQ3_LIMIT_LENGTH

The maximum size of any string or BLOB or table row, in bytes.

SQ3_LIMIT_SQL_LENGTH

The maximum length of an SQL statement, in bytes.

SQ3_LIMIT_COLUMN

The maximum number of columns in a table definition or in the result set of a SELECT or the maximum number of columns in an index or in an ORDER BY or GROUP BY clause.

SQ3_LIMIT_EXPR_DEPTH

The maximum depth of the parse tree on any expression.

SQ3_LIMIT_COMPOUND_SELECT

The maximum number of terms in a compound SELECT statement.

SQ3_LIMIT_VDBE_OP

The maximum number of instructions in a virtual machine program used to implement an SQL statement. If Sq3StmtPrepareV2 () or the equivalent tries to allocate space for more than this many opcodes in a single prepared statement, an SQ3_RESULT_NOMEM error is returned.

SQ3_LIMIT_FUNCTION_ARG

The maximum number of arguments on a function.

SQ3_LIMIT_ATTACHED

The maximum number of attached databases.

SQ3_LIMIT_LIKE_PATTERN_LENGTH

The maximum length of the pattern argument to the LIKE or GLOB operators.

SQ3_LIMIT_VARIABLE_NUMBER

The maximum index number of any parameter in an SQL statement.

SQ3_LIMIT_TRIGGER_DEPTH

The maximum depth of recursion for triggers.

SQ3_LIMIT_WORKER_THREADS
The maximum number of auxiliary worker threads that a single prepared statement may start.

Reference code from sqlite3:

#define SQLITE_LIMIT_LENGTH 0
#define SQLITE_LIMIT_SQL_LENGTH 1
#define SQLITE_LIMIT_COLUMN 2
#define SQLITE_LIMIT_EXPR_DEPTH 3
#define SQLITE_LIMIT_COMPOUND_SELECT 4
#define SQLITE_LIMIT_VDBE_OP 5
#define SQLITE_LIMIT_FUNCTION_ARG 6
#define SQLITE_LIMIT_ATTACHED 7
#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
#define SQLITE_LIMIT_VARIABLE_NUMBER 9
#define SQLITE_LIMIT_TRIGGER_DEPTH 10
#define SQLITE_LIMIT_WORKER_THREADS 11

(static) enum MkErrorE Sq3LimitE_FromInt(MK_I32 const value, enum Sq3LimitE *value_out)

top return the Sq3LimitE from integer … → API: Sq3LimitE_FromInt

(static) MK_I32 Sq3LimitE_ToInt(enum Sq3LimitE value)

top return the Sq3LimitE as integer … → API: Sq3LimitE_ToInt

(static) MK_STRN Sq3LimitE_ToString(enum Sq3LimitE value)

top return the Sq3LimitE as string … → API: Sq3LimitE_ToString


enum Sq3LockE

top File Locking Levels. → API: Sq3LockE

File Locking Levels …

SQLite uses one of these integer values as the second argument to calls it makes to the xLock() and xUnlock() methods of an sqlite3_io_methods object. These values are ordered from lest restrictive to most restrictive.

The argument to xLock() is always SHARED or higher. The argument to xUnlock is either SHARED or NONE.

Reference code from sqlite3:

#define SQLITE_LOCK_NONE 0 // xUnlock() only
#define SQLITE_LOCK_SHARED 1 // xLock() or xUnlock()
#define SQLITE_LOCK_RESERVED 2 // xLock() only
#define SQLITE_LOCK_PENDING 3 // xLock() only
#define SQLITE_LOCK_EXCLUSIVE 4 // xLock() only

(static) enum MkErrorE Sq3LockE_FromInt(MK_I32 const value, enum Sq3LockE *value_out)

top return the Sq3LockE from integer … → API: Sq3LockE_FromInt

(static) MK_I32 Sq3LockE_ToInt(enum Sq3LockE value)

top return the Sq3LockE as integer … → API: Sq3LockE_ToInt

(static) MK_STRN Sq3LockE_ToString(enum Sq3LockE value)

top return the Sq3LockE as string … → API: Sq3LockE_ToString


enum Sq3MutexE

top Mutex Types. → API: Sq3MutexE

Mutex Types …

The sqlite3_mutex_alloc () interface takes a single argument which is one of these integer constants.

The set of static mutexes may change from one SQLite release to the next. Applications that override the built-in mutex logic must be prepared to accommodate additional static mutexes.

Reference code from sqlite3:

#define SQLITE_MUTEX_FAST 0
#define SQLITE_MUTEX_RECURSIVE 1
#define SQLITE_MUTEX_STATIC_MAIN 2
#define SQLITE_MUTEX_STATIC_MEM 3 // sqlite3_malloc()
#define SQLITE_MUTEX_STATIC_MEM2 4 // NOT USED
#define SQLITE_MUTEX_STATIC_OPEN 4 // sqlite3BtreeOpen()
#define SQLITE_MUTEX_STATIC_PRNG 5 // sqlite3_randomness()
#define SQLITE_MUTEX_STATIC_LRU 6 // lru page list
#define SQLITE_MUTEX_STATIC_LRU2 7 // NOT USED
#define SQLITE_MUTEX_STATIC_PMEM 7 // sqlite3PageMalloc()
#define SQLITE_MUTEX_STATIC_APP1 8 // For use by application
#define SQLITE_MUTEX_STATIC_APP2 9 // For use by application
#define SQLITE_MUTEX_STATIC_APP3 10 // For use by application
#define SQLITE_MUTEX_STATIC_VFS1 11 // For use by built-in VFS
#define SQLITE_MUTEX_STATIC_VFS2 12 // For use by extension VFS
#define SQLITE_MUTEX_STATIC_VFS3 13 // For use by application VFS

(static) enum MkErrorE Sq3MutexE_FromInt(MK_I32 const value, enum Sq3MutexE *value_out)

top return the Sq3MutexE from integer … → API: Sq3MutexE_FromInt

(static) MK_I32 Sq3MutexE_ToInt(enum Sq3MutexE value)

top return the Sq3MutexE as integer … → API: Sq3MutexE_ToInt

(static) MK_STRN Sq3MutexE_ToString(enum Sq3MutexE value)

top return the Sq3MutexE as string … → API: Sq3MutexE_ToString


enum Sq3OpenEF

top Flags For File Open Operations. → API: Sq3OpenEF

Flags For File Open Operations …

__parser__(enum-is-flag)
typedef enum Sq3OpenEF {
SQ3_OPEN_READONLY = 0x00000001 ,
SQ3_OPEN_READWRITE = 0x00000002 ,
SQ3_OPEN_CREATE = 0x00000004 ,
SQ3_OPEN_DELETEONCLOSE = 0x00000008 ,
SQ3_OPEN_EXCLUSIVE = 0x00000010 ,
SQ3_OPEN_AUTOPROXY = 0x00000020 ,
SQ3_OPEN_URI = 0x00000040 ,
SQ3_OPEN_MEMORY = 0x00000080 ,
SQ3_OPEN_MAIN_DB = 0x00000100 ,
SQ3_OPEN_TEMP_DB = 0x00000200 ,
SQ3_OPEN_TRANSIENT_DB = 0x00000400 ,
SQ3_OPEN_MAIN_JOURNAL = 0x00000800 ,
SQ3_OPEN_TEMP_JOURNAL = 0x00001000 ,
SQ3_OPEN_SUBJOURNAL = 0x00002000 ,
SQ3_OPEN_SUPER_JOURNAL = 0x00004000 ,
SQ3_OPEN_NOMUTEX = 0x00008000 ,
SQ3_OPEN_FULLMUTEX = 0x00010000 ,
SQ3_OPEN_SHAREDCACHE = 0x00020000 ,
SQ3_OPEN_PRIVATECACHE = 0x00040000 ,
SQ3_OPEN_WAL = 0x00080000 ,
SQ3_OPEN_NOFOLLOW = 0x01000000 ,
SQ3_OPEN_EXRESCODE = 0x02000000 ,
#ifdef META_COMPILE_AS_CC
inline Sq3OpenEF operator|(Sq3OpenEF a, Sq3OpenEF b)
{
return static_cast<Sq3OpenEF>(static_cast<int>(a) | static_cast<int>(b));
}
#endif

These bit values are intended for use in the 3rd parameter to the Sq3LiteOpenV2 () interface and in the 4th parameter to the sqlite3_vfs.xOpen method.

Only those flags marked as "Ok for sqlite3_open_v2()" may be used as the third argument to the Sq3LiteOpenV2 () interface. The other flags have historically been ignored by Sq3LiteOpenV2(), though future versions of SQLite might change so that an error is raised if any of the disallowed bits are passed into Sq3LiteOpenV2(). Applications should not depend on the historical behavior.

Note in particular that passing the SQ3_OPEN_EXCLUSIVE flag into Sq3LiteOpenV2 () does not cause the underlying database file to be opened using O_EXCL. Passing SQ3_OPEN_EXCLUSIVE into Sq3LiteOpenV2 () has historically be a no-op and might become an error in future versions of SQLite.

Reference code from sqlite3:

#define SQLITE_OPEN_READONLY 0x00000001 // Ok for sqlite3_open_v2()
#define SQLITE_OPEN_READWRITE 0x00000002 // Ok for sqlite3_open_v2()
#define SQLITE_OPEN_CREATE 0x00000004 // Ok for sqlite3_open_v2()
#define SQLITE_OPEN_DELETEONCLOSE 0x00000008 // VFS only
#define SQLITE_OPEN_EXCLUSIVE 0x00000010 // VFS only
#define SQLITE_OPEN_AUTOPROXY 0x00000020 // VFS only
#define SQLITE_OPEN_URI 0x00000040 // Ok for sqlite3_open_v2()
#define SQLITE_OPEN_MEMORY 0x00000080 // Ok for sqlite3_open_v2()
#define SQLITE_OPEN_MAIN_DB 0x00000100 // VFS only
#define SQLITE_OPEN_TEMP_DB 0x00000200 // VFS only
#define SQLITE_OPEN_TRANSIENT_DB 0x00000400 // VFS only
#define SQLITE_OPEN_MAIN_JOURNAL 0x00000800 // VFS only
#define SQLITE_OPEN_TEMP_JOURNAL 0x00001000 // VFS only
#define SQLITE_OPEN_SUBJOURNAL 0x00002000 // VFS only
#define SQLITE_OPEN_SUPER_JOURNAL 0x00004000 // VFS only
#define SQLITE_OPEN_NOMUTEX 0x00008000 // Ok for sqlite3_open_v2()
#define SQLITE_OPEN_FULLMUTEX 0x00010000 // Ok for sqlite3_open_v2()
#define SQLITE_OPEN_SHAREDCACHE 0x00020000 // Ok for sqlite3_open_v2()
#define SQLITE_OPEN_PRIVATECACHE 0x00040000 // Ok for sqlite3_open_v2()
#define SQLITE_OPEN_WAL 0x00080000 // VFS only
#define SQLITE_OPEN_NOFOLLOW 0x01000000 // Ok for sqlite3_open_v2()
#define SQLITE_OPEN_EXRESCODE 0x02000000 // Extended result codes

(static) enum MkErrorE Sq3OpenEF_FromInt(MK_I32 const value, enum Sq3OpenEF *value_out)

top return the Sq3OpenEF from integer … → API: Sq3OpenEF_FromInt

(static) MK_I32 Sq3OpenEF_ToInt(enum Sq3OpenEF value)

top return the Sq3OpenEF as integer … → API: Sq3OpenEF_ToInt

(static) MK_STRN Sq3OpenEF_ToString(enum Sq3OpenEF value)

top return the Sq3OpenEF as string … → API: Sq3OpenEF_ToString


enum Sq3PrepareEF

top Prepare Flags. → API: Sq3PrepareEF

Prepare Flags …

__parser__(enum-is-flag)
typedef enum Sq3PrepareEF {
SQ3_PREPARE_NO = 0x00 ,
#ifdef META_COMPILE_AS_CC
inline Sq3PrepareEF operator|(Sq3PrepareEF a, Sq3PrepareEF b)
{
return static_cast<Sq3PrepareEF>(static_cast<int>(a) | static_cast<int>(b));
}
#endif

These constants define various flags that can be passed into "prepFlags" parameter of the Sq3StmtPrepareV3 () and sqlite3_prepare16_v3 () interfaces.

New flags may be added in future releases of SQLite.

SQ3_PREPARE_PERSISTENT

The SQ3_PREPARE_PERSISTENT flag is a hint to the query planner that the prepared statement will be retained for a long time and probably reused many times. Without this flag, Sq3StmtPrepareV3 () and sqlite3_prepare16_v3 () assume that the prepared statement will be used just once or at most a few times and then destroyed using Sq3StmtFinalize () relatively soon. The current implementation acts on this hint by avoiding the use of lookaside memory so as not to deplete the limited store of lookaside memory. Future versions of SQLite may act on this hint differently.

SQ3_PREPARE_NORMALIZE

The SQ3_PREPARE_NORMALIZE flag is a no-op. This flag used to be required for any prepared statement that wanted to use the sqlite3_normalized_sql () interface. However, the sqlite3_normalized_sql () interface is now available to all prepared statements, regardless of whether or not they use this flag.

SQ3_PREPARE_NO_VTAB
The SQ3_PREPARE_NO_VTAB flag causes the SQL compiler to return an error (error code SQ3_RESULT_ERROR) if the statement uses any virtual tables.

Reference code from sqlite3:

#define SQLITE_PREPARE_PERSISTENT 0x01
#define SQLITE_PREPARE_NORMALIZE 0x02
#define SQLITE_PREPARE_NO_VTAB 0x04

(static) enum MkErrorE Sq3PrepareEF_FromInt(MK_I32 const value, enum Sq3PrepareEF *value_out)

top return the Sq3PrepareEF from integer … → API: Sq3PrepareEF_FromInt

(static) MK_I32 Sq3PrepareEF_ToInt(enum Sq3PrepareEF value)

top return the Sq3PrepareEF as integer … → API: Sq3PrepareEF_ToInt

(static) MK_STRN Sq3PrepareEF_ToString(enum Sq3PrepareEF value)

top return the Sq3PrepareEF as string … → API: Sq3PrepareEF_ToString


enum Sq3ScanStatE

top Prepared Statement Scan Status Opcodes. → API: Sq3ScanStatE

Prepared Statement Scan Status Opcodes …

The following constants can be used for the T parameter to the sqlite3_stmt_scanstatus (S,X,T,V) interface. Each constant designates a different metric for sqlite3_stmt_scanstatus() to return.

When the value returned to V is a string, space to hold that string is managed by the prepared statement S and will be automatically freed when S is finalized.

Not all values are available for all query elements. When a value is not available, the output variable is set to -1 if the value is numeric, or to NULL if it is a string (SQ3_SCANSTAT_NAME).

SQ3_SCANSTAT_NLOOP

The sqlite3_int64 variable pointed to by the V parameter will be set to the total number of times that the X-th loop has run.

SQ3_SCANSTAT_NVISIT

The sqlite3_int64 variable pointed to by the V parameter will be set to the total number of rows examined by all iterations of the X-th loop.

SQ3_SCANSTAT_EST

The "double" variable pointed to by the V parameter will be set to the query planner's estimate for the average number of rows output from each iteration of the X-th loop. If the query planner's estimates was accurate, then this value will approximate the quotient NVISIT/NLOOP and the product of this value for all prior loops with the same SELECTID will be the NLOOP value for the current loop.

SQ3_SCANSTAT_NAME

The "const char *" variable pointed to by the V parameter will be set to a zero-terminated UTF-8 string containing the name of the index or table used for the X-th loop.

SQ3_SCANSTAT_EXPLAIN

The "const char *" variable pointed to by the V parameter will be set to a zero-terminated UTF-8 string containing the EXPLAIN QUERY PLAN description for the X-th loop.

SQ3_SCANSTAT_SELECTID

The "int" variable pointed to by the V parameter will be set to the id for the X-th query plan element. The id value is unique within the statement. The select-id is the same value as is output in the first column of an EXPLAIN QUERY PLAN query.

SQ3_SCANSTAT_PARENTID

The "int" variable pointed to by the V parameter will be set to the the id of the parent of the current query element, if applicable, or to zero if the query element has no parent. This is the same value as returned in the second column of an EXPLAIN QUERY PLAN query.

SQ3_SCANSTAT_NCYCLE
The sqlite3_int64 output value is set to the number of cycles, according to the processor time-stamp counter, that elapsed while the query element was being processed. This value is not available for all query elements - if it is unavailable the output variable is set to -1.

Reference code from sqlite3:

#define SQLITE_SCANSTAT_NLOOP 0
#define SQLITE_SCANSTAT_NVISIT 1
#define SQLITE_SCANSTAT_EST 2
#define SQLITE_SCANSTAT_NAME 3
#define SQLITE_SCANSTAT_EXPLAIN 4
#define SQLITE_SCANSTAT_SELECTID 5
#define SQLITE_SCANSTAT_PARENTID 6
#define SQLITE_SCANSTAT_NCYCLE 7

(static) enum MkErrorE Sq3ScanStatE_FromInt(MK_I32 const value, enum Sq3ScanStatE *value_out)

top return the Sq3ScanStatE from integer … → API: Sq3ScanStatE_FromInt

(static) MK_I32 Sq3ScanStatE_ToInt(enum Sq3ScanStatE value)

top return the Sq3ScanStatE as integer … → API: Sq3ScanStatE_ToInt

(static) MK_STRN Sq3ScanStatE_ToString(enum Sq3ScanStatE value)

top return the Sq3ScanStatE as string … → API: Sq3ScanStatE_ToString


enum Sq3SerializeE

top Flags for sqlite3_serialize. → API: Sq3SerializeE

Flags for sqlite3_serialize …

typedef enum Sq3SerializeE {
SQ3_SERIALIZE_NO = 0x000 ,

Zero or more of the following constants can be OR-ed together for the F argument to Sq3LiteSerialize (D,S,P,F).

SQ3_SERIALIZE_NOCOPY means that Sq3LiteSerialize () will return a pointer to contiguous in-memory database that it is currently using, without making a copy of the database. If SQLite is not currently using a contiguous in-memory database, then this option causes Sq3LiteSerialize () to return a NULL pointer. SQLite will only be using a contiguous in-memory database if it has been initialized by a prior call to Sq3LiteDeserialize ().

Reference code from sqlite3:

#define SQLITE_SERIALIZE_NOCOPY 0x001 // Do no memory allocations

(static) enum MkErrorE Sq3SerializeE_FromInt(MK_I32 const value, enum Sq3SerializeE *value_out)

top return the Sq3SerializeE from integer … → API: Sq3SerializeE_FromInt

(static) MK_I32 Sq3SerializeE_ToInt(enum Sq3SerializeE value)

top return the Sq3SerializeE as integer … → API: Sq3SerializeE_ToInt

(static) MK_STRN Sq3SerializeE_ToString(enum Sq3SerializeE value)

top return the Sq3SerializeE as string … → API: Sq3SerializeE_ToString


enum Sq3SessionObjConfigE

top Options for sqlite3session_object_config. → API: Sq3SessionObjConfigE

Options for sqlite3session_object_config …

The following values may passed as the the 2nd parameter to sqlite3session_object_config().

SQ3_SESSION_OBJCONFIG_SIZE

This option is used to set, clear or query the flag that enables the sqlite3session_changeset_size () API. Because it imposes some computational overhead, this API is disabled by default. Argument pArg must point to a value of type (int). If the value is initially 0, then the sqlite3session_changeset_size() API is disabled. If it is greater than 0, then the same API is enabled. Or, if the initial value is less than zero, no change is made. In all cases the (int) variable is set to 1 if the sqlite3session_changeset_size() API is enabled following the current call, or 0 otherwise.

It is an error (SQ3_RESULT_MISUSE) to attempt to modify this setting after the first table has been attached to the session object.

SQ3_SESSION_OBJCONFIG_ROWID

This option is used to set, clear or query the flag that enables collection of data for tables with no explicit PRIMARY KEY.

Normally, tables with no explicit PRIMARY KEY are simply ignored by the sessions module. However, if this flag is set, it behaves as if such tables have a column "_rowid_ INTEGER PRIMARY KEY" inserted as their leftmost columns.

It is an error (SQ3_RESULT_MISUSE) to attempt to modify this setting after the first table has been attached to the session object.

Reference code from sqlite3:

#define SQLITE_SESSION_OBJCONFIG_SIZE 1
#define SQLITE_SESSION_OBJCONFIG_ROWID 2

(static) enum MkErrorE Sq3SessionObjConfigE_FromInt(MK_I32 const value, enum Sq3SessionObjConfigE *value_out)

top return the Sq3SessionObjConfigE from integer … → API: Sq3SessionObjConfigE_FromInt

(static) MK_I32 Sq3SessionObjConfigE_ToInt(enum Sq3SessionObjConfigE value)

top return the Sq3SessionObjConfigE as integer … → API: Sq3SessionObjConfigE_ToInt

(static) MK_STRN Sq3SessionObjConfigE_ToString(enum Sq3SessionObjConfigE value)

top return the Sq3SessionObjConfigE as string … → API: Sq3SessionObjConfigE_ToString


enum Sq3ShmLockE

top Flags for the xShmLock VFS method. → API: Sq3ShmLockE

Flags for the xShmLock VFS method …

These integer constants define the various locking operations allowed by the xShmLock method of sqlite3_io_methods. The following are the only legal combinations of flags to the xShmLock method:

  • SQ3_SHM_LOCK | SQ3_SHM_SHARED
  • SQ3_SHM_LOCK | SQ3_SHM_EXCLUSIVE
  • SQ3_SHM_UNLOCK | SQ3_SHM_SHARED
  • SQ3_SHM_UNLOCK | SQ3_SHM_EXCLUSIVE

When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as was given on the corresponding lock.

The xShmLock method can transition between unlocked and SHARED or between unlocked and EXCLUSIVE. It cannot transition between SHARED and EXCLUSIVE.

Reference code from sqlite3:

#define SQLITE_SHM_UNLOCK 1
#define SQLITE_SHM_LOCK 2
#define SQLITE_SHM_SHARED 4
#define SQLITE_SHM_EXCLUSIVE 8

(static) enum MkErrorE Sq3ShmLockE_FromInt(MK_I32 const value, enum Sq3ShmLockE *value_out)

top return the Sq3ShmLockE from integer … → API: Sq3ShmLockE_FromInt

(static) MK_I32 Sq3ShmLockE_ToInt(enum Sq3ShmLockE value)

top return the Sq3ShmLockE as integer … → API: Sq3ShmLockE_ToInt

(static) MK_STRN Sq3ShmLockE_ToString(enum Sq3ShmLockE value)

top return the Sq3ShmLockE as string … → API: Sq3ShmLockE_ToString


enum Sq3StatusE

top Status Parameters. → API: Sq3StatusE

Status Parameters …

These integer constants designate various run-time status parameters that can be returned by Sq3Status ().

SQ3_STATUS_MEMORY_USED

This parameter is the current amount of memory checked out using Sq3Malloc (), either directly or indirectly. The figure includes calls made to Sq3Malloc () by the application and internal memory usage by the SQLite library. Auxiliary page-cache memory controlled by SQ3_CONFIG_PAGECACHE is not included in this parameter. The amount returned is the sum of the allocation sizes as reported by the xSize method in sqlite3_mem_methods.

SQ3_STATUS_MALLOC_SIZE

This parameter records the largest memory allocation request handed to Sq3Malloc () or Sq3Realloc () (or their internal equivalents). Only the value returned in the pHighwater parameter to Sq3Status () is of interest. The value written into the *pCurrent parameter is undefined.

SQ3_STATUS_MALLOC_COUNT

This parameter records the number of separate memory allocations currently checked out.

SQ3_STATUS_PAGECACHE_USED

This parameter returns the number of pages used out of the pagecache memory allocator that was configured using SQ3_CONFIG_PAGECACHE. The value returned is in pages, not in bytes.

SQ3_STATUS_PAGECACHE_OVERFLOW

This parameter returns the number of bytes of page cache allocation which could not be satisfied by the SQ3_CONFIG_PAGECACHE buffer and where forced to overflow to Sq3Malloc (). The returned value includes allocations that overflowed because they where too large (they were larger than the "sz" parameter to SQ3_CONFIG_PAGECACHE) and allocations that overflowed because no space was left in the page cache.

SQ3_STATUS_PAGECACHE_SIZE

This parameter records the largest memory allocation request handed to the pagecache memory allocator. Only the value returned in the pHighwater parameter to Sq3Status () is of interest. The value written into the *pCurrent parameter is undefined.

SQ3_STATUS_SCRATCH_USED

No longer used.

SQ3_STATUS_SCRATCH_OVERFLOW

No longer used.

SQ3_STATUS_SCRATCH_SIZE

No longer used.

SQ3_STATUS_PARSER_STACK
The *pHighwater parameter records the deepest parser stack. The *pCurrent value is undefined. The *pHighwater value is only meaningful if SQLite is compiled with YYTRACKMAXSTACKDEPTH.

New status parameters may be added from time to time.

Reference code from sqlite3:

#define SQLITE_STATUS_MEMORY_USED 0
#define SQLITE_STATUS_PAGECACHE_USED 1
#define SQLITE_STATUS_PAGECACHE_OVERFLOW 2
#define SQLITE_STATUS_SCRATCH_USED 3 // NOT USED
#define SQLITE_STATUS_SCRATCH_OVERFLOW 4 // NOT USED
#define SQLITE_STATUS_MALLOC_SIZE 5
#define SQLITE_STATUS_PARSER_STACK 6
#define SQLITE_STATUS_PAGECACHE_SIZE 7
#define SQLITE_STATUS_SCRATCH_SIZE 8 // NOT USED
#define SQLITE_STATUS_MALLOC_COUNT 9

(static) enum MkErrorE Sq3StatusE_FromInt(MK_I32 const value, enum Sq3StatusE *value_out)

top return the Sq3StatusE from integer … → API: Sq3StatusE_FromInt

(static) MK_I32 Sq3StatusE_ToInt(enum Sq3StatusE value)

top return the Sq3StatusE as integer … → API: Sq3StatusE_ToInt

(static) MK_STRN Sq3StatusE_ToString(enum Sq3StatusE value)

top return the Sq3StatusE as string … → API: Sq3StatusE_ToString


enum Sq3StmtStatusE

top Status Parameters for prepared statements. → API: Sq3StmtStatusE

Status Parameters for prepared statements …

These preprocessor macros define integer codes that name counter values associated with the Sq3StmtStatus () interface. The meanings of the various counters are as follows:

SQ3_STMTSTATUS_FULLSCAN_STEP

This is the number of times that SQLite has stepped forward in a table as part of a full table scan. Large numbers for this counter may indicate opportunities for performance improvement through careful use of indices.

SQ3_STMTSTATUS_SORT

This is the number of sort operations that have occurred. A non-zero value in this counter may indicate an opportunity to improvement performance through careful use of indices.

SQ3_STMTSTATUS_AUTOINDEX

This is the number of rows inserted into transient indices that were created automatically in order to help joins run faster. A non-zero value in this counter may indicate an opportunity to improvement performance by adding permanent indices that do not need to be reinitialized each time the statement is run.

SQ3_STMTSTATUS_VM_STEP

This is the number of virtual machine operations executed by the prepared statement if that number is less than or equal to 2147483647. The number of virtual machine operations can be used as a proxy for the total work done by the prepared statement. If the number of virtual machine operations exceeds 2147483647 then the value returned by this statement status code is undefined.

SQ3_STMTSTATUS_REPREPARE

This is the number of times that the prepare statement has been automatically regenerated due to schema changes or changes to bound parameters that might affect the query plan.

SQ3_STMTSTATUS_RUN

This is the number of times that the prepared statement has been run. A single "run" for the purposes of this counter is one or more calls to Sq3StmtStep () followed by a call to Sq3StmtReset (). The counter is incremented on the first Sq3StmtStep () call of each cycle.

SQ3_STMTSTATUS_FILTER_HIT and SQ3_STMTSTATUS_FILTER_MISS

SQ3_STMTSTATUS_FILTER_HIT is the number of times that a join step was bypassed because a Bloom filter returned not-found. The corresponding SQ3_STMTSTATUS_FILTER_MISS value is the number of times that the Bloom filter returned a find, and thus the join step had to be processed as normal.

SQ3_STMTSTATUS_MEMUSED
This is the approximate number of bytes of heap memory used to store the prepared statement. This value is not actually a counter, and so the resetFlg parameter to Sq3StmtStatus() is ignored when the opcode is SQ3_STMTSTATUS_MEMUSED.

Reference code from sqlite3:

#define SQLITE_STMTSTATUS_FULLSCAN_STEP 1
#define SQLITE_STMTSTATUS_SORT 2
#define SQLITE_STMTSTATUS_AUTOINDEX 3
#define SQLITE_STMTSTATUS_VM_STEP 4
#define SQLITE_STMTSTATUS_REPREPARE 5
#define SQLITE_STMTSTATUS_RUN 6
#define SQLITE_STMTSTATUS_FILTER_MISS 7
#define SQLITE_STMTSTATUS_FILTER_HIT 8
#define SQLITE_STMTSTATUS_MEMUSED 99

(static) enum MkErrorE Sq3StmtStatusE_FromInt(MK_I32 const value, enum Sq3StmtStatusE *value_out)

top return the Sq3StmtStatusE from integer … → API: Sq3StmtStatusE_FromInt

(static) MK_I32 Sq3StmtStatusE_ToInt(enum Sq3StmtStatusE value)

top return the Sq3StmtStatusE as integer … → API: Sq3StmtStatusE_ToInt

(static) MK_STRN Sq3StmtStatusE_ToString(enum Sq3StmtStatusE value)

top return the Sq3StmtStatusE as string … → API: Sq3StmtStatusE_ToString


enum Sq3SyncEF

top Synchronization Type Flags. → API: Sq3SyncEF

Synchronization Type Flags …

__parser__(enum-is-flag)
typedef enum Sq3SyncEF {
SQ3_SYNC_NORMAL = 0x00002 ,
SQ3_SYNC_FULL = 0x00003 ,
SQ3_SYNC_DATAONLY = 0x00010 ,
#ifdef META_COMPILE_AS_CC
inline Sq3SyncEF operator|(Sq3SyncEF a, Sq3SyncEF b)
{
return static_cast<Sq3SyncEF>(static_cast<int>(a) | static_cast<int>(b));
}
#endif

When SQLite invokes the xSync() method of an sqlite3_io_methods object it uses a combination of these integer values as the second argument.

When the SQ3_SYNC_DATAONLY flag is used, it means that the sync operation only needs to flush data to mass storage. Inode information need not be flushed. If the lower four bits of the flag equal SQ3_SYNC_NORMAL, that means to use normal fsync() semantics. If the lower four bits equal SQ3_SYNC_FULL, that means to use Mac OS X style fullsync instead of fsync().

Do not confuse the SQ3_SYNC_NORMAL and SQ3_SYNC_FULL flags with the PRAGMA synchronous=NORMAL and PRAGMA synchronous=FULL settings. The synchronous pragma determines when calls to the xSync VFS method occur and applies uniformly across all platforms. The SQ3_SYNC_NORMAL and SQ3_SYNC_FULL flags determine how energetic or rigorous or forceful the sync operations are and only make a difference on Mac OSX for the default SQLite code. (Third-party VFS implementations might also make the distinction between SQ3_SYNC_NORMAL and SQ3_SYNC_FULL, but among the operating systems natively supported by SQLite, only Mac OSX cares about the difference.)

Reference code from sqlite3:

#define SQLITE_SYNC_NORMAL 0x00002
#define SQLITE_SYNC_FULL 0x00003
#define SQLITE_SYNC_DATAONLY 0x00010

(static) enum MkErrorE Sq3SyncEF_FromInt(MK_I32 const value, enum Sq3SyncEF *value_out)

top return the Sq3SyncEF from integer … → API: Sq3SyncEF_FromInt

(static) MK_I32 Sq3SyncEF_ToInt(enum Sq3SyncEF value)

top return the Sq3SyncEF as integer … → API: Sq3SyncEF_ToInt

(static) MK_STRN Sq3SyncEF_ToString(enum Sq3SyncEF value)

top return the Sq3SyncEF as string … → API: Sq3SyncEF_ToString


enum Sq3TestCtrlE

top Testing Interface Operation Codes. → API: Sq3TestCtrlE

Testing Interface Operation Codes …

These constants are the valid operation code parameters used as the first argument to sqlite3_test_control ().

These parameters and their meanings are subject to change without notice. These values are for testing purposes only. Applications should not use any of these parameters or the sqlite3_test_control () interface.

Reference code from sqlite3:

#define SQLITE_TESTCTRL_FIRST 5
#define SQLITE_TESTCTRL_PRNG_SAVE 5
#define SQLITE_TESTCTRL_PRNG_RESTORE 6
#define SQLITE_TESTCTRL_PRNG_RESET 7 // NOT USED
#define SQLITE_TESTCTRL_FK_NO_ACTION 7
#define SQLITE_TESTCTRL_BITVEC_TEST 8
#define SQLITE_TESTCTRL_FAULT_INSTALL 9
#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10
#define SQLITE_TESTCTRL_PENDING_BYTE 11
#define SQLITE_TESTCTRL_ASSERT 12
#define SQLITE_TESTCTRL_ALWAYS 13
#define SQLITE_TESTCTRL_RESERVE 14 // NOT USED
#define SQLITE_TESTCTRL_OPTIMIZATIONS 15
#define SQLITE_TESTCTRL_ISKEYWORD 16 // NOT USED
#define SQLITE_TESTCTRL_SCRATCHMALLOC 17 // NOT USED
#define SQLITE_TESTCTRL_INTERNAL_FUNCTIONS 17
#define SQLITE_TESTCTRL_LOCALTIME_FAULT 18
#define SQLITE_TESTCTRL_EXPLAIN_STMT 19 // NOT USED
#define SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD 19
#define SQLITE_TESTCTRL_NEVER_CORRUPT 20
#define SQLITE_TESTCTRL_VDBE_COVERAGE 21
#define SQLITE_TESTCTRL_BYTEORDER 22
#define SQLITE_TESTCTRL_ISINIT 23
#define SQLITE_TESTCTRL_SORTER_MMAP 24
#define SQLITE_TESTCTRL_IMPOSTER 25
#define SQLITE_TESTCTRL_PARSER_COVERAGE 26
#define SQLITE_TESTCTRL_RESULT_INTREAL 27
#define SQLITE_TESTCTRL_PRNG_SEED 28
#define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29
#define SQLITE_TESTCTRL_SEEK_COUNT 30
#define SQLITE_TESTCTRL_TRACEFLAGS 31
#define SQLITE_TESTCTRL_TUNE 32
#define SQLITE_TESTCTRL_LOGEST 33
#define SQLITE_TESTCTRL_USELONGDOUBLE 34
#define SQLITE_TESTCTRL_LAST 34 // Largest TESTCTRL

(static) enum MkErrorE Sq3TestCtrlE_FromInt(MK_I32 const value, enum Sq3TestCtrlE *value_out)

top return the Sq3TestCtrlE from integer … → API: Sq3TestCtrlE_FromInt

(static) MK_I32 Sq3TestCtrlE_ToInt(enum Sq3TestCtrlE value)

top return the Sq3TestCtrlE as integer … → API: Sq3TestCtrlE_ToInt

(static) MK_STRN Sq3TestCtrlE_ToString(enum Sq3TestCtrlE value)

top return the Sq3TestCtrlE as string … → API: Sq3TestCtrlE_ToString


enum Sq3TextE

top Text Encodings. → API: Sq3TextE

Text Encodings …

These constant define integer codes that represent the various text encodings supported by SQLite.

Reference code from sqlite3:

#define SQLITE_UTF8 1 // IMP: R-37514-35566
#define SQLITE_UTF16LE 2 // IMP: R-03371-37637
#define SQLITE_UTF16BE 3 // IMP: R-51971-34154
#define SQLITE_UTF16 4 // Use native byte order
#define SQLITE_ANY 5 // Deprecated
#define SQLITE_UTF16_ALIGNED 8 // sqlite3_create_collation only

(static) enum MkErrorE Sq3TextE_FromInt(MK_I32 const value, enum Sq3TextE *value_out)

top return the Sq3TextE from integer … → API: Sq3TextE_FromInt

(static) MK_I32 Sq3TextE_ToInt(enum Sq3TextE value)

top return the Sq3TextE as integer … → API: Sq3TextE_ToInt

(static) MK_STRN Sq3TextE_ToString(enum Sq3TextE value)

top return the Sq3TextE as string … → API: Sq3TextE_ToString


enum Sq3TraceEF

top SQL Trace Event Codes. → API: Sq3TraceEF

SQL Trace Event Codes …

__parser__(enum-is-flag)
typedef enum Sq3TraceEF {
SQ3_TRACE_STMT = 0x01 ,
SQ3_TRACE_ROW = 0x04 ,
SQ3_TRACE_CLOSE = 0x08 ,
#ifdef META_COMPILE_AS_CC
inline Sq3TraceEF operator|(Sq3TraceEF a, Sq3TraceEF b)
{
return static_cast<Sq3TraceEF>(static_cast<int>(a) | static_cast<int>(b));
}
#endif

These constants identify classes of events that can be monitored using the sqlite3_trace_v2 () tracing logic. The M argument to sqlite3_trace_v2 (D,M,X,P) is an OR-ed combination of one or more of the following constants. The first argument to the trace callback is one of the following constants.

New tracing constants may be added in future releases.

A trace callback has four arguments: xCallback(T,C,P,X). The T argument is one of the integer type codes above. The C argument is a copy of the context pointer passed in as the fourth argument to sqlite3_trace_v2 (). The P and X arguments are pointers whose meanings depend on T.

SQ3_TRACE_STMT

An SQ3_TRACE_STMT callback is invoked when a prepared statement first begins running and possibly at other times during the execution of the prepared statement, such as at the start of each trigger subprogram. The P argument is a pointer to the prepared statement. The X argument is a pointer to a string which is the unexpanded SQL text of the prepared statement or an SQL comment that indicates the invocation of a trigger. The callback can compute the same text that would have been returned by the legacy sqlite3_trace () interface by using the X argument when X begins with "--" and invoking Sq3StmtExpandedSql (P) otherwise.

SQ3_TRACE_PROFILE

An SQ3_TRACE_PROFILE callback provides approximately the same information as is provided by the sqlite3_profile () callback. The P argument is a pointer to the prepared statement and the X argument points to a 64-bit integer which is approximately the number of nanoseconds that the prepared statement took to run. The SQ3_TRACE_PROFILE callback is invoked when the statement finishes.

SQ3_TRACE_ROW

An SQ3_TRACE_ROW callback is invoked whenever a prepared statement generates a single row of result. The P argument is a pointer to the prepared statement and the X argument is unused.

SQ3_TRACE_CLOSE
An SQ3_TRACE_CLOSE callback is invoked when a database connection closes. The P argument is a pointer to the database connection object and the X argument is unused.

Reference code from sqlite3:

#define SQLITE_TRACE_STMT 0x01
#define SQLITE_TRACE_PROFILE 0x02
#define SQLITE_TRACE_ROW 0x04
#define SQLITE_TRACE_CLOSE 0x08

(static) enum MkErrorE Sq3TraceEF_FromInt(MK_I32 const value, enum Sq3TraceEF *value_out)

top return the Sq3TraceEF from integer … → API: Sq3TraceEF_FromInt

(static) MK_I32 Sq3TraceEF_ToInt(enum Sq3TraceEF value)

top return the Sq3TraceEF as integer … → API: Sq3TraceEF_ToInt

(static) MK_STRN Sq3TraceEF_ToString(enum Sq3TraceEF value)

top return the Sq3TraceEF as string … → API: Sq3TraceEF_ToString


enum Sq3TxnE

top Allowed return values from sqlite3_txn_state() → API: Sq3TxnE

Allowed return values from sqlite3_txn_state()

typedef enum Sq3TxnE {

These constants define the current transaction state of a database file. The Sq3LiteTxnState (D,S) interface returns one of these constants in order to describe the transaction state of schema S in database connection D.

SQ3_TXN_NONE

The SQ3_TXN_NONE state means that no transaction is currently pending.

SQ3_TXN_READ

The SQ3_TXN_READ state means that the database is currently in a read transaction. Content has been read from the database file but nothing in the database file has changed. The transaction state will advanced to SQ3_TXN_WRITE if any changes occur and there are no other conflicting concurrent write transactions. The transaction state will revert to SQ3_TXN_NONE following a ROLLBACK or COMMIT.

SQ3_TXN_WRITE
The SQ3_TXN_WRITE state means that the database is currently in a write transaction. Content has been written to the database file but has not yet committed. The transaction state will change to to SQ3_TXN_NONE at the next ROLLBACK or COMMIT.

Reference code from sqlite3:

#define SQLITE_TXN_NONE 0
#define SQLITE_TXN_READ 1
#define SQLITE_TXN_WRITE 2

(static) enum MkErrorE Sq3TxnE_FromInt(MK_I32 const value, enum Sq3TxnE *value_out)

top return the Sq3TxnE from integer … → API: Sq3TxnE_FromInt

(static) MK_I32 Sq3TxnE_ToInt(enum Sq3TxnE value)

top return the Sq3TxnE as integer … → API: Sq3TxnE_ToInt

(static) MK_STRN Sq3TxnE_ToString(enum Sq3TxnE value)

top return the Sq3TxnE as string … → API: Sq3TxnE_ToString


enum Sq3TypeE

top Fundamental Datatypes. → API: Sq3TypeE

Fundamental Datatypes …

Every value in SQLite has one of five fundamental datatypes:

  • 64-bit signed integer
  • 64-bit IEEE floating point number
  • string
  • BLOB
  • NULL

These constants are codes for each of those types.

Note that the SQ3_TYPE_TEXT constant was also used in SQLite version 2 for a completely different meaning. Software that links against both SQLite version 2 and SQLite version 3 should use SQLITE3_TEXT, not SQ3_TYPE_TEXT.

Reference code from sqlite3:

#define SQLITE_INTEGER 1
#define SQLITE_FLOAT 2
#define SQLITE_BLOB 4
#define SQLITE_NULL 5
#ifdef SQLITE_TEXT
# undef SQLITE_TEXT
#else
# define SQLITE_TEXT 3
#endif
#define SQLITE3_TEXT 3

(static) enum MkErrorE Sq3TypeE_FromInt(MK_I32 const value, enum Sq3TypeE *value_out)

top return the Sq3TypeE from integer … → API: Sq3TypeE_FromInt

(static) MK_I32 Sq3TypeE_ToInt(enum Sq3TypeE value)

top return the Sq3TypeE as integer … → API: Sq3TypeE_ToInt

(static) MK_STRN Sq3TypeE_ToString(enum Sq3TypeE value)

top return the Sq3TypeE as string … → API: Sq3TypeE_ToString


enum Sq3VtabE

top Virtual Table Configuration Options. → API: Sq3VtabE

Virtual Table Configuration Options …

These macros define the various options to the Sq3LiteVtabConfig () interface that virtual table implementations can use to customize and optimize their behavior.

SQ3_VTAB_CONSTRAINT_SUPPORT

Calls of the form Sq3LiteVtabConfig(db,SQ3_VTAB_CONSTRAINT_SUPPORT,X) are supported, where X is an integer. If X is zero, then the virtual table whose xCreate or xConnect method invoked Sq3LiteVtabConfig () does not support constraints. In this configuration (which is the default) if a call to the xUpdate method returns SQ3_RESULT_CONSTRAINT, then the entire statement is rolled back as if OR ABORT had been specified as part of the users SQL statement, regardless of the actual ON CONFLICT mode specified.

If X is non-zero, then the virtual table implementation guarantees that if xUpdate returns SQ3_RESULT_CONSTRAINT, it will do so before any modifications to internal or persistent data structures have been made. If the ON CONFLICT mode is ABORT, FAIL, IGNORE or ROLLBACK, SQLite is able to roll back a statement or database transaction, and abandon or continue processing the current SQL statement as appropriate. If the ON CONFLICT mode is REPLACE and the xUpdate method returns SQ3_RESULT_CONSTRAINT, SQLite handles this as if the ON CONFLICT mode had been ABORT.

Virtual table implementations that are required to handle OR REPLACE must do so within the xUpdate method. If a call to the Sq3LiteVtabOnConflict () function indicates that the current ON CONFLICT policy is REPLACE, the virtual table implementation should silently replace the appropriate rows within the xUpdate callback and return SQ3_RESULT_OK. Or, if this is not possible, it may return SQ3_RESULT_CONSTRAINT, in which case SQLite falls back to OR ABORT constraint handling.

SQ3_VTAB_DIRECTONLY

Calls of the form Sq3LiteVtabConfig(db,SQ3_VTAB_DIRECTONLY) from within the the xConnect or xCreate methods of a virtual table implementation prohibits that virtual table from being used from within triggers and views.

SQ3_VTAB_INNOCUOUS

Calls of the form Sq3LiteVtabConfig(db,SQ3_VTAB_INNOCUOUS) from within the the xConnect or xCreate methods of a virtual table implementation identify that virtual table as being safe to use from within triggers and views. Conceptually, the SQ3_VTAB_INNOCUOUS tag means that the virtual table can do no serious harm even if it is controlled by a malicious hacker. Developers should avoid setting the SQ3_VTAB_INNOCUOUS flag unless absolutely necessary.

SQ3_VTAB_USES_ALL_SCHEMAS
Calls of the form Sq3LiteVtabConfig(db,SQ3_VTAB_USES_ALL_SCHEMAS) from within the the xConnect or xCreate methods of a virtual table implementation instruct the query planner to begin at least a read transaction on all schemas ("main", "temp", and any ATTACH-ed databases) whenever the virtual table is used.

Reference code from sqlite3:

#define SQLITE_VTAB_CONSTRAINT_SUPPORT 1
#define SQLITE_VTAB_INNOCUOUS 2
#define SQLITE_VTAB_DIRECTONLY 3
#define SQLITE_VTAB_USES_ALL_SCHEMAS 4

(static) enum MkErrorE Sq3VtabE_FromInt(MK_I32 const value, enum Sq3VtabE *value_out)

top return the Sq3VtabE from integer … → API: Sq3VtabE_FromInt

(static) MK_I32 Sq3VtabE_ToInt(enum Sq3VtabE value)

top return the Sq3VtabE as integer … → API: Sq3VtabE_ToInt

(static) MK_STRN Sq3VtabE_ToString(enum Sq3VtabE value)

top return the Sq3VtabE as string … → API: Sq3VtabE_ToString

Sq3Lite CONFIG

C-API: Sq3Lite_Config_C_API - Sq3Lite PACKAGE - configure the applicatione …

(static) MK_STRN Sq3CompileOptionGet(MK_I32 N)

top Run-Time Library Compilation Options Diagnostics … → API: Sq3CompileOptionGet

The Sq3CompileOptionUsed() function returns 0 or 1 indicating whether the specified option was defined at compile time. The SQLITE_ prefix may be omitted from the option name passed to Sq3CompileOptionUsed().

The Sq3CompileOptionGet() function allows iterating over the list of options that were defined at compile time by returning the N-th compile time option string. If N is out of range, Sq3CompileOptionGet() returns a NULL pointer. The SQLITE_ prefix is omitted from any strings returned by Sq3CompileOptionGet().

Support for the diagnostic functions Sq3CompileOptionUsed() and Sq3CompileOptionGet() may be omitted by specifying the SQLITE_OMIT_COMPILEOPTION_DIAGS option at compile time.

See also: SQL functions sqlite_compileoption_used () and sqlite_compileoption_get () and the compile_options pragma.

Reference code from sqlite3:

#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
SQLITE_API int sqlite3_compileoption_used(const char *zOptName);
#else
# define sqlite3_compileoption_used(X) 0
# define sqlite3_compileoption_get(X) ((void*)0)
#endif
SQLITE_API const char * sqlite3_compileoption_get(int N)
SQLITE_API int sqlite3_compileoption_used(const char *zOptName)

(static) MK_BOOL Sq3CompileOptionUsed(MK_STRN zOptName)

top Run-Time Library Compilation Options Diagnostics … → API: Sq3CompileOptionUsed

read more at 'Sq3CompileOptionGet'

(static,hide) void Sq3LiteProgressHandler(SQ3_LITE sq3lite, MK_I32 N, Sq3Fupu_Sq3LiteProgressHandler_X X, MK_PTR P)

top Query Progress Callbacks … → API: Sq3LiteProgressHandler

The Sq3LiteProgressHandler(D,N,X,P) interface causes the callback function X to be invoked periodically during long running calls to Sq3StmtStep () and sqlite3_prepare () and similar for database connection D. An example use for this interface is to keep a GUI updated during a large query.

The parameter P is passed through as the only parameter to the callback function X. The parameter N is the approximate number of virtual machine instructions that are evaluated between successive invocations of the callback X. If N is less than one then the progress handler is disabled.

Only a single progress handler may be defined at one time per database connection; setting a new progress handler cancels the old one. Setting parameter X to NULL disables the progress handler. The progress handler is also disabled by setting N to a value less than 1.

If the progress callback returns non-zero, the operation is interrupted. This feature can be used to implement a "Cancel" button on a GUI progress dialog box.

The progress handler callback must not do anything that will modify the database connection that invoked the progress handler. Note that Sq3StmtPrepareV2 () and Sq3StmtStep () both modify their database connections for the meaning of "modify" in this paragraph.

The progress handler callback would originally only be invoked from the bytecode engine. It still might be invoked during sqlite3_prepare () and similar because those routines might force a reparse of the schema which involves running the bytecode engine. However, beginning with SQLite version 3.41.0, the progress handler callback might also be invoked directly from sqlite3_prepare () while analyzing and generating code for complex queries.

Reference code from sqlite3:

SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
struct sqlite3 sqlite3
SQLITE_API void sqlite3_progress_handler(sqlite3 *, int, int(*)(void *), void *)

(static,hide) enum Sq3AuthReturnE Sq3LiteSetAuthorizer(SQ3_LITE sq3lite, Sq3Fupu_Sq3LiteSetAuthorizer_xAuth xAuth, MK_PTR pUserData)

top Compile-Time Authorization Callbacks … → API: Sq3LiteSetAuthorizer

This routine registers an authorizer callback with a particular database connection, supplied in the first argument. The authorizer callback is invoked as SQL statements are being compiled by sqlite3_prepare () or its variants Sq3StmtPrepareV2 (), Sq3StmtPrepareV3 (), sqlite3_prepare16 (), sqlite3_prepare16_v2 (), and sqlite3_prepare16_v3 (). At various points during the compilation process, as logic is being created to perform various actions, the authorizer callback is invoked to see if those actions are allowed. The authorizer callback should return SQ3_RESULT_OK to allow the action, SQ3_AUTHRETURN_IGNORE to disallow the specific action but allow the SQL statement to continue to be compiled, or SQ3_AUTHRETURN_DENY to cause the entire SQL statement to be rejected with an error. If the authorizer callback returns any value other than SQ3_AUTHRETURN_IGNORE, SQ3_RESULT_OK, or SQ3_AUTHRETURN_DENY then the Sq3StmtPrepareV2 () or equivalent call that triggered the authorizer will fail with an error message.

When the callback returns SQ3_RESULT_OK, that means the operation requested is ok. When the callback returns SQ3_AUTHRETURN_DENY, the Sq3StmtPrepareV2 () or equivalent call that triggered the authorizer will fail with an error message explaining that access is denied.

The first parameter to the authorizer callback is a copy of the third parameter to the Sq3LiteSetAuthorizer() interface. The second parameter to the callback is an integer action code that specifies the particular action to be authorized. The third through sixth parameters to the callback are either NULL pointers or zero-terminated strings that contain additional details about the action to be authorized. Applications must always be prepared to encounter a NULL pointer in any of the third through the sixth parameters of the authorization callback.

If the action code is SQ3_AUTHACTION_READ and the callback returns SQ3_AUTHRETURN_IGNORE then the prepared statement statement is constructed to substitute a NULL value in place of the table column that would have been read if SQ3_RESULT_OK had been returned. The SQ3_AUTHRETURN_IGNORE return can be used to deny an untrusted user access to individual columns of a table. When a table is referenced by a SELECT but no column values are extracted from that table (for example in a query like "SELECT count(*) FROM tab") then the SQ3_AUTHACTION_READ authorizer callback is invoked once for that table with a column name that is an empty string. If the action code is SQ3_AUTHACTION_DELETE and the callback returns SQ3_AUTHRETURN_IGNORE then the DELETE operation proceeds but the truncate optimization is disabled and all rows are deleted individually.

An authorizer is used when preparing SQL statements from an untrusted source, to ensure that the SQL statements do not try to access data they are not allowed to see, or that they do not try to execute malicious statements that damage the database. For example, an application may allow a user to enter arbitrary SQL queries for evaluation by a database. But the application does not want the user to be able to make arbitrary changes to the database. An authorizer could then be put in place while the user-entered SQL is being prepared that disallows everything except SELECT statements.

Applications that need to process SQL from untrusted sources might also consider lowering resource limits using Sq3LiteLimit () and limiting database size using the max_page_count PRAGMA in addition to using an authorizer.

Only a single authorizer can be in place on a database connection at a time. Each call to Sq3LiteSetAuthorizer overrides the previous call. Disable the authorizer by installing a NULL callback. The authorizer is disabled by default.

The authorizer callback must not do anything that will modify the database connection that invoked the authorizer callback. Note that Sq3StmtPrepareV2 () and Sq3StmtStep () both modify their database connections for the meaning of "modify" in this paragraph.

When Sq3StmtPrepareV2 () is used to prepare a statement, the statement might be re-prepared during Sq3StmtStep () due to a schema change. Hence, the application should ensure that the correct authorizer callback remains in place during the Sq3StmtStep ().

Note that the authorizer callback is invoked only during sqlite3_prepare () or its variants. Authorization is not performed during statement evaluation in Sq3StmtStep (), unless as stated in the previous paragraph, Sq3StmtStep() invokes Sq3StmtPrepareV2() to reprepare a statement after a schema change.

Reference code from sqlite3:

int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
void *pUserData
);
SQLITE_API int sqlite3_set_authorizer(sqlite3 *, int(*xAuth)(void *, int, const char *, const char *, const char *, const char *), void *pUserData)

(static) MK_I64 Sq3MemoryHighwater(MK_I32 resetFlag)

top Memory Allocator Statistics … → API: Sq3MemoryHighwater

SQLite provides these two interfaces for reporting on the status of the Sq3Malloc (), Sq3Free (), and Sq3Realloc () routines, which form the built-in memory allocation subsystem.

The Sq3MemoryUsed () routine returns the number of bytes of memory currently outstanding (malloced but not freed). The Sq3MemoryHighwater () routine returns the maximum value of Sq3MemoryUsed () since the high-water mark was last reset. The values returned by Sq3MemoryUsed () and Sq3MemoryHighwater () include any overhead added by SQLite in its implementation of Sq3Malloc (), but not overhead added by the any underlying system library routines that Sq3Malloc () may call.

The memory high-water mark is reset to the current value of Sq3MemoryUsed () if and only if the parameter to Sq3MemoryHighwater () is true. The value returned by Sq3MemoryHighwater (1) is the high-water mark prior to the reset.

Reference code from sqlite3:

sqlite_int64 sqlite3_int64
SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag)
SQLITE_API sqlite3_int64 sqlite3_memory_used(void)

(static) MK_I64 Sq3MemoryUsed()

top Memory Allocator Statistics … → API: Sq3MemoryUsed

read more at 'Sq3MemoryHighwater'

(static,hide) void Sq3Randomness(MK_I32 N, MK_PTR P)

top Pseudo-Random Number Generator … → API: Sq3Randomness

SQLite contains a high-quality pseudo-random number generator (PRNG) used to select random ROWIDs when inserting new records into a table that already uses the largest possible ROWID. The PRNG is also used for the built-in random() and randomblob() SQL functions. This interface allows applications to access the same PRNG for other purposes.

A call to this routine stores N bytes of randomness into buffer P. The P parameter can be a NULL pointer.

If this routine has not been previously called or if the previous call had N less than one or a NULL pointer for P, then the PRNG is seeded using randomness obtained from the xRandomness method of the default sqlite3_vfs object. If the previous call to this routine had an N of 1 or more and a non-NULL P then the pseudo-randomness is generated internally and without recourse to the sqlite3_vfs xRandomness method.

Reference code from sqlite3:

SQLITE_API void sqlite3_randomness(int N, void *P);
SQLITE_API void sqlite3_randomness(int N, void *P)

(static,hide) void Sq3SetupThreadCallback(Sq3SetupThreadF call)

top Initialize a callback which is called at runtime-setup … → API: Sq3SetupThreadCallback

A runtime is created with every new thread and the purpose of this function is to provide the possible to add extra code at the end of the runtime-setup.

Internal the MkRuntimeCallbackAdd is used to register the callback.

Parameters
[in]callthe new callback or MK_NULL for cleanup.

(static) enum MkErrorE Sq3Threadsafe()

top Test To See If The Library Is Threadsafe … → API: Sq3Threadsafe

The Sq3Threadsafe() function returns zero if and only if SQLite was compiled with mutexing code omitted due to the SQLITE_THREADSAFE compile-time option being set to 0.

SQLite can be compiled with or without mutexes. When the SQLITE_THREADSAFE C preprocessor macro is 1 or 2, mutexes are enabled and SQLite is threadsafe. When the SQLITE_THREADSAFE macro is 0, the mutexes are omitted. Without the mutexes, it is not safe to use SQLite concurrently from more than one thread.

Enabling mutexes incurs a measurable performance penalty. So if speed is of utmost importance, it makes sense to disable the mutexes. But for maximum safety, mutexes should be enabled. The default behavior is for mutexes to be enabled.

This interface can be used by an application to make sure that the version of SQLite that it is linking against was compiled with the desired setting of the SQLITE_THREADSAFE macro.

This interface only reports on the compile-time mutex setting of the SQLITE_THREADSAFE flag. If SQLite is compiled with SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but can be fully or partially disabled using a call to sqlite3_config () with the verbs SQ3_CONFIG_SINGLETHREAD, SQ3_CONFIG_MULTITHREAD, or SQ3_CONFIG_SERIALIZED. The return value of the Sq3Threadsafe() function shows only the compile-time setting of thread safety, not any run-time changes to that setting made by sqlite3_config(). In other words, the return value from Sq3Threadsafe() is unchanged by calls to sqlite3_config().

See the threading mode documentation for additional information.

Reference code from sqlite3:

SQLITE_API int sqlite3_threadsafe(void)

Sq3Lite INFO

C-API: Sq3Lite_Info_C_API - Sq3Lite PACKAGE - get information about the application …

(static) enum MkErrorE Sq3Complete(MK_STRN sql)

top Determine If An SQL Statement Is Complete … → API: Sq3Complete

These routines are useful during command-line input to determine if the currently entered text seems to form a complete SQL statement or if additional input is needed before sending the text into SQLite for parsing. These routines return 1 if the input string appears to be a complete SQL statement. A statement is judged to be complete if it ends with a semicolon token and is not a prefix of a well-formed CREATE TRIGGER statement. Semicolons that are embedded within string literals or quoted identifier names or comments are not independent tokens (they are part of the token in which they are embedded) and thus do not count as a statement terminator. Whitespace and comments that follow the final semicolon are ignored.

These routines return 0 if the statement is incomplete. If a memory allocation fails, then SQ3_RESULT_NOMEM is returned.

These routines do not parse the SQL statements thus will not detect syntactically incorrect SQL.

If SQLite has not been initialized using Sq3Initialize () prior to invoking sqlite3_complete16() then Sq3Initialize() is invoked automatically by sqlite3_complete16(). If that initialization fails, then the return value from sqlite3_complete16() will be non-zero regardless of whether or not the input SQL is complete.

The input to Sq3Complete () must be a zero-terminated UTF-8 string.

The input to sqlite3_complete16 () must be a zero-terminated UTF-16 string in native byte order.

Reference code from sqlite3:

SQLITE_API int sqlite3_complete(const char *sql);
SQLITE_API int sqlite3_complete16(const void *sql);
SQLITE_API int sqlite3_complete16(const void *sql)
SQLITE_API int sqlite3_complete(const char *sql)

(static) enum MkErrorE Sq3KeywordCheck(MK_STRN arg0, MK_I32 arg1)

top SQL Keyword Checking … → API: Sq3KeywordCheck

These routines provide access to the set of SQL language keywords recognized by SQLite. Applications can uses these routines to determine whether or not a specific identifier needs to be escaped (for example, by enclosing in double-quotes) so as not to confuse the parser.

The Sq3KeywordCount() interface returns the number of distinct keywords understood by SQLite.

The Sq3KeywordName(N,Z,L) interface finds the N-th keyword and makes *Z point to that keyword expressed as UTF8 and writes the number of bytes in the keyword into *L. The string that *Z points to is not zero-terminated. The Sq3KeywordName(N,Z,L) routine returns SQ3_RESULT_OK if N is within bounds and SQ3_RESULT_ERROR if not. If either Z or L are NULL or invalid pointers then calls to Sq3KeywordName(N,Z,L) result in undefined behavior.

The Sq3KeywordCheck(Z,L) interface checks to see whether or not the L-byte UTF8 identifier that Z points to is a keyword, returning non-zero if it is and zero if not.

The parser used by SQLite is forgiving. It is often possible to use a keyword as an identifier as long as such use does not result in a parsing ambiguity. For example, the statement "CREATE TABLE BEGIN(REPLACE,PRAGMA,END);" is accepted by SQLite, and creates a new table named "BEGIN" with three columns named "REPLACE", "PRAGMA", and "END". Nevertheless, best practice is to avoid using keywords as identifiers. Common techniques used to avoid keyword name collisions include:

  • Put all identifier names inside double-quotes. This is the official SQL way to escape identifier names.
  • Put identifier names inside &#91;...&#93;. This is not standard SQL, but it is what SQL Server does and so lots of programmers use this technique.
  • Begin every identifier with the letter "Z" as no SQL keywords start with "Z".
  • Include a digit somewhere in every identifier name.

Note that the number of keywords understood by SQLite can depend on compile-time options. For example, "VACUUM" is not a keyword if SQLite is compiled with the -DSQLITE_OMIT_VACUUM option. Also, new keywords may be added to future releases of SQLite.

Reference code from sqlite3:

SQLITE_API int sqlite3_keyword_name(int,const char**,int*);
SQLITE_API int sqlite3_keyword_check(const char*,int);
SQLITE_API int sqlite3_keyword_check(const char *, int)
SQLITE_API int sqlite3_keyword_name(int, const char **, int *)
SQLITE_API int sqlite3_keyword_count(void)

(static) enum MkErrorE Sq3KeywordCount()

top SQL Keyword Checking … → API: Sq3KeywordCount

read more at 'Sq3KeywordCheck'

(static) enum MkErrorE Sq3KeywordName(MK_I32 num, MK_STRN *kwd, MK_I32 *kwdsz)

top SQL Keyword Checking … → API: Sq3KeywordName

read more at 'Sq3KeywordCheck'

(static,runtime) enum MkErrorE Sq3KeywordNameBUF(MK_I32 num, MK_BUF *kwd_out)

top SQL Keyword Checking … → API: Sq3KeywordNameBUF_RT

read more at 'Sq3KeywordCheck'

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]numThe keyword-number
[out]kwd_outThe return-value have to be not MK_NULL.
Returns
The MkErrorE status from the DEFAULT MkErrorC in MkRuntimeS::error_mk
Attention
(do not free) The memory of the kwd_out value belongs to the called Sq3KeywordNameBUF function and therefore never becomes MK_NULL for a non-error result.
For details on the kwd_out value, see: MkKernel_Storage_C_API.

(static) enum MkErrorE Sq3Status(enum Sq3StatusE op, MK_I32 *pCurrent, MK_I32 *pHighwater, MK_BOOL resetFlag)

top SQLite Runtime Status … → API: Sq3Status

These interfaces are used to retrieve runtime status information about the performance of SQLite, and optionally to reset various highwater marks. The first argument is an integer code for the specific parameter to measure. Recognized integer codes are of the form SQ3_STATUS_.... The current value of the parameter is returned into *pCurrent. The highest recorded value is returned in *pHighwater. If the resetFlag is true, then the highest record value is reset after pHighwater is written. Some parameters do not record the highest value. For those parameters nothing is written into *pHighwater and the resetFlag is ignored. Other parameters record only the highwater mark and not the current value. For these latter parameters nothing is written into *pCurrent.

The Sq3Status() and Sq3Status64() routines return SQ3_RESULT_OK on success and a non-zero error code on failure.

If either the current value or the highwater mark is too large to be represented by a 32-bit integer, then the values returned by Sq3Status() are undefined.

See also: Sq3LiteDbStatus ()

Reference code from sqlite3:

SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
int op,
sqlite3_int64 *pCurrent,
sqlite3_int64 *pHighwater,
int resetFlag
);
SQLITE_API int sqlite3_status64(int op, sqlite3_int64 *pCurrent, sqlite3_int64 *pHighwater, int resetFlag)
SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag)

(static) enum MkErrorE Sq3Status64(enum Sq3StatusE op, MK_I64 *pCurrent, MK_I64 *pHighwater, MK_BOOL resetFlag)

top SQLite Runtime Status … → API: Sq3Status64

read more at 'Sq3Status'

Sq3Lite INTERNAL

NAVI: top, up

Sq3Lite INTERNAL ALLOC

Free Memory Allocation Subsystem …
Malloc Memory Allocation Subsystem …
Malloc64 Memory Allocation Subsystem …
Msize Memory Allocation Subsystem …
Realloc Memory Allocation Subsystem …
Realloc64

Memory Allocation Subsystem …

Sq3Lite INTERNAL MEMORY

HardHeapLimit64 Impose A Limit On Heap Size …
ReleaseMemory Attempt To Free Heap Memory …
SoftHeapLimit64

Impose A Limit On Heap Size …

Sq3Lite INTERNAL STRING

StrGlob String Globbing …
StrIcmp String Comparison …
StrLike String LIKE Matching …
StrNicmp

String Comparison …

Sq3Lite INTERNAL DETAILS

C-API: Sq3Lite_Internal_C_API - Sq3Lite PACKAGE - low level internal functions …

Sq3Lite INTERNAL ALLOC

C-API: Sq3Lite_Internal_Alloc_C_API - Memory Allocation Subsystem …

The SQLite core uses these three routines for all of its own internal memory allocation needs. "Core" in the previous sentence does not include operating-system specific VFS implementation. The Windows VFS uses native malloc() and free() for some operations.

The Sq3Malloc() routine returns a pointer to a block of memory at least N bytes in length, where N is the parameter. If Sq3Malloc() is unable to obtain sufficient free memory, it returns a NULL pointer. If the parameter N to Sq3Malloc() is zero or negative then Sq3Malloc() returns a NULL pointer.

The Sq3Malloc64(N) routine works just like Sq3Malloc(N) except that N is an unsigned 64-bit integer instead of a signed 32-bit integer.

Calling Sq3Free() with a pointer previously returned by Sq3Malloc() or Sq3Realloc() releases that memory so that it might be reused. The Sq3Free() routine is a no-op if is called with a NULL pointer. Passing a NULL pointer to Sq3Free() is harmless. After being freed, memory should neither be read nor written. Even reading previously freed memory might result in a segmentation fault or other severe error. Memory corruption, a segmentation fault, or other severe error might result if Sq3Free() is called with a non-NULL pointer that was not obtained from Sq3Malloc() or Sq3Realloc().

The Sq3Realloc(X,N) interface attempts to resize a prior memory allocation X to be at least N bytes. If the X parameter to Sq3Realloc(X,N) is a NULL pointer then its behavior is identical to calling Sq3Malloc(N). If the N parameter to Sq3Realloc(X,N) is zero or negative then the behavior is exactly the same as calling Sq3Free(X). Sq3Realloc(X,N) returns a pointer to a memory allocation of at least N bytes in size or NULL if insufficient memory is available. If M is the size of the prior allocation, then min(N,M) bytes of the prior allocation are copied into the beginning of buffer returned by Sq3Realloc(X,N) and the prior allocation is freed. If Sq3Realloc(X,N) returns NULL and N is positive, then the prior allocation is not freed.

The Sq3Realloc64(X,N) interfaces works the same as Sq3Realloc(X,N) except that N is a 64-bit unsigned integer instead of a 32-bit signed integer.

If X is a memory allocation previously obtained from Sq3Malloc(), Sq3Malloc64(), Sq3Realloc(), or Sq3Realloc64(), then Sq3Msize(X) returns the size of that memory allocation in bytes. The value returned by Sq3Msize(X) might be larger than the number of bytes requested when X was allocated. If X is a NULL pointer then Sq3Msize(X) returns zero. If X points to something that is not the beginning of memory allocation, or if it points to a formerly valid memory allocation that has now been freed, then the behavior of Sq3Msize(X) is undefined and possibly harmful.

The memory returned by Sq3Malloc(), Sq3Realloc(), Sq3Malloc64(), and Sq3Realloc64() is always aligned to at least an 8 byte boundary, or to a 4 byte boundary if the SQLITE_4_BYTE_ALIGNED_MALLOC compile-time option is used.

The pointer arguments to Sq3Free () and Sq3Realloc () must be either NULL or else pointers obtained from a prior invocation of Sq3Malloc () or Sq3Realloc () that have not yet been released.

The application must not read or write any part of a block of memory after it has been released using Sq3Free () or Sq3Realloc ().

Reference code from sqlite3:

SQLITE_API void *sqlite3_realloc(void*, int);
SQLITE_API void * sqlite3_malloc64(sqlite3_uint64)
sqlite_uint64 sqlite3_uint64
SQLITE_API void * sqlite3_realloc64(void *, sqlite3_uint64)
SQLITE_API sqlite3_uint64 sqlite3_msize(void *)
SQLITE_API void sqlite3_free(void *)
SQLITE_API void * sqlite3_realloc(void *, int)
SQLITE_API void * sqlite3_malloc(int)

(static,hide) void Sq3Free(MK_PTR N)

top Memory Allocation Subsystem … → API: Sq3Free

read more at 'Sq3Lite_Internal_Alloc_C_API'

(static,hide) MK_PTR Sq3Malloc(MK_I32 N)

top Memory Allocation Subsystem … → API: Sq3Malloc

read more at 'Sq3Lite_Internal_Alloc_C_API'

(static,hide) MK_PTR Sq3Malloc64(MK_I64 N)

top Memory Allocation Subsystem … → API: Sq3Malloc64

read more at 'Sq3Lite_Internal_Alloc_C_API'

(static,hide) MK_I64 Sq3Msize(MK_PTR N)

top Memory Allocation Subsystem … → API: Sq3Msize

read more at 'Sq3Lite_Internal_Alloc_C_API'

(static,hide) MK_PTR Sq3Realloc(MK_PTR arg0, MK_I32 N)

top Memory Allocation Subsystem … → API: Sq3Realloc

read more at 'Sq3Lite_Internal_Alloc_C_API'

(static,hide) MK_PTR Sq3Realloc64(MK_PTR arg0, MK_I64 N)

top Memory Allocation Subsystem … → API: Sq3Realloc64

read more at 'Sq3Lite_Internal_Alloc_C_API'

Sq3Lite INTERNAL MEMORY

C-API: Sq3Lite_Internal_Memory_C_API - Sq3Lite PACKAGE - functions related to index 'Internal' and doc 'Memory' …

Attempt To Free Heap Memory:

Impose A Limit On Heap Size:

Reference code from sqlite3:

// Attempt To Free Heap Memory:
// Impose A Limit On Heap Size:
SQLITE_API int sqlite3_release_memory(int)
SQLITE_API sqlite3_int64 sqlite3_hard_heap_limit64(sqlite3_int64 N)
SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N)

(static) MK_I64 Sq3HardHeapLimit64(MK_I64 N)

top Impose A Limit On Heap Size … → API: Sq3HardHeapLimit64

These interfaces impose limits on the amount of heap memory that will be by all database connections within a single process.

The Sq3SoftHeapLimit64() interface sets and/or queries the soft limit on the amount of heap memory that may be allocated by SQLite. SQLite strives to keep heap memory utilization below the soft heap limit by reducing the number of pages held in the page cache as heap memory usages approaches the limit. The soft heap limit is "soft" because even though SQLite strives to stay below the limit, it will exceed the limit rather than generate an SQ3_RESULT_NOMEM error. In other words, the soft heap limit is advisory only.

The Sq3HardHeapLimit64(N) interface sets a hard upper bound of N bytes on the amount of memory that will be allocated. The Sq3HardHeapLimit64(N) interface is similar to Sq3SoftHeapLimit64(N) except that memory allocations will fail when the hard heap limit is reached.

The return value from both Sq3SoftHeapLimit64() and Sq3HardHeapLimit64() is the size of the heap limit prior to the call, or negative in the case of an error. If the argument N is negative then no change is made to the heap limit. Hence, the current size of heap limits can be determined by invoking Sq3SoftHeapLimit64(-1) or Sq3HardHeapLimit64(-1).

Setting the heap limits to zero disables the heap limiter mechanism.

The soft heap limit may not be greater than the hard heap limit. If the hard heap limit is enabled and if sqlite3_soft_heap_limit(N) is invoked with a value of N that is greater than the hard heap limit, the soft heap limit is set to the value of the hard heap limit. The soft heap limit is automatically enabled whenever the hard heap limit is enabled. When Sq3HardHeapLimit64(N) is invoked and the soft heap limit is outside the range of 1..N, then the soft heap limit is set to N. Invoking Sq3SoftHeapLimit64(0) when the hard heap limit is enabled makes the soft heap limit equal to the hard heap limit.

The memory allocation limits can also be adjusted using PRAGMA soft_heap_limit and PRAGMA hard_heap_limit.

The heap limits are not enforced in the current implementation if one or more of following conditions are true:

The circumstances under which SQLite will enforce the heap limits may changes in future releases of SQLite.

Reference code from sqlite3:

(static) enum MkErrorE Sq3ReleaseMemory(MK_I32 N)

top Attempt To Free Heap Memory … → API: Sq3ReleaseMemory

The Sq3ReleaseMemory() interface attempts to free N bytes of heap memory by deallocating non-essential memory allocations held by the database library. Memory used to cache database pages to improve performance is an example of non-essential memory. Sq3ReleaseMemory() returns the number of bytes actually freed, which might be more or less than the amount requested. The Sq3ReleaseMemory() routine is a no-op returning zero if SQLite is not compiled with SQLITE_ENABLE_MEMORY_MANAGEMENT.

See also: Sq3LiteDbReleaseMemory ()

Reference code from sqlite3:

(static) MK_I64 Sq3SoftHeapLimit64(MK_I64 N)

top Impose A Limit On Heap Size … → API: Sq3SoftHeapLimit64

read more at 'Sq3HardHeapLimit64'

Sq3Lite INTERNAL STRING

C-API: Sq3Lite_Internal_String_C_API - Sq3Lite PACKAGE - functions related to index 'Internal' and doc 'String' …

String Comparison:

String Globbing:

String LIKE Matching:

Reference code from sqlite3:

// String Comparison:
SQLITE_API int sqlite3_stricmp(const char *, const char *);
SQLITE_API int sqlite3_strnicmp(const char *, const char *, int);
// String Globbing:
SQLITE_API int sqlite3_strglob(const char *zGlob, const char *zStr);
// String LIKE Matching:
SQLITE_API int sqlite3_strlike(const char *zGlob, const char *zStr, unsigned int cEsc);
SQLITE_API int sqlite3_strglob(const char *zGlob, const char *zStr)
SQLITE_API int sqlite3_strlike(const char *zGlob, const char *zStr, unsigned int cEsc)
SQLITE_API int sqlite3_strnicmp(const char *, const char *, int)
SQLITE_API int sqlite3_stricmp(const char *, const char *)

(static) MK_I32 Sq3StrGlob(MK_STRN zGlob, MK_STRN zStr)

top String Globbing … → API: Sq3StrGlob

The Sq3StrGlob (P,X) interface returns zero if and only if string X matches the GLOB pattern P. The definition of GLOB pattern matching used in Sq3StrGlob (P,X) is the same as for the "X GLOB P" operator in the SQL dialect understood by SQLite. The Sq3StrGlob (P,X) function is case sensitive.

Note that this routine returns zero on a match and non-zero if the strings do not match, the same as Sq3StrIcmp () and Sq3StrNicmp ().

See also: Sq3StrLike ().

Reference code from sqlite3:

SQLITE_API int sqlite3_strglob(const char *zGlob, const char *zStr);

(static) MK_I32 Sq3StrIcmp(MK_STRN arg0, MK_STRN arg1)

top String Comparison … → API: Sq3StrIcmp

The Sq3StrIcmp () and Sq3StrNicmp () APIs allow applications and extensions to compare the contents of two buffers containing UTF-8 strings in a case-independent fashion, using the same definition of "case independence" that SQLite uses internally when comparing identifiers.

Reference code from sqlite3:

SQLITE_API int sqlite3_stricmp(const char *, const char *);
SQLITE_API int sqlite3_strnicmp(const char *, const char *, int);

(static) MK_I32 Sq3StrLike(MK_STRN zGlob, MK_STRN zStr, MK_I32 cEsc)

top String LIKE Matching … → API: Sq3StrLike

The Sq3StrLike (P,X,E) interface returns zero if and only if string X matches the LIKE pattern P with escape character E. The definition of LIKE pattern matching used in Sq3StrLike (P,X,E) is the same as for the "X LIKE P ESCAPE E" operator in the SQL dialect understood by SQLite. For "X LIKE P" without the ESCAPE clause, set the E parameter of Sq3StrLike (P,X,E) to 0. As with the LIKE operator, the Sq3StrLike (P,X,E) function is case insensitive - equivalent upper and lower case ASCII characters match one another.

The Sq3StrLike (P,X,E) function matches Unicode characters, though only ASCII characters are case folded.

Note that this routine returns zero on a match and non-zero if the strings do not match, the same as Sq3StrIcmp () and Sq3StrNicmp ().

See also: Sq3StrGlob ().

Reference code from sqlite3:

SQLITE_API int sqlite3_strlike(const char *zGlob, const char *zStr, unsigned int cEsc);

(static) MK_I32 Sq3StrNicmp(MK_STRN arg0, MK_STRN arg1, MK_I32 arg2)

top String Comparison … → API: Sq3StrNicmp

read more at 'Sq3StrIcmp'

Sq3Lite VERSION

C-API: Sq3Lite_Version_C_API - Sq3Lite PACKAGE - get version information …

(static) MK_STRN Sq3Libversion()

top Run-Time Library Version Numbers … → API: Sq3Libversion

These interfaces provide the same information as the SQLITE_VERSION, SQLITE_VERSION_NUMBER, and SQLITE_SOURCE_ID C preprocessor macros but are associated with the library instead of the header file. Cautious programmers might include assert() statements in their application to verify that values returned by these interfaces match the macros in the header, and thus ensure that the application is compiled with matching library and header files.

assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );
assert( strncmp(sqlite3_sourceid(),SQLITE_SOURCE_ID,80)==0 );
assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );

The sqlite3_version[] string constant contains the text of SQLITE_VERSION macro. The Sq3Libversion() function returns a pointer to the to the sqlite3_version[] string constant. The Sq3Libversion() function is provided for use in DLLs since DLL users usually do not have direct access to string constants within the DLL. The Sq3LibversionNumber() function returns an integer equal to SQLITE_VERSION_NUMBER. The Sq3Sourceid() function returns a pointer to a string constant whose value is the same as the SQLITE_SOURCE_ID C preprocessor macro. Except if SQLite is built using an edited copy of the amalgamation, then the last four characters of the hash might be different from SQLITE_SOURCE_ID.

See also: sqlite_version () and sqlite_source_id ().

Reference code from sqlite3:

SQLITE_API const char *sqlite3_libversion(void);
SQLITE_API const char *sqlite3_sourceid(void);
#define SQLITE_EXTERN
SQLITE_API SQLITE_EXTERN const char sqlite3_version[]
SQLITE_API const char * sqlite3_sourceid(void)
SQLITE_API const char * sqlite3_libversion(void)
SQLITE_API int sqlite3_libversion_number(void)

(static) enum MkErrorE Sq3LibversionNumber()

top Run-Time Library Version Numbers … → API: Sq3LibversionNumber

read more at 'Sq3Libversion'

(static) MK_STRN Sq3Sourceid()

top Run-Time Library Version Numbers … → API: Sq3Sourceid

read more at 'Sq3Libversion'

Sq3Lite VFS

C-API: Sq3Lite_Vfs_C_API - Sq3Lite PACKAGE - work with the virtual-file-system

(static,hide) SQ3_FILENAME Sq3CreateFilename(MK_STRN zDatabase, MK_STRN zJournal, MK_STRN zWal, MK_I32 azParam_num, MK_STRN *azParam)

top Create and Destroy VFS Filenames … → API: Sq3CreateFilename

These interfaces are provided for use by VFS shim implementations and are not useful outside of that context.

The Sq3CreateFilename(D,J,W,N,P) allocates memory to hold a version of database filename D with corresponding journal file J and WAL file W and with N URI parameters key/values pairs in the array P. The result from Sq3CreateFilename(D,J,W,N,P) is a pointer to a database filename that is safe to pass to routines like:

If a memory allocation error occurs, Sq3CreateFilename() might return a NULL pointer. The memory obtained from Sq3CreateFilename(X) must be released by a corresponding call to Sq3FreeFilename(Y).

The P parameter in Sq3CreateFilename(D,J,W,N,P) should be an array of 2*N pointers to strings. Each pair of pointers in this array corresponds to a key and value for a query parameter. The P parameter may be a NULL pointer if N is zero. None of the 2*N pointers in the P array may be NULL pointers and key pointers should not be empty strings. None of the D, J, or W parameters to Sq3CreateFilename(D,J,W,N,P) may be NULL pointers, though they can be empty strings.

The Sq3FreeFilename(Y) routine releases a memory allocation previously obtained from Sq3CreateFilename(). Invoking Sq3FreeFilename(Y) where Y is a NULL pointer is a harmless no-op.

If the Y parameter to Sq3FreeFilename(Y) is anything other than a NULL pointer or a pointer previously acquired from Sq3CreateFilename(), then bad things such as heap corruption or segfaults may occur. The value Y should not be used again after Sq3FreeFilename(Y) has been called. This means that if the sqlite3_vfs.xOpen() method of a VFS has been called using Y, then the corresponding sqlite3_module.xClose() method should also be invoked prior to calling Sq3FreeFilename(Y).

Reference code from sqlite3:

const char *zDatabase,
const char *zJournal,
const char *zWal,
int nParam,
const char **azParam
);
SQLITE_API void sqlite3_free_filename(sqlite3_filename)
const char * sqlite3_filename
SQLITE_API sqlite3_filename sqlite3_create_filename(const char *zDatabase, const char *zJournal, const char *zWal, int nParam, const char **azParam)

(static) MK_STRN Sq3FilenameDatabase(SQ3_FILENAME F)

top Translate filenames … → API: Sq3FilenameDatabase

These routines are available to custom VFS implementations for translating filenames between the main database file, the journal file, and the WAL file.

If F is the name of an sqlite database file, journal file, or WAL file passed by the SQLite core into the VFS, then Sq3FilenameDatabase(F) returns the name of the corresponding database file.

If F is the name of an sqlite database file, journal file, or WAL file passed by the SQLite core into the VFS, or if F is a database filename obtained from Sq3LiteDbFilename (), then Sq3FilenameJournal(F) returns the name of the corresponding rollback journal file.

If F is the name of an sqlite database file, journal file, or WAL file that was passed by the SQLite core into the VFS, or if F is a database filename obtained from Sq3LiteDbFilename (), then Sq3FilenameWal(F) returns the name of the corresponding WAL file.

In all of the above, if F is not the name of a database, journal or WAL filename passed into the VFS from the SQLite core and F is not the return value from Sq3LiteDbFilename (), then the result is undefined and is likely a memory access violation.

Reference code from sqlite3:

SQLITE_API const char * sqlite3_filename_journal(sqlite3_filename)
SQLITE_API const char * sqlite3_filename_database(sqlite3_filename)
SQLITE_API const char * sqlite3_filename_wal(sqlite3_filename)

(static) MK_STRN Sq3FilenameJournal(SQ3_FILENAME F)

top Translate filenames … → API: Sq3FilenameJournal

read more at 'Sq3FilenameDatabase'

(static) MK_STRN Sq3FilenameWal(SQ3_FILENAME F)

top Translate filenames … → API: Sq3FilenameWal

read more at 'Sq3FilenameDatabase'

(static) void Sq3FreeFilename(SQ3_FILENAME arg0)

top Create and Destroy VFS Filenames … → API: Sq3FreeFilename

read more at 'Sq3CreateFilename'

(static) enum MkErrorE Sq3UriBoolean(SQ3_FILENAME z, MK_STRN zParam, MK_I32 bDefault)

top Obtain Values For URI Parameters … → API: Sq3UriBoolean

These are utility routines, useful to custom VFS implementations, that check if a database file was a URI that contained a specific query parameter, and if so obtains the value of that query parameter.

The first parameter to these interfaces (hereafter referred to as F) must be one of:

  • A database filename pointer created by the SQLite core and passed into the xOpen() method of a VFS implementation, or
  • A filename obtained from Sq3LiteDbFilename (), or
  • A new filename constructed using Sq3CreateFilename ().

If the F parameter is not one of the above, then the behavior is undefined and probably undesirable. Older versions of SQLite were more tolerant of invalid F parameters than newer versions.

If F is a suitable filename (as described in the previous paragraph) and if P is the name of the query parameter, then Sq3UriParameter(F,P) returns the value of the P parameter if it exists or a NULL pointer if P does not appear as a query parameter on F. If P is a query parameter of F and it has no explicit value, then Sq3UriParameter(F,P) returns a pointer to an empty string.

The Sq3UriBoolean(F,P,B) routine assumes that P is a boolean parameter and returns true (1) or false (0) according to the value of P. The Sq3UriBoolean(F,P,B) routine returns true (1) if the value of query parameter P is one of "yes", "true", or "on" in any case or if the value begins with a non-zero number. The Sq3UriBoolean(F,P,B) routines returns false (0) if the value of query parameter P is one of "no", "false", or "off" in any case or if the value begins with a numeric zero. If P is not a query parameter on F or if the value of P does not match any of the above, then Sq3UriBoolean(F,P,B) returns (B!=0).

The Sq3UriInt64(F,P,D) routine converts the value of P into a 64-bit signed integer and returns that integer, or D if P does not exist. If the value of P is something other than an integer, then zero is returned.

The Sq3UriKey(F,N) returns a pointer to the name (not the value) of the N-th query parameter for filename F, or a NULL pointer if N is less than zero or greater than the number of query parameters minus 1. The N value is zero-based so N should be 0 to obtain the name of the first query parameter, 1 for the second parameter, and so forth.

If F is a NULL pointer, then Sq3UriParameter(F,P) returns NULL and Sq3UriBoolean(F,P,B) returns B. If F is not a NULL pointer and is not a database file pathname pointer that the SQLite core passed into the xOpen VFS method, then the behavior of this routine is undefined and probably undesirable.

Beginning with SQLite version 3.31.0 (dateof:3.31.0) the input F parameter can also be the name of a rollback journal file or WAL file in addition to the main database file. Prior to version 3.31.0, these routines would only work if F was the name of the main database file. When the F parameter is the name of the rollback journal or WAL file, it has access to all the same query parameters as were found on the main database file.

See the URI filename documentation for additional information.

Reference code from sqlite3:

SQLITE_API const char *sqlite3_uri_parameter(sqlite3_filename z, const char *zParam);
SQLITE_API int sqlite3_uri_boolean(sqlite3_filename z, const char *zParam, int bDefault);
SQLITE_API const char * sqlite3_uri_parameter(sqlite3_filename z, const char *zParam)
SQLITE_API const char * sqlite3_uri_key(sqlite3_filename z, int N)
SQLITE_API int sqlite3_uri_boolean(sqlite3_filename z, const char *zParam, int bDefault)
SQLITE_API sqlite3_int64 sqlite3_uri_int64(sqlite3_filename, const char *, sqlite3_int64)

(static) MK_I64 Sq3UriInt64(SQ3_FILENAME arg0, MK_STRN arg1, MK_I64 arg2)

top Obtain Values For URI Parameters … → API: Sq3UriInt64

read more at 'Sq3UriBoolean'

(static) MK_STRN Sq3UriKey(SQ3_FILENAME z, MK_I32 N)

top Obtain Values For URI Parameters … → API: Sq3UriKey

read more at 'Sq3UriBoolean'

(static) MK_STRN Sq3UriParameter(SQ3_FILENAME z, MK_STRN zParam)

top Obtain Values For URI Parameters … → API: Sq3UriParameter

read more at 'Sq3UriBoolean'

Sq3Lite ERROR

C-API: Sq3Lite_Error_C_API - Sq3Lite PACKAGE - work with an error

Error handling in libsq3lite.

The error signals the end of an operation with an undesirable result or state.

  • The error is defined using the both enum: enum Sq3ErrorE and enum Sq3ExtendetResultCodesE
  • In a programming language WITHOUT explicit error handling (eg "C") this value is returned and the subsequent code must process the error, eg with Sq3ErrorE_Check.
  • In a programming language WITH explicit error handling (eg "Java"), the error is converted into an exception and the program flow is aborted with an error message.

(static) MK_BOOL Sq3ErrorCheckI(enum Sq3ErrorE ret)

top check if ret signal an error … → API: Sq3ErrorCheckI

Parameters
[in]retinput for libsq3lite error-check
Returns
true if ret is an error otherwise false

(static,hide) enum MkErrorE Sq3LiteErrorToMQ(MK_OBJN const obj, MK_STRN const func, MK_STRN const file, MK_I32 const line)

top if a libsq3lite funtion return a MkErrorE use this function to convert the libsq3lite-error into the libmkkernel-error … → API: Sq3LiteErrorToMQ


Sq3LiteC

Sq3LiteC CLASS

Define Sq3LiteC - low level definition, access and cast …
Export Sq3LiteC - Export class functions …
Introspection Sq3LiteC - Introspection class functions …
Misc

Sq3LiteC - Misc class functions …

Sq3LiteC TOR

OpenV2 Opening A New Database Connection …
CloseV2 Closing A Database Connection …
PrepareV2

Compiling An SQL Statement …

Sq3LiteC CONFIG

BusyHandler Register A Callback To Handle SQLITE_BUSY Errors …
BusyTimeout Set A Busy Timeout …
CommitHook Commit And Rollback Notification Callbacks …
DeclareVtab Declare The Schema Of A Virtual Table …
EnableLoadExtension Enable Or Disable Extension Loading …
ExtendedResultCodes Enable Or Disable Extended Result Codes …
Limit Run-time Limits …
LoadExtension Load An Extension …
RollbackHook Commit And Rollback Notification Callbacks …
UpdateHook

Data Change Notification Callbacks …

Sq3LiteC EXECUTION

Sleep Suspend Execution For A Short Time …
Exec One-Step Query Execution Interface …
ExecV2

The Sq3LiteExecV2() interface is a convenience wrapper around Sq3StmtPrepareV2(), Sq3StmtStep(), and Sq3StmtFinalize(), that allows an application to run multiple statements of SQL without having to use a lot of C code.

Sq3LiteC INFO

GetAutocommit Test For Auto-Commit Mode …
LastInsertRowid Last Insert Rowid …
TxnState Determine the transaction state of a database …
VtabOnConflict

Determine The Virtual Table Conflict Policy …

Sq3LiteC MODIFY

Create Sq3LiteC - functions related to index 'Modify' and doc 'Create' …
Wal

Sq3LiteC - functions related to index 'Modify' and doc 'Wal' …

Sq3LiteC QUERY

Interrupt Interrupt A Long-Running Query …
IsInterrupted

Interrupt A Long-Running Query …

Sq3LiteC ROW

Changes Count The Number Of Rows Modified …
Changes64 Count The Number Of Rows Modified …
SetLastInsertRowid Set the Last Insert Rowid value …
TotalChanges Total Number Of Rows Modified …
TotalChanges64

Total Number Of Rows Modified …

Sq3LiteC ERROR

ErrStr Error Codes And Messages …
ErrCode Error Codes And Messages …
ErrMsg Error Codes And Messages …
ErrorOffset Error Codes And Messages …
ExtendetErrCode Error Codes And Messages …
SystemErrno

Low-level system error code …

Sq3LiteC MISC

AutovacuumPages Autovacuum Compaction Amount Callback …
CollationNeeded Collation Needed Callbacks …
DbCacheflush Flush caches to disk mid-transaction …
DbFilename Return The Filename For A Database Connection …
DbName Return The Schema Name For A Database Connection …
DbReadonly Determine if a database is read-only …
DbReleaseMemory Free Memory Used By A Database Connection …
DbStatus Database Connection Status …
DbStatusBFL Database Connection Status …
Deserialize Deserialize a database …
DeserializeHide Deserialize a database …
DropModules Remove Unnecessary Virtual Table Implementations …
DropModulesHide Remove Unnecessary Virtual Table Implementations …
FileControl Low-Level Control Of Database Files …
Log log the lite
OverloadFunction Overload A Function For A Virtual Table …
Serialize Serialize a database …
SerializeHide Serialize a database …
TableColumnMetadata Extract Metadata About A Column Of A Table …
VtabConfig

Virtual Table Interface Configuration …

Sq3LiteC DETAIL

C-API: Sq3LiteC_C_API - Sq3LiteC - the class known as sq3lite or Lite defined by Sq3LiteS

Struct to represent the data of the Sq3LiteC

Database Connection Handle …

Each open SQLite database is represented by a pointer to an instance of the opaque structure named "sqlite3". It is useful to think of an Sq3LiteC pointer as an object. The sqlite3_open (), sqlite3_open16 (), and Sq3LiteOpenV2 () interfaces are its constructors, and sqlite3_close () and Sq3LiteCloseV2 () are its destructors. There are many other interfaces (such as Sq3StmtPrepareV2 (), sqlite3_create_function (), and Sq3LiteBusyTimeout () to name but three) that are methods on an Sq3LiteC object.

Reference code from sqlite3:

typedef struct sqlite3 sqlite3;

Sq3LiteC CLASS

NAVI: top, up

Sq3LiteC CLASS DEFINE

Lite cast a unknown-object into an Sq3LiteS pointer or NULL if not possible
LiteCheck check Sq3LiteS -> MkObjectS::signature
LiteCheckO check Sq3LiteS -> MkObjectS::signature
LiteN

(const) cast a unknown-object into an Sq3LiteS pointer or NULL if not possible

Sq3LiteC CLASS EXPORT

HandleResolve Handle-Resolve-Slot - return a Sq3LiteC from netHdl or MK_NULL if invalid…
HandleGet

Handle-Get-Slot - returns a export-hdl to the Sq3LiteC useable for external storage

Sq3LiteC CLASS INTROSPECTION

Instances get head-instance from linked-list of Sq3LiteS type …
Next get next instance from linked-list of Sq3LiteS type
Prev

get previous instance from linked-list of Sq3LiteS type

Sq3LiteC CLASS MISC

GetNull

Null-Slot - return a Sq3LiteC typed NULL instance …

Sq3LiteC CLASS DETAILS

C-API: Sq3LiteC_Class_C_API - Sq3LiteC - define the class …

Sq3LiteC CLASS DEFINE

C-API: Sq3LiteC_Class_Define_C_API - Sq3LiteC - low level definition, access and cast …

(static,hide) SQ3_LITE Sq3Lite(MK_MNG mng)

top cast a unknown-object into an Sq3LiteS pointer or NULL if not possible → API: Sq3Lite

(static,hide) MK_BOOL Sq3LiteCheck(MK_MNGN mng)

top check Sq3LiteS -> MkObjectS::signature … → API: Sq3LiteCheck

Returns
TRUE on valid lite and FALSE an invalid lite

(static,hide) MK_BOOL Sq3LiteCheckO(MK_OBJN obj)

top check Sq3LiteS -> MkObjectS::signature … → API: Sq3LiteCheckO

Returns
TRUE on valid lite and FALSE an invalid lite

(static,hide) SQ3_LITEN Sq3LiteN(MK_MNGN mng)

top (const) cast a unknown-object into an Sq3LiteS pointer or NULL if not possible → API: Sq3LiteN

Sq3LiteC CLASS EXPORT

Sq3LiteC - Export class functions …

(static,runtime) SQ3_LITE Sq3LiteHandleResolve(MK_HDL const netHdl)

top Handle-Resolve-Slot - return a Sq3LiteC from netHdl or MK_NULL if invalid… → API: Sq3LiteHandleResolve_RT

The Sq3LiteHandleResolve undo the Sq3LiteHandleGet and is intended to export a unique identifer into external code not belonging to the Programming-Language-Micro-Kernel (PLMK).

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]netHdlhandle former exported with Sq3LiteHandleGet
Returns
the required handle or MK_NULL if netHdl is invalid

(runtime) MK_HDL Sq3LiteHandleGet(SQ3_LITE const lite)

top Handle-Get-Slot - returns a export-hdl to the Sq3LiteC useable for external storage → API: Sq3LiteHandleGet_RT

The export-hdl is a reference to an instance that can be stored in software and converted back into an instance using the Sq3LiteHandleResolve.

The export-hdl is only valid until the Programming-Language-Micro-Kernel (PLMK) ends.

example: The export-hdl is used in rpc to identify an object across the network.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]liteProgramming-Language-Micro-Kernel (PLMK) instance from sqlite3
Returns
the required export-hdl

Sq3LiteC CLASS INTROSPECTION

Sq3LiteC - Introspection class functions …

(static,runtime) SQ3_LITE Sq3LiteInstances()

top get head-instance from linked-list of Sq3LiteS type … → API: Sq3LiteInstances_RT

The head-instance is the last instance created.

SQ3_LITE Sq3LiteNext(SQ3_LITE const lite)

top get next instance from linked-list of Sq3LiteS type → API: Sq3LiteNext

SQ3_LITE Sq3LitePrev(SQ3_LITE const lite)

top get previous instance from linked-list of Sq3LiteS type → API: Sq3LitePrev

Sq3LiteC CLASS MISC

Sq3LiteC - Misc class functions …

(static) SQ3_LITE Sq3LiteGetNull()

top Null-Slot - return a Sq3LiteC typed NULL instance … → API: Sq3LiteGetNull

Sq3LiteC TOR

C-API: Sq3LiteC_TOR_C_API - Sq3LiteC - various functions to create, initialize and destroy …

(constructor,static) enum MkErrorE Sq3LiteOpenV2(MK_STRN filename, SQ3_LITE *ppDb, enum Sq3OpenEF flags, MK_STRN zVfs)

top Opening A New Database Connection … → API: Sq3LiteOpenV2

These routines open an SQLite database file as specified by the filename argument. The filename argument is interpreted as UTF-8 for sqlite3_open() and Sq3LiteOpenV2() and as UTF-16 in the native byte order for sqlite3_open16(). A database connection handle is usually returned in *ppDb, even if an error occurs. The only exception is that if SQLite is unable to allocate memory to hold the Sq3LiteC object, a NULL will be written into *ppDb instead of a pointer to the Sq3LiteC object. If the database is opened (and/or created) successfully, then SQ3_RESULT_OK is returned. Otherwise an error code is returned. The Sq3LiteErrMsg () or sqlite3_errmsg16 () routines can be used to obtain an English language description of the error following a failure of any of the sqlite3_open() routines.

The default encoding will be UTF-8 for databases created using sqlite3_open() or Sq3LiteOpenV2(). The default encoding for databases created using sqlite3_open16() will be UTF-16 in the native byte order.

Whether or not an error occurs when it is opened, resources associated with the database connection handle should be released by passing it to sqlite3_close () when it is no longer required.

The Sq3LiteOpenV2() interface works like sqlite3_open() except that it accepts two additional parameters for additional control over the new database connection. The flags parameter to Sq3LiteOpenV2() must include, at a minimum, one of the following three flag combinations:

SQ3_OPEN_READONLY

The database is opened in read-only mode. If the database does not already exist, an error is returned.

SQ3_OPEN_READWRITE

The database is opened for reading and writing if possible, or reading only if the file is write protected by the operating system. In either case the database must already exist, otherwise an error is returned. For historical reasons, if opening in read-write mode fails due to OS-level permissions, an attempt is made to open it in read-only mode. Sq3LiteDbReadonly () can be used to determine whether the database is actually read-write.

SQ3_OPEN_READWRITE | SQ3_OPEN_CREATE
The database is opened for reading and writing, and is created if it does not already exist. This is the behavior that is always used for sqlite3_open() and sqlite3_open16().

In addition to the required flags, the following optional flags are also supported:

SQ3_OPEN_URI

The filename can be interpreted as a URI if this flag is set.

SQ3_OPEN_MEMORY

The database will be opened as an in-memory database. The database is named by the "filename" argument for the purposes of cache-sharing, if shared cache mode is enabled, but the "filename" is otherwise ignored.

SQ3_OPEN_NOMUTEX

The new database connection will use the "multi-thread" threading mode. This means that separate threads are allowed to use SQLite at the same time, as long as each thread is using a different database connection.

SQ3_OPEN_FULLMUTEX

The new database connection will use the "serialized" threading mode. This means the multiple threads can safely attempt to use the same database connection at the same time. (Mutexes will block any actual concurrency, but in this mode there is no harm in trying.)

SQ3_OPEN_SHAREDCACHE

The database is opened shared cache enabled, overriding the default shared cache setting provided by sqlite3_enable_shared_cache (). The use of shared cache mode is discouraged and hence shared cache capabilities may be omitted from many builds of SQLite. In such cases, this option is a no-op.

SQ3_OPEN_PRIVATECACHE

The database is opened shared cache disabled, overriding the default shared cache setting provided by sqlite3_enable_shared_cache ().

SQ3_OPEN_EXRESCODE

The database connection comes up in "extended result code mode". In other words, the database behaves has if Sq3LiteExtendedResultCodes (db,1) where called on the database connection as soon as the connection is created. In addition to setting the extended result code mode, this flag also causes Sq3LiteOpenV2 () to return an extended result code.

SQ3_OPEN_NOFOLLOW
The database filename is not allowed to contain a symbolic link

If the 3rd parameter to Sq3LiteOpenV2() is not one of the required combinations shown above optionally combined with other SQ3_OPEN_* bits then the behavior is undefined. Historic versions of SQLite have silently ignored surplus bits in the flags parameter to Sq3LiteOpenV2(), however that behavior might not be carried through into future versions of SQLite and so applications should not rely upon it. Note in particular that the SQ3_OPEN_EXCLUSIVE flag is a no-op for Sq3LiteOpenV2(). The SQ3_OPEN_EXCLUSIVE does not cause the open to fail if the database already exists. The SQ3_OPEN_EXCLUSIVE flag is intended for use by the VFS interface only, and not by Sq3LiteOpenV2().

The fourth parameter to Sq3LiteOpenV2() is the name of the sqlite3_vfs object that defines the operating system interface that the new database connection should use. If the fourth parameter is a NULL pointer then the default sqlite3_vfs object is used.

If the filename is ":memory:", then a private, temporary in-memory database is created for the connection. This in-memory database will vanish when the database connection is closed. Future versions of SQLite might make use of additional special filenames that begin with the ":" character. It is recommended that when a database filename actually does begin with a ":" character you should prefix the filename with a pathname such as "./" to avoid ambiguity.

If the filename is an empty string, then a private, temporary on-disk database will be created. This private database will be automatically deleted as soon as the database connection is closed.

URI Filenames

If URI filename interpretation is enabled, and the filename argument begins with "file:", then the filename is interpreted as a URI. URI filename interpretation is enabled if the SQ3_OPEN_URI flag is set in the third argument to Sq3LiteOpenV2(), or if it has been enabled globally using the SQ3_CONFIG_URI option with the sqlite3_config () method or by the SQLITE_USE_URI compile-time option. URI filename interpretation is turned off by default, but future releases of SQLite might enable URI filename interpretation by default. See "<a href="https://www.sqlite.org/uri.html">URI filenames</a>" for additional information.

URI filenames are parsed according to RFC 3986. If the URI contains an authority, then it must be either an empty string or the string "localhost". If the authority is not an empty string or "localhost", an error is returned to the caller. The fragment component of a URI, if present, is ignored.

SQLite uses the path component of the URI as the name of the disk file which contains the database. If the path begins with a '/' character, then it is interpreted as an absolute path. If the path does not begin with a '/' (meaning that the authority section is omitted from the URI) then the path is interpreted as a relative path. On windows, the first component of an absolute path is a drive specification (e.g. "C:").

The query component of a URI may contain parameters that are interpreted either by SQLite itself, or by a custom VFS implementation. SQLite and its built-in VFSes interpret the following query parameters:

  • vfs: The "vfs" parameter may be used to specify the name of a VFS object that provides the operating system interface that should be used to access the database file on disk. If this option is set to an empty string the default VFS object is used. Specifying an unknown VFS is an error. If Sq3LiteOpenV2() is used and the vfs option is present, then the VFS specified by the option takes precedence over the value passed as the fourth parameter to Sq3LiteOpenV2().

  • mode: The mode parameter may be set to either "ro", "rw", "rwc", or "memory". Attempting to set it to any other value is an error. If "ro" is specified, then the database is opened for read-only access, just as if the SQ3_OPEN_READONLY flag had been set in the third argument to Sq3LiteOpenV2(). If the mode option is set to "rw", then the database is opened for read-write (but not create) access, as if SQ3_OPEN_READWRITE (but not SQ3_OPEN_CREATE) had been set. Value "rwc" is equivalent to setting both SQ3_OPEN_READWRITE and SQ3_OPEN_CREATE. If the mode option is set to "memory" then a pure in-memory database that never reads or writes from disk is used. It is an error to specify a value for the mode parameter that is less restrictive than that specified by the flags passed in the third parameter to Sq3LiteOpenV2().

  • cache: The cache parameter may be set to either "shared" or "private". Setting it to "shared" is equivalent to setting the SQ3_OPEN_SHAREDCACHE bit in the flags argument passed to Sq3LiteOpenV2(). Setting the cache parameter to "private" is equivalent to setting the SQ3_OPEN_PRIVATECACHE bit. If Sq3LiteOpenV2() is used and the "cache" parameter is present in a URI filename, its value overrides any behavior requested by setting SQ3_OPEN_PRIVATECACHE or SQ3_OPEN_SHAREDCACHE flag.

  • psow: The psow parameter indicates whether or not the powersafe overwrite property does or does not apply to the storage media on which the database file resides.

  • nolock: The nolock parameter is a boolean query parameter which if set disables file locking in rollback journal modes. This is useful for accessing a database on a filesystem that does not support locking. Caution: Database corruption might result if two or more processes write to the same database and any one of those processes uses nolock=1.

  • immutable: The immutable parameter is a boolean query parameter that indicates that the database file is stored on read-only media. When immutable is set, SQLite assumes that the database file cannot be changed, even by a process with higher privilege, and so the database is opened read-only and all locking and change detection is disabled. Caution: Setting the immutable property on a database file that does in fact change can result in incorrect query results and/or SQ3_RESULT_CORRUPT errors. See also: SQ3_IOCAP_IMMUTABLE.

Specifying an unknown parameter in the query component of a URI is not an error. Future versions of SQLite might understand additional query parameters. See "<a href="https://www.sqlite.org/uri.html#coreqp">query parameters with special meaning to SQLite</a>" for additional information.

URI filename examples

URI filenames Results
file:data.db Open the file "data.db" in the current directory.
file:/home/fred/data.db
file:///home/fred/data.db
file://localhost/home/fred/data.db
Open the database file "/home/fred/data.db".
file://darkstar/home/fred/data.db An error. "darkstar" is not a recognized authority.
file:///C:/Documents%20and%20Settings/fred/Desktop/data.db Windows only: Open the file "data.db" on fred's desktop on drive C:. Note that the %20 escaping in this example is not strictly necessary - space characters can be used literally in URI filenames.
file:data.db?mode=ro&cache=private Open file "data.db" in the current directory for read-only access. Regardless of whether or not shared-cache mode is enabled by default, use a private cache.
file:/home/fred/data.db?vfs=unix-dotfile Open file "/home/fred/data.db". Use the special VFS "unix-dotfile" that uses dot-files in place of posix advisory locking.
file:data.db?mode=readonly An error. "readonly" is not a valid option for the "mode" parameter. Use "ro" instead: "file:data.db?mode=ro".

URI hexadecimal escape sequences (HH) are supported within the path and query components of a URI. A hexadecimal escape sequence consists of a percent sign - "%" - followed by exactly two hexadecimal digits specifying an octet value. Before the path or query components of a URI filename are interpreted, they are encoded using UTF-8 and all hexadecimal escape sequences replaced by a single byte containing the corresponding octet. If this process generates an invalid UTF-8 encoding, the results are undefined.

Note to Windows users: The encoding used for the filename argument of sqlite3_open() and Sq3LiteOpenV2() must be UTF-8, not whatever codepage is currently defined. Filenames containing international characters must be converted to UTF-8 prior to passing them into sqlite3_open() or Sq3LiteOpenV2().

Note to Windows Runtime users: The temporary directory must be set prior to calling sqlite3_open() or Sq3LiteOpenV2(). Otherwise, various features that require the use of temporary files may fail.

See also: sqlite3_temp_directory

Reference code from sqlite3:

const char *filename, // Database filename (UTF-8)
sqlite3 **ppDb // OUT: SQLite db handle
);
const void *filename, // Database filename (UTF-16)
sqlite3 **ppDb // OUT: SQLite db handle
);
const char *filename, // Database filename (UTF-8)
sqlite3 **ppDb, // OUT: SQLite db handle
int flags, // Flags
const char *zVfs // Name of VFS module to use
);
SQLITE_API int sqlite3_open_v2(const char *filename, sqlite3 **ppDb, int flags, const char *zVfs)
SQLITE_API int sqlite3_open(const char *filename, sqlite3 **ppDb)
SQLITE_API int sqlite3_open16(const void *filename, sqlite3 **ppDb)

(destructor) enum MkErrorE Sq3LiteCloseV2(SQ3_LITE sq3lite)

top Closing A Database Connection … → API: Sq3LiteCloseV2

The sqlite3_close() and Sq3LiteCloseV2() routines are destructors for the Sq3LiteC object. Calls to sqlite3_close() and Sq3LiteCloseV2() return SQ3_RESULT_OK if the Sq3LiteC object is successfully destroyed and all associated resources are deallocated.

Ideally, applications should finalize all prepared statements, close all BLOB handles, and finish all sqlite3_backup objects associated with the Sq3LiteC object prior to attempting to close the object. If the database connection is associated with unfinalized prepared statements, BLOB handlers, and/or unfinished sqlite3_backup objects then sqlite3_close() will leave the database connection open and return SQ3_RESULT_BUSY. If Sq3LiteCloseV2() is called with unfinalized prepared statements, unclosed BLOB handlers, and/or unfinished Sq3Backup's, it returns SQ3_RESULT_OK regardless, but instead of deallocating the database connection immediately, it marks the database connection as an unusable "zombie" and makes arrangements to automatically deallocate the database connection after all prepared statements are finalized, all BLOB handles are closed, and all backups have finished. The Sq3LiteCloseV2() interface is intended for use with host languages that are garbage collected, and where the order in which destructors are called is arbitrary.

If an Sq3LiteC object is destroyed while a transaction is open, the transaction is automatically rolled back.

The C parameter to sqlite3_close (C) and Sq3LiteCloseV2 (C) must be either a NULL pointer or an Sq3LiteC object pointer obtained from sqlite3_open (), sqlite3_open16 (), or Sq3LiteOpenV2 (), and not previously closed. Calling sqlite3_close() or Sq3LiteCloseV2() with a NULL pointer argument is a harmless no-op.

Reference code from sqlite3:

SQLITE_API int sqlite3_close(sqlite3 *)
SQLITE_API int sqlite3_close_v2(sqlite3 *)

(constructor) enum MkErrorE Sq3LitePrepareV2(SQ3_LITE db, MkStringR zSql, SQ3_STMT *ppStmt)

top Compiling An SQL Statement … → API: Sq3LitePrepareV2

This is an enhanced version of Sq3StmtPrepareV2Hide. The last argument pzTail is stored into the Sq3StmtC class Sq3StmtS::pzTail attribute and can be accessed with Sq3StmtGetPzTail.

Parameters
[in]dbthe Sq3LiteC instance to work on a database
[in]zSqlThe statement to be compiled, encoded as UTF-8
[out]ppStmtThe new Sq3StmtC instance
Returns
The MkErrorE status from the DEFAULT MkErrorC in MkRuntimeS::error_mk

Sq3StmtPrepareV2Hide : documentation

Compiling An SQL Statement …
To execute an SQL statement, it must first be compiled into a byte-code program using one of these routines. Or, in other words, these routines are constructors for the prepared statement object.
The preferred routine to use is Sq3StmtPrepareV2 (). The sqlite3_prepare () interface is legacy and should be avoided. Sq3StmtPrepareV3 () has an extra "prepFlags" option that is used for special purposes.
The use of the UTF-8 interfaces is preferred, as SQLite currently does all parsing using UTF-8. The UTF-16 interfaces are provided as a convenience. The UTF-16 interfaces work by converting the input text into UTF-8, then invoking the corresponding UTF-8 interface.
The first argument, "db", is a database connection obtained from a prior successful call to sqlite3_open (), Sq3LiteOpenV2 () or sqlite3_open16 (). The database connection must not have been closed.
The second argument, "zSql", is the statement to be compiled, encoded as either UTF-8 or UTF-16. The sqlite3_prepare(), Sq3StmtPrepareV2(), and Sq3StmtPrepareV3() interfaces use UTF-8, and sqlite3_prepare16(), sqlite3_prepare16_v2(), and sqlite3_prepare16_v3() use UTF-16.
If the nByte argument is negative, then zSql is read up to the first zero terminator. If nByte is positive, then it is the number of bytes read from zSql. If nByte is zero, then no prepared statement is generated. If the caller knows that the supplied string is nul-terminated, then there is a small performance advantage to passing an nByte parameter that is the number of bytes in the input string including the nul-terminator.
If pzTail is not NULL then *pzTail is made to point to the first byte past the end of the first SQL statement in zSql. These routines only compile the first statement in zSql, so *pzTail is left pointing to what remains uncompiled.
ppStmt is left pointing to a compiled prepared statement that can be executed using Sq3StmtStep (). If there is an error, *ppStmt is set to NULL. If the input text contains no SQL (if the input is an empty string or a comment) then *ppStmt is set to NULL. The calling procedure is responsible for deleting the compiled SQL statement using Sq3StmtFinalize () after it has finished with it. ppStmt may not be NULL.
On success, the sqlite3_prepare() family of routines return SQ3_RESULT_OK; otherwise an error code is returned.
The Sq3StmtPrepareV2(), Sq3StmtPrepareV3(), sqlite3_prepare16_v2(), and sqlite3_prepare16_v3() interfaces are recommended for all new programs. The older interfaces (sqlite3_prepare() and sqlite3_prepare16()) are retained for backwards compatibility, but their use is discouraged. In the "vX" interfaces, the prepared statement that is returned (the Sq3StmtC object) contains a copy of the original SQL text. This causes the Sq3StmtStep () interface to behave differently in three ways:
  1. If the database schema changes, instead of returning SQ3_RESULT_SCHEMA as it always used to do, Sq3StmtStep () will automatically recompile the SQL statement and try to run it again. As many as SQLITE_MAX_SCHEMA_RETRY retries will occur before Sq3StmtStep() gives up and returns an error.

  2. When an error occurs, Sq3StmtStep () will return one of the detailed error codes or extended error codes. The legacy behavior was that Sq3StmtStep () would only return a generic SQ3_RESULT_ERROR result code and the application would have to make a second call to Sq3StmtReset () in order to find the underlying cause of the problem. With the "v2" prepare interfaces, the underlying reason for the error is returned immediately.

  3. If the specific value bound to a host parameter in the WHERE clause might influence the choice of query plan for a statement, then the statement will be automatically recompiled, as if there had been a schema change, on the first Sq3StmtStep () call following any change to the bindings of that parameter. The specific value of a WHERE-clause parameter might influence the choice of query plan if the parameter is the left-hand side of a LIKE or GLOB operator or if the parameter is compared to an indexed column and the SQLITE_ENABLE_STAT4 compile-time option is enabled.
Sq3StmtPrepareV3() differs from Sq3StmtPrepareV2() only in having the extra prepFlags parameter, which is a bit array consisting of zero or more of the SQ3_PREPARE_* flags. The Sq3StmtPrepareV2() interface works exactly the same as Sq3StmtPrepareV3() with a zero prepFlags parameter.
Reference code from sqlite3:
sqlite3 *db, // Database handle
const char *zSql, // SQL statement, UTF-8 encoded
int nByte, // Maximum length of zSql in bytes.
sqlite3_stmt **ppStmt, // OUT: Statement handle
const char **pzTail // OUT: Pointer to unused portion of zSql
);
sqlite3 *db, // Database handle
const char *zSql, // SQL statement, UTF-8 encoded
int nByte, // Maximum length of zSql in bytes.
sqlite3_stmt **ppStmt, // OUT: Statement handle
const char **pzTail // OUT: Pointer to unused portion of zSql
);
sqlite3 *db, // Database handle
const char *zSql, // SQL statement, UTF-8 encoded
int nByte, // Maximum length of zSql in bytes.
unsigned int prepFlags, // Zero or more SQLITE_PREPARE_ flags
sqlite3_stmt **ppStmt, // OUT: Statement handle
const char **pzTail // OUT: Pointer to unused portion of zSql
);
sqlite3 *db, // Database handle
const void *zSql, // SQL statement, UTF-16 encoded
int nByte, // Maximum length of zSql in bytes.
sqlite3_stmt **ppStmt, // OUT: Statement handle
const void **pzTail // OUT: Pointer to unused portion of zSql
);
sqlite3 *db, // Database handle
const void *zSql, // SQL statement, UTF-16 encoded
int nByte, // Maximum length of zSql in bytes.
sqlite3_stmt **ppStmt, // OUT: Statement handle
const void **pzTail // OUT: Pointer to unused portion of zSql
);
sqlite3 *db, // Database handle
const void *zSql, // SQL statement, UTF-16 encoded
int nByte, // Maximum length of zSql in bytes.
unsigned int prepFlags, // Zero or more SQLITE_PREPARE_ flags
sqlite3_stmt **ppStmt, // OUT: Statement handle
const void **pzTail // OUT: Pointer to unused portion of zSql
);
SQLITE_API int sqlite3_prepare_v3(sqlite3 *db, const char *zSql, int nByte, unsigned int prepFlags, sqlite3_stmt **ppStmt, const char **pzTail)
SQLITE_API int sqlite3_prepare16_v3(sqlite3 *db, const void *zSql, int nByte, unsigned int prepFlags, sqlite3_stmt **ppStmt, const void **pzTail)
SQLITE_API int sqlite3_prepare_v2(sqlite3 *db, const char *zSql, int nByte, sqlite3_stmt **ppStmt, const char **pzTail)
SQLITE_API int sqlite3_prepare(sqlite3 *db, const char *zSql, int nByte, sqlite3_stmt **ppStmt, const char **pzTail)
SQLITE_API int sqlite3_prepare16(sqlite3 *db, const void *zSql, int nByte, sqlite3_stmt **ppStmt, const void **pzTail)
SQLITE_API int sqlite3_prepare16_v2(sqlite3 *db, const void *zSql, int nByte, sqlite3_stmt **ppStmt, const void **pzTail)
struct sqlite3_stmt sqlite3_stmt

Sq3LiteC CONFIG

C-API: Sq3LiteC_Config_C_API - Sq3LiteC - configure the class

(hide) enum MkErrorE Sq3LiteBusyHandler(SQ3_LITE sq3lite, Sq3Fupu_Sq3LiteBusyHandler_arg1 arg1, MK_PTR arg2)

top Register A Callback To Handle SQLITE_BUSY Errors … → API: Sq3LiteBusyHandler

The Sq3LiteBusyHandler(D,X,P) routine sets a callback function X that might be invoked with argument P whenever an attempt is made to access a database table associated with database connection D when another thread or process has the table locked. The Sq3LiteBusyHandler() interface is used to implement Sq3LiteBusyTimeout () and PRAGMA busy_timeout.

If the busy callback is NULL, then SQ3_RESULT_BUSY is returned immediately upon encountering the lock. If the busy callback is not NULL, then the callback might be invoked with two arguments.

The first argument to the busy handler is a copy of the void* pointer which is the third argument to Sq3LiteBusyHandler(). The second argument to the busy handler callback is the number of times that the busy handler has been invoked previously for the same locking event. If the busy callback returns 0, then no additional attempts are made to access the database and SQ3_RESULT_BUSY is returned to the application. If the callback returns non-zero, then another attempt is made to access the database and the cycle repeats.

The presence of a busy handler does not guarantee that it will be invoked when there is lock contention. If SQLite determines that invoking the busy handler could result in a deadlock, it will go ahead and return SQ3_RESULT_BUSY to the application instead of invoking the busy handler. Consider a scenario where one process is holding a read lock that it is trying to promote to a reserved lock and a second process is holding a reserved lock that it is trying to promote to an exclusive lock. The first process cannot proceed because it is blocked by the second and the second process cannot proceed because it is blocked by the first. If both processes invoke the busy handlers, neither will make any progress. Therefore, SQLite returns SQ3_RESULT_BUSY for the first process, hoping that this will induce the first process to release its read lock and allow the second process to proceed.

The default busy callback is NULL.

There can only be a single busy handler defined for each database connection. Setting a new busy handler clears any previously set handler. Note that calling Sq3LiteBusyTimeout () or evaluating PRAGMA busy_timeout=N will change the busy handler and thus clear any previously set busy handler.

The busy callback should not take any actions which modify the database connection that invoked the busy handler. In other words, the busy handler is not reentrant. Any such actions result in undefined behavior.

A busy handler must not close the database connection or prepared statement that invoked the busy handler.

Reference code from sqlite3:

SQLITE_API int sqlite3_busy_handler(sqlite3*,int(*)(void*,int),void*);
SQLITE_API int sqlite3_busy_handler(sqlite3 *, int(*)(void *, int), void *)

enum MkErrorE Sq3LiteBusyTimeout(SQ3_LITE sq3lite, MK_I32 ms)

top Set A Busy Timeout … → API: Sq3LiteBusyTimeout

This routine sets a busy handler that sleeps for a specified amount of time when a table is locked. The handler will sleep multiple times until at least "ms" milliseconds of sleeping have accumulated. After at least "ms" milliseconds of sleeping, the handler returns 0 which causes Sq3StmtStep () to return SQ3_RESULT_BUSY.

Calling this routine with an argument less than or equal to zero turns off all busy handlers.

There can only be a single busy handler for a particular database connection at any given moment. If another busy handler was defined (using Sq3LiteBusyHandler ()) prior to calling this routine, that other busy handler is cleared.

See also: PRAGMA busy_timeout

Reference code from sqlite3:

SQLITE_API int sqlite3_busy_timeout(sqlite3 *, int ms)

(hide) MK_PTR Sq3LiteCommitHook(SQ3_LITE sq3lite, Sq3Fupu_Sq3LiteCommitHook_arg1 arg1, MK_PTR arg2)

top Commit And Rollback Notification Callbacks … → API: Sq3LiteCommitHook

The Sq3LiteCommitHook() interface registers a callback function to be invoked whenever a transaction is committed. Any callback set by a previous call to Sq3LiteCommitHook() for the same database connection is overridden. The Sq3LiteRollbackHook() interface registers a callback function to be invoked whenever a transaction is rolled back. Any callback set by a previous call to Sq3LiteRollbackHook() for the same database connection is overridden. The pArg argument is passed through to the callback. If the callback on a commit hook function returns non-zero, then the commit is converted into a rollback.

The Sq3LiteCommitHook(D,C,P) and Sq3LiteRollbackHook(D,C,P) functions return the P argument from the previous call of the same function on the same database connection D, or NULL for the first call for each function on D.

The commit and rollback hook callbacks are not reentrant. The callback implementation must not do anything that will modify the database connection that invoked the callback. Any actions to modify the database connection must be deferred until after the completion of the Sq3StmtStep () call that triggered the commit or rollback hook in the first place. Note that running any other SQL statements, including SELECT statements, or merely calling Sq3StmtPrepareV2 () and Sq3StmtStep () will modify the database connections for the meaning of "modify" in this paragraph.

Registering a NULL function disables the callback.

When the commit hook callback routine returns zero, the COMMIT operation is allowed to continue normally. If the commit hook returns non-zero, then the COMMIT is converted into a ROLLBACK. The rollback hook is invoked on a rollback that results from a commit hook returning non-zero, just as it would be with any other rollback.

For the purposes of this API, a transaction is said to have been rolled back if an explicit "ROLLBACK" statement is executed, or an error or constraint causes an implicit rollback to occur. The rollback callback is not invoked if a transaction is automatically rolled back because the database connection is closed.

See also the Sq3LiteUpdateHook () interface.

Reference code from sqlite3:

SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
SQLITE_API void * sqlite3_commit_hook(sqlite3 *, int(*)(void *), void *)
SQLITE_API void * sqlite3_rollback_hook(sqlite3 *, void(*)(void *), void *)

enum MkErrorE Sq3LiteDeclareVtab(SQ3_LITE sq3lite, MK_STRN zSQL)

top Declare The Schema Of A Virtual Table … → API: Sq3LiteDeclareVtab

The xCreate and xConnect methods of a virtual table module call this interface to declare the format (the names and datatypes of the columns) of the virtual tables they implement.

Reference code from sqlite3:

SQLITE_API int sqlite3_declare_vtab(sqlite3*, const char *zSQL);
SQLITE_API int sqlite3_declare_vtab(sqlite3 *, const char *zSQL)

enum MkErrorE Sq3LiteEnableLoadExtension(SQ3_LITE db, MK_I32 onoff)

top Enable Or Disable Extension Loading … → API: Sq3LiteEnableLoadExtension

So as not to open security holes in older applications that are unprepared to deal with extension loading, and as a means of disabling extension loading while evaluating user-entered SQL, the following API is provided to turn the Sq3LiteLoadExtension () mechanism on and off.

Extension loading is off by default. Call the Sq3LiteEnableLoadExtension() routine with onoff==1 to turn extension loading on and call it with onoff==0 to turn it back off again.

This interface enables or disables both the C-API Sq3LiteLoadExtension () and the SQL function load_extension (). Use sqlite3_db_config(db,SQ3_DBCONFIG_ENABLE_LOAD_EXTENSION,..) to enable or disable only the C-API.

Security warning: It is recommended that extension loading be enabled using the SQ3_DBCONFIG_ENABLE_LOAD_EXTENSION method rather than this interface, so the load_extension () SQL function remains disabled. This will prevent SQL injections from giving attackers access to extension loading capabilities.

Reference code from sqlite3:

SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff)

enum MkErrorE Sq3LiteExtendedResultCodes(SQ3_LITE sq3lite, MK_I32 onoff)

top Enable Or Disable Extended Result Codes … → API: Sq3LiteExtendedResultCodes

The Sq3LiteExtendedResultCodes() routine enables or disables the extended result codes feature of SQLite. The extended result codes are disabled by default for historical compatibility.

Reference code from sqlite3:

SQLITE_API int sqlite3_extended_result_codes(sqlite3 *, int onoff)

enum MkErrorE Sq3LiteLimit(SQ3_LITE sq3lite, enum Sq3LimitE id, MK_I32 newVal)

top Run-time Limits … → API: Sq3LiteLimit

This interface allows the size of various constructs to be limited on a connection by connection basis. The first parameter is the database connection whose limit is to be set or queried. The second parameter is one of the limit categories that define a class of constructs to be size limited. The third parameter is the new limit for that construct.

If the new limit is a negative number, the limit is unchanged. For each limit category SQ3_LIMIT_NAME there is a hard upper bound set at compile-time by a C preprocessor macro called SQLITE_MAX_NAME. (The "_LIMIT_" in the name is changed to "_MAX_".) Attempts to increase a limit above its hard upper bound are silently truncated to the hard upper bound.

Regardless of whether or not the limit was changed, the Sq3LiteLimit () interface returns the prior value of the limit. Hence, to find the current value of a limit without changing it, simply invoke this interface with the third parameter set to -1.

Run-time limits are intended for use in applications that manage both their own internal database and also databases that are controlled by untrusted external sources. An example application might be a web browser that has its own databases for storing history and separate databases controlled by JavaScript applications downloaded off the Internet. The internal databases can be given the large, default limits. Databases managed by external sources can be given much smaller limits designed to prevent a denial of service attack. Developers might also want to use the Sq3LiteSetAuthorizer () interface to further control untrusted SQL. The size of the database created by an untrusted script can be contained using the max_page_count PRAGMA.

New run-time limit categories may be added in future releases.

Reference code from sqlite3:

SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
SQLITE_API int sqlite3_limit(sqlite3 *, int id, int newVal)

enum MkErrorE Sq3LiteLoadExtension(SQ3_LITE db, MK_STRN zFile, MK_STRN zProc, MK_STR *pzErrMsg)

top Load An Extension … → API: Sq3LiteLoadExtension

This interface loads an SQLite extension library from the named file.

The Sq3LiteLoadExtension() interface attempts to load an SQLite extension library contained in the file zFile. If the file cannot be loaded directly, attempts are made to load with various operating-system specific extensions added. So for example, if "samplelib" cannot be loaded, then names like "samplelib.so" or "samplelib.dylib" or "samplelib.dll" might be tried also.

The entry point is zProc. zProc may be 0, in which case SQLite will try to come up with an entry point name on its own. It first tries "sqlite3_extension_init". If that does not work, it constructs a name "sqlite3_X_init" where the X is consists of the lower-case equivalent of all ASCII alphabetic characters in the filename from the last "/" to the first following "." and omitting any initial "lib". The Sq3LiteLoadExtension() interface returns SQ3_RESULT_OK on success and SQ3_RESULT_ERROR if something goes wrong. If an error occurs and pzErrMsg is not 0, then the Sq3LiteLoadExtension () interface shall attempt to fill *pzErrMsg with error message text stored in memory obtained from Sq3Malloc (). The calling function should free this memory by calling Sq3Free ().

Extension loading must be enabled using Sq3LiteEnableLoadExtension () or sqlite3_db_config(db,SQ3_DBCONFIG_ENABLE_LOAD_EXTENSION,1,NULL) prior to calling this API, otherwise an error will be returned.

Security warning: It is recommended that the SQ3_DBCONFIG_ENABLE_LOAD_EXTENSION method be used to enable only this interface. The use of the Sq3LiteEnableLoadExtension () interface should be avoided. This will keep the SQL function load_extension () disabled and prevent SQL injections from giving attackers access to extension loading capabilities.

See also the load_extension() SQL function.

Reference code from sqlite3:

sqlite3 *db, // Load the extension into this database connection
const char *zFile, // Name of the shared library containing extension
const char *zProc, // Entry point. Derived from zFile if 0
char **pzErrMsg // Put error message here if not 0
);
SQLITE_API int sqlite3_load_extension(sqlite3 *db, const char *zFile, const char *zProc, char **pzErrMsg)

(hide) MK_PTR Sq3LiteRollbackHook(SQ3_LITE sq3lite, Sq3Fupu_Sq3LiteRollbackHook_arg1 arg1, MK_PTR arg2)

top Commit And Rollback Notification Callbacks … → API: Sq3LiteRollbackHook

read more at 'Sq3LiteCommitHook'

(hide) MK_PTR Sq3LiteUpdateHook(SQ3_LITE sq3lite, Sq3Fupu_Sq3LiteUpdateHook_arg1 arg1, MK_PTR arg2)

top Data Change Notification Callbacks … → API: Sq3LiteUpdateHook

The Sq3LiteUpdateHook() interface registers a callback function with the database connection identified by the first argument to be invoked whenever a row is updated, inserted or deleted in a rowid table. Any callback set by a previous call to this function for the same database connection is overridden.

The second argument is a pointer to the function to invoke when a row is updated, inserted or deleted in a rowid table. The first argument to the callback is a copy of the third argument to Sq3LiteUpdateHook(). The second callback argument is one of SQ3_AUTHACTION_INSERT, SQ3_AUTHACTION_DELETE, or SQ3_AUTHACTION_UPDATE, depending on the operation that caused the callback to be invoked. The third and fourth arguments to the callback contain pointers to the database and table name containing the affected row. The final callback parameter is the rowid of the row. In the case of an update, this is the rowid after the update takes place.

The update hook is not invoked when internal system tables are modified (i.e. sqlite_sequence). The update hook is not invoked when WITHOUT ROWID tables are modified.

In the current implementation, the update hook is not invoked when conflicting rows are deleted because of an ON CONFLICT REPLACE clause. Nor is the update hook invoked when rows are deleted using the truncate optimization. The exceptions defined in this paragraph might change in a future release of SQLite.

The update hook implementation must not do anything that will modify the database connection that invoked the update hook. Any actions to modify the database connection must be deferred until after the completion of the Sq3StmtStep () call that triggered the update hook. Note that Sq3StmtPrepareV2 () and Sq3StmtStep () both modify their database connections for the meaning of "modify" in this paragraph.

The Sq3LiteUpdateHook(D,C,P) function returns the P argument from the previous call on the same database connection D, or NULL for the first call on D.

See also the Sq3LiteCommitHook (), Sq3LiteRollbackHook (), and sqlite3_preupdate_hook () interfaces.

Reference code from sqlite3:

void(*)(void *,int ,char const *,char const *,sqlite3_int64),
void*
);
SQLITE_API void * sqlite3_update_hook(sqlite3 *, void(*)(void *, int, char const *, char const *, sqlite3_int64), void *)

Sq3LiteC EXECUTION

C-API: Sq3LiteC_Execution_C_API - Sq3LiteC - execute a sql statement …

(static) enum MkErrorE Sq3LiteSleep(MK_I32 arg0)

top Suspend Execution For A Short Time … → API: Sq3LiteSleep

The Sq3LiteSleep() function causes the current thread to suspend execution for at least a number of milliseconds specified in its parameter.

If the operating system does not support sleep requests with millisecond time resolution, then the time will be rounded up to the nearest second. The number of milliseconds of sleep actually requested from the operating system is returned.

SQLite implements this interface by calling the xSleep() method of the default sqlite3_vfs object. If the xSleep() method of the default VFS is not implemented correctly, or not implemented at all, then the behavior of Sq3LiteSleep() may deviate from the description in the previous paragraphs.

If a negative argument is passed to Sq3LiteSleep() the results vary by VFS and operating system. Some system treat a negative argument as an instruction to sleep forever. Others understand it to mean do not sleep at all. In SQLite version 3.42.0 and later, a negative argument passed into Sq3LiteSleep() is changed to zero before it is relayed down into the xSleep method of the VFS.

Reference code from sqlite3:

SQLITE_API int sqlite3_sleep(int)

enum MkErrorE Sq3LiteExec(SQ3_LITE sq3lite, MK_STRN sql, Sq3Fupu_Sq3LiteExec_callback_call callback_call, MK_CBP callback_data)

top One-Step Query Execution Interface … → API: Sq3LiteExec

Parameters
[in]sq3litethe Sq3LiteC instance to work on a database
[in]sqlThe sql data to be processed
[in]callback_call(C-only) The callback to call from type Sq3LiteExecV2CB
[in]callback_dataThe additional data, used as Sq3LiteExecV2CB first argument and as callback for a non-C language.
Returns
The MkErrorE status from the DEFAULT MkErrorC in MkRuntimeS::error_mk (C-only)
Sq3LiteExec : callback signature
#define Sq3Fupu_Sq3LiteExec_callback_call_ret MK_I32
#define Sq3Fupu_Sq3LiteExec_callback_call_args MK_CBP callV1, MK_I32 num, MK_STR *vals, MK_STR *cols
Sq3Fupu_Sq3LiteExec_callback_call_ret(* Sq3Fupu_Sq3LiteExec_callback_call)(Sq3Fupu_Sq3LiteExec_callback_call_args)
#define Sq3Fupu_Sq3LiteExec_callback_call_args
#define Sq3Fupu_Sq3LiteExec_callback_call_ret

The callback Sq3Fupu_Sq3LiteExec_callback_call has the same signature as the sqlite3_exec callback.

Read more about how to define a service-callback in theLink .

Note
For the C-language the callback_call is the function called and the callback_data is the additional data. This is different for the non-C-languges from (C,C++,C#,VB.NET,Java,Python,Ruby,Perl,PHP,Tcl or GO).
For the non-C-language the callback_call is internal and the callback_data is the target-language-callback.
Sq3LiteExec : callback example
// RPC example for a callback SINGELTON to provide a callback with ARRAY-of-STRING as argument
static Sq3Fupu_Sq3LiteExec_callback_call_ret Sq3LiteExecCB (Sq3Fupu_Sq3LiteExec_callback_call_args)
{
  // constructer define local attributes
  const struct Sq3CbS * cbP = (struct Sq3CbS *) callV1;
  MkRtSetup_RT(cbP->mkrt);

  const MQ_CTX rpc = cbP->rpc;
  if (cbP->ret == NULL) {   // callback_first_check == 2
    // "Callback1" to collect **all** result sets into **one** MkBufferStreamC data object 
    // which is then sent to the client at the end with **one** response.
    MqSendSTART_E(rpc);
    MqSendBFL_E(rpc, MkBufferListCreateVC(num,(MK_STRN*)vals));
    MqSendBFL_E(rpc, MkBufferListCreateVC(num,(MK_STRN*)cols));
    MqSendRETURN_SUB(rpc);
  } else {                  // callback_first_check == 1
    // "Callback2" to send each result set **individually** to the client
    MkBufferStreamReset(cbP->ret);
    MkBufferStreamWriteBFL_E(cbP->ret, MkBufferListCreateVC(num,(MK_STRN*)vals));
    MkBufferStreamWriteBFL_E(cbP->ret, MkBufferListCreateVC(num,(MK_STRN*)cols));
  }
  return 0;
error:
  MkErrorStack_1X(rpc);
  return 1;
}

#define rpc mqctx   // naming in MQ_SERVICE_CALL_ARGS

// RPC callback called from service
static enum MkErrorE SrvSq3LiteExec ( MQ_SERVICE_CALL_ARGS )
{
  // create one THREAD-LOCAL callback instance as storage for additional attributes
  MkBufferStreamCreateTLS_T(MkBufferStream256C,bus);

  // collect service data
  SQ3_LITE sq3lite = Sq3LiteHandleResolve_e(MqReadHDL_e(rpc));
  MK_STRN sql = MqReadSTR_e(rpc);
  const MK_I32 callback_first_check = MqReadI32_e(rpc);
  Sq3Fupu_Sq3LiteExec_callback_call callback = NULL;
  MK_CBP callback_first_ptr = NULL;

  // initialize the "Sq3LiteExecData", set the "Callback"
  switch (callback_first_check) {
    case 0:
      callback = NULL;
      callback_first_ptr = NULL;
      break;
    case 1: {
      callback = Sq3LiteExecCB;
      struct Sq3CbS Sq3CbS_callback_first_ptr = {MK_RT_PTR,rpc,bus};
      callback_first_ptr = &Sq3CbS_callback_first_ptr;
      break;
    }
    case 2: {
      callback = Sq3LiteExecCB;
      struct Sq3CbS Sq3CbS_callback_first_ptr = {MK_RT_PTR,rpc,NULL};
      callback_first_ptr = &Sq3CbS_callback_first_ptr;
      break;
    }
    default: {
      return MkErrorSetV_1E("invalid control number '%d', expect: 1,2,3", callback_first_check);
    }
  }

  // start the "sql" query with "Exec"
  Sq3LiteExec_E(sq3lite, sql, callback, callback_first_ptr);

  // if "Callback2" was used, return the MkBufferStreamC data object
  MqSendSTART_E(rpc);
  switch (callback_first_check) {
    case 1:
      MqSendBUS_FLAT_E(rpc,bus);
      break;
  }
error:
  return MqSendRETURN(rpc);
}
#undef rpc

sqlite3_exec : documentation

The Sq3LiteExec() interface is a convenience wrapper around Sq3StmtPrepareV2 (), Sq3StmtStep (), and Sq3StmtFinalize (), that allows an application to run multiple statements of SQL without having to use a lot of C code.

The Sq3LiteExec() interface runs zero or more UTF-8 encoded, semicolon-separate SQL statements passed into its 2nd argument, in the context of the database connection passed in as its 1st argument. If the callback function of the 3rd argument to Sq3LiteExec() is not NULL, then it is invoked for each result row coming out of the evaluated SQL statements. The 4th argument to Sq3LiteExec() is relayed through to the 1st argument of each callback invocation. If the callback pointer to Sq3LiteExec() is NULL, then no callback is ever invoked and result rows are ignored.

If an error occurs while evaluating the SQL statements passed into Sq3LiteExec(), then execution of the current statement stops and subsequent statements are skipped. If the 5th parameter to Sq3LiteExec() is not NULL then any error message is written into memory obtained from Sq3Malloc () and passed back through the 5th parameter. To avoid memory leaks, the application should invoke Sq3Free () on error message strings returned through the 5th parameter of Sq3LiteExec() after the error message string is no longer needed. If the 5th parameter to Sq3LiteExec() is not NULL and no errors occur, then Sq3LiteExec() sets the pointer in its 5th parameter to NULL before returning.

If an Sq3LiteExec() callback returns non-zero, the Sq3LiteExec() routine returns SQ3_RESULT_ABORT without invoking the callback again and without running any subsequent SQL statements.

The 2nd argument to the Sq3LiteExec() callback function is the number of columns in the result. The 3rd argument to the Sq3LiteExec() callback is an array of pointers to strings obtained as if from Sq3StmtColumnText (), one for each column. If an element of a result row is NULL then the corresponding string pointer for the Sq3LiteExec() callback is a NULL pointer. The 4th argument to the Sq3LiteExec() callback is an array of pointers to strings where each entry represents the name of corresponding result column as obtained from Sq3StmtColumnName ().

If the 2nd parameter to Sq3LiteExec() is a NULL pointer, a pointer to an empty string, or a pointer that contains only whitespace and/or SQL comments, then no SQL statements are evaluated and the database is not changed.

Restrictions:

Reference code from sqlite3:

sqlite3*, // An open database
const char *sql, // SQL to be evaluated
int (*callback)(void*,int,char**,char**), // Callback function
void *, // 1st argument to callback
char **errmsg // Error msg written here
);
SQLITE_API int sqlite3_exec(sqlite3 *, const char *sql, int(*callback)(void *, int, char **, char **), void *, char **errmsg)

(runtime) enum MkErrorE Sq3LiteExecV2(SQ3_LITE sq3lite, MK_STRN sql, Sq3LiteExecV2CB callback_call, MK_CBP callback)

top The Sq3LiteExecV2() interface is a convenience wrapper around Sq3StmtPrepareV2(), Sq3StmtStep(), and Sq3StmtFinalize(), that allows an application to run multiple statements of SQL without having to use a lot of C code. → API: Sq3LiteExecV2_RT

This is an enhanced version of Sq3LiteExec with support of MkBufferListC data-type for the vals and cols arguments.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]sq3litethe Sq3LiteC instance to work on a database
[in]sqlThe sql data to be processed
[in]callback_call(C-only) The callback to call from type Sq3LiteExecV2CB
[in]callbackThe additional data, used as Sq3LiteExecV2CB first argument and as callback for a non-C language.
Returns
The MkErrorE status from the DEFAULT MkErrorC in MkRuntimeS::error_mk

Sq3LiteC INFO

C-API: Sq3LiteC_Info_C_API - Sq3LiteC - get information

MK_I32 Sq3LiteGetAutocommit(SQ3_LITE sq3lite)

top Test For Auto-Commit Mode … → API: Sq3LiteGetAutocommit

The Sq3LiteGetAutocommit() interface returns non-zero or zero if the given database connection is or is not in autocommit mode, respectively. Autocommit mode is on by default. Autocommit mode is disabled by a BEGIN statement. Autocommit mode is re-enabled by a COMMIT or ROLLBACK.

If certain kinds of errors occur on a statement within a multi-statement transaction (errors including SQ3_RESULT_FULL, SQ3_RESULT_IOERR, SQ3_RESULT_NOMEM, SQ3_RESULT_BUSY, and SQ3_RESULT_INTERRUPT) then the transaction might be rolled back automatically. The only way to find out whether SQLite automatically rolled back the transaction after an error is to use this function.

If another thread changes the autocommit status of the database connection while this routine is running, then the return value is undefined.

Reference code from sqlite3:

SQLITE_API int sqlite3_get_autocommit(sqlite3 *)

MK_I64 Sq3LiteLastInsertRowid(SQ3_LITE sq3lite)

top Last Insert Rowid … → API: Sq3LiteLastInsertRowid

Each entry in most SQLite tables (except for WITHOUT ROWID tables) has a unique 64-bit signed integer key called the "rowid". The rowid is always available as an undeclared column named ROWID, OID, or ROWID as long as those names are not also used by explicitly declared columns. If the table has a column of type INTEGER PRIMARY KEY then that column is another alias for the rowid.

The Sq3LiteLastInsertRowid(D) interface usually returns the rowid of the most recent successful INSERT into a rowid table or virtual table on database connection D. Inserts into WITHOUT ROWID tables are not recorded. If no successful INSERTs into rowid tables have ever occurred on the database connection D, then Sq3LiteLastInsertRowid(D) returns zero.

As well as being set automatically as rows are inserted into database tables, the value returned by this function may be set explicitly by Sq3LiteSetLastInsertRowid ()

Some virtual table implementations may INSERT rows into rowid tables as part of committing a transaction (e.g. to flush data accumulated in memory to disk). In this case subsequent calls to this function return the rowid associated with these internal INSERT operations, which leads to unintuitive results. Virtual table implementations that do write to rowid tables in this way can avoid this problem by restoring the original rowid value using Sq3LiteSetLastInsertRowid () before returning control to the user.

If an INSERT occurs within a trigger then this routine will return the rowid of the inserted row as long as the trigger is running. Once the trigger program ends, the value returned by this routine reverts to what it was before the trigger was fired.

An INSERT that fails due to a constraint violation is not a successful INSERT and does not change the value returned by this routine. Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK, and INSERT OR ABORT make no changes to the return value of this routine when their insertion fails. When INSERT OR REPLACE encounters a constraint violation, it does not fail. The INSERT continues to completion after deleting rows that caused the constraint problem so INSERT OR REPLACE will always change the return value of this interface.

For the purposes of this routine, an INSERT is considered to be successful even if it is subsequently rolled back.

This function is accessible to SQL statements via the last_insert_rowid() SQL function.

If a separate thread performs a new INSERT on the same database connection while the Sq3LiteLastInsertRowid () function is running and thus changes the last insert rowid, then the value returned by Sq3LiteLastInsertRowid () is unpredictable and might not equal either the old or the new last insert rowid.

Reference code from sqlite3:

SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3 *)

enum MkErrorE Sq3LiteTxnState(SQ3_LITE sq3lite, MK_STRN zSchema)

top Determine the transaction state of a database … → API: Sq3LiteTxnState

The Sq3LiteTxnState(D,S) interface returns the current transaction state of schema S in database connection D. If S is NULL, then the highest transaction state of any schema on database connection D is returned. Transaction states are (in order of lowest to highest):

  1. SQ3_TXN_NONE
  2. SQ3_TXN_READ
  3. SQ3_TXN_WRITE

If the S argument to Sq3LiteTxnState(D,S) is not the name of a valid schema, then -1 is returned.

Reference code from sqlite3:

SQLITE_API int sqlite3_txn_state(sqlite3*,const char *zSchema);
SQLITE_API int sqlite3_txn_state(sqlite3 *, const char *zSchema)

enum MkErrorE Sq3LiteVtabOnConflict(SQ3_LITE sq3lite)

top Determine The Virtual Table Conflict Policy … → API: Sq3LiteVtabOnConflict

This function may only be called from within a call to the xUpdate method of a virtual table implementation for an INSERT or UPDATE operation. The value returned is one of SQ3_CONFLICT_ROLLBACK, SQ3_AUTHRETURN_IGNORE, SQ3_CONFLICT_FAIL, SQ3_RESULT_ABORT, or SQ3_CONFLICT_REPLACE, according to the ON CONFLICT mode of the SQL statement that triggered the call to the xUpdate method of the virtual table.

Reference code from sqlite3:

SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *)

Sq3LiteC MODIFY

NAVI: top, up

Sq3LiteC MODIFY CREATE

CreateCollationV2 Define New Collating Sequences …
CreateFunctionV2 Create Or Redefine SQL Functions …
CreateWindowFunction

Create Or Redefine SQL Functions …

Sq3LiteC MODIFY WAL

WalAutocheckpoint Configure an auto-checkpoint …
WalCheckpointV2 Checkpoint a database …
WalHook

Write-Ahead Log Commit Hook …

Sq3LiteC MODIFY DETAILS

C-API: Sq3LiteC_Modify_C_API - Sq3LiteC - modify the database

Sq3LiteC MODIFY CREATE

C-API: Sq3LiteC_Modify_Create_C_API - Sq3LiteC - functions related to index 'Modify' and doc 'Create' …

Create Or Redefine SQL Functions:

Define New Collating Sequences:

Reference code from sqlite3:

// Create Or Redefine SQL Functions:
sqlite3 *db,
const char *zFunctionName,
int nArg,
int eTextRep,
void *pApp,
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
void (*xFinal)(sqlite3_context*)
);
sqlite3 *db,
const void *zFunctionName,
int nArg,
int eTextRep,
void *pApp,
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
void (*xFinal)(sqlite3_context*)
);
sqlite3 *db,
const char *zFunctionName,
int nArg,
int eTextRep,
void *pApp,
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
void (*xFinal)(sqlite3_context*),
void(*xDestroy)(void*)
);
sqlite3 *db,
const char *zFunctionName,
int nArg,
int eTextRep,
void *pApp,
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
void (*xFinal)(sqlite3_context*),
void (*xValue)(sqlite3_context*),
void (*xInverse)(sqlite3_context*,int,sqlite3_value**),
void(*xDestroy)(void*)
);
// Define New Collating Sequences:
const char *zName,
int eTextRep,
void *pArg,
int(*xCompare)(void*,int,const void*,int,const void*)
);
const char *zName,
int eTextRep,
void *pArg,
int(*xCompare)(void*,int,const void*,int,const void*),
void(*xDestroy)(void*)
);
const void *zName,
int eTextRep,
void *pArg,
int(*xCompare)(void*,int,const void*,int,const void*)
);
struct sqlite3_context sqlite3_context
SQLITE_API int sqlite3_create_collation16(sqlite3 *, const void *zName, int eTextRep, void *pArg, int(*xCompare)(void *, int, const void *, int, const void *))
SQLITE_API int sqlite3_create_function(sqlite3 *db, const char *zFunctionName, int nArg, int eTextRep, void *pApp, void(*xFunc)(sqlite3_context *, int, sqlite3_value **), void(*xStep)(sqlite3_context *, int, sqlite3_value **), void(*xFinal)(sqlite3_context *))
SQLITE_API int sqlite3_create_function16(sqlite3 *db, const void *zFunctionName, int nArg, int eTextRep, void *pApp, void(*xFunc)(sqlite3_context *, int, sqlite3_value **), void(*xStep)(sqlite3_context *, int, sqlite3_value **), void(*xFinal)(sqlite3_context *))
SQLITE_API int sqlite3_create_window_function(sqlite3 *db, const char *zFunctionName, int nArg, int eTextRep, void *pApp, void(*xStep)(sqlite3_context *, int, sqlite3_value **), void(*xFinal)(sqlite3_context *), void(*xValue)(sqlite3_context *), void(*xInverse)(sqlite3_context *, int, sqlite3_value **), void(*xDestroy)(void *))
struct sqlite3_value sqlite3_value
SQLITE_API int sqlite3_create_collation_v2(sqlite3 *, const char *zName, int eTextRep, void *pArg, int(*xCompare)(void *, int, const void *, int, const void *), void(*xDestroy)(void *))
SQLITE_API int sqlite3_create_collation(sqlite3 *, const char *zName, int eTextRep, void *pArg, int(*xCompare)(void *, int, const void *, int, const void *))
SQLITE_API int sqlite3_create_function_v2(sqlite3 *db, const char *zFunctionName, int nArg, int eTextRep, void *pApp, void(*xFunc)(sqlite3_context *, int, sqlite3_value **), void(*xStep)(sqlite3_context *, int, sqlite3_value **), void(*xFinal)(sqlite3_context *), void(*xDestroy)(void *))

(hide) enum MkErrorE Sq3LiteCreateCollationV2(SQ3_LITE sq3lite, MK_STRN zName, enum Sq3TextE eTextRep, MK_PTR pArg, Sq3Fupu_Sq3LiteCreateCollationV2_xCompare xCompare, Sq3Fupu_Sq3LiteCreateCollationV2_xDestroy xDestroy)

top Define New Collating Sequences … → API: Sq3LiteCreateCollationV2

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 sqlite3_create_collation() and Sq3LiteCreateCollationV2() 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:

  1. If A==B then B==A.
  2. If A==B and B==C then A==C.
  3. If A<B THEN B>A.
  4. If A<B and B<C then A<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 Sq3LiteCreateCollationV2() works like sqlite3_create_collation() 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 Sq3LiteCreateCollationV2() function fails. Applications that invoke Sq3LiteCreateCollationV2() 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: Sq3LiteCollationNeeded () and sqlite3_collation_needed16 ().

Reference code from sqlite3:

const char *zName,
int eTextRep,
void *pArg,
int(*xCompare)(void*,int,const void*,int,const void*)
);
const char *zName,
int eTextRep,
void *pArg,
int(*xCompare)(void*,int,const void*,int,const void*),
void(*xDestroy)(void*)
);
const void *zName,
int eTextRep,
void *pArg,
int(*xCompare)(void*,int,const void*,int,const void*)
);

(hide) enum MkErrorE Sq3LiteCreateFunctionV2(SQ3_LITE db, MK_STRN zFunctionName, MK_I32 nArg, enum Sq3TextE eTextRep, MK_PTR pApp, Sq3Fupu_Sq3LiteCreateFunctionV2_xFunc xFunc, Sq3Fupu_Sq3LiteCreateFunctionV2_xStep xStep, Sq3Fupu_Sq3LiteCreateFunctionV2_xFinal xFinal, Sq3Fupu_Sq3LiteCreateFunctionV2_xDestroy xDestroy)

top Create Or Redefine SQL Functions … → API: Sq3LiteCreateFunctionV2

These functions (collectively known as "function creation routines") are used to add SQL functions or aggregates or to redefine the behavior of existing SQL functions or aggregates. The only differences between the three "sqlite3_create_function*" routines are the text encoding expected for the second parameter (the name of the function being created) and the presence or absence of a destructor callback for the application data pointer. Function Sq3LiteCreateWindowFunction() is similar, but allows the user to supply the extra callback functions needed by aggregate window functions.

The first parameter is the database connection to which the SQL function is to be added. If an application uses more than one database connection then application-defined SQL functions must be added to each database connection separately.

The second parameter is the name of the SQL function to be created or redefined. The length of the name is limited to 255 bytes in a UTF-8 representation, exclusive of the zero-terminator. Note that the name length limit is in UTF-8 bytes, not characters nor UTF-16 bytes. Any attempt to create a function with a longer name will result in SQ3_RESULT_MISUSE being returned.

The third parameter (nArg) is the number of arguments that the SQL function or aggregate takes. If this parameter is -1, then the SQL function or aggregate may take any number of arguments between 0 and the limit set by Sq3LiteLimit(SQ3_LIMIT_FUNCTION_ARG). If the third parameter is less than -1 or greater than 127 then the behavior is undefined.

The fourth parameter, eTextRep, specifies what text encoding this SQL function prefers for its parameters. The application should set this parameter to SQ3_TEXT_UTF16LE if the function implementation invokes sqlite3_value_text16le () on an input, or SQ3_TEXT_UTF16BE if the implementation invokes sqlite3_value_text16be () on an input, or SQ3_TEXT_UTF16 if sqlite3_value_text16 () is used, or SQ3_TEXT_UTF8 otherwise. The same SQL function may be registered multiple times using different preferred text encodings, with different implementations for each encoding. When multiple implementations of the same function are available, SQLite will pick the one that involves the least amount of data conversion.

The fourth parameter may optionally be ORed with SQ3_FUNCTION_DETERMINISTIC to signal that the function will always return the same result given the same inputs within a single SQL statement. Most SQL functions are deterministic. The built-in random () SQL function is an example of a function that is not deterministic. The SQLite query planner is able to perform additional optimizations on deterministic functions, so use of the SQ3_FUNCTION_DETERMINISTIC flag is recommended where possible.

The fourth parameter may also optionally include the SQ3_FUNCTION_DIRECTONLY flag, which if present prevents the function from being invoked from within VIEWs, TRIGGERs, CHECK constraints, generated column expressions, index expressions, or the WHERE clause of partial indexes.

For best security, the SQ3_FUNCTION_DIRECTONLY flag is recommended for all application-defined SQL functions that do not need to be used inside of triggers, view, CHECK constraints, or other elements of the database schema. This flags is especially recommended for SQL functions that have side effects or reveal internal application state. Without this flag, an attacker might be able to modify the schema of a database file to include invocations of the function with parameters chosen by the attacker, which the application will then execute when the database file is opened and read.

The fifth parameter is an arbitrary pointer. The implementation of the function can gain access to this pointer using sqlite3_user_data ().

The sixth, seventh and eighth parameters passed to the three "sqlite3_create_function*" functions, xFunc, xStep and xFinal, are pointers to C-language functions that implement the SQL function or aggregate. A scalar SQL function requires an implementation of the xFunc callback only; NULL pointers must be passed as the xStep and xFinal parameters. An aggregate SQL function requires an implementation of xStep and xFinal and NULL pointer must be passed for xFunc. To delete an existing SQL function or aggregate, pass NULL pointers for all three function callbacks.

The sixth, seventh, eighth and ninth parameters (xStep, xFinal, xValue and xInverse) passed to Sq3LiteCreateWindowFunction are pointers to C-language callbacks that implement the new function. xStep and xFinal must both be non-NULL. xValue and xInverse may either both be NULL, in which case a regular aggregate function is created, or must both be non-NULL, in which case the new function may be used as either an aggregate or aggregate window function. More details regarding the implementation of aggregate window functions are available here.

If the final parameter to Sq3LiteCreateFunctionV2() or Sq3LiteCreateWindowFunction() is not NULL, then it is destructor for the application data pointer. The destructor is invoked when the function is deleted, either by being overloaded or when the database connection closes. The destructor is also invoked if the call to Sq3LiteCreateFunctionV2() fails. When the destructor callback is invoked, it is passed a single argument which is a copy of the application data pointer which was the fifth parameter to Sq3LiteCreateFunctionV2().

It is permitted to register multiple implementations of the same functions with the same name but with either differing numbers of arguments or differing preferred text encodings. SQLite will use the implementation that most closely matches the way in which the SQL function is used. A function implementation with a non-negative nArg parameter is a better match than a function implementation with a negative nArg. A function where the preferred text encoding matches the database encoding is a better match than a function where the encoding is different. A function where the encoding difference is between UTF16le and UTF16be is a closer match than a function where the encoding difference is between UTF8 and UTF16.

Built-in functions may be overloaded by new application-defined functions.

An application-defined function is permitted to call other SQLite interfaces. However, such calls must not close the database connection nor finalize or reset the prepared statement in which the function is running.

Reference code from sqlite3:

sqlite3 *db,
const char *zFunctionName,
int nArg,
int eTextRep,
void *pApp,
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
void (*xFinal)(sqlite3_context*)
);
sqlite3 *db,
const void *zFunctionName,
int nArg,
int eTextRep,
void *pApp,
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
void (*xFinal)(sqlite3_context*)
);
sqlite3 *db,
const char *zFunctionName,
int nArg,
int eTextRep,
void *pApp,
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
void (*xFinal)(sqlite3_context*),
void(*xDestroy)(void*)
);
sqlite3 *db,
const char *zFunctionName,
int nArg,
int eTextRep,
void *pApp,
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
void (*xFinal)(sqlite3_context*),
void (*xValue)(sqlite3_context*),
void (*xInverse)(sqlite3_context*,int,sqlite3_value**),
void(*xDestroy)(void*)
);

(hide) enum MkErrorE Sq3LiteCreateWindowFunction(SQ3_LITE db, MK_STRN zFunctionName, MK_I32 nArg, enum Sq3TextE eTextRep, MK_PTR pApp, Sq3Fupu_Sq3LiteCreateWindowFunction_xStep xStep, Sq3Fupu_Sq3LiteCreateWindowFunction_xFinal xFinal, Sq3Fupu_Sq3LiteCreateWindowFunction_xValue xValue, Sq3Fupu_Sq3LiteCreateWindowFunction_xInverse xInverse, Sq3Fupu_Sq3LiteCreateWindowFunction_xDestroy xDestroy)

top Create Or Redefine SQL Functions … → API: Sq3LiteCreateWindowFunction

read more at 'Sq3LiteCreateFunctionV2'

Sq3LiteC MODIFY WAL

C-API: Sq3LiteC_Modify_Wal_C_API - Sq3LiteC - functions related to index 'Modify' and doc 'Wal' …

Write-Ahead Log Commit Hook:

Configure an auto-checkpoint:

Checkpoint a database:

Reference code from sqlite3:

// Write-Ahead Log Commit Hook:
int(*)(void *,sqlite3*,const char*,int),
void*
);
// Configure an auto-checkpoint:
// Checkpoint a database:
sqlite3 *db, // Database handle
const char *zDb, // Name of attached database (or NULL)
int eMode, // SQLITE_CHECKPOINT_* value
int *pnLog, // OUT: Size of WAL log in frames
int *pnCkpt // OUT: Total number of frames checkpointed
);
SQLITE_API int sqlite3_wal_checkpoint_v2(sqlite3 *db, const char *zDb, int eMode, int *pnLog, int *pnCkpt)
SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N)
SQLITE_API void * sqlite3_wal_hook(sqlite3 *, int(*)(void *, sqlite3 *, const char *, int), void *)

enum MkErrorE Sq3LiteWalAutocheckpoint(SQ3_LITE db, MK_I32 N)

top Configure an auto-checkpoint … → API: Sq3LiteWalAutocheckpoint

The Sq3LiteWalAutocheckpoint (D,N) is a wrapper around Sq3LiteWalHook () that causes any database on database connection D to automatically checkpoint after committing a transaction if there are N or more frames in the write-ahead log file. Passing zero or a negative value as the nFrame parameter disables automatic checkpoints entirely.

The callback registered by this function replaces any existing callback registered using Sq3LiteWalHook (). Likewise, registering a callback using Sq3LiteWalHook () disables the automatic checkpoint mechanism configured by this function.

The wal_autocheckpoint pragma can be used to invoke this interface from SQL.

Checkpoints initiated by this mechanism are PASSIVE.

Every new database connection defaults to having the auto-checkpoint enabled with a threshold of 1000 or SQLITE_DEFAULT_WAL_AUTOCHECKPOINT pages. The use of this interface is only necessary if the default setting is found to be suboptimal for a particular application.

Reference code from sqlite3:

enum MkErrorE Sq3LiteWalCheckpointV2(SQ3_LITE db, MK_STRN zDb, MK_I32 eMode, MK_I32 *pnLog, MK_I32 *pnCkpt)

top Checkpoint a database … → API: Sq3LiteWalCheckpointV2

The Sq3LiteWalCheckpointV2(D,X,M,L,C) interface runs a checkpoint operation on database X of database connection D in mode M. Status information is written back into integers pointed to by L and C. The M parameter must be a valid checkpoint mode:

SQ3_CHECKPOINT_PASSIVE

Checkpoint as many frames as possible without waiting for any database readers or writers to finish, then sync the database file if all frames in the log were checkpointed. The busy-handler callback is never invoked in the SQ3_CHECKPOINT_PASSIVE mode. On the other hand, passive mode might leave the checkpoint unfinished if there are concurrent readers or writers.

SQ3_CHECKPOINT_FULL

This mode blocks (it invokes the busy-handler callback) until there is no database writer and all readers are reading from the most recent database snapshot. It then checkpoints all frames in the log file and syncs the database file. This mode blocks new database writers while it is pending, but new database readers are allowed to continue unimpeded.

SQ3_CHECKPOINT_RESTART

This mode works the same way as SQ3_CHECKPOINT_FULL with the addition that after checkpointing the log file it blocks (calls the busy-handler callback) until all readers are reading from the database file only. This ensures that the next writer will restart the log file from the beginning. Like SQ3_CHECKPOINT_FULL, this mode blocks new database writer attempts while it is pending, but does not impede readers.

SQ3_CHECKPOINT_TRUNCATE
This mode works the same way as SQ3_CHECKPOINT_RESTART with the addition that it also truncates the log file to zero bytes just prior to a successful return.

If pnLog is not NULL, then *pnLog is set to the total number of frames in the log file or to -1 if the checkpoint could not run because of an error or because the database is not in WAL mode. If pnCkpt is not NULL,then *pnCkpt is set to the total number of checkpointed frames in the log file (including any that were already checkpointed before the function was called) or to -1 if the checkpoint could not run due to an error or because the database is not in WAL mode. Note that upon successful completion of an SQ3_CHECKPOINT_TRUNCATE, the log file will have been truncated to zero bytes and so both *pnLog and *pnCkpt will be set to zero.

All calls obtain an exclusive "checkpoint" lock on the database file. If any other process is running a checkpoint operation at the same time, the lock cannot be obtained and SQ3_RESULT_BUSY is returned. Even if there is a busy-handler configured, it will not be invoked in this case.

The SQ3_CHECKPOINT_FULL, RESTART and TRUNCATE modes also obtain the exclusive "writer" lock on the database file. If the writer lock cannot be obtained immediately, and a busy-handler is configured, it is invoked and the writer lock retried until either the busy-handler returns 0 or the lock is successfully obtained. The busy-handler is also invoked while waiting for database readers as described above. If the busy-handler returns 0 before the writer lock is obtained or while waiting for database readers, the checkpoint operation proceeds from that point in the same way as SQ3_CHECKPOINT_PASSIVE - checkpointing as many frames as possible without blocking any further. SQ3_RESULT_BUSY is returned in this case.

If parameter zDb is NULL or points to a zero length string, then the specified operation is attempted on all WAL databases attached to database connection db. In this case the values written to output parameters *pnLog and *pnCkpt are undefined. If an SQ3_RESULT_BUSY error is encountered when processing one or more of the attached WAL databases, the operation is still attempted on any remaining attached databases and SQ3_RESULT_BUSY is returned at the end. If any other error occurs while processing an attached database, processing is abandoned and the error code is returned to the caller immediately. If no error (SQ3_RESULT_BUSY or otherwise) is encountered while processing the attached databases, SQ3_RESULT_OK is returned.

If database zDb is the name of an attached database that is not in WAL mode, SQ3_RESULT_OK is returned and both *pnLog and *pnCkpt set to -1. If zDb is not NULL (or a zero length string) and is not the name of any attached database, SQ3_RESULT_ERROR is returned to the caller.

Unless it returns SQ3_RESULT_MISUSE, the Sq3LiteWalCheckpointV2() interface sets the error information that is queried by Sq3LiteErrCode () and Sq3LiteErrMsg ().

The PRAGMA wal_checkpoint command can be used to invoke this interface from SQL.

Reference code from sqlite3:

sqlite3 *db, // Database handle
const char *zDb, // Name of attached database (or NULL)
int eMode, // SQLITE_CHECKPOINT_* value
int *pnLog, // OUT: Size of WAL log in frames
int *pnCkpt // OUT: Total number of frames checkpointed
);

(hide) MK_PTR Sq3LiteWalHook(SQ3_LITE sq3lite, Sq3Fupu_Sq3LiteWalHook_arg1 arg1, MK_PTR arg2)

top Write-Ahead Log Commit Hook … → API: Sq3LiteWalHook

The Sq3LiteWalHook () function is used to register a callback that is invoked each time data is committed to a database in wal mode.

The callback is invoked by SQLite after the commit has taken place and the associated write-lock on the database released, so the implementation may read, write or checkpoint the database as required.

The first parameter passed to the callback function when it is invoked is a copy of the third parameter passed to Sq3LiteWalHook() when registering the callback. The second is a copy of the database handle. The third parameter is the name of the database that was written to - either "main" or the name of an ATTACH-ed database. The fourth parameter is the number of pages currently in the write-ahead log file, including those that were just committed.

The callback function should normally return SQ3_RESULT_OK. If an error code is returned, that error will propagate back up through the SQLite code base to cause the statement that provoked the callback to report an error, though the commit will have still occurred. If the callback returns SQ3_RESULT_ROW or SQ3_RESULT_DONE, or if it returns a value that does not correspond to any valid SQLite error code, the results are undefined.

A single database handle may have at most a single write-ahead log callback registered at one time. Calling Sq3LiteWalHook () replaces any previously registered write-ahead log callback. The return value is a copy of the third parameter from the previous call, if any, or 0. Note that the Sq3LiteWalAutocheckpoint () interface and the wal_autocheckpoint pragma both invoke Sq3LiteWalHook () and will overwrite any prior Sq3LiteWalHook () settings.

Reference code from sqlite3:

int(*)(void *,sqlite3*,const char*,int),
void*
);

Sq3LiteC QUERY

C-API: Sq3LiteC_Query_C_API - Sq3LiteC - work with a query

void Sq3LiteInterrupt(SQ3_LITE sq3lite)

top Interrupt A Long-Running Query … → API: Sq3LiteInterrupt

This function causes any pending database operation to abort and return at its earliest opportunity. This routine is typically called in response to a user action such as pressing "Cancel" or Ctrl-C where the user wants a long query operation to halt immediately.

It is safe to call this routine from a thread different from the thread that is currently running the database operation. But it is not safe to call this routine with a database connection that is closed or might close before Sq3LiteInterrupt() returns.

If an SQL operation is very nearly finished at the time when Sq3LiteInterrupt() is called, then it might not have an opportunity to be interrupted and might continue to completion.

An SQL operation that is interrupted will return SQ3_RESULT_INTERRUPT. If the interrupted SQL operation is an INSERT, UPDATE, or DELETE that is inside an explicit transaction, then the entire transaction will be rolled back automatically.

The Sq3LiteInterrupt(D) call is in effect until all currently running SQL statements on database connection D complete. Any new SQL statements that are started after the Sq3LiteInterrupt() call and before the running statement count reaches zero are interrupted as if they had been running prior to the Sq3LiteInterrupt() call. New SQL statements that are started after the running statement count reaches zero are not effected by the Sq3LiteInterrupt(). A call to Sq3LiteInterrupt(D) that occurs when there are no running SQL statements is a no-op and has no effect on SQL statements that are started after the Sq3LiteInterrupt() call returns.

The Sq3LiteIsInterrupted (D) interface can be used to determine whether or not an interrupt is currently in effect for database connection D. It returns 1 if an interrupt is currently in effect, or 0 otherwise.

Reference code from sqlite3:

SQLITE_API int sqlite3_is_interrupted(sqlite3 *)
SQLITE_API void sqlite3_interrupt(sqlite3 *)

MK_BOOL Sq3LiteIsInterrupted(SQ3_LITE sq3lite)

top Interrupt A Long-Running Query … → API: Sq3LiteIsInterrupted

read more at 'Sq3LiteInterrupt'

Sq3LiteC ROW

C-API: Sq3LiteC_Row_C_API - Sq3LiteC - work with a row

enum MkErrorE Sq3LiteChanges(SQ3_LITE sq3lite)

top Count The Number Of Rows Modified … → API: Sq3LiteChanges

These functions return the number of rows modified, inserted or deleted by the most recently completed INSERT, UPDATE or DELETE statement on the database connection specified by the only parameter. The two functions are identical except for the type of the return value and that if the number of rows modified by the most recent INSERT, UPDATE or DELETE is greater than the maximum value supported by type "int", then the return value of Sq3LiteChanges() is undefined. Executing any other type of SQL statement does not modify the value returned by these functions.

Only changes made directly by the INSERT, UPDATE or DELETE statement are considered - auxiliary changes caused by triggers, foreign key actions or REPLACE constraint resolution are not counted.

Changes to a view that are intercepted by INSTEAD OF triggers are not counted. The value returned by Sq3LiteChanges() immediately after an INSERT, UPDATE or DELETE statement run on a view is always zero. Only changes made to real tables are counted.

Things are more complicated if the Sq3LiteChanges() function is executed while a trigger program is running. This may happen if the program uses the changes() SQL function, or if some other callback function invokes Sq3LiteChanges() directly. Essentially:

  • Before entering a trigger program the value returned by Sq3LiteChanges() function is saved. After the trigger program has finished, the original value is restored.

  • Within a trigger program each INSERT, UPDATE and DELETE statement sets the value returned by Sq3LiteChanges() upon completion as normal. Of course, this value will not include any changes performed by sub-triggers, as the Sq3LiteChanges() value will be saved and restored after each sub-trigger has run.

This means that if the changes() SQL function (or similar) is used by the first INSERT, UPDATE or DELETE statement within a trigger, it returns the value as set when the calling statement began executing. If it is used by the second or subsequent such statement within a trigger program, the value returned reflects the number of rows modified by the previous INSERT, UPDATE or DELETE statement within the same trigger.

If a separate thread makes changes on the same database connection while Sq3LiteChanges () is running then the value returned is unpredictable and not meaningful.

See also:

Reference code from sqlite3:

SQLITE_API int sqlite3_changes(sqlite3 *)
SQLITE_API sqlite3_int64 sqlite3_changes64(sqlite3 *)

MK_I64 Sq3LiteChanges64(SQ3_LITE sq3lite)

top Count The Number Of Rows Modified … → API: Sq3LiteChanges64

read more at 'Sq3LiteChanges'

void Sq3LiteSetLastInsertRowid(SQ3_LITE sq3lite, MK_I64 arg1)

top Set the Last Insert Rowid value … → API: Sq3LiteSetLastInsertRowid

The Sq3LiteSetLastInsertRowid(D, R) method allows the application to set the value returned by calling Sq3LiteLastInsertRowid(D) to R without inserting a row into the database.

Reference code from sqlite3:

SQLITE_API void sqlite3_set_last_insert_rowid(sqlite3 *, sqlite3_int64)

enum MkErrorE Sq3LiteTotalChanges(SQ3_LITE sq3lite)

top Total Number Of Rows Modified … → API: Sq3LiteTotalChanges

These functions return the total number of rows inserted, modified or deleted by all INSERT, UPDATE or DELETE statements completed since the database connection was opened, including those executed as part of trigger programs. The two functions are identical except for the type of the return value and that if the number of rows modified by the connection exceeds the maximum value supported by type "int", then the return value of Sq3LiteTotalChanges() is undefined. Executing any other type of SQL statement does not affect the value returned by Sq3LiteTotalChanges().

Changes made as part of foreign key actions are included in the count, but those made as part of REPLACE constraint resolution are not. Changes to a view that are intercepted by INSTEAD OF triggers are not counted.

The Sq3LiteTotalChanges (D) interface only reports the number of rows that changed due to SQL statement run against database connection D. Any changes by other database connections are ignored. To detect changes against a database file from other database connections use the PRAGMA data_version command or the SQ3_FCNTL_DATA_VERSION file control.

If a separate thread makes changes on the same database connection while Sq3LiteTotalChanges () is running then the value returned is unpredictable and not meaningful.

See also:

Reference code from sqlite3:

SQLITE_API int sqlite3_total_changes(sqlite3 *)
SQLITE_API sqlite3_int64 sqlite3_total_changes64(sqlite3 *)

MK_I64 Sq3LiteTotalChanges64(SQ3_LITE sq3lite)

top Total Number Of Rows Modified … → API: Sq3LiteTotalChanges64

read more at 'Sq3LiteTotalChanges'

Sq3LiteC ERROR

C-API: Sq3LiteC_Error_C_API - Sq3LiteC - work with an error

(static) MK_STRN Sq3LiteErrStr(MK_I32 arg0)

top Error Codes And Messages … → API: Sq3LiteErrStr

read more at 'Sq3LiteErrCode'

enum Sq3ErrorE Sq3LiteErrCode(SQ3_LITE db)

top Error Codes And Messages … → API: Sq3LiteErrCode

If the most recent sqlite3_* API call associated with database connection D failed, then the Sq3LiteErrCode(D) interface returns the numeric result code or extended result code for that API call. The Sq3LiteExtendetErrCode() interface is the same except that it always returns the extended result code even when extended result codes are disabled.

The values returned by Sq3LiteErrCode() and/or Sq3LiteExtendetErrCode() might change with each API call. Except, there are some interfaces that are guaranteed to never change the value of the error code. The error-code preserving interfaces include the following:

The Sq3LiteErrMsg() and sqlite3_errmsg16() return English-language text that describes the error, as either UTF-8 or UTF-16 respectively. (See how SQLite handles invalid UTF for exceptions to this rule.) Memory to hold the error message string is managed internally. The application does not need to worry about freeing the result. However, the error string might be overwritten or deallocated by subsequent calls to other SQLite interface functions.

The Sq3LiteErrStr() interface returns the English-language text that describes the result code, as UTF-8. Memory to hold the error message string is managed internally and must not be freed by the application.

If the most recent error references a specific token in the input SQL, the Sq3LiteErrorOffset() interface returns the byte offset of the start of that token. The byte offset returned by Sq3LiteErrorOffset() assumes that the input SQL is UTF8. If the most recent error does not reference a specific token in the input SQL, then the Sq3LiteErrorOffset() function returns -1.

When the serialized threading mode is in use, it might be the case that a second error occurs on a separate thread in between the time of the first error and the call to these interfaces. When that happens, the second error will be reported since these interfaces always report the most recent result. To avoid this, each thread can obtain exclusive use of the database connection D by invoking sqlite3_mutex_enter(sqlite3_db_mutex(D)) before beginning to use D and invoking sqlite3_mutex_leave(sqlite3_db_mutex(D)) after all calls to the interfaces listed here are completed.

If an interface fails with SQ3_RESULT_MISUSE, that means the interface was invoked incorrectly by the application. In that case, the error code and message may or may not be set.

Reference code from sqlite3:

SQLITE_API const char *sqlite3_errstr(int);
SQLITE_API int sqlite3_error_offset(sqlite3 *db)
SQLITE_API const char * sqlite3_errstr(int)
SQLITE_API int sqlite3_extended_errcode(sqlite3 *db)
SQLITE_API int sqlite3_errcode(sqlite3 *db)
SQLITE_API const void * sqlite3_errmsg16(sqlite3 *)
SQLITE_API const char * sqlite3_errmsg(sqlite3 *)

MK_STRN Sq3LiteErrMsg(SQ3_LITE sq3lite)

top Error Codes And Messages … → API: Sq3LiteErrMsg

read more at 'Sq3LiteErrCode'

enum MkErrorE Sq3LiteErrorOffset(SQ3_LITE db)

top Error Codes And Messages … → API: Sq3LiteErrorOffset

read more at 'Sq3LiteErrCode'

enum Sq3ExtendetResultCodesE Sq3LiteExtendetErrCode(SQ3_LITE db)

top Error Codes And Messages … → API: Sq3LiteExtendetErrCode

read more at 'Sq3LiteErrCode'

enum MkErrorE Sq3LiteSystemErrno(SQ3_LITE sq3lite)

top Low-level system error code … → API: Sq3LiteSystemErrno

Attempt to return the underlying operating system error code or error number that caused the most recent I/O error or failure to open a file. The return value is OS-dependent. For example, on unix systems, after Sq3LiteOpenV2 () returns SQ3_RESULT_CANTOPEN, this interface could be called to get back the underlying "errno" that caused the problem, such as ENOSPC, EAUTH, EISDIR, and so forth.

Reference code from sqlite3:

SQLITE_API int sqlite3_system_errno(sqlite3 *)

Sq3LiteC MISC

C-API: Sq3LiteC_Misc_C_API - Sq3LiteC - various functions to perform misc operations …

(hide) enum MkErrorE Sq3LiteAutovacuumPages(SQ3_LITE db, Sq3Fupu_Sq3LiteAutovacuumPages_arg1 arg1, MK_PTR arg2, Sq3Fupu_Sq3LiteAutovacuumPages_arg3 arg3)

top Autovacuum Compaction Amount Callback … → API: Sq3LiteAutovacuumPages

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:

sqlite3 *db,
unsigned int(*)(void*,const char*,unsigned int,unsigned int,unsigned int),
void*,
void(*)(void*)
);
SQLITE_API int sqlite3_autovacuum_pages(sqlite3 *db, unsigned int(*)(void *, const char *, unsigned int, unsigned int, unsigned int), void *, void(*)(void *))

(hide) enum MkErrorE Sq3LiteCollationNeeded(SQ3_LITE sq3lite, MK_PTR arg1, Sq3Fupu_Sq3LiteCollationNeeded_arg2 arg2)

top Collation Needed Callbacks … → API: Sq3LiteCollationNeeded

To avoid having to register all collation sequences before a database can be used, a single callback function may be registered with the database connection to be invoked whenever an undefined collation sequence is required.

If the function is registered using the Sq3LiteCollationNeeded() API, then it is passed the names of undefined collation sequences as strings encoded in UTF-8. If sqlite3_collation_needed16() is used, the names are passed as UTF-16 in machine native byte order. A call to either function replaces the existing collation-needed callback.

When the callback is invoked, the first argument passed is a copy of the second argument to Sq3LiteCollationNeeded() or sqlite3_collation_needed16(). The second argument is the database connection. The third argument is one of SQ3_TEXT_UTF8, SQ3_TEXT_UTF16BE, or SQ3_TEXT_UTF16LE, indicating the most desirable form of the collation sequence function required. The fourth parameter is the name of the required collation sequence.

The callback function should register the desired collation using sqlite3_create_collation (), sqlite3_create_collation16 (), or Sq3LiteCreateCollationV2 ().

Reference code from sqlite3:

void*,
void(*)(void*,sqlite3*,int eTextRep,const char*)
);
void*,
void(*)(void*,sqlite3*,int eTextRep,const void*)
);
SQLITE_API int sqlite3_collation_needed16(sqlite3 *, void *, void(*)(void *, sqlite3 *, int eTextRep, const void *))
SQLITE_API int sqlite3_collation_needed(sqlite3 *, void *, void(*)(void *, sqlite3 *, int eTextRep, const char *))

enum MkErrorE Sq3LiteDbCacheflush(SQ3_LITE sq3lite)

top Flush caches to disk mid-transaction … → API: Sq3LiteDbCacheflush

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:

SQLITE_API int sqlite3_db_cacheflush(sqlite3 *)

SQ3_FILENAME Sq3LiteDbFilename(SQ3_LITE db, MK_STRN zDbName)

top Return The Filename For A Database Connection … → API: Sq3LiteDbFilename

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:

SQLITE_API sqlite3_filename sqlite3_db_filename(sqlite3 *db, const char *zDbName)

MK_STRN Sq3LiteDbName(SQ3_LITE db, MK_I32 N)

top Return The Schema Name For A Database Connection … → API: Sq3LiteDbName

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:

SQLITE_API const char *sqlite3_db_name(sqlite3 *db, int N);
SQLITE_API const char * sqlite3_db_name(sqlite3 *db, int N)

enum MkErrorE Sq3LiteDbReadonly(SQ3_LITE db, MK_STRN zDbName)

top Determine if a database is read-only … → API: Sq3LiteDbReadonly

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:

SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName)

enum MkErrorE Sq3LiteDbReleaseMemory(SQ3_LITE sq3lite)

top Free Memory Used By A Database Connection … → API: Sq3LiteDbReleaseMemory

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:

SQLITE_API int sqlite3_db_release_memory(sqlite3 *)

enum MkErrorE Sq3LiteDbStatus(SQ3_LITE sq3lite, enum Sq3DbStatusE op, MK_I32 *pCur, MK_I32 *pHiwtr, MK_BOOL resetFlg)

top Database Connection Status … → API: Sq3LiteDbStatus

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:

SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
SQLITE_API int sqlite3_db_status(sqlite3 *, int op, int *pCur, int *pHiwtr, int resetFlg)

(runtime) enum MkErrorE Sq3LiteDbStatusBFL(SQ3_LITE sq3lite, enum Sq3DbStatusE op, MK_BFL *val_out, MK_BOOL resetFlg)

top Database Connection Status … → API: Sq3LiteDbStatusBFL_RT

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:

SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]sq3litethe Sq3LiteC instance to work on a database
[in]opa value from the enum Sq3DbStatusE
[out]val_outThe return-value have to be none MK_NULL.
[in]resetFlgIf the resetFlg is true, then the highest instantaneous value is reset back down to the current value.
Returns
The MkErrorE status from the DEFAULT MkErrorC in MkRuntimeS::error_mk
Attention
(do not free) The memory of the val_out value belongs to the called Sq3LiteDbStatusBFL function and therefore never becomes MK_NULL for a non-error result.
For details on the val_out value, see: MkKernel_Storage_C_API.

(runtime) enum MkErrorE Sq3LiteDeserialize(SQ3_LITE sq3lite, MK_STRN zSchema, MkBinaryR pData, enum Sq3DeSerializeEF mFlags)

top Deserialize a database … → API: Sq3LiteDeserialize_RT

This is an enhanced version of Sq3LiteDeserializeHide, the return value changed to MkBinaryR.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]sq3litethe Sq3LiteC instance to work on a database
[in]zSchemaWhich DB to reopen with the deserialization
[in]pDataThe serialized database content
[in]mFlagsZero or more Sq3SerializeE flags
Returns
The MkErrorE status from the DEFAULT MkErrorC in MkRuntimeS::error_mk

Sq3LiteDeserializeHide : documentation

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:
sqlite3 *db, // The database connection
const char *zSchema, // Which DB to reopen with the deserialization
unsigned char *pData, // The serialized database content
sqlite3_int64 szDb, // Number bytes in the deserialization
sqlite3_int64 szBuf, // Total size of buffer pData[]
unsigned mFlags // Zero or more SQLITE_DESERIALIZE_* flags
);
SQLITE_API int sqlite3_deserialize(sqlite3 *db, const char *zSchema, unsigned char *pData, sqlite3_int64 szDb, sqlite3_int64 szBuf, unsigned mFlags)

(hide) enum MkErrorE Sq3LiteDeserializeHide(SQ3_LITE db, MK_STRN zSchema, MK_BIN pData, MK_I64 szDb, MK_I64 szBuf, enum Sq3DeSerializeEF mFlags)

top Deserialize a database … → API: Sq3LiteDeserializeHide

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:

sqlite3 *db, // The database connection
const char *zSchema, // Which DB to reopen with the deserialization
unsigned char *pData, // The serialized database content
sqlite3_int64 szDb, // Number bytes in the deserialization
sqlite3_int64 szBuf, // Total size of buffer pData[]
unsigned mFlags // Zero or more SQLITE_DESERIALIZE_* flags
);

(runtime) enum MkErrorE Sq3LiteDropModules(SQ3_LITE sq3lite, MK_BFL azKeepBfl)

top Remove Unnecessary Virtual Table Implementations … → API: Sq3LiteDropModules_RT

This is an enhanced version of Sq3LiteDropModulesHide.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]sq3litethe Sq3LiteC instance to work on a database
azKeepBflThe MkBufferListC list of modules to drop
Returns
The MkErrorE status from the DEFAULT MkErrorC in MkRuntimeS::error_mk

Sq3LiteDropModulesHide : documentation

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.
Reference code from sqlite3:
sqlite3 *db, // Remove modules from this connection
const char **azKeep // Except, do not remove the ones named here
);
SQLITE_API int sqlite3_drop_modules(sqlite3 *db, const char **azKeep)

(hide) enum MkErrorE Sq3LiteDropModulesHide(SQ3_LITE db, MK_STRN *azKeep)

top Remove Unnecessary Virtual Table Implementations … → API: Sq3LiteDropModulesHide

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:

sqlite3 *db, // Remove modules from this connection
const char **azKeep // Except, do not remove the ones named here
);

(hide) enum MkErrorE Sq3LiteFileControl(SQ3_LITE sq3lite, MK_STRN zDbName, enum Sq3TestCtrlE op, MK_PTR arg3)

top Low-Level Control Of Database Files … → API: Sq3LiteFileControl

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:

SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
SQLITE_API int sqlite3_file_control(sqlite3 *, const char *zDbName, int op, void *)

(runtime) void Sq3LiteLog(SQ3_LITEN const lite, MK_OBJN fmtobj, MK_DBG const debug, MK_STRN const callfunc, MK_I32 const lvl)

top log the lite … → API: Sq3LiteLog_RT

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]liteProgramming-Language-Micro-Kernel (PLMK) instance from sqlite3
[in]fmtobjmanaged object used to format the log-message (default=MK_NULL → use default-format)
[in]debugthe debug level from MkRuntimeS::debug, use 0 <= debug <= 9 (default=0)
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)
[in]lvla user-defined prefix starting with "" for lvl=0 and increase with " " for lvl+1 (default=0)

enum MkErrorE Sq3LiteOverloadFunction(SQ3_LITE sq3lite, MK_STRN zFuncName, MK_I32 nArg)

top Overload A Function For A Virtual Table … → API: Sq3LiteOverloadFunction

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:

SQLITE_API int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
SQLITE_API int sqlite3_overload_function(sqlite3 *, const char *zFuncName, int nArg)

MkBinaryR Sq3LiteSerialize(SQ3_LITE sq3lite, MK_STRN zSchema, enum Sq3SerializeE mFlags)

top Serialize a database … → API: Sq3LiteSerialize

This is an enhanced version of Sq3LiteSerializeHide, the return value changed to MkBinaryR.

Parameters
[in]sq3litethe Sq3LiteC instance to work on a database
[in]zSchemaWhich DB to serialize. ex: "main", "temp", ...
[in]mFlagsZero or more Sq3SerializeE flags
Returns
The data requested as MkBinaryR

Sq3LiteSerializeHide : documentation

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:
sqlite3 *db, // The database connection
const char *zSchema, // Which DB to serialize. ex: "main", "temp", ...
sqlite3_int64 *piSize, // Write size of the DB here, if not NULL
unsigned int mFlags // Zero or more SQLITE_SERIALIZE_* flags
);
SQLITE_API unsigned char * sqlite3_serialize(sqlite3 *db, const char *zSchema, sqlite3_int64 *piSize, unsigned int mFlags)

(hide) MK_BIN Sq3LiteSerializeHide(SQ3_LITE db, MK_STRN zSchema, MK_I64 *piSize, enum Sq3SerializeE mFlags)

top Serialize a database … → API: Sq3LiteSerializeHide

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:

sqlite3 *db, // The database connection
const char *zSchema, // Which DB to serialize. ex: "main", "temp", ...
sqlite3_int64 *piSize, // Write size of the DB here, if not NULL
unsigned int mFlags // Zero or more SQLITE_SERIALIZE_* flags
);

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)

top Extract Metadata About A Column Of A Table … → API: Sq3LiteTableColumnMetadata

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
Type

Description

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:

sqlite3 *db, // Connection handle
const char *zDbName, // Database name or NULL
const char *zTableName, // Table name
const char *zColumnName, // Column name
char const **pzDataType, // OUTPUT: Declared data type
char const **pzCollSeq, // OUTPUT: Collation sequence name
int *pNotNull, // OUTPUT: True if NOT NULL constraint exists
int *pPrimaryKey, // OUTPUT: True if column part of PK
int *pAutoinc // OUTPUT: True if column is auto-increment
);
SQLITE_API int sqlite3_table_column_metadata(sqlite3 *db, const char *zDbName, const char *zTableName, const char *zColumnName, char const **pzDataType, char const **pzCollSeq, int *pNotNull, int *pPrimaryKey, int *pAutoinc)

(hide,macro) enum MkErrorE Sq3LiteVtabConfig(SQ3_LITE sq3lite, enum Sq3VtabE op, ...)

top Virtual Table Interface Configuration … → API: Sq3LiteVtabConfig

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:

SQLITE_API int sqlite3_vtab_config(sqlite3 *, int op,...)

Sq3ValueC

Sq3ValueC CLASS

Define Sq3ValueC - low level definition, access and cast …
Export Sq3ValueC - Export class functions …
Introspection Sq3ValueC - Introspection class functions …
Misc

Sq3ValueC - Misc class functions …

Sq3ValueC TOR

Free Copy And Free SQL Values …
Dup

Copy And Free SQL Values …

Sq3ValueC INFO

Bytes Obtaining SQL Values …
Encoding Report the internal text encoding state of an sqlite3_value object …
FromBind Obtaining SQL Values …
Log log the val
NoChange Obtaining SQL Values …
NumericType Obtaining SQL Values …
SubType Finding The Subtype Of SQL Values …
Type

Obtaining SQL Values …

Sq3ValueC TYPES

BinaryR Obtaining SQL Values …
Blob Obtaining SQL Values …
BlobHide Obtaining SQL Values …
BUF Obtaining a MkBufferC value…
Double Obtaining SQL Values …
Int Obtaining SQL Values …
Int64 Obtaining SQL Values …
Pointer Obtaining SQL Values …
StringR Obtaining SQL Values …
Text

Obtaining SQL Values …

Sq3ValueC VTAB

VtabInFirst Find all elements on the right-hand side of an IN constraint …
VtabInNext

Find all elements on the right-hand side of an IN constraint …

Sq3ValueC DETAIL

C-API: Sq3ValueC_C_API - Sq3ValueC - the class known as sq3val or Value define by Sq3ValueS

Struct to represent the data of the Sq3ValueC

Dynamically Typed Value Object …

SQLite uses the Sq3ValueC object to represent all values that can be stored in a database table. SQLite uses dynamic typing for the values it stores. Values stored in Sq3ValueC objects can be integers, floating point values, strings, BLOBs, or NULL.

An Sq3ValueC object may be either "protected" or "unprotected". Some interfaces require a protected Sq3ValueC. Other interfaces will accept either a protected or an unprotected Sq3ValueC. Every interface that accepts Sq3ValueC arguments specifies whether or not it requires a protected Sq3ValueC. The Sq3ValueDup () interface can be used to construct a new protected Sq3ValueC from an unprotected Sq3ValueC.

The terms "protected" and "unprotected" refer to whether or not a mutex is held. An internal mutex is held for a protected Sq3ValueC object but no mutex is held for an unprotected Sq3ValueC object. If SQLite is compiled to be single-threaded (with SQLITE_THREADSAFE=0 and with Sq3Threadsafe () returning 0) or if SQLite is run in one of reduced mutex modes SQ3_CONFIG_SINGLETHREAD or SQ3_CONFIG_MULTITHREAD then there is no distinction between protected and unprotected Sq3ValueC objects and they can be used interchangeably. However, for maximum code portability it is recommended that applications still make the distinction between protected and unprotected Sq3ValueC objects even when not strictly required.

The Sq3ValueC objects that are passed as parameters into the implementation of application-defined SQL functions are protected. The Sq3ValueC objects returned by sqlite3_vtab_rhs_value () are protected. The Sq3ValueC object returned by Sq3StmtColumnValue () is unprotected. Unprotected Sq3ValueC objects may only be used as arguments to sqlite3_result_value (), Sq3StmtBindValue (), and Sq3ValueDup (). The sqlite3_value_type() family of interfaces require protected Sq3ValueC objects.

Reference code from sqlite3:

Sq3ValueC CLASS

NAVI: top, up

Sq3ValueC CLASS DEFINE

Val cast a unknown-object into an Sq3ValueS pointer or NULL if not possible
ValCheck check Sq3ValueS -> MkObjectS::signature
ValCheckO check Sq3ValueS -> MkObjectS::signature
ValN

(const) cast a unknown-object into an Sq3ValueS pointer or NULL if not possible

Sq3ValueC CLASS EXPORT

HandleResolve Handle-Resolve-Slot - return a Sq3ValueC from netHdl or MK_NULL if invalid…
HandleGet

Handle-Get-Slot - returns a export-hdl to the Sq3ValueC useable for external storage

Sq3ValueC CLASS INTROSPECTION

Instances get head-instance from linked-list of Sq3ValueS type …
Next get next instance from linked-list of Sq3ValueS type
Prev

get previous instance from linked-list of Sq3ValueS type

Sq3ValueC CLASS MISC

GetNull

Null-Slot - return a Sq3ValueC typed NULL instance …

Sq3ValueC CLASS DETAILS

C-API: Sq3ValueC_Class_C_API - Sq3ValueC - define the class …

Sq3ValueC CLASS DEFINE

C-API: Sq3ValueC_Class_Define_C_API - Sq3ValueC - low level definition, access and cast …

(static,hide) SQ3_VAL Sq3Val(MK_MNG mng)

top cast a unknown-object into an Sq3ValueS pointer or NULL if not possible → API: Sq3Val

(static,hide) MK_BOOL Sq3ValCheck(MK_MNGN mng)

top check Sq3ValueS -> MkObjectS::signature … → API: Sq3ValCheck

Returns
TRUE on valid val and FALSE an invalid val

(static,hide) MK_BOOL Sq3ValCheckO(MK_OBJN obj)

top check Sq3ValueS -> MkObjectS::signature … → API: Sq3ValCheckO

Returns
TRUE on valid val and FALSE an invalid val

(static,hide) SQ3_VALN Sq3ValN(MK_MNGN mng)

top (const) cast a unknown-object into an Sq3ValueS pointer or NULL if not possible → API: Sq3ValN

Sq3ValueC CLASS EXPORT

Sq3ValueC - Export class functions …

(static,runtime) SQ3_VAL Sq3ValueHandleResolve(MK_HDL const netHdl)

top Handle-Resolve-Slot - return a Sq3ValueC from netHdl or MK_NULL if invalid… → API: Sq3ValueHandleResolve_RT

The Sq3ValueHandleResolve undo the Sq3ValueHandleGet and is intended to export a unique identifer into external code not belonging to the Programming-Language-Micro-Kernel (PLMK).

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]netHdlhandle former exported with Sq3ValueHandleGet
Returns
the required handle or MK_NULL if netHdl is invalid

(runtime) MK_HDL Sq3ValueHandleGet(SQ3_VAL const val)

top Handle-Get-Slot - returns a export-hdl to the Sq3ValueC useable for external storage → API: Sq3ValueHandleGet_RT

The export-hdl is a reference to an instance that can be stored in software and converted back into an instance using the Sq3ValueHandleResolve.

The export-hdl is only valid until the Programming-Language-Micro-Kernel (PLMK) ends.

example: The export-hdl is used in rpc to identify an object across the network.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]valProgramming-Language-Micro-Kernel (PLMK) instance from sqlite3_value
Returns
the required export-hdl

Sq3ValueC CLASS INTROSPECTION

Sq3ValueC - Introspection class functions …

(static,runtime) SQ3_VAL Sq3ValueInstances()

top get head-instance from linked-list of Sq3ValueS type … → API: Sq3ValueInstances_RT

The head-instance is the last instance created.

SQ3_VAL Sq3ValueNext(SQ3_VAL const val)

top get next instance from linked-list of Sq3ValueS type → API: Sq3ValueNext

SQ3_VAL Sq3ValuePrev(SQ3_VAL const val)

top get previous instance from linked-list of Sq3ValueS type → API: Sq3ValuePrev

Sq3ValueC CLASS MISC

Sq3ValueC - Misc class functions …

(static) SQ3_VAL Sq3ValueGetNull()

top Null-Slot - return a Sq3ValueC typed NULL instance … → API: Sq3ValueGetNull

Sq3ValueC TOR

C-API: Sq3ValueC_TOR_C_API - Sq3ValueC - various functions to create, initialize and destroy …

(destructor) void Sq3ValueFree(SQ3_VAL sq3val)

top Copy And Free SQL Values … → API: Sq3ValueFree

read more at 'Sq3ValueDup'

(constructor) SQ3_VAL Sq3ValueDup(SQ3_VALN sq3val)

top Copy And Free SQL Values … → API: Sq3ValueDup

The Sq3ValueDup(V) interface makes a copy of the Sq3ValueC object D and returns a pointer to that copy. The Sq3ValueC returned is a protected Sq3ValueC object even if the input is not. The Sq3ValueDup(V) interface returns NULL if V is NULL or if a memory allocation fails. If V is a pointer value, then the result of Sq3ValueDup(V) is a NULL value.

The Sq3ValueFree(V) interface frees an Sq3ValueC object previously obtained from Sq3ValueDup (). If V is a NULL pointer then Sq3ValueFree(V) is a harmless no-op.

Reference code from sqlite3:

SQLITE_API sqlite3_value * sqlite3_value_dup(const sqlite3_value *)
SQLITE_API void sqlite3_value_free(sqlite3_value *)

Sq3ValueC INFO

C-API: Sq3ValueC_Info_C_API - Sq3ValueC - get type-information

enum Sq3TextE Sq3ValueBytes(SQ3_VALN sq3val)

top Obtaining SQL Values … → API: Sq3ValueBytes

read more at 'Sq3ValueBlob'

enum Sq3TextE Sq3ValueEncoding(SQ3_VALN sq3val)

top Report the internal text encoding state of an sqlite3_value object … → API: Sq3ValueEncoding

The Sq3ValueEncoding(X) interface returns one of SQ3_TEXT_UTF8, SQ3_TEXT_UTF16BE, or SQ3_TEXT_UTF16LE according to the current text encoding of the value X, assuming that X has type TEXT. If Sq3ValueType(X) returns something other than SQ3_TYPE_TEXT, then the return value from Sq3ValueEncoding(X) is meaningless. Calls to Sq3ValueText (X), sqlite3_value_text16 (X), sqlite3_value_text16be (X), sqlite3_value_text16le (X), Sq3ValueBytes (X), or sqlite3_value_bytes16 (X) might change the encoding of the value X and thus change the return from subsequent calls to Sq3ValueEncoding(X).

This routine is intended for used by applications that test and validate the SQLite implementation. This routine is inquiring about the opaque internal state of an Sq3ValueC object. Ordinary applications should not need to know what the internal state of an Sq3ValueC object is and hence should not need to use this interface.

Reference code from sqlite3:

SQLITE_API int sqlite3_value_encoding(sqlite3_value *)

MK_BOOL Sq3ValueFromBind(SQ3_VALN sq3val)

top Obtaining SQL Values … → API: Sq3ValueFromBind

read more at 'Sq3ValueBlob'

(runtime) void Sq3ValueLog(SQ3_VALN const val, MK_OBJN fmtobj, MK_DBG const debug, MK_STRN const callfunc, MK_I32 const lvl)

top log the val … → API: Sq3ValueLog_RT

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]valProgramming-Language-Micro-Kernel (PLMK) instance from sqlite3_value
[in]fmtobjmanaged object used to format the log-message (default=MK_NULL → use default-format)
[in]debugthe debug level from MkRuntimeS::debug, use 0 <= debug <= 9 (default=0)
[in]callfunca user-defined postfix to identify the calling function or the environment (default=name-of-function)
[in]lvla user-defined prefix starting with "" for lvl=0 and increase with " " for lvl+1 (default=0)

MK_BOOL Sq3ValueNoChange(SQ3_VALN sq3val)

top Obtaining SQL Values … → API: Sq3ValueNoChange

read more at 'Sq3ValueBlob'

enum Sq3TypeE Sq3ValueNumericType(SQ3_VALN sq3val)

top Obtaining SQL Values … → API: Sq3ValueNumericType

read more at 'Sq3ValueBlob'

MK_I32 Sq3ValueSubType(SQ3_VALN sq3val)

top Finding The Subtype Of SQL Values … → API: Sq3ValueSubType

The Sq3ValueSubType(V) function returns the subtype for an application-defined SQL function argument V. The subtype information can be used to pass a limited amount of context from one SQL function to another. Use the sqlite3_result_subtype () routine to set the subtype for the return value of an SQL function.

Every application-defined SQL function that invoke this interface should include the SQ3_FUNCTION_SUBTYPE property in the text encoding argument when the function is registered. If the SQ3_FUNCTION_SUBTYPE property is omitted, then Sq3ValueSubType() might return zero instead of the upstream subtype in some corner cases.

Reference code from sqlite3:

SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value *)

enum Sq3TypeE Sq3ValueType(SQ3_VALN sq3val)

top Obtaining SQL Values … → API: Sq3ValueType

read more at 'Sq3ValueBlob'

Sq3ValueC TYPES

C-API: Sq3ValueC_Types_C_API - Sq3ValueC - get type from value

MkBinaryR Sq3ValueBinaryR(SQ3_VALN sq3val)

top Obtaining SQL Values … → API: Sq3ValueBinaryR

read more at 'Sq3ValueBlobHide'

(runtime) MK_BUF Sq3ValueBlob(SQ3_VALN sq3val)

top Obtaining SQL Values … → API: Sq3ValueBlob_RT

read more at 'Sq3ValueBlobHide'

Attention
(do not free) The memory of the out/return value belongs to the called LibSq3Lite function and therefore never becomes MK_NULL for a non-error result.
For details on the out/return value, see: MkKernel_Storage_C_API.

(hide) MK_BINN Sq3ValueBlobHide(SQ3_VALN sq3val)

top Obtaining SQL Values … → API: Sq3ValueBlobHide

Summary:

sqlite3_value_blobBLOB value
sqlite3_value_doubleREAL value
sqlite3_value_int32-bit INTEGER value
sqlite3_value_int6464-bit INTEGER value
sqlite3_value_pointerPointer value
sqlite3_value_textUTF-8 TEXT value
sqlite3_value_text16UTF-16 TEXT value in the native byteorder
sqlite3_value_text16beUTF-16be TEXT value
sqlite3_value_text16leUTF-16le TEXT value
   
sqlite3_value_bytesSize of a BLOB or a UTF-8 TEXT in bytes
sqlite3_value_bytes16   →  Size of UTF-16 TEXT in bytes
sqlite3_value_typeDefault datatype of the value
sqlite3_value_numeric_type   →  Best numeric datatype of the value
sqlite3_value_nochange   →  True if the column is unchanged in an UPDATE against a virtual table.
sqlite3_value_frombind   →  True if value originated from a bound parameter

Details:

These routines extract type, size, and content information from protected Sq3ValueC objects. Protected Sq3ValueC objects are used to pass parameter information into the functions that implement application-defined SQL functions and virtual tables.

These routines work only with protected Sq3ValueC objects. Any attempt to use these routines on an unprotected Sq3ValueC is not threadsafe.

These routines work just like the corresponding column access functions except that these routines take a single protected Sq3ValueC object pointer instead of a Sq3StmtC* pointer and an integer column number.

The sqlite3_value_text16() interface extracts a UTF-16 string in the native byte-order of the host machine. The sqlite3_value_text16be() and sqlite3_value_text16le() interfaces extract UTF-16 strings as big-endian and little-endian respectively.

If Sq3ValueC object V was initialized using Sq3StmtBindPointer (S,I,P,X,D) or sqlite3_result_pointer (C,P,X,D) and if X and Y are strings that compare equal according to strcmp(X,Y), then Sq3ValuePointer(V,Y) will return the pointer P. Otherwise, Sq3ValuePointer(V,Y) returns a NULL. The Sq3StmtBindPointer() routine is part of the pointer passing interface added for SQLite 3.20.0.

The Sq3ValueType(V) interface returns the datatype code for the initial datatype of the Sq3ValueC object V. The returned value is one of SQ3_TYPE_INTEGER, SQ3_TYPE_FLOAT, SQ3_TYPE_TEXT, SQ3_TYPE_BLOB, or SQ3_TYPE_NULL. Other interfaces might change the datatype for an Sq3ValueC object. For example, if the datatype is initially SQ3_TYPE_INTEGER and Sq3ValueText(V) is called to extract a text value for that integer, then subsequent calls to Sq3ValueType(V) might return SQ3_TYPE_TEXT. Whether or not a persistent internal datatype conversion occurs is undefined and may change from one release of SQLite to the next.

The Sq3ValueNumericType() interface attempts to apply numeric affinity to the value. This means that an attempt is made to convert the value to an integer or floating point. If such a conversion is possible without loss of information (in other words, if the value is a string that looks like a number) then the conversion is performed. Otherwise no conversion occurs. The datatype after conversion is returned.

Within the xUpdate method of a virtual table, the Sq3ValueNoChange(X) interface returns true if and only if the column corresponding to X is unchanged by the UPDATE operation that the xUpdate method call was invoked to implement and if and the prior xColumn method call that was invoked to extracted the value for that column returned without setting a result (probably because it queried sqlite3_vtab_nochange () and found that the column was unchanging). Within an xUpdate method, any value for which Sq3ValueNoChange(X) is true will in all other respects appear to be a NULL value. If Sq3ValueNoChange(X) is invoked anywhere other than within an xUpdate method call for an UPDATE statement, then the return value is arbitrary and meaningless.

The Sq3ValueFromBind(X) interface returns non-zero if the value X originated from one of the sqlite3_bind() interfaces. If X comes from an SQL literal value, or a table column, or an expression, then Sq3ValueFromBind(X) returns zero.

Please pay particular attention to the fact that the pointer returned from Sq3ValueBlob (), Sq3ValueText (), or sqlite3_value_text16 () can be invalidated by a subsequent call to Sq3ValueBytes (), sqlite3_value_bytes16 (), Sq3ValueText (), or sqlite3_value_text16 ().

These routines must be called from the same thread as the SQL function that supplied the Sq3ValueC* parameters.

As long as the input parameter is correct, these routines can only fail if an out-of-memory error occurs during a format conversion. Only the following subset of interfaces are subject to out-of-memory errors:

If an out-of-memory error occurs, then the return value from these routines is the same as if the column had contained an SQL NULL value. Valid SQL NULL returns can be distinguished from out-of-memory errors by invoking the Sq3LiteErrCode () immediately after the suspect return value is obtained and before any other SQLite interface is called on the same database connection.

Reference code from sqlite3:

SQLITE_API const void * sqlite3_value_text16le(sqlite3_value *)
SQLITE_API int sqlite3_value_numeric_type(sqlite3_value *)
SQLITE_API const void * sqlite3_value_text16(sqlite3_value *)
SQLITE_API double sqlite3_value_double(sqlite3_value *)
SQLITE_API int sqlite3_value_int(sqlite3_value *)
SQLITE_API int sqlite3_value_bytes16(sqlite3_value *)
SQLITE_API void * sqlite3_value_pointer(sqlite3_value *, const char *)
SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value *)
SQLITE_API int sqlite3_value_type(sqlite3_value *)
SQLITE_API const void * sqlite3_value_text16be(sqlite3_value *)
SQLITE_API int sqlite3_value_nochange(sqlite3_value *)
SQLITE_API int sqlite3_value_frombind(sqlite3_value *)
SQLITE_API int sqlite3_value_bytes(sqlite3_value *)
SQLITE_API const unsigned char * sqlite3_value_text(sqlite3_value *)
SQLITE_API const void * sqlite3_value_blob(sqlite3_value *)

(runtime) MK_BUF Sq3ValueBUF(SQ3_VALN const val)

top Obtaining a MkBufferC value… → API: Sq3ValueBUF_RT

read more at Sq3ValueBlobHide

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]valProgramming-Language-Micro-Kernel (PLMK) instance from sqlite3_value

MK_DBL Sq3ValueDouble(SQ3_VALN sq3val)

top Obtaining SQL Values … → API: Sq3ValueDouble

read more at 'Sq3ValueBlob'

MK_I32 Sq3ValueInt(SQ3_VALN sq3val)

top Obtaining SQL Values … → API: Sq3ValueInt

read more at 'Sq3ValueBlob'

MK_I64 Sq3ValueInt64(SQ3_VALN sq3val)

top Obtaining SQL Values … → API: Sq3ValueInt64

read more at 'Sq3ValueBlob'

(hide) MK_PTR Sq3ValuePointer(SQ3_VALN sq3val, MK_STRN arg1)

top Obtaining SQL Values … → API: Sq3ValuePointer

read more at 'Sq3ValueBlob'

MkStringR Sq3ValueStringR(SQ3_VALN sq3val)

top Obtaining SQL Values … → API: Sq3ValueStringR

read more at 'Sq3ValueBlobHide'

Attention
(do not free) The memory of the out/return value belongs to the called LibSq3Lite function and therefore never becomes MK_NULL for a non-error result.
For details on the out/return value, see: MkKernel_Storage_C_API.

MK_STRN Sq3ValueText(SQ3_VALN sq3val)

top Obtaining SQL Values … → API: Sq3ValueText

read more at 'Sq3ValueBlob'

Sq3ValueC VTAB

C-API: Sq3ValueC_Vtab_C_API - Sq3ValueC - work with the virtual-file-system

enum MkErrorE Sq3ValueVtabInFirst(SQ3_VAL pVal, SQ3_VAL *ppOut)

top Find all elements on the right-hand side of an IN constraint … → API: Sq3ValueVtabInFirst

These interfaces are only useful from within the xFilter() method of a virtual table implementation. The result of invoking these interfaces from any other context is undefined and probably harmful.

The X parameter in a call to Sq3ValueVtabInFirst(X,P) or Sq3ValueVtabInNext(X,P) should be one of the parameters to the xFilter method which invokes these routines, and specifically a parameter that was previously selected for all-at-once IN constraint processing use the sqlite3_vtab_in () interface in the xBestIndex method. If the X parameter is not an xFilter argument that was selected for all-at-once IN constraint processing, then these routines return SQ3_RESULT_ERROR.

Use these routines to access all values on the right-hand side of the IN constraint using code like the following:

   for(rc=sqlite3_vtab_in_first(pList, &pVal);
       rc==SQ3_RESULT_OK && pVal;
       rc=sqlite3_vtab_in_next(pList, &pVal)
   ){
     // do something with pVal
   }
   if( rc!=SQ3_RESULT_OK ){
     // an error has occurred
   }

On success, the Sq3ValueVtabInFirst(X,P) and Sq3ValueVtabInNext(X,P) routines return SQ3_RESULT_OK and set *P to point to the first or next value on the RHS of the IN constraint. If there are no more values on the right hand side of the IN constraint, then *P is set to NULL and these routines return SQ3_RESULT_DONE. The return value might be some other value, such as SQ3_RESULT_NOMEM, in the event of a malfunction.

The *ppOut values returned by these routines are only valid until the next call to either of these routines or until the end of the xFilter method from which these routines were called. If the virtual table implementation needs to retain the *ppOut values for longer, it must make copies. The *ppOut values are protected.

Reference code from sqlite3:

SQLITE_API int sqlite3_vtab_in_first(sqlite3_value *pVal, sqlite3_value **ppOut)
SQLITE_API int sqlite3_vtab_in_next(sqlite3_value *pVal, sqlite3_value **ppOut)

enum MkErrorE Sq3ValueVtabInNext(SQ3_VAL pVal, SQ3_VAL *ppOut)

top Find all elements on the right-hand side of an IN constraint … → API: Sq3ValueVtabInNext

read more at 'Sq3ValueVtabInFirst'


Sq3StmtC

Sq3StmtC CLASS

Define Sq3StmtC - low level definition, access and cast …
Export Sq3StmtC - Export class functions …
Introspection Sq3StmtC - Introspection class functions …
Misc

Sq3StmtC - Misc class functions …

Sq3StmtC TOR

PrepareV2 Compiling An SQL Statement …
PrepareV2Hide Compiling An SQL Statement …
PrepareV3 Compiling An SQL Statement …
PrepareV3Hide Compiling An SQL Statement …
Finalize

Destroy A Prepared Statement Object …

Sq3StmtC BIND

BindBlob Bind a MkBinaryR Value To a Prepared Statement …
BindBlob64 Bind a MkBinaryR Value To a Prepared Statement …
BindBlob64Hide Binding Values To Prepared Statements …
BindBlobHide Binding Values To Prepared Statements …
BindDouble Binding Values To Prepared Statements …
BindInt Binding Values To Prepared Statements …
BindInt64 Binding Values To Prepared Statements …
BindNull Binding Values To Prepared Statements …
BindParameterCount Number Of SQL Parameters …
BindParameterIndex Index Of A Parameter With A Given Name …
BindParameterName Name Of A Host Parameter …
BindPointer Binding Values To Prepared Statements …
BindText Bind a MkStringR Value To a Prepared Statement …
BindText64 Bind a MkStringR Value To a Prepared Statement …
BindText64Hide Binding Values To Prepared Statements …
BindTextHide Binding Values To Prepared Statements …
BindValue Binding Values To Prepared Statements …
BindZeroblob Binding Values To Prepared Statements …
BindZeroblob64

Binding Values To Prepared Statements …

Sq3StmtC COLUMN

ColumnBlob Result a MkBinaryR Value From A Query.
ColumnBlobHide Result Values From A Query …
ColumnBytes Result Values From A Query …
ColumnCount Number Of Columns In A Result Set …
ColumnDecltype Declared Datatype Of A Query Result …
ColumnDouble Result Values From A Query …
ColumnInt Result Values From A Query …
ColumnInt64 Result Values From A Query …
ColumnName Column Names In A Result Set …
ColumnText Result a MkStringR Value From A Query.
ColumnTextHide Result Values From A Query …
ColumnType Result Values From A Query …
ColumnValue

Result Values From A Query …

Sq3StmtC INFO

Busy Determine If A Prepared Statement Has Been Reset …
DataCount Number of columns in a result set …
DbHandle Find The Database Handle Of A Prepared Statement …
IsExplain Query The EXPLAIN Setting For A Prepared Statement …
Log log the val
Readonly Determine If An SQL Statement Writes The Database …
Status

Prepared Statement Status …

Sq3StmtC SQL

ExpandedSql Retrieving Statement SQL …
GetPzTail return the non compiled sql-statement from Sq3StmtPrepareV2 and Sq3StmtPrepareV3
Sql

Retrieving Statement SQL …

Sq3StmtC MISC

NextStmt Find the next prepared statement …
ClearBindings Reset All Bindings On A Prepared Statement …
Explain Change The EXPLAIN Setting For A Prepared Statement …
Reset Reset A Prepared Statement Object …
Step

Evaluate An SQL Statement …

Sq3StmtC DETAIL

C-API: Sq3StmtC_C_API - Sq3StmtC - the class known as sq3stmt or Statement defined by Sq3StmtS

Struct to represent the data of the Sq3StmtC

Prepared Statement Object …

An instance of this object represents a single SQL statement that has been compiled into binary form and is ready to be evaluated.

Think of each SQL statement as a separate computer program. The original SQL text is source code. A prepared statement object is the compiled object code. All SQL must be converted into a prepared statement before it can be run.

The life-cycle of a prepared statement object usually goes like this:

  1. Create the prepared statement object using Sq3StmtPrepareV2 ().
  2. Bind values to parameters using the Sq3StmtBindValue*() interfaces.
  3. Run the SQL by calling Sq3StmtStep () one or more times.
  4. Reset the prepared statement using Sq3StmtReset () then go back to step 2. Do this zero or more times.
  5. Destroy the object using Sq3StmtFinalize ().

Reference code from sqlite3:

typedef struct sqlite3_stmt sqlite3_stmt;

Sq3StmtC CLASS

NAVI: top, up

Sq3StmtC CLASS DEFINE

Stmt cast a unknown-object into an Sq3StmtS pointer or NULL if not possible
StmtCheck check Sq3StmtS -> MkObjectS::signature
StmtCheckO check Sq3StmtS -> MkObjectS::signature
StmtN

(const) cast a unknown-object into an Sq3StmtS pointer or NULL if not possible

Sq3StmtC CLASS EXPORT

HandleResolve Handle-Resolve-Slot - return a Sq3StmtC from netHdl or MK_NULL if invalid…
HandleGet

Handle-Get-Slot - returns a export-hdl to the Sq3StmtC useable for external storage

Sq3StmtC CLASS INTROSPECTION

Instances get head-instance from linked-list of Sq3StmtS type …
Next get next instance from linked-list of Sq3StmtS type
Prev

get previous instance from linked-list of Sq3StmtS type

Sq3StmtC CLASS MISC

GetNull

Null-Slot - return a Sq3StmtC typed NULL instance …

Sq3StmtC CLASS DETAILS

C-API: Sq3StmtC_Class_C_API - Sq3StmtC - define the class …

Sq3StmtC CLASS DEFINE

C-API: Sq3StmtC_Class_Define_C_API - Sq3StmtC - low level definition, access and cast …

(static,hide) SQ3_STMT Sq3Stmt(MK_MNG mng)

top cast a unknown-object into an Sq3StmtS pointer or NULL if not possible → API: Sq3Stmt

(static,hide) MK_BOOL Sq3StmtCheck(MK_MNGN mng)

top check Sq3StmtS -> MkObjectS::signature … → API: Sq3StmtCheck

Returns
TRUE on valid stmt and FALSE an invalid stmt

(static,hide) MK_BOOL Sq3StmtCheckO(MK_OBJN obj)

top check Sq3StmtS -> MkObjectS::signature … → API: Sq3StmtCheckO

Returns
TRUE on valid stmt and FALSE an invalid stmt

(static,hide) SQ3_STMTN Sq3StmtN(MK_MNGN mng)

top (const) cast a unknown-object into an Sq3StmtS pointer or NULL if not possible → API: Sq3StmtN

Sq3StmtC CLASS EXPORT

Sq3StmtC - Export class functions …

(static,runtime) SQ3_STMT Sq3StmtHandleResolve(MK_HDL const netHdl)

top Handle-Resolve-Slot - return a Sq3StmtC from netHdl or MK_NULL if invalid… → API: Sq3StmtHandleResolve_RT

The Sq3StmtHandleResolve undo the Sq3StmtHandleGet and is intended to export a unique identifer into external code not belonging to the Programming-Language-Micro-Kernel (PLMK).

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]netHdlhandle former exported with Sq3StmtHandleGet
Returns
the required handle or MK_NULL if netHdl is invalid

(runtime) MK_HDL Sq3StmtHandleGet(SQ3_STMT const stmt)

top Handle-Get-Slot - returns a export-hdl to the Sq3StmtC useable for external storage → API: Sq3StmtHandleGet_RT

The export-hdl is a reference to an instance that can be stored in software and converted back into an instance using the Sq3StmtHandleResolve.

The export-hdl is only valid until the Programming-Language-Micro-Kernel (PLMK) ends.

example: The export-hdl is used in rpc to identify an object across the network.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]stmtProgramming-Language-Micro-Kernel (PLMK) instance from sqlite3_stmt
Returns
the required export-hdl

Sq3StmtC CLASS INTROSPECTION

Sq3StmtC - Introspection class functions …

(static,runtime) SQ3_STMT Sq3StmtInstances()

top get head-instance from linked-list of Sq3StmtS type … → API: Sq3StmtInstances_RT

The head-instance is the last instance created.

SQ3_STMT Sq3StmtNext(SQ3_STMT const stmt)

top get next instance from linked-list of Sq3StmtS type → API: Sq3StmtNext

SQ3_STMT Sq3StmtPrev(SQ3_STMT const stmt)

top get previous instance from linked-list of Sq3StmtS type → API: Sq3StmtPrev

Sq3StmtC CLASS MISC

Sq3StmtC - Misc class functions …

(static) SQ3_STMT Sq3StmtGetNull()

top Null-Slot - return a Sq3StmtC typed NULL instance … → API: Sq3StmtGetNull

Sq3StmtC TOR

C-API: Sq3StmtC_TOR_C_API - Sq3StmtC - various functions to create, initialize and destroy …

(constructor,static) enum MkErrorE Sq3StmtPrepareV2(SQ3_LITE db, MkStringR zSql, SQ3_STMT *ppStmt)

top Compiling An SQL Statement … → API: Sq3StmtPrepareV2

This is an enhanced version of Sq3StmtPrepareV2Hide using the Programming-Language-Micro-Kernel (PLMK) definition of a zSql called MkStringR. The last argument pzTail is stored into the Sq3StmtC class Sq3StmtS::pzTail attribute and can be accessed with Sq3StmtGetPzTail.

Parameters
[in]dbthe Sq3LiteC instance to work on a database
[in]zSqlThe statement to be compiled, encoded as UTF-8
[out]ppStmtThe new Sq3StmtC instance
Returns
The MkErrorE status from the DEFAULT MkErrorC in MkRuntimeS::error_mk

Sq3StmtPrepareV2Hide : documentation

Compiling An SQL Statement …
To execute an SQL statement, it must first be compiled into a byte-code program using one of these routines. Or, in other words, these routines are constructors for the prepared statement object.
The preferred routine to use is Sq3StmtPrepareV2 (). The sqlite3_prepare () interface is legacy and should be avoided. Sq3StmtPrepareV3 () has an extra "prepFlags" option that is used for special purposes.
The use of the UTF-8 interfaces is preferred, as SQLite currently does all parsing using UTF-8. The UTF-16 interfaces are provided as a convenience. The UTF-16 interfaces work by converting the input text into UTF-8, then invoking the corresponding UTF-8 interface.
The first argument, "db", is a database connection obtained from a prior successful call to sqlite3_open (), Sq3LiteOpenV2 () or sqlite3_open16 (). The database connection must not have been closed.
The second argument, "zSql", is the statement to be compiled, encoded as either UTF-8 or UTF-16. The sqlite3_prepare(), Sq3StmtPrepareV2(), and Sq3StmtPrepareV3() interfaces use UTF-8, and sqlite3_prepare16(), sqlite3_prepare16_v2(), and sqlite3_prepare16_v3() use UTF-16.
If the nByte argument is negative, then zSql is read up to the first zero terminator. If nByte is positive, then it is the number of bytes read from zSql. If nByte is zero, then no prepared statement is generated. If the caller knows that the supplied string is nul-terminated, then there is a small performance advantage to passing an nByte parameter that is the number of bytes in the input string including the nul-terminator.
If pzTail is not NULL then *pzTail is made to point to the first byte past the end of the first SQL statement in zSql. These routines only compile the first statement in zSql, so *pzTail is left pointing to what remains uncompiled.
ppStmt is left pointing to a compiled prepared statement that can be executed using Sq3StmtStep (). If there is an error, *ppStmt is set to NULL. If the input text contains no SQL (if the input is an empty string or a comment) then *ppStmt is set to NULL. The calling procedure is responsible for deleting the compiled SQL statement using Sq3StmtFinalize () after it has finished with it. ppStmt may not be NULL.
On success, the sqlite3_prepare() family of routines return SQ3_RESULT_OK; otherwise an error code is returned.
The Sq3StmtPrepareV2(), Sq3StmtPrepareV3(), sqlite3_prepare16_v2(), and sqlite3_prepare16_v3() interfaces are recommended for all new programs. The older interfaces (sqlite3_prepare() and sqlite3_prepare16()) are retained for backwards compatibility, but their use is discouraged. In the "vX" interfaces, the prepared statement that is returned (the Sq3StmtC object) contains a copy of the original SQL text. This causes the Sq3StmtStep () interface to behave differently in three ways:
  1. If the database schema changes, instead of returning SQ3_RESULT_SCHEMA as it always used to do, Sq3StmtStep () will automatically recompile the SQL statement and try to run it again. As many as SQLITE_MAX_SCHEMA_RETRY retries will occur before Sq3StmtStep() gives up and returns an error.

  2. When an error occurs, Sq3StmtStep () will return one of the detailed error codes or extended error codes. The legacy behavior was that Sq3StmtStep () would only return a generic SQ3_RESULT_ERROR result code and the application would have to make a second call to Sq3StmtReset () in order to find the underlying cause of the problem. With the "v2" prepare interfaces, the underlying reason for the error is returned immediately.

  3. If the specific value bound to a host parameter in the WHERE clause might influence the choice of query plan for a statement, then the statement will be automatically recompiled, as if there had been a schema change, on the first Sq3StmtStep () call following any change to the bindings of that parameter. The specific value of a WHERE-clause parameter might influence the choice of query plan if the parameter is the left-hand side of a LIKE or GLOB operator or if the parameter is compared to an indexed column and the SQLITE_ENABLE_STAT4 compile-time option is enabled.
Sq3StmtPrepareV3() differs from Sq3StmtPrepareV2() only in having the extra prepFlags parameter, which is a bit array consisting of zero or more of the SQ3_PREPARE_* flags. The Sq3StmtPrepareV2() interface works exactly the same as Sq3StmtPrepareV3() with a zero prepFlags parameter.
Reference code from sqlite3:
sqlite3 *db, // Database handle
const char *zSql, // SQL statement, UTF-8 encoded
int nByte, // Maximum length of zSql in bytes.
sqlite3_stmt **ppStmt, // OUT: Statement handle
const char **pzTail // OUT: Pointer to unused portion of zSql
);
sqlite3 *db, // Database handle
const char *zSql, // SQL statement, UTF-8 encoded
int nByte, // Maximum length of zSql in bytes.
sqlite3_stmt **ppStmt, // OUT: Statement handle
const char **pzTail // OUT: Pointer to unused portion of zSql
);
sqlite3 *db, // Database handle
const char *zSql, // SQL statement, UTF-8 encoded
int nByte, // Maximum length of zSql in bytes.
unsigned int prepFlags, // Zero or more SQLITE_PREPARE_ flags
sqlite3_stmt **ppStmt, // OUT: Statement handle
const char **pzTail // OUT: Pointer to unused portion of zSql
);
sqlite3 *db, // Database handle
const void *zSql, // SQL statement, UTF-16 encoded
int nByte, // Maximum length of zSql in bytes.
sqlite3_stmt **ppStmt, // OUT: Statement handle
const void **pzTail // OUT: Pointer to unused portion of zSql
);
sqlite3 *db, // Database handle
const void *zSql, // SQL statement, UTF-16 encoded
int nByte, // Maximum length of zSql in bytes.
sqlite3_stmt **ppStmt, // OUT: Statement handle
const void **pzTail // OUT: Pointer to unused portion of zSql
);
sqlite3 *db, // Database handle
const void *zSql, // SQL statement, UTF-16 encoded
int nByte, // Maximum length of zSql in bytes.
unsigned int prepFlags, // Zero or more SQLITE_PREPARE_ flags
sqlite3_stmt **ppStmt, // OUT: Statement handle
const void **pzTail // OUT: Pointer to unused portion of zSql
);

(constructor,static,hide) enum MkErrorE Sq3StmtPrepareV2Hide(SQ3_LITE db, MK_STRN zSql, MK_I32 nByte, SQ3_STMT *ppStmt, MK_STRN *pzTail)

top Compiling An SQL Statement … → API: Sq3StmtPrepareV2Hide

To execute an SQL statement, it must first be compiled into a byte-code program using one of these routines. Or, in other words, these routines are constructors for the prepared statement object.

The preferred routine to use is Sq3StmtPrepareV2 (). The sqlite3_prepare () interface is legacy and should be avoided. Sq3StmtPrepareV3 () has an extra "prepFlags" option that is used for special purposes.

The use of the UTF-8 interfaces is preferred, as SQLite currently does all parsing using UTF-8. The UTF-16 interfaces are provided as a convenience. The UTF-16 interfaces work by converting the input text into UTF-8, then invoking the corresponding UTF-8 interface.

The first argument, "db", is a database connection obtained from a prior successful call to sqlite3_open (), Sq3LiteOpenV2 () or sqlite3_open16 (). The database connection must not have been closed.

The second argument, "zSql", is the statement to be compiled, encoded as either UTF-8 or UTF-16. The sqlite3_prepare(), Sq3StmtPrepareV2(), and Sq3StmtPrepareV3() interfaces use UTF-8, and sqlite3_prepare16(), sqlite3_prepare16_v2(), and sqlite3_prepare16_v3() use UTF-16.

If the nByte argument is negative, then zSql is read up to the first zero terminator. If nByte is positive, then it is the number of bytes read from zSql. If nByte is zero, then no prepared statement is generated. If the caller knows that the supplied string is nul-terminated, then there is a small performance advantage to passing an nByte parameter that is the number of bytes in the input string including the nul-terminator.

If pzTail is not NULL then *pzTail is made to point to the first byte past the end of the first SQL statement in zSql. These routines only compile the first statement in zSql, so *pzTail is left pointing to what remains uncompiled.

ppStmt is left pointing to a compiled prepared statement that can be executed using Sq3StmtStep (). If there is an error, *ppStmt is set to NULL. If the input text contains no SQL (if the input is an empty string or a comment) then *ppStmt is set to NULL. The calling procedure is responsible for deleting the compiled SQL statement using Sq3StmtFinalize () after it has finished with it. ppStmt may not be NULL.

On success, the sqlite3_prepare() family of routines return SQ3_RESULT_OK; otherwise an error code is returned.

The Sq3StmtPrepareV2(), Sq3StmtPrepareV3(), sqlite3_prepare16_v2(), and sqlite3_prepare16_v3() interfaces are recommended for all new programs. The older interfaces (sqlite3_prepare() and sqlite3_prepare16()) are retained for backwards compatibility, but their use is discouraged. In the "vX" interfaces, the prepared statement that is returned (the Sq3StmtC object) contains a copy of the original SQL text. This causes the Sq3StmtStep () interface to behave differently in three ways:

  1. If the database schema changes, instead of returning SQ3_RESULT_SCHEMA as it always used to do, Sq3StmtStep () will automatically recompile the SQL statement and try to run it again. As many as SQLITE_MAX_SCHEMA_RETRY retries will occur before Sq3StmtStep() gives up and returns an error.

  2. When an error occurs, Sq3StmtStep () will return one of the detailed error codes or extended error codes. The legacy behavior was that Sq3StmtStep () would only return a generic SQ3_RESULT_ERROR result code and the application would have to make a second call to Sq3StmtReset () in order to find the underlying cause of the problem. With the "v2" prepare interfaces, the underlying reason for the error is returned immediately.

  3. If the specific value bound to a host parameter in the WHERE clause might influence the choice of query plan for a statement, then the statement will be automatically recompiled, as if there had been a schema change, on the first Sq3StmtStep () call following any change to the bindings of that parameter. The specific value of a WHERE-clause parameter might influence the choice of query plan if the parameter is the left-hand side of a LIKE or GLOB operator or if the parameter is compared to an indexed column and the SQLITE_ENABLE_STAT4 compile-time option is enabled.

Sq3StmtPrepareV3() differs from Sq3StmtPrepareV2() only in having the extra prepFlags parameter, which is a bit array consisting of zero or more of the SQ3_PREPARE_* flags. The Sq3StmtPrepareV2() interface works exactly the same as Sq3StmtPrepareV3() with a zero prepFlags parameter.

Reference code from sqlite3:

sqlite3 *db, // Database handle
const char *zSql, // SQL statement, UTF-8 encoded
int nByte, // Maximum length of zSql in bytes.
sqlite3_stmt **ppStmt, // OUT: Statement handle
const char **pzTail // OUT: Pointer to unused portion of zSql
);
sqlite3 *db, // Database handle
const char *zSql, // SQL statement, UTF-8 encoded
int nByte, // Maximum length of zSql in bytes.
sqlite3_stmt **ppStmt, // OUT: Statement handle
const char **pzTail // OUT: Pointer to unused portion of zSql
);
sqlite3 *db, // Database handle
const char *zSql, // SQL statement, UTF-8 encoded
int nByte, // Maximum length of zSql in bytes.
unsigned int prepFlags, // Zero or more SQLITE_PREPARE_ flags
sqlite3_stmt **ppStmt, // OUT: Statement handle
const char **pzTail // OUT: Pointer to unused portion of zSql
);
sqlite3 *db, // Database handle
const void *zSql, // SQL statement, UTF-16 encoded
int nByte, // Maximum length of zSql in bytes.
sqlite3_stmt **ppStmt, // OUT: Statement handle
const void **pzTail // OUT: Pointer to unused portion of zSql
);
sqlite3 *db, // Database handle
const void *zSql, // SQL statement, UTF-16 encoded
int nByte, // Maximum length of zSql in bytes.
sqlite3_stmt **ppStmt, // OUT: Statement handle
const void **pzTail // OUT: Pointer to unused portion of zSql
);
sqlite3 *db, // Database handle
const void *zSql, // SQL statement, UTF-16 encoded
int nByte, // Maximum length of zSql in bytes.
unsigned int prepFlags, // Zero or more SQLITE_PREPARE_ flags
sqlite3_stmt **ppStmt, // OUT: Statement handle
const void **pzTail // OUT: Pointer to unused portion of zSql
);

(constructor,static) enum MkErrorE Sq3StmtPrepareV3(SQ3_LITE db, MkStringR zSql, enum Sq3PrepareEF prepFlags, SQ3_STMT *ppStmt)

top Compiling An SQL Statement … → API: Sq3StmtPrepareV3

This is an enhanced version of Sq3StmtPrepareV2Hide using the Programming-Language-Micro-Kernel (PLMK) definition of a zSql called MkStringR. The last argument pzTail is stored into the Sq3StmtC class Sq3StmtS::pzTail attribute and can be accessed with Sq3StmtGetPzTail.

Parameters
[in]dbthe Sq3LiteC instance to work on a database
[in]zSqlThe statement to be compiled, encoded as UTF-8
[in]prepFlagsIs a bit array consisting of zero or more of the SQ3_PREPARE_* flags.
[out]ppStmtThe new Sq3StmtC instance
Returns
The MkErrorE status from the DEFAULT MkErrorC in MkRuntimeS::error_mk

Sq3StmtPrepareV3Hide : documentation

Compiling An SQL Statement …

(constructor,static,hide) enum MkErrorE Sq3StmtPrepareV3Hide(SQ3_LITE db, MK_STRN zSql, MK_I32 nByte, enum Sq3PrepareEF prepFlags, SQ3_STMT *ppStmt, MK_STRN *pzTail)

top Compiling An SQL Statement … → API: Sq3StmtPrepareV3Hide

read more at 'Sq3StmtPrepareV2'

(destructor) enum MkErrorE Sq3StmtFinalize(SQ3_STMT pStmt)

top Destroy A Prepared Statement Object … → API: Sq3StmtFinalize

The Sq3StmtFinalize() function is called to delete a prepared statement. If the most recent evaluation of the statement encountered no errors or if the statement is never been evaluated, then Sq3StmtFinalize() returns SQ3_RESULT_OK. If the most recent evaluation of statement S failed, then Sq3StmtFinalize(S) returns the appropriate error code or extended error code.

The Sq3StmtFinalize(S) routine can be called at any point during the life cycle of prepared statement S: before statement S is ever evaluated, after one or more calls to Sq3StmtReset (), or after any call to Sq3StmtStep () regardless of whether or not the statement has completed execution.

Invoking Sq3StmtFinalize() on a NULL pointer is a harmless no-op.

The application must finalize every prepared statement in order to avoid resource leaks. It is a grievous error for the application to try to use a prepared statement after it has been finalized. Any use of a prepared statement after it has been finalized can result in undefined and undesirable behavior such as segfaults and heap corruption.

Reference code from sqlite3:

SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt)

Sq3StmtC BIND

C-API: Sq3StmtC_Bind_C_API - Sq3StmtC - bind a type

(runtime) enum MkErrorE Sq3StmtBindBlob(SQ3_STMT sq3stmt, MK_I32 pos, MkBinaryR blob)

top Bind a MkBinaryR Value To a Prepared Statement … → API: Sq3StmtBindBlob_RT

This is an enhanced version of Sq3StmtBindBlob64Hide using the Programming-Language-Micro-Kernel (PLMK) definition of a blob called MkBinaryR and the default value for the cb as SQLITE_TRANSIENT.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]sq3stmtthe Sq3StmtC instance to work on a statement
[in]posThe index of the SQL parameter to be set, the leftmost SQL parameter has an index of 1.
[in]blobThe MkBinaryR value to be bind.
Returns
The MkErrorE status from the DEFAULT MkErrorC in MkRuntimeS::error_mk

Sq3StmtBindBlobHide : documentation

Binding Values To Prepared Statements …
In the SQL statement text input to Sq3StmtPrepareV2 () and its variants, literals may be replaced by a parameter that matches one of following templates:
  • ?
  • ?NNN
  • :VVV
  • @amp;VVV
  • $VVV
In the templates above, NNN represents an integer literal, and VVV represents an alphanumeric identifier. The values of these parameters (also called "host parameter names" or "SQL parameters") can be set using the Sq3StmtBindValue*() routines defined here.
The first argument to the Sq3StmtBindValue*() routines is always a pointer to the Sq3StmtC object returned from Sq3StmtPrepareV2 () or its variants.
The second argument is the index of the SQL parameter to be set. The leftmost SQL parameter has an index of 1. When the same named SQL parameter is used more than once, second and subsequent occurrences have the same index as the first occurrence. The index for named parameters can be looked up using the Sq3StmtBindParameterIndex () API if desired. The index for "?NNN" parameters is the value of NNN. The NNN value must be between 1 and the Sq3LiteLimit () parameter SQ3_LIMIT_VARIABLE_NUMBER (default value: 32766).
The third argument is the value to bind to the parameter. If the third parameter to Sq3StmtBindText() or sqlite3_bind_text16() or Sq3StmtBindBlob() is a NULL pointer then the fourth parameter is ignored and the end result is the same as Sq3StmtBindNull(). If the third parameter to Sq3StmtBindText() is not NULL, then it should be a pointer to well-formed UTF8 text. If the third parameter to sqlite3_bind_text16() is not NULL, then it should be a pointer to well-formed UTF16 text. If the third parameter to Sq3StmtBindText64() is not NULL, then it should be a pointer to a well-formed unicode string that is either UTF8 if the sixth parameter is SQ3_TEXT_UTF8, or UTF16 otherwise.
The byte-order of UTF16 input text is determined by the byte-order mark (BOM, U+FEFF) found in first character, which is removed, or in the absence of a BOM the byte order is the native byte order of the host machine for sqlite3_bind_text16() or the byte order specified in the 6th parameter for Sq3StmtBindText64(). If UTF16 input text contains invalid unicode characters, then SQLite might change those invalid characters into the unicode replacement character: U+FFFD.
In those routines that have a fourth argument, its value is the number of bytes in the parameter. To be clear: the value is the number of bytes in the value, not the number of characters. If the fourth parameter to Sq3StmtBindText() or sqlite3_bind_text16() is negative, then the length of the string is the number of bytes up to the first zero terminator. If the fourth parameter to Sq3StmtBindBlob() is negative, then the behavior is undefined. If a non-negative fourth parameter is provided to Sq3StmtBindText() or sqlite3_bind_text16() or Sq3StmtBindText64() then that parameter must be the byte offset where the NUL terminator would occur assuming the string were NUL terminated. If any NUL characters occurs at byte offsets less than the value of the fourth parameter then the resulting string value will contain embedded NULs. The result of expressions involving strings with embedded NULs is undefined.
The fifth argument to the BLOB and string binding interfaces controls or indicates the lifetime of the object referenced by the third parameter. These three options exist: (1) A destructor to dispose of the BLOB or string after SQLite has finished with it may be passed. It is called to dispose of the BLOB or string even if the call to the bind API fails, except the destructor is not called if the third parameter is a NULL pointer or the fourth parameter is negative. (2) The special constant, SQLITE_STATIC, may be passed to indicate that the application remains responsible for disposing of the object. In this case, the object and the provided pointer to it must remain valid until either the prepared statement is finalized or the same SQL parameter is bound to something else, whichever occurs sooner. (3) The constant, SQLITE_TRANSIENT, may be passed to indicate that the object is to be copied prior to the return from Sq3StmtBindValue*(). The object and pointer to it must remain valid until then. SQLite will then manage the lifetime of its private copy.
The sixth argument to Sq3StmtBindText64() must be one of SQ3_TEXT_UTF8, SQ3_TEXT_UTF16, SQ3_TEXT_UTF16BE, or SQ3_TEXT_UTF16LE to specify the encoding of the text in the third parameter. If the sixth argument to Sq3StmtBindText64() is not one of the allowed values shown above, or if the text encoding is different from the encoding specified by the sixth parameter, then the behavior is undefined.
The Sq3StmtBindZeroblob() routine binds a BLOB of length N that is filled with zeroes. A zeroblob uses a fixed amount of memory (just an integer to hold its size) while it is being processed. Zeroblobs are intended to serve as placeholders for BLOBs whose content is later written using incremental BLOB I/O routines. A negative value for the zeroblob results in a zero-length BLOB.
The Sq3StmtBindPointer(S,I,P,T,D) routine causes the I-th parameter in prepared statement S to have an SQL value of NULL, but to also be associated with the pointer P of type T. D is either a NULL pointer or a pointer to a destructor function for P. SQLite will invoke the destructor D with a single argument of P when it is finished using P. The T parameter should be a static string, preferably a string literal. The Sq3StmtBindPointer() routine is part of the pointer passing interface added for SQLite 3.20.0.
If any of the Sq3StmtBindValue*() routines are called with a NULL pointer for the prepared statement or with a prepared statement for which Sq3StmtStep () has been called more recently than Sq3StmtReset (), then the call will return SQ3_RESULT_MISUSE. If any Sq3StmtBindValue() routine is passed a prepared statement that has been finalized, the result is undefined and probably harmful.
Bindings are not cleared by the Sq3StmtReset () routine. Unbound parameters are interpreted as NULL.
The Sq3StmtBindValue* routines return SQ3_RESULT_OK on success or an error code if anything goes wrong. SQ3_RESULT_TOOBIG might be returned if the size of a string or BLOB exceeds limits imposed by Sq3LiteLimit(SQ3_LIMIT_LENGTH) or SQLITE_MAX_LENGTH. SQ3_RESULT_RANGE is returned if the parameter index is out of range. SQ3_RESULT_NOMEM is returned if malloc() fails.
Reference code from sqlite3:
SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
void(*)(void*));
SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
void(*)(void*), unsigned char encoding);
SQLITE_API int sqlite3_bind_pointer(sqlite3_stmt*, int, void*, const char*,void(*)(void*));
SQLITE_API int sqlite3_bind_pointer(sqlite3_stmt *, int, void *, const char *, void(*)(void *))
SQLITE_API int sqlite3_bind_blob64(sqlite3_stmt *, int, const void *, sqlite3_uint64, void(*)(void *))
SQLITE_API int sqlite3_bind_null(sqlite3_stmt *, int)
SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt *, int, sqlite3_uint64)
SQLITE_API int sqlite3_bind_blob(sqlite3_stmt *, int, const void *, int n, void(*)(void *))
SQLITE_API int sqlite3_bind_text16(sqlite3_stmt *, int, const void *, int, void(*)(void *))
SQLITE_API int sqlite3_bind_text(sqlite3_stmt *, int, const char *, int, void(*)(void *))
SQLITE_API int sqlite3_bind_double(sqlite3_stmt *, int, double)
SQLITE_API int sqlite3_bind_value(sqlite3_stmt *, int, const sqlite3_value *)
SQLITE_API int sqlite3_bind_text64(sqlite3_stmt *, int, const char *, sqlite3_uint64, void(*)(void *), unsigned char encoding)
SQLITE_API int sqlite3_bind_int(sqlite3_stmt *, int, int)
SQLITE_API int sqlite3_bind_int64(sqlite3_stmt *, int, sqlite3_int64)
SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt *, int, int n)

(runtime,hide) enum MkErrorE Sq3StmtBindBlob64(SQ3_STMT sq3stmt, MK_I32 pos, MkBinaryR blob)

top Bind a MkBinaryR Value To a Prepared Statement … → API: Sq3StmtBindBlob64_RT

This is an enhanced version of Sq3StmtBindBlob64Hide using the Programming-Language-Micro-Kernel (PLMK) definition of a blob called MkBinaryR and the default value for the cb as SQLITE_TRANSIENT.

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]sq3stmtthe Sq3StmtC instance to work on a statement
[in]posThe index of the SQL parameter to be set, the leftmost SQL parameter has an index of 1.
[in]blobThe MkBinaryR value to be bind.
Returns
The MkErrorE status from the DEFAULT MkErrorC in MkRuntimeS::error_mk

Sq3StmtBindBlob64Hide : documentation

Binding Values To Prepared Statements …

(hide) enum MkErrorE Sq3StmtBindBlob64Hide(SQ3_STMT sq3stmt, MK_I32 pos, MK_PTRN blob, MK_I64 len, Sq3Fupu_Sq3StmtBindBlob64Hide_cb cb)

top Binding Values To Prepared Statements … → API: Sq3StmtBindBlob64Hide

read more at 'Sq3StmtBindBlob'

(hide) enum MkErrorE Sq3StmtBindBlobHide(SQ3_STMT sq3stmt, MK_I32 pos, MK_PTRN blob, MK_I32 len, Sq3Fupu_Sq3StmtBindBlobHide_cb cb)

top Binding Values To Prepared Statements … → API: Sq3StmtBindBlobHide

In the SQL statement text input to Sq3StmtPrepareV2 () and its variants, literals may be replaced by a parameter that matches one of following templates:

  • ?
  • ?NNN
  • :VVV
  • @amp;VVV
  • $VVV

In the templates above, NNN represents an integer literal, and VVV represents an alphanumeric identifier. The values of these parameters (also called "host parameter names" or "SQL parameters") can be set using the Sq3StmtBindValue*() routines defined here.

The first argument to the Sq3StmtBindValue*() routines is always a pointer to the Sq3StmtC object returned from Sq3StmtPrepareV2 () or its variants.

The second argument is the index of the SQL parameter to be set. The leftmost SQL parameter has an index of 1. When the same named SQL parameter is used more than once, second and subsequent occurrences have the same index as the first occurrence. The index for named parameters can be looked up using the Sq3StmtBindParameterIndex () API if desired. The index for "?NNN" parameters is the value of NNN. The NNN value must be between 1 and the Sq3LiteLimit () parameter SQ3_LIMIT_VARIABLE_NUMBER (default value: 32766).

The third argument is the value to bind to the parameter. If the third parameter to Sq3StmtBindText() or sqlite3_bind_text16() or Sq3StmtBindBlob() is a NULL pointer then the fourth parameter is ignored and the end result is the same as Sq3StmtBindNull(). If the third parameter to Sq3StmtBindText() is not NULL, then it should be a pointer to well-formed UTF8 text. If the third parameter to sqlite3_bind_text16() is not NULL, then it should be a pointer to well-formed UTF16 text. If the third parameter to Sq3StmtBindText64() is not NULL, then it should be a pointer to a well-formed unicode string that is either UTF8 if the sixth parameter is SQ3_TEXT_UTF8, or UTF16 otherwise.

The byte-order of UTF16 input text is determined by the byte-order mark (BOM, U+FEFF) found in first character, which is removed, or in the absence of a BOM the byte order is the native byte order of the host machine for