Documentation
¶
Overview ¶
Package sqlite implements the SQLite dialect driver (Tier 2). This file is the lexer profile: token boundaries only, no SQL understanding.
Index ¶
- Constants
- func AffinityRef(decltype string) (dialect.TypeRef, bool)
- type Frontend
- func (Frontend) Parse(sqlText string) (dialect.Tree, error)
- func (f Frontend) ProbeExpr(expr string) error
- func (f Frontend) ProbeGroupBy(clause string) error
- func (f Frontend) ProbeInsertValue(expr string) error
- func (f Frontend) ProbeJoinItem(item string) error
- func (f Frontend) ProbeOrderBy(clause string) error
- func (f Frontend) ProbeOrderByKey(expr string) error
- func (f Frontend) ProbeSetItem(item string) error
- type Oracle
- func (o *Oracle) Describe(ctx context.Context, sql string) (dialect.Desc, error)
- func (o *Oracle) Plan(ctx context.Context, sql string) error
- func (o *Oracle) PlanText(ctx context.Context, sql string) (string, error)
- func (o *Oracle) ServerVersion(ctx context.Context) (string, error)
- func (o *Oracle) Snapshot(ctx context.Context) (*cache.Catalog, error)
- type Profile
- type TypeMap
Constants ¶
const ( TypeInteger uint32 = 1 TypeReal uint32 = 2 TypeText uint32 = 3 TypeBlob uint32 = 4 TypeNumeric uint32 = 5 TypeBool uint32 = 6 TypeTime uint32 = 7 )
SQLite has no OIDs and no static column types — only declared types and affinity rules. dialect.TypeRef.OID carries one of the small codes below; TypeRef.Name keeps the normalized declared type for diagnostics. The encoding is stable — it is what the committed cache stores.
Variables ¶
This section is empty.
Functions ¶
func AffinityRef ¶
AffinityRef classifies a declared column type per SQLite's affinity rules (https://sqlite.org/datatype3.html §3.1), with deliberate carve-outs for the conventional BOOLEAN and date/time declarations (numeric affinity in SQLite, but bool / time.Time is what Go callers want; drivers convert on scan). ok is false only for an empty declared type — an expression column, which needs a `-- @column` annotation.
Types ¶
type Frontend ¶
type Frontend struct{}
Frontend is the rqlite/sql-backed grammar frontend for SQLite: a pure-Go parser with byte offsets on every node (including relation names, unlike the TiDB AST). Known parser gaps versus the current SQLite grammar — RIGHT/FULL JOIN (3.39+) — surface as parse diagnostics; the real-engine oracle backstops everything the grammar accepts.
func (Frontend) ProbeExpr ¶
ProbeExpr checks that expr forms exactly one boolean-position expression. Parenthesis balance is the rules' (lexer-level) concern.
func (Frontend) ProbeGroupBy ¶
ProbeGroupBy checks that clause is exactly one statement-level GROUP BY clause and nothing more.
func (Frontend) ProbeInsertValue ¶
ProbeInsertValue checks that expr is exactly one VALUES row item. (SQLite has no per-item DEFAULT keyword; it fails to parse, which is the correct dialect answer.)
func (Frontend) ProbeJoinItem ¶
ProbeJoinItem checks that item is a join item attachable to a preceding FROM entry.
func (Frontend) ProbeOrderBy ¶
ProbeOrderBy checks that clause is exactly one statement-level ORDER BY clause and nothing more.
func (Frontend) ProbeOrderByKey ¶
ProbeOrderByKey checks that expr is exactly one sort key.
func (Frontend) ProbeSetItem ¶
ProbeSetItem checks that item is exactly one UPDATE SET assignment.
type Oracle ¶
type Oracle struct {
// contains filtered or unexported fields
}
Oracle is the sqlite3_prepare-backed type oracle over the in-process engine (ncruces/go-sqlite3: the real SQLite compiled to WASM, run under wazero — pure Go, nothing external). Preparing compiles the statement through SQLite's planner, so prepare alone is both the parse and the plan check; EXPLAIN QUERY PLAN adds the human-readable plan. Result columns are typed by declared type through the affinity rules; expression columns have no declared type (SQLite returns NULL) and stay zero-typed — the pipeline fills them from mandatory `-- @column` annotations. Parameter slots are never typed by SQLite; `-- @param` annotations are mandatory (Tier 2).
func (*Oracle) Plan ¶
Plan prepares EXPLAIN QUERY PLAN and steps it: preparing already runs SQLite's planner, stepping surfaces any late errors. Unbound parameters are NULL by SQLite's rules — no data is touched.
type Profile ¶
type Profile struct{}
func (Profile) InEmptySQL ¶
InEmptySQL is the arity-0 @in emission (FALSE even for NULL operands; SQLite allows a FROM-less SELECT with WHERE).
func (Profile) PlaceholderStyle ¶
func (Profile) PlaceholderStyle() dialect.PlaceholderStyle
PlaceholderStyle declares SQLite's '?' per-occurrence binding.
type TypeMap ¶
type TypeMap struct{}
TypeMap maps encoded SQLite type refs to Go types for generated code.
func (TypeMap) TypeByName ¶
TypeByName resolves a `-- @param name: type` / `-- @column name: type` annotation — on SQLite the mandatory source of parameter types and of expression-column types. Length arguments are stripped; resolution then follows the affinity rules, so any declarable SQLite type name works.