sqlite

package
v0.0.0-...-bdbe55d Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package sqlite generates the SQLite dialect seed under internal/engine/sqlite/dialect from sqlite3 shells built from the amalgamation sqlite.org publishes, run against in-memory databases that need no server, and from the amalgamation itself.

SQLite describes its functions as far as their names, their kinds and the number of arguments each takes — pragma_function_list — and no further: it types values rather than columns or functions, so nothing in the database says what a function returns or what it expects. The source does, in its way. Every function is registered with the C functions that implement it, and those set their result through sqlite3_result_* and read their arguments through sqlite3_value_*, which is as close as SQLite comes to declaring a signature. So functions.jsonl is built from both: the shell says which functions exist, how many arguments each overload takes and whether it aggregates, and the amalgamation says what each returns and what its arguments hold. A function the shell reports that the source does not register, or whose implementation sets no result, fails generation rather than being guessed at. What neither can say — which scalar functions return NULL for arguments that are not — is a short list in signatures.go; for aggregates it is found by running each over no rows.

Which functions a SQLite has is decided when it is compiled, so the dialect treats compile options the way the PostgreSQL dialect treats contrib extensions. functions.jsonl is what a build with the default options has, and each further option gets a directory under extensions/ holding the functions a build with that option adds — found the way CREATE EXTENSION's additions are, by comparing the catalog with and without. SQLite has no catalog of types or operators, so types.jsonl and operators.jsonl are hand-written.

The shells are built once per pinned version by Install.

Index

Constants

View Source
const DefaultVersion = "3.53.4"

DefaultVersion is the SQLite release the dialect is generated from. It is the release the ncruces/go-sqlite3 driver in the main module embeds, so the functions the dialect knows are the ones the tests run against. Bumping it is a deliberate change: releases add functions and overloads, so regenerate and review the dialect after changing it, and add the new release's amalgamation to the table below.

View Source
const Engine = "sqlite"

Engine is the name of the engine directory the dialect lives under.

Variables

This section is empty.

Functions

func Analyze

func Analyze(ctx context.Context, dir string, c endtoend.Case) ([]byte, error)

Analyze runs a case's queries through the analysis shell and returns what SQLite reports in the JSON shape sqlc analyze prints.

func Check

func Check(ctx context.Context, dir string, c endtoend.Case) (string, error)

Check compares what SQLite reports for a case with the output the case committed, returning a diff when they differ.

func Generate

func Generate(ctx context.Context, dir string) (dialect.Files, error)

Generate reads the dialect from the shells under dir and the amalgamation they were built from.

func Install

func Install(ctx context.Context, version, goos, goarch string, progress io.Writer) (string, error)

Install downloads the amalgamation for a version into the cache and compiles the shell from it once per build, returning the directory the shells are under. Builds already there are kept, so adding an option compiles only its shell. The download is checked against the table's SHA3-256 before it is unpacked. Compiling takes the compiler CC names, or cc, and a few seconds per build without optimisation, which a shell that only reads catalogs does not need.

goos and goarch are what every installer is handed; the sources build the same everywhere a C compiler is, but no default compiler or link line is known for Windows.

func Locate

func Locate() (string, error)

Locate finds the directory of shells Install made for DefaultVersion.

func Version

func Version(ctx context.Context, dir string) (string, error)

Version reports the release the default shell is.

Types

This section is empty.

Jump to

Keyboard shortcuts

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