statement

package
v0.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package statement implements a virtual table that turns any SQL statement into a parametrized view. The statement is supplied as the USING argument; its bound parameters become HIDDEN columns on the vtab, so WHERE-clause equality constraints get pushed back through the prepared statement.

CREATE VIRTUAL TABLE adults USING statement(
    'SELECT id, name FROM users WHERE age >= ?');

-- min_age is exposed as a HIDDEN column; constrain it to bind ?1.
SELECT * FROM adults WHERE "?1" = 18;

Named parameters become correspondingly-named HIDDEN columns:

CREATE VIRTUAL TABLE q USING statement(
    'SELECT id FROM users WHERE name LIKE :pat');

SELECT * FROM q WHERE pat = 'al%';

Constraints

Only positional `?` and named `:name`/`@name`/`$name` parameters are supported as HIDDEN columns. Output columns inherit their declared types from the underlying SELECT via sqlite3_column_decltype.

Ported from ncruces/ext/statement, the SQLite community's statement-vtab extension.

Index

Constants

View Source
const ModuleName = "statement"

ModuleName is the name the vtab registers under: `statement`.

Variables

This section is empty.

Functions

func Register

func Register(c *sqlite.Conn) error

Register installs the `statement` virtual table on c.

Registration is per-connection. For pool-wide install via sqlite.Driver.ConnectHook, blank-import the auto sub-package:

import _ "gosqlite.org/ext/statement/auto"

Types

This section is empty.

Directories

Path Synopsis
Package auto wires the statement extension via a sqlite.Driver.ConnectHook so every new connection registers the `statement` vtab.
Package auto wires the statement extension via a sqlite.Driver.ConnectHook so every new connection registers the `statement` vtab.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL