Skip to documentation
SLOP

tiny.sql.statement

Reference tiny.sql statement

Defined in tiny.sql.

API (35)

Actions

Public operations.

Types and contracts

Public types and contracts.

Values and defaults

Public values and defaults.

No direct callersNo direct callstiny.sqlstatement
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Source: lib/sql/src/statement/ast.zig:137

zig
pub const Analyze = struct {    table: []const u8,};

Source: lib/sql/src/statement/ast.zig:101

zig
pub const Assignment = struct {    column: []const u8,    value: Expression,};

Source: lib/sql/src/statement/ast.zig:131

zig
pub const CreateIndex = struct {    name: []const u8,    table: []const u8,    columns: [][]const u8,};

Source: lib/sql/src/statement/ast.zig:117

zig
pub const CreateTable = struct {    table: []const u8,    columns: []catalog_mod.ColumnDefinition,    indexes: []catalog_mod.IndexDefinition,    pub fn relationDefinition(self: CreateTable) catalog_mod.RelationDefinition {        return .{            .name = self.table,            .columns = self.columns,            .indexes = self.indexes,        };    }};

Source: lib/sql/src/statement/ast.zig:112

zig
pub const Delete = struct {    table: []const u8,    predicates: []Predicate,};

Source: lib/sql/src/statement/ast.zig:141

zig
pub const DropTable = struct {    table: []const u8,};

Source: lib/sql/src/statement/ast.zig:52

zig
pub const Expression = union(enum) {    literal: row.Value,    parameter: usize,};

Source: lib/sql/src/statement/ast.zig:57

zig
pub const Insert = struct {    table: []const u8,    columns: ?[][]const u8 = null,    values: []Expression,};

Source: lib/sql/src/statement/ast.zig:87

zig
pub const OrderKey = struct {    column: PredicateColumn,    descending: bool = false,};

Source: lib/sql/src/statement/ast.zig:200

zig
pub const Parsed = struct {    statement: Statement,    parameters: []Parameter,    pub fn deinit(self: *Parsed, allocator: Allocator) void {        allocator.free(self.parameters);        self.statement.deinit(allocator);        self.* = undefined;    }};

Source: lib/sql/src/statement/ast.zig:81

zig
pub const Predicate = struct {    column: PredicateColumn,    operator: PredicateOperator,    value: Expression,};

Source: lib/sql/src/statement/ast.zig:68

zig
pub const PredicateColumn = union(enum) {    rowid,    field: []const u8,};

Source: lib/sql/src/statement/ast.zig:73

zig
pub const PredicateOperator = enum {    eq,    lt,    lte,    gt,    gte,};

Source: lib/sql/src/statement/ast.zig:63

zig
pub const Projection = union(enum) {    all,    columns: [][]const u8,};

Source: lib/sql/src/statement/ast.zig:92

zig
pub const Select = struct {    table: []const u8,    projection: Projection,    predicates: []Predicate = &.{},    order: []OrderKey = &.{},    limit: ?Expression = null,    offset: ?Expression = null,};

Source: lib/sql/src/statement/ast.zig:106

zig
pub const Update = struct {    table: []const u8,    assignments: []Assignment,    predicates: []Predicate,};

Source: lib/sql/src/statement/execute.zig:122

zig
pub const ExecuteOptions = struct {    durability: file.CommitDurability = .synced,    validate_indexes: bool = false,    session: ?*session_mod.DatabaseSession = null,    write: ?*session_mod.DatabaseWrite = null,    fn commit(self: ExecuteOptions) file.CommitOptions {        return .{            .durability = self.durability,            .validate_indexes = self.validate_indexes,        };    }    fn databaseSession(self: ExecuteOptions) ast_mod.Error!*session_mod.DatabaseSession {        if (self.write) |write| return write.session;        return self.session orelse error.WriteSessionRequired;    }};

Source: lib/sql/src/statement/result.zig:148

zig
pub const Rows = struct {    allocator: Allocator,    storage: RowStorage,    cursor: usize = 0,    pub fn deinit(self: *Rows) void {        switch (self.storage) {            .single => |bytes| if (bytes) |owned| self.allocator.free(owned),            .many => |rows| {                for (rows) |bytes| self.allocator.free(bytes);                self.allocator.free(rows);            },        }        self.* = undefined;    }    pub fn next(self: *Rows) ?[]const u8 {        switch (self.storage) {            .single => |bytes| {                if (self.cursor != 0) return null;                self.cursor = 1;                return bytes;            },            .many => |rows| {                if (self.cursor >= rows.len) return null;                const bytes = rows[self.cursor];                self.cursor += 1;                return bytes;            },        }    }    pub fn count(self: *const Rows) usize {        return switch (self.storage) {            .single => |bytes| if (bytes == null) 0 else 1,            .many => |rows| rows.len,        };    }};

Source: lib/sql/src/statement/access.zig:605

zig
pub fn columnIndex(definitions: []const catalog_mod.ColumnDefinition, name: []const u8) ?usize {    for (definitions, 0..) |definition, index| {        if (std.ascii.eqlIgnoreCase(definition.name, name)) return index;    }    return null;}
Called byCallsNo direct callsprivate sourcelib.sql.src.statement.accessindexCoversColumnprivate sourcelib.sql.src.statement.accessindexCoversPredicatestatementcolumnIndex
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/sql/src/statement/ast.zig:40

zig
pub const Error =    plan.Error ||    session_mod.DatabaseError ||    std.mem.Allocator.Error ||    StatementError;
Called byCallsNo direct callersStatementdeinitstatement.Parseddeinit
Static calls · unresolved targets: 0 · external targets: 1.

Source: lib/sql/src/statement/ast.zig:46

zig
pub const max_parameters: usize = 1024;

Source: lib/sql/src/statement/execute.zig:1188

zig
pub fn prepare(catalog: *const catalog_mod.Catalog, allocator: Allocator, source: []const u8) ast_mod.Error!Prepared {    return try prepareWithValidation(catalog, allocator, source, .content);}
Called byCallstest sourcelib.sql.src.statement.executetest: covering index and table scan r...test sourcelib.sql.src.statement.executetest: covering planner requires order...test sourcelib.sql.src.statement.executetest: prepared index cursor keeps one...test sourcelib.sql.src.statement.executetest: prepared statement cache key in...test sourcelib.sql.src.statement.executetest: prepared statement ignores unre...+29 moreprivate sourcelib.sql.src.statement.executeprepareWithValidationstatementprepare
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/sql/src/statement/execute.zig:1192

zig
pub fn prepareReadOnly(catalog: *const catalog_mod.Catalog, allocator: Allocator, source: []const u8) ast_mod.Error!Prepared {    return try prepareWithValidation(catalog, allocator, source, .shape);}
Called byCallstest sourcelib.sql.src.statement.executetest: prepared read only statements u...private sourcelib.sql.src.statement.executeprepareWithValidationstatementprepareReadOnly
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/sql/src/statement/parse.zig:11

zig
pub fn parse(allocator: Allocator, source: []const u8) ast_mod.Error!ast_mod.Statement {    var parsed = try parseWithParameters(allocator, source);    errdefer parsed.deinit(allocator);    allocator.free(parsed.parameters);    return parsed.statement;}
Called byCallstest sourcelib.sql.src.statement.parsetest: statement parser accepts bare s...test sourcelib.sql.src.statement.parsetest: statement parser accepts order ...test sourcelib.sql.src.statement.parsetest: statement parser accepts rowid ...test sourcelib.sql.src.statement.parsetest: statement parser accepts update...statementparseWithParametersstatementparse
Static calls · unresolved targets: 0 · external targets: 2.

Source: lib/sql/src/statement/parse.zig:18

zig
pub fn parseWithParameters(allocator: Allocator, source: []const u8) ast_mod.Error!ast_mod.Parsed {    const phase = trace.scope("statement.parse");    defer phase.end();    var parser = Parser{ .source = source };    defer parser.parameters.deinit(allocator);    const statement = try parser.statement(allocator);    errdefer {        var owned = statement;        owned.deinit(allocator);    }    try parser.finish();    return .{        .statement = statement,        .parameters = try parser.parameters.toOwnedSlice(allocator),    };}
Called byCallsNo direct callsstatementparsetest sourcelib.sql.src.statement.parsetest: parse reaches allocation-free s...statementparseWithParameters
Static calls · unresolved targets: 0 · external targets: 7.

Source: lib/sql/src/root.zig:43

zig
pub const statement = @import("statement/root.zig");

Source: lib/sql/src/statement/root.zig

zig
const ast_mod = @import("ast.zig");const parse_mod = @import("parse.zig");const access_mod = @import("access.zig");const result_mod = @import("result.zig");const cursor_mod = @import("cursor.zig");const execute_mod = @import("execute.zig");pub const Error = ast_mod.Error;pub const max_parameters = ast_mod.max_parameters;pub const Parameter = ast_mod.Parameter;pub const Expression = ast_mod.Expression;pub const Insert = ast_mod.Insert;pub const Projection = ast_mod.Projection;pub const PredicateColumn = ast_mod.PredicateColumn;pub const PredicateOperator = ast_mod.PredicateOperator;pub const Predicate = ast_mod.Predicate;pub const OrderKey = ast_mod.OrderKey;pub const Select = ast_mod.Select;pub const Assignment = ast_mod.Assignment;pub const Update = ast_mod.Update;pub const Delete = ast_mod.Delete;pub const CreateTable = ast_mod.CreateTable;pub const CreateIndex = ast_mod.CreateIndex;pub const Analyze = ast_mod.Analyze;pub const DropTable = ast_mod.DropTable;pub const Statement = ast_mod.Statement;pub const Parsed = ast_mod.Parsed;pub const parse = parse_mod.parse;pub const parseWithParameters = parse_mod.parseWithParameters;pub const Rows = result_mod.Rows;pub const Result = result_mod.Result;pub const Cursor = cursor_mod.Cursor;pub const ExecuteOptions = execute_mod.ExecuteOptions;pub const Prepared = execute_mod.Prepared;pub const prepare = execute_mod.prepare;pub const prepareReadOnly = execute_mod.prepareReadOnly;pub const columnIndex = access_mod.columnIndex;

Complete caller list for statement.prepare

34 direct callers.

Audit

Definitions31
Public names31
Members49
Version26.7.0
Revisiondaab053ee433