### Xsqlite3changeset_start Source: https://pkg.go.dev/modernc.org/sqlite/lib Starts a changeset iterator. ```APIDOC ## Xsqlite3changeset_start ### Description Starts a changeset iterator. ### Signature func Xsqlite3changeset_start(tls *libc.TLS, pp uintptr, nChangeset int32, pChangeset uintptr) (r int32) ``` -------------------------------- ### F Get Rw Hint Constant Source: https://pkg.go.dev/modernc.org/sqlite/lib File control operation constant to get read-write hint. ```go const F_GET_RW_HINT = 1035 ``` -------------------------------- ### Xsqlite3changeset_start_v2 Source: https://pkg.go.dev/modernc.org/sqlite/lib Starts a changeset iterator with version 2. ```APIDOC ## Xsqlite3changeset_start_v2 ### Description Starts a changeset iterator with version 2. ### Signature func Xsqlite3changeset_start_v2(tls *libc.TLS, pp uintptr, nChangeset int32, pChangeset uintptr, flags int32) (r int32) ``` -------------------------------- ### F Get File Rw Hint Constant Source: https://pkg.go.dev/modernc.org/sqlite/lib File control operation constant to get file read-write hint. ```go const F_GET_FILE_RW_HINT = 1037 ``` -------------------------------- ### Xsqlite3changeset_start_strm Source: https://pkg.go.dev/modernc.org/sqlite/lib Starts a changeset iterator from a stream. ```APIDOC ## Xsqlite3changeset_start_strm ### Description Starts a changeset iterator from a stream. ### Signature func Xsqlite3changeset_start_strm(tls *libc.TLS, pp uintptr, __ccgo_fp_xInput uintptr, pIn uintptr) (r int32) ``` -------------------------------- ### Xsqlite3changeset_start_v2_strm Source: https://pkg.go.dev/modernc.org/sqlite/lib Starts a changeset iterator from a stream with version 2. ```APIDOC ## Xsqlite3changeset_start_v2_strm ### Description Starts a changeset iterator from a stream with version 2. ### Signature func Xsqlite3changeset_start_v2_strm(tls *libc.TLS, pp uintptr, __ccgo_fp_xInput uintptr, pIn uintptr, flags int32) (r int32) ``` -------------------------------- ### Start Streaming Changeset Iterator - Go Source: https://pkg.go.dev/modernc.org/sqlite/lib A streaming version of `sqlite3changeset_start` for iterating through changeset contents. ```go func Xsqlite3changeset_start_strm(tls *libc.TLS, pp uintptr, __ccgo_fp_xInput uintptr, pIn uintptr) (r int32) ``` -------------------------------- ### Get the next NPY token Source: https://pkg.go.dev/modernc.org/sqlite/vec Parses and returns the next token from a given byte range. Requires start and end pointers for the data, and an output pointer for the token. ```go func Xnpy_token_next(tls *libc.TLS, start uintptr, end uintptr, out uintptr) (r int32) ``` -------------------------------- ### C Documentation for fts5SetupPrefixIter Source: https://pkg.go.dev/modernc.org/sqlite/lib Comment explaining the context object passed to fts5VisitEntries. ```c /* ** Context object passed by fts5SetupPrefixIter() to fts5VisitEntries(). */ ``` -------------------------------- ### Start Streaming Changeset Iterator with Flags - Go Source: https://pkg.go.dev/modernc.org/sqlite/lib A streaming version of `sqlite3changeset_start_v2` for iterating through changeset contents with flags. ```go func Xsqlite3changeset_start_v2_strm(tls *libc.TLS, pp uintptr, __ccgo_fp_xInput uintptr, pIn uintptr, flags int32) (r int32) ``` -------------------------------- ### Accessing DBStatus via database/sql Source: https://pkg.go.dev/modernc.org/sqlite Example demonstrating how to access DBStatus through the database/sql Raw connection escape hatch to retrieve cache spill status. ```go err := sqlConn.Raw(func(dc any) error { cur, _, err := dc.(sqlite.DBStatus).Status(sqlite.DBStatusCacheSpill, false) if err != nil { return err } // use cur return nil }) ``` -------------------------------- ### Create a new SqlDb instance Source: https://pkg.go.dev/modernc.org/sqlite-bench/app Constructor for creating a new SqlDb, requiring a driver name and an existing database connection. ```go func NewSqlDb(driverName string, db *sql.DB) *SqlDb ``` -------------------------------- ### F Get Seals Constant Source: https://pkg.go.dev/modernc.org/sqlite/lib File control operation constant to get file seals. ```go const F_GET_SEALS = 1034 ``` -------------------------------- ### F Get Sig Constant Source: https://pkg.go.dev/modernc.org/sqlite/lib File control operation constant to get signal number. ```go const F_GETSIG = 11 ``` -------------------------------- ### Create a new Article Source: https://pkg.go.dev/modernc.org/sqlite-bench/app Constructor function for creating a new Article instance. ```go func NewArticle(id int, created time.Time, userId int, text string) Article ``` -------------------------------- ### Get SQLite Library Version String Source: https://pkg.go.dev/modernc.org/sqlite/lib Returns a pointer to the SQLite library version string. ```go func Xsqlite3_libversion(tls *libc.TLS) (r uintptr) ``` -------------------------------- ### F Get Own Constant Source: https://pkg.go.dev/modernc.org/sqlite/lib File control operation constant to get owner process ID. ```go const F_GETOWN = 9 ``` -------------------------------- ### Create a new User Source: https://pkg.go.dev/modernc.org/sqlite-bench/app Constructor function for creating a new User instance. ```go func NewUser(id int, created time.Time, email string, active bool) User ``` -------------------------------- ### Handle Module Arguments in Virtual Table Connect/Create Source: https://pkg.go.dev/modernc.org/sqlite The `args []string` passed to `Create/Connect` are configuration from `USING module(...)`. Your module can parse these arguments; they are not automatically treated as columns. ```go args []string ``` -------------------------------- ### F Get Lease Constant Source: https://pkg.go.dev/modernc.org/sqlite/lib File control operation constant to get file lease. ```go const F_GETLEASE = 1025 ``` -------------------------------- ### Xsqlite3_backup_init Source: https://pkg.go.dev/modernc.org/sqlite/lib Creates an sqlite3_backup process to copy database contents from a source to a destination. Returns a pointer to the new sqlite3_backup object on success, or NULL on failure. ```APIDOC ## func Xsqlite3_backup_init ### Description Create an sqlite3_backup process to copy the contents of zSrcDb from connection handle pSrcDb to zDestDb in pDestDb. If successful, return a pointer to the new sqlite3_backup object. If an error occurs, NULL is returned and an error code and error message stored in database handle pDestDb. ### Signature ```go func Xsqlite3_backup_init(tls *libc.TLS, pDestDb uintptr, zDestDb uintptr, pSrcDb uintptr, zSrcDb uintptr) (r uintptr) ``` ``` -------------------------------- ### F Get Fd Constant Source: https://pkg.go.dev/modernc.org/sqlite/lib File control operation constant to get file descriptor. ```go const F_GETFD = 1 ``` -------------------------------- ### Xsqlite3_backup_init Source: https://pkg.go.dev/modernc.org/sqlite/lib Initializes a backup operation. ```APIDOC ## func Xsqlite3_backup_init(tls *libc.TLS, pDestDb uintptr, zDestDb uintptr, pSrcDb uintptr, ...) (r uintptr) ### Description Initializes a backup operation from a source database to a destination database. Returns a backup handle. ### Signature func Xsqlite3_backup_init(tls *libc.TLS, pDestDb uintptr, zDestDb uintptr, pSrcDb uintptr, ...) (r uintptr) ``` -------------------------------- ### Initialize Array - Go Source: https://pkg.go.dev/modernc.org/sqlite/vec Initializes an array with a specified element size and capacity. Returns SQLITE_OK on success, or SQLITE_NOMEM on failure. ```go func Xarray_init(tls *libc.TLS, array uintptr, element_size Tsize_t, init_capacity Tsize_t) (r int32) ``` -------------------------------- ### F Get Pipe Sz Constant Source: https://pkg.go.dev/modernc.org/sqlite/lib File control operation constant to get pipe size. ```go const F_GETPIPE_SZ = 1032 ``` -------------------------------- ### F Get Own Ex Constant Source: https://pkg.go.dev/modernc.org/sqlite/lib File control operation constant for extended owner information. ```go const F_GETOWN_EX = 16 ``` -------------------------------- ### F Get Owner Uids Constant Source: https://pkg.go.dev/modernc.org/sqlite/lib File control operation constant to get owner UIDs. ```go const F_GETOWNER_UIDS = 17 ``` -------------------------------- ### Configuring Go Workspaces Source: https://pkg.go.dev/modernc.org/sqlite Instructs the Go build system to use the local modified libc and the current project directory. ```bash 0:jnml@e5-1650:~/src/modernc.org/sqlite$ go work use $(go env GOPATH)/src/modernc.org/libc 0:jnml@e5-1650:~/src/modernc.org/sqlite$ go work use . ``` -------------------------------- ### Prepare SQL Statement (v3) Source: https://pkg.go.dev/modernc.org/sqlite/lib Prepares an SQL statement with additional flags. Use this version when specific preparation behaviors are needed. ```go func Xsqlite3_prepare_v3(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, prepFlags uint32, ppStmt uintptr, pzTail uintptr) (r int32) ``` -------------------------------- ### F Get Lk Constant Source: https://pkg.go.dev/modernc.org/sqlite/lib File control operation constant to get file lock information. ```go const F_GETLK = 5 ``` -------------------------------- ### RegisterPageCache Source: https://pkg.go.dev/modernc.org/sqlite Installs a page cache for the SQLite driver. This must be called before the first sql.Open or driver.Open. ```APIDOC ## func RegisterPageCache ¶ added in v1.53.0 ### Description RegisterPageCache installs m as the process-global SQLite page cache via SQLITE_CONFIG_PCACHE2. It MUST be called before the first sql.Open or driver.Open in the program. ### Concurrency - Safe to call concurrently with itself and with other Register* entry points. - Blocks until any sql.Open calls currently in progress complete. - Once any connection has been opened, returns ErrPageCacheTooLate without mutating the global module slot. - Calling twice with the same module value is a no-op success. Calling twice with a different value returns ErrPageCacheConflict. - A failed first install is sticky: every subsequent Register call returns the same error. ``` -------------------------------- ### AT_SYMLINK_FOLLOW Constant Source: https://pkg.go.dev/modernc.org/sqlite/lib Flag to follow symbolic links. ```go const AT_SYMLINK_FOLLOW = 1024 ``` -------------------------------- ### F Get Fl Constant Source: https://pkg.go.dev/modernc.org/sqlite/lib File control operation constant to get file status flags. ```go const F_GETFL = 3 ``` -------------------------------- ### Prepare SQL Statement (v2) Source: https://pkg.go.dev/modernc.org/sqlite/lib Prepares an SQL statement for execution. Use this version for general statement preparation. ```go func Xsqlite3_prepare_v2(tls *libc.TLS, db uintptr, zSql uintptr, nBytes int32, ppStmt uintptr, pzTail uintptr) (r int32) ``` -------------------------------- ### Get Connection Limit Source: https://pkg.go.dev/modernc.org/sqlite Calls sqlite3_limit to get the current limit value for a connection. Use (*sql.DB).Conn() to obtain a sql.Conn. ```go func Limit(c *sql.Conn, id int, newVal int) (r int, err error) ``` -------------------------------- ### Running Benchmark Tests Source: https://pkg.go.dev/modernc.org/sqlite/benchmark Invoke benchmark tests using the standard Go testing command. Use flags to configure memory usage and repetition for stable results. ```bash go test -v . ``` -------------------------------- ### Xvec0_get_latest_chunk_rowid Source: https://pkg.go.dev/modernc.org/sqlite/vec Gets the rowid of the latest chunk. ```APIDOC ## Xvec0_get_latest_chunk_rowid ### Description Gets the rowid of the latest chunk. ### Parameters - **tls** (**libc.TLS*) - TLS pointer. - **p** (*uintptr*) - Pointer to the vec0 table. - **chunk_rowid** (*uintptr*) - Pointer to store the chunk rowid. - **partitionKeyValues** (*uintptr*) - Pointer to partition key values. ### Returns - **r** (*int32*) - Returns SQLITE_OK on success, or an error code on failure. ``` -------------------------------- ### Benchmark Results Comparison Source: https://pkg.go.dev/modernc.org/sqlite/benchmark Displays benchmark results comparing the pure-Go SQLite driver against the CGo implementation across various operations. Results include performance multipliers and operation times. ```text === RUN Test_BenchmarkSQLite goos: darwin goarch: amd64 cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz repeat: 1 time(s) in-memory SQLite: false bench_create_index | 1.80x | CGo: 120.880 ms/op | Pure-Go: 217.574 ms/op bench_select_on_string_comparison | 2.25x | CGo: 19.326 ms/op | Pure-Go: 43.498 ms/op bench_select_with_index | 5.84x | CGo: 0.002 ms/op | Pure-Go: 0.014 ms/op bench_select_without_index | 1.50x | CGo: 6.071 ms/op | Pure-Go: 9.111 ms/op bench_insert | 1.17x | CGo: 0.481 ms/op | Pure-Go: 0.565 ms/op bench_insert_in_transaction | 1.78x | CGo: 0.004 ms/op | Pure-Go: 0.006 ms/op bench_insert_into_indexed | 1.62x | CGo: 0.008 ms/op | Pure-Go: 0.013 ms/op bench_insert_from_select | 1.80x | CGo: 30.409 ms/op | Pure-Go: 54.703 ms/op bench_update_text_with_index | 3.26x | CGo: 0.004 ms/op | Pure-Go: 0.013 ms/op bench_update_with_index | 4.20x | CGo: 0.003 ms/op | Pure-Go: 0.011 ms/op bench_update_without_index | 1.40x | CGo: 6.421 ms/op | Pure-Go: 9.010 ms/op bench_delete_without_index | 1.28x | CGo: 180.734 ms/op | Pure-Go: 231.105 ms/op bench_delete_with_index | 1.85x | CGo: 34.284 ms/op | Pure-Go: 63.569 ms/op --- PASS: Test_BenchmarkSQLite (171.62s) ``` -------------------------------- ### Begin a Change in a Changegroup Source: https://pkg.go.dev/modernc.org/sqlite/lib Initiates the process of adding a change to a changegroup object. Used to start constructing a new change entry. ```go func Xsqlite3changegroup_change_begin(tls *libc.TLS, pGrp uintptr, eOp int32, zTab uintptr, bIndirect int32, pzErr uintptr) (r int32) ``` -------------------------------- ### Initialize SQLite Backup Operation Go Function Source: https://pkg.go.dev/modernc.org/sqlite/lib Creates an sqlite3_backup process to copy data between two SQLite databases. Returns a pointer to the new backup object on success, or NULL on error. Requires TLS context, destination and source database handles, and their names. ```go func Xsqlite3_backup_init(tls *libc.TLS, pDestDb uintptr, zDestDb uintptr, pSrcDb uintptr, zSrcDb uintptr) (r uintptr) ``` -------------------------------- ### Create CSV Loader Table Source: https://pkg.go.dev/modernc.org/sqlite Example of creating a virtual table to load data from a CSV file. The module infers columns from the file header and streams rows. ```sql CREATE VIRTUAL TABLE csv_users USING csv(filename="/tmp/users.csv", delimiter=",", header=true) ``` -------------------------------- ### Open Database Connection (v2) Source: https://pkg.go.dev/modernc.org/sqlite/lib Opens a new database handle with extended options, including flags and a VFS name. ```go func Xsqlite3_open_v2(tls *libc.TLS, filename uintptr, ppDb uintptr, flags int32, zVfs uintptr) (r int32) ``` -------------------------------- ### STAT_GET_NLT Constant Source: https://pkg.go.dev/modernc.org/sqlite/lib Constant for getting statistics not less than. ```go const STAT_GET_NLT = 3 ``` -------------------------------- ### S_IRWXU Constant Source: https://pkg.go.dev/modernc.org/sqlite/lib File permission flags for read, write, and execute for the user (owner). ```go const S_IRWXU = 448 ``` -------------------------------- ### STAT_GET_NEQ Constant Source: https://pkg.go.dev/modernc.org/sqlite/lib Constant for getting statistics not equal to. ```go const STAT_GET_NEQ = 2 ``` -------------------------------- ### Initialize OS Interface Source: https://pkg.go.dev/modernc.org/sqlite/lib Initializes the operating system interface, registering VFS implementations. This is called once during SQLite initialization and should not use memory allocation or mutex subsystems. ```go func Xsqlite3_os_init(tls *libc.TLS) (r int32) ``` -------------------------------- ### STAT_GET_NDLT Constant Source: https://pkg.go.dev/modernc.org/sqlite/lib Constant for getting statistics not greater than. ```go const STAT_GET_NDLT = 4 ``` -------------------------------- ### Xsqlite3session_indirect Source: https://pkg.go.dev/modernc.org/sqlite/lib Sets or gets the indirect flag for a session. ```APIDOC ## Xsqlite3session_indirect ### Description Sets or gets the indirect flag for a session. ### Method func Xsqlite3session_indirect(tls *libc.TLS, pSession uintptr, bIndirect int32) (r int32) ### Parameters - **tls** (*libc.TLS): Thread-local storage pointer. - **pSession** (uintptr): Pointer to the session. - **bIndirect** (int32): A flag to set the indirect mode (non-zero) or get the current mode (zero). ### Returns - **r** (int32): An integer indicating the result of the operation. ``` -------------------------------- ### Debug and Development Build Options Source: https://pkg.go.dev/modernc.org/sqlite These options can be passed to `go generate` via the GO_GENERATE environment variable for custom builds. ```text -DSQLITE_DEBUG -DSQLITE_MEM_DEBUG -ccgo-verify-structs ``` -------------------------------- ### Implement BestIndex for Virtual Table Planning in Go Source: https://pkg.go.dev/modernc.org/sqlite In `BestIndex`, inspect `info.Constraints`, `info.OrderBy`, and `info.ColUsed` to determine the optimal query plan. Set `ArgIndex` to define the order for `Filter` arguments and `Omit` to indicate constraints handled by the module. ```go info.Constraints (with Column, Op, Usable, 0-based ArgIndex, and Omit), info.OrderBy, and info.ColUsed (bitmask of referenced columns) ``` ```go Set ArgIndex (0-based) to populate Filter’s vals in the chosen order; set Omit to ask SQLite not to re-check a constraint you fully handle. ``` -------------------------------- ### Xbitmap_get Source: https://pkg.go.dev/modernc.org/sqlite/vec Gets the value of a specific bit in a bitmap. ```APIDOC ## func Xbitmap_get(tls *libc.TLS, bitmap uintptr, position Ti32) (r int32) ### Description Retrieves the value of the bit at the specified position. ### Parameters * **tls** (*libc.TLS) - The TLS pointer. * **bitmap** (uintptr) - Pointer to the bitmap. * **position** (Ti32) - The position of the bit to retrieve. ### Returns * **r** (int32) - The value of the bit (0 or 1). ``` -------------------------------- ### Connecting to a SQLite Database Source: https://pkg.go.dev/modernc.org/sqlite Use this snippet to open a connection to a SQLite database using the driver. Ensure the driver is imported. ```go import ( "database/sql" _ "modernc.org/sqlite" ) ... db, err := sql.Open("sqlite", dsnURI) ... ``` -------------------------------- ### STAT_GET_STAT1 Constant Source: https://pkg.go.dev/modernc.org/sqlite/lib Constant for getting statistics of type STAT1. ```go const STAT_GET_STAT1 = 0 ``` -------------------------------- ### Create Context with Constraint Support Source: https://pkg.go.dev/modernc.org/sqlite/vtab Use NewContextWithConstraintSupport to create a Context that enables constraint support. This is typically used by the engine. ```go func NewContextWithConstraintSupport(declare func(string) error, constraintSupport func() error) Context ``` -------------------------------- ### Driver.Open Source: https://pkg.go.dev/modernc.org/sqlite Opens a new SQLite database connection. ```APIDOC ## Driver.Open ### Description Opens a new connection to an SQLite database specified by the `name` parameter. The `name` typically represents the path to the database file. ### Method func (d *Driver) Open(name string) (conn driver.Conn, err error) ### Parameters #### Path Parameters - `name` (string) - The name or path of the database file to open. ### Return Values - `conn` (driver.Conn) - A database connection object. - `err` (error) - An error if the connection could not be opened. ``` -------------------------------- ### STAT_GET_ROWID Constant Source: https://pkg.go.dev/modernc.org/sqlite/lib Constant for getting statistics by row ID. ```go const STAT_GET_ROWID = 1 ``` -------------------------------- ### Get Database File Object Source: https://pkg.go.dev/modernc.org/sqlite/lib Retrieves the sqlite3_file object for the main database using the WAL or Journal name provided to xOpen. ```go func Xsqlite3_database_file_object(tls *libc.TLS, zName uintptr) (r uintptr) ``` -------------------------------- ### Xsqlite3rbu_db Source: https://pkg.go.dev/modernc.org/sqlite/lib Gets the database handle associated with an RBU operation. ```APIDOC ## Xsqlite3rbu_db ### Description Gets the database handle associated with an RBU operation. ### Signature func Xsqlite3rbu_db(tls *libc.TLS, pRbu uintptr, bRbu int32) (r uintptr) ``` -------------------------------- ### Create Rebaser Source: https://pkg.go.dev/modernc.org/sqlite/lib Creates a new rebaser object. This is the initial step before configuring or using a rebaser. ```go func Xsqlite3rebaser_create(tls *libc.TLS, ppNew uintptr) (r int32) ``` -------------------------------- ### NewSqlDb Source: https://pkg.go.dev/modernc.org/sqlite-bench2/app Creates a new SqlDb instance. ```APIDOC ## NewSqlDb ### Description Creates a new SqlDb instance. ### Signature ```go func NewSqlDb(driverName string, db *sql.DB) *SqlDb ``` ``` -------------------------------- ### Create Method Signature Source: https://pkg.go.dev/modernc.org/sqlite/pcache The Create method allocates a fresh per-database cache, serving as the sqlite.PageCache entry point called by SQLite. ```go func (p *Pool) Create(pageSize, extraSize int, purgeable bool) (sqlite.Cache, error) ``` -------------------------------- ### Get Latest Chunk RowID Source: https://pkg.go.dev/modernc.org/sqlite/vec Retrieves the rowid of the latest chunk. ```go func Xvec0_get_latest_chunk_rowid(tls *libc.TLS, p uintptr, chunk_rowid uintptr, partitionKeyValues uintptr) (r int32) ``` -------------------------------- ### TPrefixSetupCtx Struct Definition Source: https://pkg.go.dev/modernc.org/sqlite/lib Context for setting up prefix iteration in FTS5. ```go type TPrefixSetupCtx = struct { FxMerge uintptr FxAppend uintptr FiLastRowid Ti64 FnMerge int32 FaBuf uintptr FnBuf int32 Fdoclist TFts5Buffer FpTokendata uintptr } ``` -------------------------------- ### Get SQLite Keyword Name Source: https://pkg.go.dev/modernc.org/sqlite/lib Retrieves the name of an SQLite keyword by its index. ```go func Xsqlite3_keyword_name(tls *libc.TLS, i int32, pzName uintptr, pnName uintptr) (r int32) ``` -------------------------------- ### SQLite Changeset Configuration and Apply Flags Source: https://pkg.go.dev/modernc.org/sqlite/lib Constants for configuring and applying changesets in SQLite. ```go const SQLITE_CHANGEGROUP_CONFIG_PATCHSET = 1 ``` ```go const SQLITE_CHANGESETAPPLY_FKNOACTION = 8 ``` ```go const SQLITE_CHANGESETAPPLY_IGNORENOOP = 4 ``` ```go const SQLITE_CHANGESETAPPLY_INVERT = 2 ``` ```go const SQLITE_CHANGESETAPPLY_NOSAVEPOINT = 1 ``` ```go const SQLITE_CHANGESETAPPLY_NOUPDATELOOP = 16 ``` ```go const SQLITE_CHANGESETSTART_INVERT = 2 ``` -------------------------------- ### TCGETX Constant Source: https://pkg.go.dev/modernc.org/sqlite/lib Terminal control code for getting extended terminal attributes. ```go const TCGETX = 21554 ``` -------------------------------- ### TCGETS Constant Source: https://pkg.go.dev/modernc.org/sqlite/lib Terminal control code for getting terminal attributes (BSD). ```go const TCGETS = 21505 ``` -------------------------------- ### Create New String Source: https://pkg.go.dev/modernc.org/sqlite/lib Allocates and initializes a new dynamic string object. Requires a database handle. ```go func Xsqlite3_str_new(tls *libc.TLS, db uintptr) (r uintptr) ``` -------------------------------- ### General and Configuration Constants Source: https://pkg.go.dev/modernc.org/sqlite/lib These constants define general limits, configuration options, and special values. ```go const TMP_MAX = 10000 ``` ```go const TOKEN = 0 ``` ```go const TRANS_NONE = 0 ``` ```go const TRANS_READ = 1 ``` ```go const TRANS_WRITE = 2 ``` ```go const TREETRACE_ENABLED = 0 ``` ```go const TRIGGER_AFTER = 2 ``` ```go const TRIGGER_BEFORE = 1 ``` ```go const UINT16_MAX = 65535 ``` ```go const UINT32_MAX = 4294967295 ``` ```go const UINT64_MAX = 18446744073709551615 ``` ```go const UINT8_MAX = 255 ``` ```go const UINTMAX_MAX = 18446744073709551615 ``` ```go const UINTPTR_MAX = 18446744073709551615 ``` ```go const UINT_FAST16_MAX = 4294967295 ``` ```go const UINT_FAST32_MAX = 4294967295 ``` ```go const UINT_FAST64_MAX = 18446744073709551615 ``` ```go const UINT_FAST8_MAX = 255 ``` ```go const UINT_LEAST16_MAX = 65535 ``` ```go const UINT_LEAST32_MAX = 4294967295 ``` ```go const UINT_LEAST64_MAX = 18446744073709551615 ``` ```go const UINT_LEAST8_MAX = 255 ``` ```go const UNIXFILE_DELETE = 32 ``` ```go const UNIXFILE_DIRSYNC = 8 ``` ```go const UNIXFILE_EXCL = 1 ``` ```go const UNIXFILE_NOLOCK = 128 ``` ```go const UNIXFILE_PERSIST_WAL = 4 ``` ```go const UNIXFILE_PSOW = 16 ``` ```go const UNIXFILE_RDONLY = 2 ``` ```go const UNIXFILE_URI = 64 ``` ```go const UNIX_SHM_BASE = 120 ``` ```go const UNIX_SHM_DMS = 128 ``` ```go const UNKNOWN_LOCK = 5 ``` ```go const USE_PREAD = 1 ``` ```go const UTIME_NOW = 1073741823 ``` ```go const UTIME_OMIT = 1073741822 ``` ```go const UpperToLower = 0 ``` ```go const VDBE_DISPLAY_P4 = 1 ``` ```go const VDBE_HALT_STATE = 3 ``` ```go const VDBE_INIT_STATE = 0 ``` ```go const VDBE_READY_STATE = 1 ``` ```go const VDBE_RUN_STATE = 2 ``` ```go const ViewCanHaveRowid = 0 ``` ```go const WALINDEX_HDR_SIZE = 0 ``` ```go const WALINDEX_MAX_VERSION = 3007000 ``` ```go const WALINDEX_PGSZ = 0 ``` ```go const WAL_ALL_BUT_WRITE = 1 ``` ```go const WAL_CKPT_LOCK = 1 ``` ```go const WAL_EXCLUSIVE_MODE = 1 ``` ```go const WAL_FRAME_HDRSIZE = 24 ``` ```go const WAL_HDRSIZE = 32 ``` ```go const WAL_HEAPMEMORY_MODE = 2 ``` ```go const WAL_LOCK_CKPT = 1 ``` ```go const WAL_LOCK_READ0 = 3 ``` ```go const WAL_LOCK_WRITE = 0 ``` ```go const WAL_MAGIC = 931071618 ``` ```go const WAL_MAX_VERSION = 3007000 ``` ```go const WAL_NORMAL_MODE = 0 ``` ```go const WAL_NREADER = 5 ``` ```go const WAL_RDONLY = 1 ``` -------------------------------- ### TCGETA Constant Source: https://pkg.go.dev/modernc.org/sqlite/lib Terminal control code for getting terminal attributes (POSIX). ```go const TCGETA = 21509 ``` -------------------------------- ### Create a new bitmap Source: https://pkg.go.dev/modernc.org/sqlite/vec Allocates and initializes a new bitmap of a given size. Requires a TLS context and the number of elements. ```go func Xbitmap_new(tls *libc.TLS, n Ti32) (r uintptr) ``` -------------------------------- ### Start Changeset Iterator - Go Source: https://pkg.go.dev/modernc.org/sqlite/lib Creates an iterator to traverse the contents of a changeset. ```go func Xsqlite3changeset_start(tls *libc.TLS, pp uintptr, nChangeset int32, pChangeset uintptr) (r int32) ``` -------------------------------- ### Temporary Directory Constant Source: https://pkg.go.dev/modernc.org/sqlite/lib The default temporary directory path. ```Go const P_tmpdir = "/tmp" ``` -------------------------------- ### Xsqlite3changeset_invert_strm Source: https://pkg.go.dev/modernc.org/sqlite/lib Streaming version of Xsqlite3changeset_invert. This function is available starting from version 1.12.0. ```APIDOC ## Xsqlite3changeset_invert_strm ### Description Streaming version of sqlite3changeset_invert(). ### Signature ```go func Xsqlite3changeset_invert_strm(tls *libc.TLS, __ccgo_fp_xInput uintptr, pIn uintptr, __ccgo_fp_xOutput uintptr, pOut uintptr) (r int32) ``` ``` -------------------------------- ### InitData C Documentation Source: https://pkg.go.dev/modernc.org/sqlite/lib C-style documentation explaining the purpose of the TInitData structure for communicating initialization information. ```c /* ** A pointer to this structure is used to communicate information ** from sqlite3Init and OP_ParseSchema into the sqlite3InitCallback. */ ``` -------------------------------- ### Xsqlite3changeset_invert Source: https://pkg.go.dev/modernc.org/sqlite/lib Inverts a changeset object. This function is available starting from version 1.12.0. ```APIDOC ## Xsqlite3changeset_invert ### Description Inverts a changeset object. ### Signature ```go func Xsqlite3changeset_invert(tls *libc.TLS, nChangeset int32, pChangeset uintptr, pnInverted uintptr, ppInverted uintptr) (r int32) ``` ``` -------------------------------- ### Xsqlite3changeset_finalize Source: https://pkg.go.dev/modernc.org/sqlite/lib Finalizes a changeset iterator. This function is available starting from version 1.12.0. ```APIDOC ## Xsqlite3changeset_finalize ### Description Finalizes an iterator allocated with sqlite3changeset_start(). This function may not be called on iterators passed to a conflict handler callback by changeset_apply(). ### Signature ```go func Xsqlite3changeset_finalize(tls *libc.TLS, p uintptr) (r int32) ``` ``` -------------------------------- ### Xsqlite3changeset_concat_strm Source: https://pkg.go.dev/modernc.org/sqlite/lib Streaming version of Xsqlite3changeset_concat. This function is available starting from version 1.12.0. ```APIDOC ## Xsqlite3changeset_concat_strm ### Description Streaming version of sqlite3changeset_concat(). ### Signature ```go func Xsqlite3changeset_concat_strm(tls *libc.TLS, __ccgo_fp_xInputA uintptr, pInA uintptr, __ccgo_fp_xInputB uintptr, pInB uintptr, __ccgo_fp_xOutput uintptr, pOut uintptr) (r int32) ``` ``` -------------------------------- ### AT_EMPTY_PATH Constant Source: https://pkg.go.dev/modernc.org/sqlite/lib Flag indicating an empty path is permitted. ```go const AT_EMPTY_PATH = 4096 ``` -------------------------------- ### Xsqlite3changeset_apply_v3_strm Source: https://pkg.go.dev/modernc.org/sqlite/lib Streaming version of Xsqlite3changeset_apply_v3. This function is available starting from version 1.42.0. ```APIDOC ## Xsqlite3changeset_apply_v3_strm ### Description Applies the changeset passed via xInput/pIn to the main database attached to handle "db". Invokes the supplied conflict handler callback to resolve any conflicts encountered while applying the change. ### Signature ```go func Xsqlite3changeset_apply_v3_strm(tls *libc.TLS, db uintptr, __ccgo_fp_xInput uintptr, pIn uintptr, __ccgo_fp_xFilter uintptr, __ccgo_fp_xConflict uintptr, pCtx uintptr, ppRebase uintptr, pnRebase uintptr, flags int32) (r int32) ``` ``` -------------------------------- ### Get SQLite Keyword Count Source: https://pkg.go.dev/modernc.org/sqlite/lib Returns the total number of recognized SQLite keywords. ```go func Xsqlite3_keyword_count(tls *libc.TLS) (r int32) ``` -------------------------------- ### S_IEXEC Constant Source: https://pkg.go.dev/modernc.org/sqlite/lib File permission flag for execute permission for the owner. ```go const S_IEXEC = 64 ``` -------------------------------- ### Get Database Mutex Source: https://pkg.go.dev/modernc.org/sqlite/lib Retrieves the mutex associated with a given SQLite database connection. ```go func Xsqlite3_db_mutex(tls *libc.TLS, db uintptr) (r uintptr) ``` -------------------------------- ### Xsqlite3_os_init Source: https://pkg.go.dev/modernc.org/sqlite/lib Initializes the operating system interface, registering VFS implementations. This is called once during SQLite initialization. ```APIDOC ## func Xsqlite3_os_init ### Description Initialize the operating system interface. This routine registers all VFS implementations for unix-like operating systems. This routine, and the sqlite3_os_end() routine that follows, should be the only routines in this file that are visible from other files. This routine is called once during SQLite initialization and by a single thread. The memory allocation and mutex subsystems have not necessarily been initialized when this routine is called, and so they should not be used. ### Signature ```go func Xsqlite3_os_init(tls *libc.TLS) (r int32) ``` ``` -------------------------------- ### SQLite Version and Configuration Constants Source: https://pkg.go.dev/modernc.org/sqlite/lib Constants for SQLite version information and configuration options. ```go const SQLITE_U64_DIGITS = 20 ``` ```go const SQLITE_UPDATE = 23 ``` ```go const SQLITE_USE_URI = 0 ``` ```go const SQLITE_VERSION = "3.53.2" ``` ```go const SQLITE_VERSION_NUMBER = 3053002 ``` -------------------------------- ### Get Column Blob Source: https://pkg.go.dev/modernc.org/sqlite/lib Retrieves a BLOB value from the current row of a result set. ```go func Xsqlite3_column_blob(tls *libc.TLS, pStmt uintptr, i int32) (r uintptr) ``` -------------------------------- ### Get Metadata Text Long Value Source: https://pkg.go.dev/modernc.org/sqlite/vec Retrieves a long text value from metadata. ```go func Xvec0_get_metadata_text_long_value(tls *libc.TLS, p uintptr, stmt uintptr, metadata_idx int32, rowid Ti64, n uintptr, s uintptr) (r int32) ``` -------------------------------- ### Initialize SQLite vector extension Source: https://pkg.go.dev/modernc.org/sqlite/vec Initializes the SQLite vector extension. Requires a TLS context, database handle, error message pointer, and API pointer. ```go func Xsqlite3_vec_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) (r int32) ``` -------------------------------- ### Xsqlite3changeset_apply_v3 Source: https://pkg.go.dev/modernc.org/sqlite/lib Applies a changeset to the main database. This function is available starting from version 1.42.0. ```APIDOC ## Xsqlite3changeset_apply_v3 ### Description Applies the changeset passed via pChangeset/nChangeset to the main database attached to handle "db". ### Signature ```go func Xsqlite3changeset_apply_v3(tls *libc.TLS, db uintptr, nChangeset int32, pChangeset uintptr, __ccgo_fp_xFilter uintptr, __ccgo_fp_xConflict uintptr, pCtx uintptr, ppRebase uintptr, pnRebase uintptr, flags int32) (r int32) ``` ``` -------------------------------- ### Initialize SQLite vector extension with static blobs Source: https://pkg.go.dev/modernc.org/sqlite/vec Initializes the SQLite vector extension with support for static blobs. Requires a TLS context, database handle, error message pointer, and API pointer. ```go func Xsqlite3_vec_static_blobs_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) (r int32) ``` -------------------------------- ### Driver.Open Source: https://pkg.go.dev/modernc.org/sqlite Opens a new connection to the SQLite database. The name parameter can be a file path or a URI with query parameters for configuration. ```APIDOC ## func (*Driver) Open ### Description Open returns a new connection to the database. The name is a string in a driver-specific format. Open may return a cached connection (one previously closed), but doing so is unnecessary; the sql package maintains a pool of idle connections for efficient re-use. The returned connection is only used by one goroutine at a time. The name may be a filename, e.g., "/tmp/mydata.sqlite", or a URI, in which case it may include a '?' followed by one or more query parameters. For example, "file:///tmp/mydata.sqlite?_pragma=foreign_keys(1)&_time_format=sqlite". The supported query parameters are: - **_pragma**: Each value will be run as a "PRAGMA ..." statement (with the PRAGMA keyword added for you). May be specified more than once, '&'-separated. For more information on supported PRAGMAs see: https://www.sqlite.org/pragma.html - **_time_format**: The name of a format to use when writing time values to the database. The currently supported values are (1) "sqlite" for YYYY-MM-DD HH:MM:SS.SSS[+-]HH:MM (format 4 from https://www.sqlite.org/lang_datefunc.html#time_values with sub-second precision and timezone specifier) and (2) "datetime" for YYYY-MM-DD HH:MM:SS (format 3, matching the output of SQLite's datetime() function). If this parameter is not specified, then the default String() format will be used. - **_time_integer_format**: The name of an integer format to use when writing time values. By default, the time is stored as string and the format can be set with _time_format parameter. If _time_integer_format is set, the time will be stored as an integer and the integer value will depend on the integer format. If you decide to set both _time_format and _time_integer_format, the time will be converted as integer and the _time_format value will be ignored. Currently the supported value are "unix","unix_milli", "unix_micro" and "unix_nano", which corresponds to seconds, milliseconds, microseconds or nanoseconds since unixepoch (1 January 1970 00:00:00 UTC). - **_inttotime**: Enable conversion of time column (DATE, DATETIME,TIMESTAMP) from integer to time if the field contain integer (int64). - **_texttotime**: Enable ColumnTypeScanType to report time.Time instead of string for TEXT columns declared as DATE, DATETIME, TIME, or TIMESTAMP. - **_timezone**: A timezone to use for all time reads and writes, such as "UTC". The value is parsed by time.LoadLocation. Writes will convert to the timezone before formatting as a string; it does not impact _inttotime integer values, as they always use UTC. Reads will interpret timezone-less strings as being in this timezone. Values that are in a known timezone, such as a string with a timezone specifier or an integer with _inttotime (specified to be in UTC), will be converted to this timezone. - **_txlock**: The locking behavior to use when beginning a transaction. May be "deferred" (the default), "immediate", or "exclusive" (case insensitive). See: https://www.sqlite.org/lang_transaction.html#deferred_immediate_and_exclusive_transactions - **_dqs**: Opt-in toggle for SQLite's double-quoted string literal compatibility quirk on the connection. Accepts the values strconv.ParseBool understands ("0"/"1", "false"/"true", "f"/"t", case-insensitive). When absent or set to a true value, SQLite's built-in behavior is unchanged: a double-quoted identifier that fails to resolve is silently re-interpreted as a string literal. When set to a false value, SQLITE_DBCONFIG_DQS_DDL and SQLITE_DBCONFIG_DQS_DML are both turned off via sqlite3_db_config so that mistakes hidden by the legacy fallback surface as a parse error instead. See: https://www.sqlite.org/quirks.html#dblquote and https://gitlab.com/cznic/sqlite/-/issues/61 - **_error_rc**: Opt-in error-string reporting mode for synthesised errors. Accepts the values strconv.ParseBool understands ("0"/"1", "false"/"true", "f"/"t", case-insensitive). When absent or set to a false value, the legacy "errstr: errmsg (rc)" form is preserved byte-for-byte: the canonical sqlite3_errstr(rc) and the connection's sqlite3_errmsg(db) are concatenated even when the latter belongs to a different operation, which can read as misleading on open-time failures such as SQLITE_CANTOPEN reporting "out of memory". When set to a true value, the appended errmsg is suppressed if sqlite3_extended_errcode(db) is inconsistent with the operation rc (full match first, primary code as fallback); in that case the canonical errstr(rc) is used alone. The Code() returned by the driver's *Error is unchanged in either mode. The parameter is parsed before sqlite3_open_v2 so open-time errors are covered. See https://gitlab.com/cznic/sqlite/-/issues/230. ### Method Open ### Endpoint N/A (Function Call) ### Parameters #### Path Parameters None #### Query Parameters See description for supported query parameters. #### Request Body None ### Request Example ```go driver := &sqlite.Driver{} conn, err := driver.Open("file:mydata.sqlite?_pragma=foreign_keys(1)") ``` ### Response #### Success Response (200) - **conn** (driver.Conn) - A database connection. - **err** (error) - An error if the connection failed, nil otherwise. #### Response Example ```go // Successful connection // conn is a valid driver.Conn object // err is nil // Failed connection // conn is nil // err is an error object ``` ``` -------------------------------- ### Xsqlite3changeset_apply_v2_strm Source: https://pkg.go.dev/modernc.org/sqlite/lib Applies a changeset in a streaming fashion. This function is available starting from version 1.12.0. ```APIDOC ## Xsqlite3changeset_apply_v2_strm ### Description Applies a changeset in a streaming fashion. ### Signature ```go func Xsqlite3changeset_apply_v2_strm(tls *libc.TLS, db uintptr, __ccgo_fp_xInput uintptr, pIn uintptr, __ccgo_fp_xFilter uintptr, __ccgo_fp_xConflict uintptr, pCtx uintptr, ppRebase uintptr, pnRebase uintptr, flags int32) (r int32) ``` ``` -------------------------------- ### PatchIssue199 Source: https://pkg.go.dev/modernc.org/sqlite/lib Applies a patch for issue 199. This function is available starting from version 1.34.3. ```APIDOC ## func PatchIssue199 ### Description Applies a patch for issue 199. ### Added in version v1.34.3 ``` -------------------------------- ### Initial Git Status and Log Source: https://pkg.go.dev/modernc.org/sqlite Shows the initial state of the git repository and the latest commit before enabling debug logs. ```bash 0:jnml@e5-1650:~/src/modernc.org/sqlite$ git status On branch master Your branch is up to date with 'origin/master'. nothing to commit, working tree clean 0:jnml@e5-1650:~/src/modernc.org/sqlite$ git log -1 commit df33b8d15107f3cc777799c0fe105f74ef499e62 (HEAD -> master, tag: v1.21.1, origin/master, origin/HEAD, wips, ok) Author: Jan Mercl <0xjnml@gmail.com> Date: Mon Mar 27 16:18:28 2023 +0200 upgrade to SQLite 3.41.2 ``` -------------------------------- ### Get Streaming SQLite Session Patchset Source: https://pkg.go.dev/modernc.org/sqlite/lib A streaming version of sqlite3session_patchset() for obtaining patchset information. ```go func Xsqlite3session_patchset_strm(tls *libc.TLS, pSession uintptr, __ccgo_fp_xOutput uintptr, pOut uintptr) (r int32) ``` -------------------------------- ### Initialize SQLite Source: https://pkg.go.dev/modernc.org/sqlite/lib Must be called to initialize SQLite subsystems before significant operations. It's often called automatically by functions like sqlite3_open(). ```go func Xsqlite3_initialize(tls *libc.TLS) (r int32) ``` -------------------------------- ### NewUser Source: https://pkg.go.dev/modernc.org/sqlite-bench2/app Creates a new User object. ```APIDOC ## NewUser ### Description Creates a new User object. ### Signature ```go func NewUser(id int, created time.Time, email string, active bool) User ``` ``` -------------------------------- ### Get RBU State - Go Source: https://pkg.go.dev/modernc.org/sqlite/lib Returns the current state of an RBU vacuum or update operation. ```go func Xsqlite3rbu_state(tls *libc.TLS, p uintptr) (r int32) ``` -------------------------------- ### Get RBU Database Handle - Go Source: https://pkg.go.dev/modernc.org/sqlite/lib Returns the database handle associated with an RBU handle. ```go func Xsqlite3rbu_db(tls *libc.TLS, pRbu uintptr, bRbu int32) (r uintptr) ``` -------------------------------- ### C Documentation for json_pretty() recursion context Source: https://pkg.go.dev/modernc.org/sqlite/lib Provides C-style documentation comments explaining the context for recursion in the json_pretty() function. ```c /* Context for recursion of json_pretty() */ ``` -------------------------------- ### S_IFDIR Constant Source: https://pkg.go.dev/modernc.org/sqlite/lib File type flag for directory. ```go const S_IFDIR = 16384 ``` -------------------------------- ### Get Journal Filename in SQLite Source: https://pkg.go.dev/modernc.org/sqlite/lib Xsqlite3_filename_journal retrieves the journal filename associated with a given filename. ```go func Xsqlite3_filename_journal(tls *libc.TLS, zFilename uintptr) (r uintptr) ``` -------------------------------- ### Configure Rebaser Source: https://pkg.go.dev/modernc.org/sqlite/lib Configures a rebaser object. Call this one or more times to set up rebaser parameters. ```go func Xsqlite3rebaser_configure(tls *libc.TLS, p uintptr, nRebase int32, pRebase uintptr) (r int32) ``` -------------------------------- ### Get Vec0 RowID from ID Source: https://pkg.go.dev/modernc.org/sqlite/vec Retrieves a row ID from a given ID value in Vec0. ```go func Xvec0_rowid_from_id(tls *libc.TLS, p uintptr, valueId uintptr, rowid uintptr) (r int32) ``` -------------------------------- ### Authorization and Configuration Functions Source: https://pkg.go.dev/modernc.org/sqlite/lib Functions for setting up authorization callbacks, auxiliary data, and client data. ```APIDOC ## Xsqlite3_set_authorizer ### Description Registers an authorizer callback function to intercept and authorize SQL operations. ### Parameters - `tls` (*libc.TLS): Thread-local storage pointer. - `db` (uintptr): Handle to the database connection. - `__ccgo_fp_xAuth` (uintptr): Pointer to the authorizer callback function. - `pArg` (uintptr): User-provided argument to the authorizer callback. - `r` (int32): Returns SQLITE_OK on success, or an error code otherwise. ``` ```APIDOC ## Xsqlite3_set_auxdata ### Description Associates auxiliary data with a SQL function or aggregate. ### Parameters - `tls` (*libc.TLS): Thread-local storage pointer. - `pCtx` (uintptr): Pointer to the context object. - `iArg` (int32): The argument index. - `pAux` (uintptr): Pointer to the auxiliary data. - `...`: Variadic arguments, potentially for a destructor. ``` ```APIDOC ## Xsqlite3_set_clientdata ### Description Associates client-defined data with a database connection. ### Parameters - `tls` (*libc.TLS): Thread-local storage pointer. - `db` (uintptr): Handle to the database connection. - `zName` (uintptr): The name of the client data. - `pData` (uintptr): Pointer to the client data. - `...`: Variadic arguments. - `r` (int32): Returns SQLITE_OK on success, or an error code otherwise. ```