From 1dc06bff4954b864f0b40d92035e19c853e7d34a Mon Sep 17 00:00:00 2001 From: Nuno Cruces Date: Thu, 9 Nov 2023 16:35:45 +0000 Subject: [PATCH] Simplify URLs. --- README.md | 12 +++---- backup.go | 16 ++++----- blob.go | 18 +++++----- conn.go | 22 ++++++------ const.go | 12 +++---- context.go | 32 ++++++++--------- driver/driver.go | 6 ++-- driver/savepoint.go | 2 +- embed/README.md | 12 +++---- error.go | 6 ++-- func.go | 10 +++--- gormlite/sqlite.go | 4 +-- pointer.go | 2 +- sqlite3/sqlite_cfg.h | 2 +- stmt.go | 66 +++++++++++++++++------------------ time.go | 10 +++--- tx.go | 20 +++++------ value.go | 22 ++++++------ vfs/README.md | 2 +- vfs/api.go | 20 +++++------ vfs/const.go | 14 ++++---- vfs/memdb/README.md | 2 +- vfs/readervfs/example_test.go | 2 +- vfs/registry.go | 6 ++-- 24 files changed, 160 insertions(+), 160 deletions(-) diff --git a/README.md b/README.md index 1ac3b99..2470b79 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Go module `github.com/ncruces/go-sqlite3` wraps a [WASM](https://webassembly.org and uses [wazero](https://wazero.io/) to provide `cgo`-free SQLite bindings. - [`github.com/ncruces/go-sqlite3`](https://pkg.go.dev/github.com/ncruces/go-sqlite3) - wraps the [C SQLite API](https://www.sqlite.org/cintro.html) + wraps the [C SQLite API](https://sqlite.org/cintro.html) ([example usage](https://pkg.go.dev/github.com/ncruces/go-sqlite3#example-package)). - [`github.com/ncruces/go-sqlite3/driver`](https://pkg.go.dev/github.com/ncruces/go-sqlite3/driver) provides a [`database/sql`](https://pkg.go.dev/database/sql) driver @@ -22,7 +22,7 @@ and uses [wazero](https://wazero.io/) to provide `cgo`-free SQLite bindings. - [`github.com/ncruces/go-sqlite3/ext/unicode`](https://pkg.go.dev/github.com/ncruces/go-sqlite3/ext/unicode) registers Unicode aware functions. - [`github.com/ncruces/go-sqlite3/vfs`](https://pkg.go.dev/github.com/ncruces/go-sqlite3/vfs) - wraps the [C SQLite VFS API](https://www.sqlite.org/vfs.html) and provides a pure Go implementation. + wraps the [C SQLite VFS API](https://sqlite.org/vfs.html) and provides a pure Go implementation. - [`github.com/ncruces/go-sqlite3/vfs/memdb`](https://pkg.go.dev/github.com/ncruces/go-sqlite3/vfs/memdb) implements an in-memory VFS. - [`github.com/ncruces/go-sqlite3/vfs/readervfs`](https://pkg.go.dev/github.com/ncruces/go-sqlite3/vfs/readervfs) @@ -32,14 +32,14 @@ and uses [wazero](https://wazero.io/) to provide `cgo`-free SQLite bindings. ### Caveats -This module replaces the SQLite [OS Interface](https://www.sqlite.org/vfs.html) +This module replaces the SQLite [OS Interface](https://sqlite.org/vfs.html) (aka VFS) with a [pure Go](vfs/) implementation. This has benefits, but also comes with some drawbacks. #### Write-Ahead Logging Because WASM does not support shared memory, -[WAL](https://www.sqlite.org/wal.html) support is [limited](https://www.sqlite.org/wal.html#noshm). +[WAL](https://sqlite.org/wal.html) support is [limited](https://sqlite.org/wal.html#noshm). To work around this limitation, SQLite is [patched](sqlite3/locking_mode.patch) to always use `EXCLUSIVE` locking mode for WAL databases. @@ -52,7 +52,7 @@ with WAL mode databases you should disable connection pooling by calling #### File Locking POSIX advisory locks, which SQLite uses on Unix, are -[broken by design](https://www.sqlite.org/src/artifact/2e8b12?ln=1073-1161). +[broken by design](https://sqlite.org/src/artifact/2e8b12?ln=1073-1161). On Linux, macOS and illumos, this module uses [OFD locks](https://www.gnu.org/software/libc/manual/html_node/Open-File-Description-Locks.html) @@ -67,7 +67,7 @@ On Windows, this module uses `LockFile`, `LockFileEx`, and `UnlockFile`, like SQLite. On all other platforms, file locking is not supported, and you must use -[`nolock=1`](https://www.sqlite.org/uri.html#urinolock) +[`nolock=1`](https://sqlite.org/uri.html#urinolock) to open database files. To use the [`database/sql`](https://pkg.go.dev/database/sql) driver with `nolock=1` you must disable connection pooling by calling diff --git a/backup.go b/backup.go index 17efa03..70c289c 100644 --- a/backup.go +++ b/backup.go @@ -2,7 +2,7 @@ package sqlite3 // Backup is an handle to an ongoing online backup operation. // -// https://www.sqlite.org/c3ref/backup.html +// https://sqlite.org/c3ref/backup.html type Backup struct { c *Conn handle uint32 @@ -15,7 +15,7 @@ type Backup struct { // and blocks until the entire backup is complete. // Use [Conn.BackupInit] for incremental backup. // -// https://www.sqlite.org/backup.html +// https://sqlite.org/backup.html func (src *Conn) Backup(srcDB, dstURI string) error { b, err := src.BackupInit(srcDB, dstURI) if err != nil { @@ -31,7 +31,7 @@ func (src *Conn) Backup(srcDB, dstURI string) error { // Restore opens the SQLite database file srcURI, // and blocks until the entire restore is complete. // -// https://www.sqlite.org/backup.html +// https://sqlite.org/backup.html func (dst *Conn) Restore(dstDB, srcURI string) error { src, err := dst.openDB(srcURI, OPEN_READONLY|OPEN_URI) if err != nil { @@ -52,7 +52,7 @@ func (dst *Conn) Restore(dstDB, srcURI string) error { // then initializes a backup that copies the contents of srcDB on the src connection // to the "main" database in dstURI. // -// https://www.sqlite.org/c3ref/backup_finish.html#sqlite3backupinit +// https://sqlite.org/c3ref/backup_finish.html#sqlite3backupinit func (src *Conn) BackupInit(srcDB, dstURI string) (*Backup, error) { dst, err := src.openDB(dstURI, OPEN_READWRITE|OPEN_CREATE|OPEN_URI) if err != nil { @@ -91,7 +91,7 @@ func (c *Conn) backupInit(dst uint32, dstName string, src uint32, srcName string // // It is safe to close a nil, zero or closed Backup. // -// https://www.sqlite.org/c3ref/backup_finish.html#sqlite3backupfinish +// https://sqlite.org/c3ref/backup_finish.html#sqlite3backupfinish func (b *Backup) Close() error { if b == nil || b.handle == 0 { return nil @@ -106,7 +106,7 @@ func (b *Backup) Close() error { // Step copies up to nPage pages between the source and destination databases. // If nPage is negative, all remaining source pages are copied. // -// https://www.sqlite.org/c3ref/backup_finish.html#sqlite3backupstep +// https://sqlite.org/c3ref/backup_finish.html#sqlite3backupstep func (b *Backup) Step(nPage int) (done bool, err error) { r := b.c.call(b.c.api.backupStep, uint64(b.handle), uint64(nPage)) if r == _DONE { @@ -118,7 +118,7 @@ func (b *Backup) Step(nPage int) (done bool, err error) { // Remaining returns the number of pages still to be backed up // at the conclusion of the most recent [Backup.Step]. // -// https://www.sqlite.org/c3ref/backup_finish.html#sqlite3backupremaining +// https://sqlite.org/c3ref/backup_finish.html#sqlite3backupremaining func (b *Backup) Remaining() int { r := b.c.call(b.c.api.backupRemaining, uint64(b.handle)) return int(r) @@ -127,7 +127,7 @@ func (b *Backup) Remaining() int { // PageCount returns the total number of pages in the source database // at the conclusion of the most recent [Backup.Step]. // -// https://www.sqlite.org/c3ref/backup_finish.html#sqlite3backuppagecount +// https://sqlite.org/c3ref/backup_finish.html#sqlite3backuppagecount func (b *Backup) PageCount() int { r := b.c.call(b.c.api.backupPageCount, uint64(b.handle)) return int(r) diff --git a/blob.go b/blob.go index 5ecc35f..6a59a85 100644 --- a/blob.go +++ b/blob.go @@ -15,7 +15,7 @@ type ZeroBlob int64 // // It implements [io.ReadWriteSeeker] for incremental BLOB I/O. // -// https://www.sqlite.org/c3ref/blob.html +// https://sqlite.org/c3ref/blob.html type Blob struct { c *Conn bytes int64 @@ -27,7 +27,7 @@ var _ io.ReadWriteSeeker = &Blob{} // OpenBlob opens a BLOB for incremental I/O. // -// https://www.sqlite.org/c3ref/blob_open.html +// https://sqlite.org/c3ref/blob_open.html func (c *Conn) OpenBlob(db, table, column string, row int64, write bool) (*Blob, error) { c.checkInterrupt() defer c.arena.reset() @@ -59,7 +59,7 @@ func (c *Conn) OpenBlob(db, table, column string, row int64, write bool) (*Blob, // // It is safe to close a nil, zero or closed Blob. // -// https://www.sqlite.org/c3ref/blob_close.html +// https://sqlite.org/c3ref/blob_close.html func (b *Blob) Close() error { if b == nil || b.handle == 0 { return nil @@ -73,14 +73,14 @@ func (b *Blob) Close() error { // Size returns the size of the BLOB in bytes. // -// https://www.sqlite.org/c3ref/blob_bytes.html +// https://sqlite.org/c3ref/blob_bytes.html func (b *Blob) Size() int64 { return b.bytes } // Read implements the [io.Reader] interface. // -// https://www.sqlite.org/c3ref/blob_read.html +// https://sqlite.org/c3ref/blob_read.html func (b *Blob) Read(p []byte) (n int, err error) { if b.offset >= b.bytes { return 0, io.EOF @@ -112,7 +112,7 @@ func (b *Blob) Read(p []byte) (n int, err error) { // WriteTo implements the [io.WriterTo] interface. // -// https://www.sqlite.org/c3ref/blob_read.html +// https://sqlite.org/c3ref/blob_read.html func (b *Blob) WriteTo(w io.Writer) (n int64, err error) { if b.offset >= b.bytes { return 0, nil @@ -156,7 +156,7 @@ func (b *Blob) WriteTo(w io.Writer) (n int64, err error) { // Write implements the [io.Writer] interface. // -// https://www.sqlite.org/c3ref/blob_write.html +// https://sqlite.org/c3ref/blob_write.html func (b *Blob) Write(p []byte) (n int, err error) { defer b.c.arena.reset() ptr := b.c.arena.bytes(p) @@ -173,7 +173,7 @@ func (b *Blob) Write(p []byte) (n int, err error) { // ReadFrom implements the [io.ReaderFrom] interface. // -// https://www.sqlite.org/c3ref/blob_write.html +// https://sqlite.org/c3ref/blob_write.html func (b *Blob) ReadFrom(r io.Reader) (n int64, err error) { want := int64(1024 * 1024) avail := b.bytes - b.offset @@ -241,7 +241,7 @@ func (b *Blob) Seek(offset int64, whence int) (int64, error) { // Reopen moves a BLOB handle to a new row of the same database table. // -// https://www.sqlite.org/c3ref/blob_reopen.html +// https://sqlite.org/c3ref/blob_reopen.html func (b *Blob) Reopen(row int64) error { err := b.c.error(b.c.call(b.c.api.blobReopen, uint64(b.handle), uint64(row))) b.bytes = int64(b.c.call(b.c.api.blobBytes, uint64(b.handle))) diff --git a/conn.go b/conn.go index c2f24bb..56df742 100644 --- a/conn.go +++ b/conn.go @@ -15,7 +15,7 @@ import ( // Conn is a database connection handle. // A Conn is not safe for concurrent use by multiple goroutines. // -// https://www.sqlite.org/c3ref/sqlite3.html +// https://sqlite.org/c3ref/sqlite3.html type Conn struct { *sqlite @@ -38,7 +38,7 @@ func Open(filename string) (*Conn, error) { // // sqlite3.Open("file:demo.db?_pragma=busy_timeout(10000)") // -// https://www.sqlite.org/c3ref/open.html +// https://sqlite.org/c3ref/open.html func OpenFlags(filename string, flags OpenFlag) (*Conn, error) { if flags&(OPEN_READONLY|OPEN_READWRITE|OPEN_CREATE) == 0 { flags |= OPEN_READWRITE | OPEN_CREATE @@ -126,7 +126,7 @@ func (c *Conn) closeDB(handle uint32) { // // It is safe to close a nil, zero or closed Conn. // -// https://www.sqlite.org/c3ref/close.html +// https://sqlite.org/c3ref/close.html func (c *Conn) Close() error { if c == nil || c.handle == 0 { return nil @@ -148,7 +148,7 @@ func (c *Conn) Close() error { // Exec is a convenience function that allows an application to run // multiple statements of SQL without having to use a lot of code. // -// https://www.sqlite.org/c3ref/exec.html +// https://sqlite.org/c3ref/exec.html func (c *Conn) Exec(sql string) error { c.checkInterrupt() defer c.arena.reset() @@ -168,7 +168,7 @@ func (c *Conn) Prepare(sql string) (stmt *Stmt, tail string, err error) { // If the input text contains no SQL (if the input is an empty string or a comment), // both stmt and err will be nil. // -// https://www.sqlite.org/c3ref/prepare.html +// https://sqlite.org/c3ref/prepare.html func (c *Conn) PrepareFlags(sql string, flags PrepareFlag) (stmt *Stmt, tail string, err error) { if emptyStatement(sql) { return nil, "", nil @@ -199,7 +199,7 @@ func (c *Conn) PrepareFlags(sql string, flags PrepareFlag) (stmt *Stmt, tail str // GetAutocommit tests the connection for auto-commit mode. // -// https://www.sqlite.org/c3ref/get_autocommit.html +// https://sqlite.org/c3ref/get_autocommit.html func (c *Conn) GetAutocommit() bool { r := c.call(c.api.autocommit, uint64(c.handle)) return r != 0 @@ -208,7 +208,7 @@ func (c *Conn) GetAutocommit() bool { // LastInsertRowID returns the rowid of the most recent successful INSERT // on the database connection. // -// https://www.sqlite.org/c3ref/last_insert_rowid.html +// https://sqlite.org/c3ref/last_insert_rowid.html func (c *Conn) LastInsertRowID() int64 { r := c.call(c.api.lastRowid, uint64(c.handle)) return int64(r) @@ -218,7 +218,7 @@ func (c *Conn) LastInsertRowID() int64 { // by the most recently completed INSERT, UPDATE or DELETE statement // on the database connection. // -// https://www.sqlite.org/c3ref/changes.html +// https://sqlite.org/c3ref/changes.html func (c *Conn) Changes() int64 { r := c.call(c.api.changes, uint64(c.handle)) return int64(r) @@ -237,7 +237,7 @@ func (c *Conn) Changes() int64 { // // SetInterrupt returns the old context assigned to the connection. // -// https://www.sqlite.org/c3ref/interrupt.html +// https://sqlite.org/c3ref/interrupt.html func (c *Conn) SetInterrupt(ctx context.Context) (old context.Context) { // Is it the same context? if ctx == c.interrupt { @@ -282,7 +282,7 @@ func (c *Conn) checkInterrupt() { // Pragma executes a PRAGMA statement and returns any results. // -// https://www.sqlite.org/pragma.html +// https://sqlite.org/pragma.html func (c *Conn) Pragma(str string) ([]string, error) { stmt, _, err := c.Prepare(`PRAGMA ` + str) if err != nil { @@ -305,7 +305,7 @@ func (c *Conn) error(rc uint64, sql ...string) error { // // It can be used to access SQLite features like [online backup]. // -// [online backup]: https://www.sqlite.org/backup.html +// [online backup]: https://sqlite.org/backup.html type DriverConn interface { Raw() *Conn } diff --git a/const.go b/const.go index 14757e2..510e25e 100644 --- a/const.go +++ b/const.go @@ -18,7 +18,7 @@ const ( // ErrorCode is a result code that [Error.Code] might return. // -// https://www.sqlite.org/rescode.html +// https://sqlite.org/rescode.html type ErrorCode uint8 const ( @@ -54,7 +54,7 @@ const ( // ExtendedErrorCode is a result code that [Error.ExtendedCode] might return. // -// https://www.sqlite.org/rescode.html +// https://sqlite.org/rescode.html type ( ExtendedErrorCode uint16 xErrorCode = ExtendedErrorCode @@ -140,7 +140,7 @@ const ( // OpenFlag is a flag for the [OpenFlags] function. // -// https://www.sqlite.org/c3ref/c_open_autoproxy.html +// https://sqlite.org/c3ref/c_open_autoproxy.html type OpenFlag uint32 const ( @@ -159,7 +159,7 @@ const ( // PrepareFlag is a flag that can be passed to [Conn.PrepareFlags]. // -// https://www.sqlite.org/c3ref/c_prepare_normalize.html +// https://sqlite.org/c3ref/c_prepare_normalize.html type PrepareFlag uint32 const ( @@ -170,7 +170,7 @@ const ( // FunctionFlag is a flag that can be passed to [Conn.PrepareFlags]. // -// https://www.sqlite.org/c3ref/c_deterministic.html +// https://sqlite.org/c3ref/c_deterministic.html type FunctionFlag uint32 const ( @@ -182,7 +182,7 @@ const ( // Datatype is a fundamental datatype of SQLite. // -// https://www.sqlite.org/c3ref/c_blob.html +// https://sqlite.org/c3ref/c_blob.html type Datatype uint32 const ( diff --git a/context.go b/context.go index b0b5563..5eaabf2 100644 --- a/context.go +++ b/context.go @@ -12,7 +12,7 @@ import ( // Context is the context in which an SQL function executes. // An SQLite [Context] is in no way related to a Go [context.Context]. // -// https://www.sqlite.org/c3ref/context.html +// https://sqlite.org/c3ref/context.html type Context struct { c *Conn handle uint32 @@ -29,7 +29,7 @@ func (ctx Context) Conn() *Conn { // SetAuxData saves metadata for argument n of the function. // -// https://www.sqlite.org/c3ref/get_auxdata.html +// https://sqlite.org/c3ref/get_auxdata.html func (ctx Context) SetAuxData(n int, data any) { ptr := util.AddHandle(ctx.c.ctx, data) ctx.c.call(ctx.c.api.setAuxData, uint64(ctx.handle), uint64(n), uint64(ptr)) @@ -37,7 +37,7 @@ func (ctx Context) SetAuxData(n int, data any) { // GetAuxData returns metadata for argument n of the function. // -// https://www.sqlite.org/c3ref/get_auxdata.html +// https://sqlite.org/c3ref/get_auxdata.html func (ctx Context) GetAuxData(n int) any { ptr := uint32(ctx.c.call(ctx.c.api.getAuxData, uint64(ctx.handle), uint64(n))) return util.GetHandle(ctx.c.ctx, ptr) @@ -47,7 +47,7 @@ func (ctx Context) GetAuxData(n int) any { // SQLite does not have a separate boolean storage class. // Instead, boolean values are stored as integers 0 (false) and 1 (true). // -// https://www.sqlite.org/c3ref/result_blob.html +// https://sqlite.org/c3ref/result_blob.html func (ctx Context) ResultBool(value bool) { var i int64 if value { @@ -58,14 +58,14 @@ func (ctx Context) ResultBool(value bool) { // ResultInt sets the result of the function to an int. // -// https://www.sqlite.org/c3ref/result_blob.html +// https://sqlite.org/c3ref/result_blob.html func (ctx Context) ResultInt(value int) { ctx.ResultInt64(int64(value)) } // ResultInt64 sets the result of the function to an int64. // -// https://www.sqlite.org/c3ref/result_blob.html +// https://sqlite.org/c3ref/result_blob.html func (ctx Context) ResultInt64(value int64) { ctx.c.call(ctx.c.api.resultInteger, uint64(ctx.handle), uint64(value)) @@ -73,7 +73,7 @@ func (ctx Context) ResultInt64(value int64) { // ResultFloat sets the result of the function to a float64. // -// https://www.sqlite.org/c3ref/result_blob.html +// https://sqlite.org/c3ref/result_blob.html func (ctx Context) ResultFloat(value float64) { ctx.c.call(ctx.c.api.resultFloat, uint64(ctx.handle), math.Float64bits(value)) @@ -81,7 +81,7 @@ func (ctx Context) ResultFloat(value float64) { // ResultText sets the result of the function to a string. // -// https://www.sqlite.org/c3ref/result_blob.html +// https://sqlite.org/c3ref/result_blob.html func (ctx Context) ResultText(value string) { ptr := ctx.c.newString(value) ctx.c.call(ctx.c.api.resultText, @@ -92,7 +92,7 @@ func (ctx Context) ResultText(value string) { // ResultBlob sets the result of the function to a []byte. // Returning a nil slice is the same as calling [Context.ResultNull]. // -// https://www.sqlite.org/c3ref/result_blob.html +// https://sqlite.org/c3ref/result_blob.html func (ctx Context) ResultBlob(value []byte) { ptr := ctx.c.newBytes(value) ctx.c.call(ctx.c.api.resultBlob, @@ -102,7 +102,7 @@ func (ctx Context) ResultBlob(value []byte) { // BindZeroBlob sets the result of the function to a zero-filled, length n BLOB. // -// https://www.sqlite.org/c3ref/result_blob.html +// https://sqlite.org/c3ref/result_blob.html func (ctx Context) ResultZeroBlob(n int64) { ctx.c.call(ctx.c.api.resultZeroBlob, uint64(ctx.handle), uint64(n)) @@ -110,7 +110,7 @@ func (ctx Context) ResultZeroBlob(n int64) { // ResultNull sets the result of the function to NULL. // -// https://www.sqlite.org/c3ref/result_blob.html +// https://sqlite.org/c3ref/result_blob.html func (ctx Context) ResultNull() { ctx.c.call(ctx.c.api.resultNull, uint64(ctx.handle)) @@ -118,7 +118,7 @@ func (ctx Context) ResultNull() { // ResultTime sets the result of the function to a [time.Time]. // -// https://www.sqlite.org/c3ref/result_blob.html +// https://sqlite.org/c3ref/result_blob.html func (ctx Context) ResultTime(value time.Time, format TimeFormat) { if format == TimeFormatDefault { ctx.resultRFC3339Nano(value) @@ -152,7 +152,7 @@ func (ctx Context) resultRFC3339Nano(value time.Time) { // except that it also associates ptr with that NULL value such that it can be retrieved // within an application-defined SQL function using [Value.Pointer]. // -// https://www.sqlite.org/c3ref/result_blob.html +// https://sqlite.org/c3ref/result_blob.html func (ctx Context) ResultPointer(ptr any) { valPtr := util.AddHandle(ctx.c.ctx, ptr) ctx.c.call(ctx.c.api.resultPointer, uint64(valPtr)) @@ -160,7 +160,7 @@ func (ctx Context) ResultPointer(ptr any) { // ResultJSON sets the result of the function to the JSON encoding of value. // -// https://www.sqlite.org/c3ref/result_blob.html +// https://sqlite.org/c3ref/result_blob.html func (ctx Context) ResultJSON(value any) { data, err := json.Marshal(value) if err != nil { @@ -174,7 +174,7 @@ func (ctx Context) ResultJSON(value any) { // ResultValue sets the result of the function a copy of [Value]. // -// https://www.sqlite.org/c3ref/result_blob.html +// https://sqlite.org/c3ref/result_blob.html func (ctx Context) ResultValue(value Value) { if value.sqlite != ctx.c.sqlite { ctx.ResultError(MISUSE) @@ -185,7 +185,7 @@ func (ctx Context) ResultValue(value Value) { // ResultError sets the result of the function an error. // -// https://www.sqlite.org/c3ref/result_blob.html +// https://sqlite.org/c3ref/result_blob.html func (ctx Context) ResultError(err error) { if errors.Is(err, NOMEM) { ctx.c.call(ctx.c.api.resultErrorMem, uint64(ctx.handle)) diff --git a/driver/driver.go b/driver/driver.go index 319cbdc..daa6003 100644 --- a/driver/driver.go +++ b/driver/driver.go @@ -21,9 +21,9 @@ // Order matters: // busy timeout and locking mode should be the first PRAGMAs set, in that order. // -// [URI]: https://www.sqlite.org/uri.html -// [PRAGMA]: https://www.sqlite.org/pragma.html -// [TRANSACTION]: https://www.sqlite.org/lang_transaction.html#deferred_immediate_and_exclusive_transactions +// [URI]: https://sqlite.org/uri.html +// [PRAGMA]: https://sqlite.org/pragma.html +// [TRANSACTION]: https://sqlite.org/lang_transaction.html#deferred_immediate_and_exclusive_transactions package driver import ( diff --git a/driver/savepoint.go b/driver/savepoint.go index 0e2f48f..60aa6b9 100644 --- a/driver/savepoint.go +++ b/driver/savepoint.go @@ -9,7 +9,7 @@ import ( // Savepoint establishes a new transaction savepoint. // -// https://www.sqlite.org/lang_savepoint.html +// https://sqlite.org/lang_savepoint.html func Savepoint(tx *sql.Tx) sqlite3.Savepoint { var ctx saveptCtx tx.ExecContext(&ctx, "") diff --git a/embed/README.md b/embed/README.md index d55a7b9..397d7d9 100644 --- a/embed/README.md +++ b/embed/README.md @@ -4,12 +4,12 @@ This folder includes an embeddable WASM build of SQLite 3.44.0 for use with [`github.com/ncruces/go-sqlite3`](https://pkg.go.dev/github.com/ncruces/go-sqlite3). The following optional features are compiled in: -- [math functions](https://www.sqlite.org/lang_mathfunc.html) -- [FTS3/4](https://www.sqlite.org/fts3.html)/[5](https://www.sqlite.org/fts5.html) -- [JSON](https://www.sqlite.org/json1.html) -- [R*Tree](https://www.sqlite.org/rtree.html) -- [GeoPoly](https://www.sqlite.org/geopoly.html) -- [soundex](https://www.sqlite.org/lang_corefunc.html#soundex) +- [math functions](https://sqlite.org/lang_mathfunc.html) +- [FTS3/4](https://sqlite.org/fts3.html)/[5](https://sqlite.org/fts5.html) +- [JSON](https://sqlite.org/json1.html) +- [R*Tree](https://sqlite.org/rtree.html) +- [GeoPoly](https://sqlite.org/geopoly.html) +- [soundex](https://sqlite.org/lang_corefunc.html#soundex) - [base64](https://github.com/sqlite/sqlite/blob/master/ext/misc/base64.c) - [decimal](https://github.com/sqlite/sqlite/blob/master/ext/misc/decimal.c) - [regexp](https://github.com/sqlite/sqlite/blob/master/ext/misc/regexp.c) diff --git a/error.go b/error.go index c91dccd..7d9cf6f 100644 --- a/error.go +++ b/error.go @@ -9,7 +9,7 @@ import ( // Error wraps an SQLite Error Code. // -// https://www.sqlite.org/c3ref/errcode.html +// https://sqlite.org/c3ref/errcode.html type Error struct { str string msg string @@ -19,14 +19,14 @@ type Error struct { // Code returns the primary error code for this error. // -// https://www.sqlite.org/rescode.html +// https://sqlite.org/rescode.html func (e *Error) Code() ErrorCode { return ErrorCode(e.code) } // ExtendedCode returns the extended error code for this error. // -// https://www.sqlite.org/rescode.html +// https://sqlite.org/rescode.html func (e *Error) ExtendedCode() ExtendedErrorCode { return ExtendedErrorCode(e.code) } diff --git a/func.go b/func.go index 0077d2b..53e53cb 100644 --- a/func.go +++ b/func.go @@ -19,7 +19,7 @@ func (c *Conn) AnyCollationNeeded() { // CreateCollation defines a new collating sequence. // -// https://www.sqlite.org/c3ref/create_collation.html +// https://sqlite.org/c3ref/create_collation.html func (c *Conn) CreateCollation(name string, fn func(a, b []byte) int) error { namePtr := c.arena.string(name) funcPtr := util.AddHandle(c.ctx, fn) @@ -34,7 +34,7 @@ func (c *Conn) CreateCollation(name string, fn func(a, b []byte) int) error { // CreateFunction defines a new scalar SQL function. // -// https://www.sqlite.org/c3ref/create_function.html +// https://sqlite.org/c3ref/create_function.html func (c *Conn) CreateFunction(name string, nArg int, flag FunctionFlag, fn func(ctx Context, arg ...Value)) error { namePtr := c.arena.string(name) funcPtr := util.AddHandle(c.ctx, fn) @@ -48,7 +48,7 @@ func (c *Conn) CreateFunction(name string, nArg int, flag FunctionFlag, fn func( // If fn returns a [WindowFunction], then an aggregate window function is created. // If fn returns an [io.Closer], it will be called to free resources. // -// https://www.sqlite.org/c3ref/create_function.html +// https://sqlite.org/c3ref/create_function.html func (c *Conn) CreateWindowFunction(name string, nArg int, flag FunctionFlag, fn func() AggregateFunction) error { call := c.api.createAggregate namePtr := c.arena.string(name) @@ -64,7 +64,7 @@ func (c *Conn) CreateWindowFunction(name string, nArg int, flag FunctionFlag, fn // AggregateFunction is the interface an aggregate function should implement. // -// https://www.sqlite.org/appfunc.html +// https://sqlite.org/appfunc.html type AggregateFunction interface { // Step is invoked to add a row to the current window. // The function arguments, if any, corresponding to the row being added are passed to Step. @@ -76,7 +76,7 @@ type AggregateFunction interface { // WindowFunction is the interface an aggregate window function should implement. // -// https://www.sqlite.org/windowfunctions.html +// https://sqlite.org/windowfunctions.html type WindowFunction interface { AggregateFunction diff --git a/gormlite/sqlite.go b/gormlite/sqlite.go index 99c7f43..a5b0d69 100644 --- a/gormlite/sqlite.go +++ b/gormlite/sqlite.go @@ -53,7 +53,7 @@ func (dialector _Dialector) Initialize(db *gorm.DB) (err error) { if err := db.ConnPool.QueryRowContext(context.Background(), "select sqlite_version()").Scan(&version); err != nil { return err } - // https://www.sqlite.org/releaselog/3_35_0.html + // https://sqlite.org/releaselog/3_35_0.html if compareVersion(version, "3.35.0") >= 0 { callbacks.RegisterDefaultCallbacks(db, &callbacks.Config{ CreateClauses: []string{"INSERT", "VALUES", "ON CONFLICT", "RETURNING"}, @@ -202,7 +202,7 @@ func (dialector _Dialector) DataTypeOf(field *schema.Field) string { case schema.Int, schema.Uint: if field.AutoIncrement { // doesn't check `PrimaryKey`, to keep backward compatibility - // https://www.sqlite.org/autoinc.html + // https://sqlite.org/autoinc.html return "integer PRIMARY KEY AUTOINCREMENT" } else { return "integer" diff --git a/pointer.go b/pointer.go index 23158df..dba1e44 100644 --- a/pointer.go +++ b/pointer.go @@ -4,7 +4,7 @@ package sqlite3 // that can be used as an argument to // [database/sql.DB.Exec] and similar methods. // -// https://www.sqlite.org/bindptr.html +// https://sqlite.org/bindptr.html func Pointer[T any](val T) any { return pointer[T]{val} } diff --git a/sqlite3/sqlite_cfg.h b/sqlite3/sqlite_cfg.h index e40a8e3..97705bb 100644 --- a/sqlite3/sqlite_cfg.h +++ b/sqlite3/sqlite_cfg.h @@ -53,7 +53,7 @@ // Because WASM does not support shared memory, // SQLite disables WAL for WASM builds. // We patch SQLite to use exclusive locking mode instead. -// https://www.sqlite.org/wal.html#noshm +// https://sqlite.org/wal.html#noshm #undef SQLITE_OMIT_WAL // Amalgamated Extensions diff --git a/stmt.go b/stmt.go index 67b44db..d449669 100644 --- a/stmt.go +++ b/stmt.go @@ -11,7 +11,7 @@ import ( // Stmt is a prepared statement object. // -// https://www.sqlite.org/c3ref/stmt.html +// https://sqlite.org/c3ref/stmt.html type Stmt struct { c *Conn err error @@ -22,7 +22,7 @@ type Stmt struct { // // It is safe to close a nil, zero or closed Stmt. // -// https://www.sqlite.org/c3ref/finalize.html +// https://sqlite.org/c3ref/finalize.html func (s *Stmt) Close() error { if s == nil || s.handle == 0 { return nil @@ -36,7 +36,7 @@ func (s *Stmt) Close() error { // Reset resets the prepared statement object. // -// https://www.sqlite.org/c3ref/reset.html +// https://sqlite.org/c3ref/reset.html func (s *Stmt) Reset() error { r := s.c.call(s.c.api.reset, uint64(s.handle)) s.err = nil @@ -45,7 +45,7 @@ func (s *Stmt) Reset() error { // ClearBindings resets all bindings on the prepared statement. // -// https://www.sqlite.org/c3ref/clear_bindings.html +// https://sqlite.org/c3ref/clear_bindings.html func (s *Stmt) ClearBindings() error { r := s.c.call(s.c.api.clearBindings, uint64(s.handle)) return s.c.error(r) @@ -59,7 +59,7 @@ func (s *Stmt) ClearBindings() error { // If an error has occurred, Step returns false; // call [Stmt.Err] or [Stmt.Reset] to get the error. // -// https://www.sqlite.org/c3ref/step.html +// https://sqlite.org/c3ref/step.html func (s *Stmt) Step() bool { s.c.checkInterrupt() r := s.c.call(s.c.api.step, uint64(s.handle)) @@ -77,7 +77,7 @@ func (s *Stmt) Step() bool { // Err gets the last error occurred during [Stmt.Step]. // Err returns nil after [Stmt.Reset] is called. // -// https://www.sqlite.org/c3ref/step.html +// https://sqlite.org/c3ref/step.html func (s *Stmt) Err() error { return s.err } @@ -92,7 +92,7 @@ func (s *Stmt) Exec() error { // BindCount returns the number of SQL parameters in the prepared statement. // -// https://www.sqlite.org/c3ref/bind_parameter_count.html +// https://sqlite.org/c3ref/bind_parameter_count.html func (s *Stmt) BindCount() int { r := s.c.call(s.c.api.bindCount, uint64(s.handle)) @@ -102,7 +102,7 @@ func (s *Stmt) BindCount() int { // BindIndex returns the index of a parameter in the prepared statement // given its name. // -// https://www.sqlite.org/c3ref/bind_parameter_index.html +// https://sqlite.org/c3ref/bind_parameter_index.html func (s *Stmt) BindIndex(name string) int { defer s.c.arena.reset() namePtr := s.c.arena.string(name) @@ -114,7 +114,7 @@ func (s *Stmt) BindIndex(name string) int { // BindName returns the name of a parameter in the prepared statement. // The leftmost SQL parameter has an index of 1. // -// https://www.sqlite.org/c3ref/bind_parameter_name.html +// https://sqlite.org/c3ref/bind_parameter_name.html func (s *Stmt) BindName(param int) string { r := s.c.call(s.c.api.bindName, uint64(s.handle), uint64(param)) @@ -131,7 +131,7 @@ func (s *Stmt) BindName(param int) string { // SQLite does not have a separate boolean storage class. // Instead, boolean values are stored as integers 0 (false) and 1 (true). // -// https://www.sqlite.org/c3ref/bind_blob.html +// https://sqlite.org/c3ref/bind_blob.html func (s *Stmt) BindBool(param int, value bool) error { var i int64 if value { @@ -143,7 +143,7 @@ func (s *Stmt) BindBool(param int, value bool) error { // BindInt binds an int to the prepared statement. // The leftmost SQL parameter has an index of 1. // -// https://www.sqlite.org/c3ref/bind_blob.html +// https://sqlite.org/c3ref/bind_blob.html func (s *Stmt) BindInt(param int, value int) error { return s.BindInt64(param, int64(value)) } @@ -151,7 +151,7 @@ func (s *Stmt) BindInt(param int, value int) error { // BindInt64 binds an int64 to the prepared statement. // The leftmost SQL parameter has an index of 1. // -// https://www.sqlite.org/c3ref/bind_blob.html +// https://sqlite.org/c3ref/bind_blob.html func (s *Stmt) BindInt64(param int, value int64) error { r := s.c.call(s.c.api.bindInteger, uint64(s.handle), uint64(param), uint64(value)) @@ -161,7 +161,7 @@ func (s *Stmt) BindInt64(param int, value int64) error { // BindFloat binds a float64 to the prepared statement. // The leftmost SQL parameter has an index of 1. // -// https://www.sqlite.org/c3ref/bind_blob.html +// https://sqlite.org/c3ref/bind_blob.html func (s *Stmt) BindFloat(param int, value float64) error { r := s.c.call(s.c.api.bindFloat, uint64(s.handle), uint64(param), math.Float64bits(value)) @@ -171,7 +171,7 @@ func (s *Stmt) BindFloat(param int, value float64) error { // BindText binds a string to the prepared statement. // The leftmost SQL parameter has an index of 1. // -// https://www.sqlite.org/c3ref/bind_blob.html +// https://sqlite.org/c3ref/bind_blob.html func (s *Stmt) BindText(param int, value string) error { ptr := s.c.newString(value) r := s.c.call(s.c.api.bindText, @@ -185,7 +185,7 @@ func (s *Stmt) BindText(param int, value string) error { // The leftmost SQL parameter has an index of 1. // Binding a nil slice is the same as calling [Stmt.BindNull]. // -// https://www.sqlite.org/c3ref/bind_blob.html +// https://sqlite.org/c3ref/bind_blob.html func (s *Stmt) BindBlob(param int, value []byte) error { ptr := s.c.newBytes(value) r := s.c.call(s.c.api.bindBlob, @@ -198,7 +198,7 @@ func (s *Stmt) BindBlob(param int, value []byte) error { // BindZeroBlob binds a zero-filled, length n BLOB to the prepared statement. // The leftmost SQL parameter has an index of 1. // -// https://www.sqlite.org/c3ref/bind_blob.html +// https://sqlite.org/c3ref/bind_blob.html func (s *Stmt) BindZeroBlob(param int, n int64) error { r := s.c.call(s.c.api.bindZeroBlob, uint64(s.handle), uint64(param), uint64(n)) @@ -208,7 +208,7 @@ func (s *Stmt) BindZeroBlob(param int, n int64) error { // BindNull binds a NULL to the prepared statement. // The leftmost SQL parameter has an index of 1. // -// https://www.sqlite.org/c3ref/bind_blob.html +// https://sqlite.org/c3ref/bind_blob.html func (s *Stmt) BindNull(param int) error { r := s.c.call(s.c.api.bindNull, uint64(s.handle), uint64(param)) @@ -218,7 +218,7 @@ func (s *Stmt) BindNull(param int) error { // BindTime binds a [time.Time] to the prepared statement. // The leftmost SQL parameter has an index of 1. // -// https://www.sqlite.org/c3ref/bind_blob.html +// https://sqlite.org/c3ref/bind_blob.html func (s *Stmt) BindTime(param int, value time.Time, format TimeFormat) error { if format == TimeFormatDefault { return s.bindRFC3339Nano(param, value) @@ -254,7 +254,7 @@ func (s *Stmt) bindRFC3339Nano(param int, value time.Time) error { // but it also associates ptr with that NULL value such that it can be retrieved // within an application-defined SQL function using [Value.Pointer]. // -// https://www.sqlite.org/c3ref/bind_blob.html +// https://sqlite.org/c3ref/bind_blob.html func (s *Stmt) BindPointer(param int, ptr any) error { valPtr := util.AddHandle(s.c.ctx, ptr) r := s.c.call(s.c.api.bindPointer, @@ -265,7 +265,7 @@ func (s *Stmt) BindPointer(param int, ptr any) error { // BindJSON binds the JSON encoding of value to the prepared statement. // The leftmost SQL parameter has an index of 1. // -// https://www.sqlite.org/c3ref/bind_blob.html +// https://sqlite.org/c3ref/bind_blob.html func (s *Stmt) BindJSON(param int, value any) error { data, err := json.Marshal(value) if err != nil { @@ -281,7 +281,7 @@ func (s *Stmt) BindJSON(param int, value any) error { // ColumnCount returns the number of columns in a result set. // -// https://www.sqlite.org/c3ref/column_count.html +// https://sqlite.org/c3ref/column_count.html func (s *Stmt) ColumnCount() int { r := s.c.call(s.c.api.columnCount, uint64(s.handle)) @@ -291,7 +291,7 @@ func (s *Stmt) ColumnCount() int { // ColumnName returns the name of the result column. // The leftmost column of the result set has the index 0. // -// https://www.sqlite.org/c3ref/column_name.html +// https://sqlite.org/c3ref/column_name.html func (s *Stmt) ColumnName(col int) string { r := s.c.call(s.c.api.columnName, uint64(s.handle), uint64(col)) @@ -306,7 +306,7 @@ func (s *Stmt) ColumnName(col int) string { // ColumnType returns the initial [Datatype] of the result column. // The leftmost column of the result set has the index 0. // -// https://www.sqlite.org/c3ref/column_blob.html +// https://sqlite.org/c3ref/column_blob.html func (s *Stmt) ColumnType(col int) Datatype { r := s.c.call(s.c.api.columnType, uint64(s.handle), uint64(col)) @@ -319,7 +319,7 @@ func (s *Stmt) ColumnType(col int) Datatype { // Instead, boolean values are retrieved as integers, // with 0 converted to false and any other value to true. // -// https://www.sqlite.org/c3ref/column_blob.html +// https://sqlite.org/c3ref/column_blob.html func (s *Stmt) ColumnBool(col int) bool { if i := s.ColumnInt64(col); i != 0 { return true @@ -330,7 +330,7 @@ func (s *Stmt) ColumnBool(col int) bool { // ColumnInt returns the value of the result column as an int. // The leftmost column of the result set has the index 0. // -// https://www.sqlite.org/c3ref/column_blob.html +// https://sqlite.org/c3ref/column_blob.html func (s *Stmt) ColumnInt(col int) int { return int(s.ColumnInt64(col)) } @@ -338,7 +338,7 @@ func (s *Stmt) ColumnInt(col int) int { // ColumnInt64 returns the value of the result column as an int64. // The leftmost column of the result set has the index 0. // -// https://www.sqlite.org/c3ref/column_blob.html +// https://sqlite.org/c3ref/column_blob.html func (s *Stmt) ColumnInt64(col int) int64 { r := s.c.call(s.c.api.columnInteger, uint64(s.handle), uint64(col)) @@ -348,7 +348,7 @@ func (s *Stmt) ColumnInt64(col int) int64 { // ColumnFloat returns the value of the result column as a float64. // The leftmost column of the result set has the index 0. // -// https://www.sqlite.org/c3ref/column_blob.html +// https://sqlite.org/c3ref/column_blob.html func (s *Stmt) ColumnFloat(col int) float64 { r := s.c.call(s.c.api.columnFloat, uint64(s.handle), uint64(col)) @@ -358,7 +358,7 @@ func (s *Stmt) ColumnFloat(col int) float64 { // ColumnTime returns the value of the result column as a [time.Time]. // The leftmost column of the result set has the index 0. // -// https://www.sqlite.org/c3ref/column_blob.html +// https://sqlite.org/c3ref/column_blob.html func (s *Stmt) ColumnTime(col int, format TimeFormat) time.Time { var v any switch s.ColumnType(col) { @@ -383,7 +383,7 @@ func (s *Stmt) ColumnTime(col int, format TimeFormat) time.Time { // ColumnText returns the value of the result column as a string. // The leftmost column of the result set has the index 0. // -// https://www.sqlite.org/c3ref/column_blob.html +// https://sqlite.org/c3ref/column_blob.html func (s *Stmt) ColumnText(col int) string { return string(s.ColumnRawText(col)) } @@ -392,7 +392,7 @@ func (s *Stmt) ColumnText(col int) string { // the value of the result column as a []byte. // The leftmost column of the result set has the index 0. // -// https://www.sqlite.org/c3ref/column_blob.html +// https://sqlite.org/c3ref/column_blob.html func (s *Stmt) ColumnBlob(col int, buf []byte) []byte { return append(buf, s.ColumnRawBlob(col)...) } @@ -402,7 +402,7 @@ func (s *Stmt) ColumnBlob(col int, buf []byte) []byte { // subsequent calls to [Stmt] methods. // The leftmost column of the result set has the index 0. // -// https://www.sqlite.org/c3ref/column_blob.html +// https://sqlite.org/c3ref/column_blob.html func (s *Stmt) ColumnRawText(col int) []byte { r := s.c.call(s.c.api.columnText, uint64(s.handle), uint64(col)) @@ -414,7 +414,7 @@ func (s *Stmt) ColumnRawText(col int) []byte { // subsequent calls to [Stmt] methods. // The leftmost column of the result set has the index 0. // -// https://www.sqlite.org/c3ref/column_blob.html +// https://sqlite.org/c3ref/column_blob.html func (s *Stmt) ColumnRawBlob(col int) []byte { r := s.c.call(s.c.api.columnBlob, uint64(s.handle), uint64(col)) @@ -437,7 +437,7 @@ func (s *Stmt) columnRawBytes(col int, ptr uint32) []byte { // and stores it in the value pointed to by ptr. // The leftmost column of the result set has the index 0. // -// https://www.sqlite.org/c3ref/column_blob.html +// https://sqlite.org/c3ref/column_blob.html func (s *Stmt) ColumnJSON(col int, ptr any) error { var data []byte switch s.ColumnType(col) { diff --git a/time.go b/time.go index 257ac1d..e5cc3ed 100644 --- a/time.go +++ b/time.go @@ -15,12 +15,12 @@ import ( // See the documentation for the [TimeFormatDefault] constant // for formats recognized by SQLite. // -// https://www.sqlite.org/lang_datefunc.html +// https://sqlite.org/lang_datefunc.html type TimeFormat string // TimeFormats recognized by SQLite to encode/decode time values. // -// https://www.sqlite.org/lang_datefunc.html +// https://sqlite.org/lang_datefunc.html const ( TimeFormatDefault TimeFormat = "" // time.RFC3339Nano @@ -83,9 +83,9 @@ const ( // a float64 for [TimeFormatJulianDay] and [TimeFormatUnixFrac], // or an int64 for the other numeric formats. // -// https://www.sqlite.org/lang_datefunc.html +// https://sqlite.org/lang_datefunc.html // -// [collating sequence]: https://www.sqlite.org/datatype3.html#collating_sequences +// [collating sequence]: https://sqlite.org/datatype3.html#collating_sequences func (f TimeFormat) Encode(t time.Time) any { switch f { // Numeric formats @@ -136,7 +136,7 @@ func (f TimeFormat) Encode(t time.Time) any { // Unix timestamps before 1980 and after 9999 may be misinterpreted as julian day numbers, // or have the wrong time unit. // -// https://www.sqlite.org/lang_datefunc.html +// https://sqlite.org/lang_datefunc.html func (f TimeFormat) Decode(v any) (time.Time, error) { switch f { // Numeric formats diff --git a/tx.go b/tx.go index 64fbe6b..dc26655 100644 --- a/tx.go +++ b/tx.go @@ -12,14 +12,14 @@ import ( // Tx is an in-progress database transaction. // -// https://www.sqlite.org/lang_transaction.html +// https://sqlite.org/lang_transaction.html type Tx struct { c *Conn } // Begin starts a deferred transaction. // -// https://www.sqlite.org/lang_transaction.html +// https://sqlite.org/lang_transaction.html func (c *Conn) Begin() Tx { // BEGIN even if interrupted. err := c.txExecInterrupted(`BEGIN DEFERRED`) @@ -31,7 +31,7 @@ func (c *Conn) Begin() Tx { // BeginImmediate starts an immediate transaction. // -// https://www.sqlite.org/lang_transaction.html +// https://sqlite.org/lang_transaction.html func (c *Conn) BeginImmediate() (Tx, error) { err := c.Exec(`BEGIN IMMEDIATE`) if err != nil { @@ -42,7 +42,7 @@ func (c *Conn) BeginImmediate() (Tx, error) { // BeginExclusive starts an exclusive transaction. // -// https://www.sqlite.org/lang_transaction.html +// https://sqlite.org/lang_transaction.html func (c *Conn) BeginExclusive() (Tx, error) { err := c.Exec(`BEGIN EXCLUSIVE`) if err != nil { @@ -63,7 +63,7 @@ func (c *Conn) BeginExclusive() (Tx, error) { // // ... do work in the transaction // } // -// https://www.sqlite.org/lang_transaction.html +// https://sqlite.org/lang_transaction.html func (tx Tx) End(errp *error) { recovered := recover() if recovered != nil { @@ -94,7 +94,7 @@ func (tx Tx) End(errp *error) { // Commit commits the transaction. // -// https://www.sqlite.org/lang_transaction.html +// https://sqlite.org/lang_transaction.html func (tx Tx) Commit() error { return tx.c.Exec(`COMMIT`) } @@ -102,7 +102,7 @@ func (tx Tx) Commit() error { // Rollback rolls back the transaction, // even if the connection has been interrupted. // -// https://www.sqlite.org/lang_transaction.html +// https://sqlite.org/lang_transaction.html func (tx Tx) Rollback() error { return tx.c.txExecInterrupted(`ROLLBACK`) } @@ -110,7 +110,7 @@ func (tx Tx) Rollback() error { // Savepoint is a marker within a transaction // that allows for partial rollback. // -// https://www.sqlite.org/lang_savepoint.html +// https://sqlite.org/lang_savepoint.html type Savepoint struct { c *Conn name string @@ -118,7 +118,7 @@ type Savepoint struct { // Savepoint establishes a new transaction savepoint. // -// https://www.sqlite.org/lang_savepoint.html +// https://sqlite.org/lang_savepoint.html func (c *Conn) Savepoint() Savepoint { // Names can be reused; this makes catching bugs more likely. name := saveptName() + "_" + strconv.Itoa(int(rand.Int31())) @@ -198,7 +198,7 @@ func (s Savepoint) Release(errp *error) { // even if the connection has been interrupted. // Rollback does not release the savepoint. // -// https://www.sqlite.org/lang_transaction.html +// https://sqlite.org/lang_transaction.html func (s Savepoint) Rollback() error { // ROLLBACK even if interrupted. return s.c.txExecInterrupted(fmt.Sprintf("ROLLBACK TO %q;", s.name)) diff --git a/value.go b/value.go index 5da5ac8..4c7f304 100644 --- a/value.go +++ b/value.go @@ -11,7 +11,7 @@ import ( // Value is any value that can be stored in a database table. // -// https://www.sqlite.org/c3ref/value.html +// https://sqlite.org/c3ref/value.html type Value struct { *sqlite handle uint32 @@ -19,7 +19,7 @@ type Value struct { // Type returns the initial [Datatype] of the value. // -// https://www.sqlite.org/c3ref/value_blob.html +// https://sqlite.org/c3ref/value_blob.html func (v Value) Type() Datatype { r := v.call(v.api.valueType, uint64(v.handle)) return Datatype(r) @@ -30,7 +30,7 @@ func (v Value) Type() Datatype { // Instead, boolean values are retrieved as integers, // with 0 converted to false and any other value to true. // -// https://www.sqlite.org/c3ref/value_blob.html +// https://sqlite.org/c3ref/value_blob.html func (v Value) Bool() bool { if i := v.Int64(); i != 0 { return true @@ -40,14 +40,14 @@ func (v Value) Bool() bool { // Int returns the value as an int. // -// https://www.sqlite.org/c3ref/value_blob.html +// https://sqlite.org/c3ref/value_blob.html func (v Value) Int() int { return int(v.Int64()) } // Int64 returns the value as an int64. // -// https://www.sqlite.org/c3ref/value_blob.html +// https://sqlite.org/c3ref/value_blob.html func (v Value) Int64() int64 { r := v.call(v.api.valueInteger, uint64(v.handle)) return int64(r) @@ -55,7 +55,7 @@ func (v Value) Int64() int64 { // Float returns the value as a float64. // -// https://www.sqlite.org/c3ref/value_blob.html +// https://sqlite.org/c3ref/value_blob.html func (v Value) Float() float64 { r := v.call(v.api.valueFloat, uint64(v.handle)) return math.Float64frombits(r) @@ -63,7 +63,7 @@ func (v Value) Float() float64 { // Time returns the value as a [time.Time]. // -// https://www.sqlite.org/c3ref/value_blob.html +// https://sqlite.org/c3ref/value_blob.html func (v Value) Time(format TimeFormat) time.Time { var a any switch v.Type() { @@ -84,7 +84,7 @@ func (v Value) Time(format TimeFormat) time.Time { // Text returns the value as a string. // -// https://www.sqlite.org/c3ref/value_blob.html +// https://sqlite.org/c3ref/value_blob.html func (v Value) Text() string { return string(v.RawText()) } @@ -92,7 +92,7 @@ func (v Value) Text() string { // Blob appends to buf and returns // the value as a []byte. // -// https://www.sqlite.org/c3ref/value_blob.html +// https://sqlite.org/c3ref/value_blob.html func (v Value) Blob(buf []byte) []byte { return append(buf, v.RawBlob()...) } @@ -101,7 +101,7 @@ func (v Value) Blob(buf []byte) []byte { // The []byte is owned by SQLite and may be invalidated by // subsequent calls to [Value] methods. // -// https://www.sqlite.org/c3ref/value_blob.html +// https://sqlite.org/c3ref/value_blob.html func (v Value) RawText() []byte { r := v.call(v.api.valueText, uint64(v.handle)) return v.rawBytes(uint32(r)) @@ -111,7 +111,7 @@ func (v Value) RawText() []byte { // The []byte is owned by SQLite and may be invalidated by // subsequent calls to [Value] methods. // -// https://www.sqlite.org/c3ref/value_blob.html +// https://sqlite.org/c3ref/value_blob.html func (v Value) RawBlob() []byte { r := v.call(v.api.valueBlob, uint64(v.handle)) return v.rawBytes(uint32(r)) diff --git a/vfs/README.md b/vfs/README.md index ee47315..0d734b4 100644 --- a/vfs/README.md +++ b/vfs/README.md @@ -1,6 +1,6 @@ # Go SQLite VFS API -This package implements the SQLite [OS Interface](https://www.sqlite.org/vfs.html) (aka VFS). +This package implements the SQLite [OS Interface](https://sqlite.org/vfs.html) (aka VFS). It replaces the default SQLite VFS with a pure Go implementation. diff --git a/vfs/api.go b/vfs/api.go index c414d30..df4d790 100644 --- a/vfs/api.go +++ b/vfs/api.go @@ -7,7 +7,7 @@ import "net/url" // // Use sqlite3.ErrorCode or sqlite3.ExtendedErrorCode to return specific error codes to SQLite. // -// https://www.sqlite.org/c3ref/vfs.html +// https://sqlite.org/c3ref/vfs.html type VFS interface { Open(name string, flags OpenFlag) (File, OpenFlag, error) Delete(name string, syncDir bool) error @@ -18,7 +18,7 @@ type VFS interface { // VFSParams extends VFS with the ability to handle URI parameters // through the OpenParams method. // -// https://www.sqlite.org/c3ref/uri_boolean.html +// https://sqlite.org/c3ref/uri_boolean.html type VFSParams interface { VFS OpenParams(name string, flags OpenFlag, params url.Values) (File, OpenFlag, error) @@ -29,7 +29,7 @@ type VFSParams interface { // Use sqlite3.ErrorCode or sqlite3.ExtendedErrorCode to return specific error codes to SQLite. // In particular, sqlite3.BUSY is necessary to correctly implement lock methods. // -// https://www.sqlite.org/c3ref/io_methods.html +// https://sqlite.org/c3ref/io_methods.html type File interface { Close() error ReadAt(p []byte, off int64) (n int, err error) @@ -47,7 +47,7 @@ type File interface { // FileLockState extends File to implement the // SQLITE_FCNTL_LOCKSTATE file control opcode. // -// https://www.sqlite.org/c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntllockstate +// https://sqlite.org/c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntllockstate type FileLockState interface { File LockState() LockLevel @@ -56,7 +56,7 @@ type FileLockState interface { // FileSizeHint extends File to implement the // SQLITE_FCNTL_SIZE_HINT file control opcode. // -// https://www.sqlite.org/c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlsizehint +// https://sqlite.org/c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlsizehint type FileSizeHint interface { File SizeHint(size int64) error @@ -65,7 +65,7 @@ type FileSizeHint interface { // FileHasMoved extends File to implement the // SQLITE_FCNTL_HAS_MOVED file control opcode. // -// https://www.sqlite.org/c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlhasmoved +// https://sqlite.org/c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlhasmoved type FileHasMoved interface { File HasMoved() (bool, error) @@ -74,7 +74,7 @@ type FileHasMoved interface { // FileOverwrite extends File to implement the // SQLITE_FCNTL_OVERWRITE file control opcode. // -// https://www.sqlite.org/c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntloverwrite +// https://sqlite.org/c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntloverwrite type FileOverwrite interface { File Overwrite() error @@ -83,7 +83,7 @@ type FileOverwrite interface { // FilePowersafeOverwrite extends File to implement the // SQLITE_FCNTL_POWERSAFE_OVERWRITE file control opcode. // -// https://www.sqlite.org/c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlpowersafeoverwrite +// https://sqlite.org/c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlpowersafeoverwrite type FilePowersafeOverwrite interface { File PowersafeOverwrite() bool @@ -93,7 +93,7 @@ type FilePowersafeOverwrite interface { // FilePowersafeOverwrite extends File to implement the // SQLITE_FCNTL_COMMIT_PHASETWO file control opcode. // -// https://www.sqlite.org/c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlcommitphasetwo +// https://sqlite.org/c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlcommitphasetwo type FileCommitPhaseTwo interface { File CommitPhaseTwo() error @@ -103,7 +103,7 @@ type FileCommitPhaseTwo interface { // SQLITE_FCNTL_BEGIN_ATOMIC_WRITE, SQLITE_FCNTL_COMMIT_ATOMIC_WRITE // and SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE file control opcodes. // -// https://www.sqlite.org/c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlbeginatomicwrite +// https://sqlite.org/c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlbeginatomicwrite type FileBatchAtomicWrite interface { File BeginAtomicWrite() error diff --git a/vfs/const.go b/vfs/const.go index 110e8b5..49f2a5e 100644 --- a/vfs/const.go +++ b/vfs/const.go @@ -8,7 +8,7 @@ const ( _DEFAULT_SECTOR_SIZE = 4096 ) -// https://www.sqlite.org/rescode.html +// https://sqlite.org/rescode.html type _ErrorCode uint32 func (e _ErrorCode) Error() string { @@ -49,7 +49,7 @@ const ( // OpenFlag is a flag for the [VFS] Open method. // -// https://www.sqlite.org/c3ref/c_open_autoproxy.html +// https://sqlite.org/c3ref/c_open_autoproxy.html type OpenFlag uint32 const ( @@ -78,7 +78,7 @@ const ( // AccessFlag is a flag for the [VFS] Access method. // -// https://www.sqlite.org/c3ref/c_access_exists.html +// https://sqlite.org/c3ref/c_access_exists.html type AccessFlag uint32 const ( @@ -89,7 +89,7 @@ const ( // SyncFlag is a flag for the [File] Sync method. // -// https://www.sqlite.org/c3ref/c_sync_dataonly.html +// https://sqlite.org/c3ref/c_sync_dataonly.html type SyncFlag uint32 const ( @@ -100,7 +100,7 @@ const ( // LockLevel is a value used with [File] Lock and Unlock methods. // -// https://www.sqlite.org/c3ref/c_lock_exclusive.html +// https://sqlite.org/c3ref/c_lock_exclusive.html type LockLevel uint32 const ( @@ -146,7 +146,7 @@ const ( // DeviceCharacteristic is a flag retuned by the [File] DeviceCharacteristics method. // -// https://www.sqlite.org/c3ref/c_iocap_atomic.html +// https://sqlite.org/c3ref/c_iocap_atomic.html type DeviceCharacteristic uint32 const ( @@ -167,7 +167,7 @@ const ( IOCAP_BATCH_ATOMIC DeviceCharacteristic = 0x00004000 ) -// https://www.sqlite.org/c3ref/c_fcntl_begin_atomic_write.html +// https://sqlite.org/c3ref/c_fcntl_begin_atomic_write.html type _FcntlOpcode uint32 const ( diff --git a/vfs/memdb/README.md b/vfs/memdb/README.md index 6a2b8a6..07ed91c 100644 --- a/vfs/memdb/README.md +++ b/vfs/memdb/README.md @@ -1,6 +1,6 @@ # Go `"memdb"` SQLite VFS -This package implements the [`"memdb"`](https://www.sqlite.org/src/file/src/memdb.c) +This package implements the [`"memdb"`](https://sqlite.org/src/file/src/memdb.c) SQLite VFS in pure Go. It has some benefits over the C version: diff --git a/vfs/readervfs/example_test.go b/vfs/readervfs/example_test.go index 8daaf83..42ab50e 100644 --- a/vfs/readervfs/example_test.go +++ b/vfs/readervfs/example_test.go @@ -18,7 +18,7 @@ import ( var testDB string func Example_http() { - readervfs.Create("demo.db", httpreadat.New("https://www.sanford.io/demo.db")) + readervfs.Create("demo.db", httpreadat.New("https://sanford.io/demo.db")) defer readervfs.Delete("demo.db") db, err := sql.Open("sqlite3", "file:demo.db?vfs=reader") diff --git a/vfs/registry.go b/vfs/registry.go index 33bc54b..7009444 100644 --- a/vfs/registry.go +++ b/vfs/registry.go @@ -12,7 +12,7 @@ var ( // If there is no match, nil is returned. // If name is empty, the default VFS is returned. // -// https://www.sqlite.org/c3ref/vfs_find.html +// https://sqlite.org/c3ref/vfs_find.html func Find(name string) VFS { if name == "" || name == "os" { return vfsOS{} @@ -24,7 +24,7 @@ func Find(name string) VFS { // Register registers a VFS. // -// https://www.sqlite.org/c3ref/vfs_find.html +// https://sqlite.org/c3ref/vfs_find.html func Register(name string, vfs VFS) { if name == "" || name == "os" { return @@ -39,7 +39,7 @@ func Register(name string, vfs VFS) { // Unregister unregisters a VFS. // -// https://www.sqlite.org/c3ref/vfs_find.html +// https://sqlite.org/c3ref/vfs_find.html func Unregister(name string) { vfsRegistryMtx.Lock() defer vfsRegistryMtx.Unlock()