tiny.sql.statement
Defined in tiny.sql.
API (35)
Actions
Public operations.
CreateTable.relationDefinitionParsed.deinitRows.countRows.deinitRows.nextcolumnIndexparseparseWithParametersprepareprepareReadOnly
Types and contracts
Public types and contracts.
AnalyzeAssignmentCreateIndexCreateTableCursorDeleteDropTableErrorExecuteOptionsExpressionInsertOrderKeyParameterParsedPredicatePredicateColumnPredicateOperatorPreparedProjectionResultRowsSelectStatementUpdate
Values and defaults
Public values and defaults.
Source
Source: lib/sql/src/statement/ast.zig:137
pub const Analyze = struct { table: []const u8,};Source: lib/sql/src/statement/ast.zig:101
pub const Assignment = struct { column: []const u8, value: Expression,};Source: lib/sql/src/statement/ast.zig:131
pub const CreateIndex = struct { name: []const u8, table: []const u8, columns: [][]const u8,};Source: lib/sql/src/statement/ast.zig:117
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
pub const Delete = struct { table: []const u8, predicates: []Predicate,};Source: lib/sql/src/statement/ast.zig:141
pub const DropTable = struct { table: []const u8,};Source: lib/sql/src/statement/ast.zig:52
pub const Expression = union(enum) { literal: row.Value, parameter: usize,};Source: lib/sql/src/statement/ast.zig:57
pub const Insert = struct { table: []const u8, columns: ?[][]const u8 = null, values: []Expression,};Source: lib/sql/src/statement/ast.zig:87
pub const OrderKey = struct { column: PredicateColumn, descending: bool = false,};Source: lib/sql/src/statement/ast.zig:200
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
pub const Predicate = struct { column: PredicateColumn, operator: PredicateOperator, value: Expression,};Source: lib/sql/src/statement/ast.zig:68
pub const PredicateColumn = union(enum) { rowid, field: []const u8,};Source: lib/sql/src/statement/ast.zig:73
pub const PredicateOperator = enum { eq, lt, lte, gt, gte,};Source: lib/sql/src/statement/ast.zig:63
pub const Projection = union(enum) { all, columns: [][]const u8,};Source: lib/sql/src/statement/ast.zig:92
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
pub const Update = struct { table: []const u8, assignments: []Assignment, predicates: []Predicate,};Source: lib/sql/src/statement/execute.zig:122
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
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
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;}Source: lib/sql/src/statement/ast.zig:40
pub const Error = plan.Error || session_mod.DatabaseError || std.mem.Allocator.Error || StatementError;Source: lib/sql/src/statement/ast.zig:46
pub const max_parameters: usize = 1024;Source: lib/sql/src/statement/execute.zig:1188
pub fn prepare(catalog: *const catalog_mod.Catalog, allocator: Allocator, source: []const u8) ast_mod.Error!Prepared { return try prepareWithValidation(catalog, allocator, source, .content);}Source: lib/sql/src/statement/execute.zig:1192
pub fn prepareReadOnly(catalog: *const catalog_mod.Catalog, allocator: Allocator, source: []const u8) ast_mod.Error!Prepared { return try prepareWithValidation(catalog, allocator, source, .shape);}Source: lib/sql/src/statement/parse.zig:11
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;}Source: lib/sql/src/statement/parse.zig:18
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), };}Source: lib/sql/src/root.zig:43
pub const statement = @import("statement/root.zig");Source: lib/sql/src/statement/root.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.
lib.sql.src.statement.execute.test_covering_index_and_table_scan_return_the_same_overflow-backed_cards[function] — test source atlib/sql/src/statement/execute.zig:4208in nearest public ownerlib.sql.src.statement.executelib.sql.src.statement.execute.test_covering_planner_requires_order,_binary_covered_columns_and_a_lower_cost[function] — test source atlib/sql/src/statement/execute.zig:4113in nearest public ownerlib.sql.src.statement.executelib.sql.src.statement.execute.test_prepared_index_cursor_keeps_one_relation_read_across_table_mutation[function] — test source atlib/sql/src/statement/execute.zig:2805in nearest public ownerlib.sql.src.statement.executelib.sql.src.statement.execute.test_prepared_statement_cache_key_includes_parameter_shape[function] — test source atlib/sql/src/statement/execute.zig:3905in nearest public ownerlib.sql.src.statement.executelib.sql.src.statement.execute.test_prepared_statement_ignores_unrelated_catalog_schema_changes[function] — test source atlib/sql/src/statement/execute.zig:3944in nearest public ownerlib.sql.src.statement.executelib.sql.src.statement.execute.test_prepared_statement_reprepares_after_stats_root_changes[function] — test source atlib/sql/src/statement/execute.zig:3989in nearest public ownerlib.sql.src.statement.executelib.sql.src.statement.execute.test_prepared_statements_bind_parameters_by_index_and_name[function] — test source atlib/sql/src/statement/execute.zig:3829in nearest public ownerlib.sql.src.statement.executelib.sql.src.statement.execute.test_prepared_statements_choose_indexed_and_scanned_predicates[function] — test source atlib/sql/src/statement/execute.zig:2861in nearest public ownerlib.sql.src.statement.executelib.sql.src.statement.execute.test_prepared_statements_create_indexes_over_existing_rows[function] — test source atlib/sql/src/statement/execute.zig:2491in nearest public ownerlib.sql.src.statement.executelib.sql.src.statement.execute.test_prepared_statements_delete_rows_matching_predicates[function] — test source atlib/sql/src/statement/execute.zig:1893in nearest public ownerlib.sql.src.statement.executelib.sql.src.statement.execute.test_prepared_statements_drop_tables_and_report_missing_tables[function] — test source atlib/sql/src/statement/execute.zig:2602in nearest public ownerlib.sql.src.statement.executelib.sql.src.statement.execute.test_prepared_statements_insert_select_and_delete_rowid_rows[function] — test source atlib/sql/src/statement/execute.zig:2663in nearest public ownerlib.sql.src.statement.executelib.sql.src.statement.execute.test_prepared_statements_order_selected_rows_with_windows[function] — test source atlib/sql/src/statement/execute.zig:1381in nearest public ownerlib.sql.src.statement.executelib.sql.src.statement.execute.test_prepared_statements_require_matching_predicate_index_collation[function] — test source atlib/sql/src/statement/execute.zig:3768in nearest public ownerlib.sql.src.statement.executelib.sql.src.statement.execute.test_prepared_statements_resolve_catalog_columns_for_insert_and_select_projection[function] — test source atlib/sql/src/statement/execute.zig:2735in nearest public ownerlib.sql.src.statement.executelib.sql.src.statement.execute.test_prepared_statements_route_catalog_writes_through_database_sessions[function] — test source atlib/sql/src/statement/execute.zig:2427in nearest public ownerlib.sql.src.statement.executelib.sql.src.statement.execute.test_prepared_statements_select_bare_tables_with_limit_and_offset_windows[function] — test source atlib/sql/src/statement/execute.zig:1622in nearest public ownerlib.sql.src.statement.executelib.sql.src.statement.execute.test_prepared_statements_stage_bounded_writes_without_steady_allocation[function] — test source atlib/sql/src/statement/execute.zig:2270in nearest public ownerlib.sql.src.statement.executelib.sql.src.statement.execute.test_prepared_statements_stage_predicate_deletes_with_read-your-writes[function] — test source atlib/sql/src/statement/execute.zig:2098in nearest public ownerlib.sql.src.statement.executelib.sql.src.statement.execute.test_prepared_statements_stage_predicate_updates_with_read-your-writes[function] — test source atlib/sql/src/statement/execute.zig:2016in nearest public ownerlib.sql.src.statement.executelib.sql.src.statement.execute.test_prepared_statements_stage_repeated_executes_against_one_staged_base[function] — test source atlib/sql/src/statement/execute.zig:2177in nearest public ownerlib.sql.src.statement.executelib.sql.src.statement.execute.test_prepared_statements_stage_updates_with_read-your-writes[function] — test source atlib/sql/src/statement/execute.zig:1960in nearest public ownerlib.sql.src.statement.executelib.sql.src.statement.execute.test_prepared_statements_stream_rowid-ascending_orders_through_the_scan_window[function] — test source atlib/sql/src/statement/execute.zig:1544in nearest public ownerlib.sql.src.statement.executelib.sql.src.statement.execute.test_prepared_statements_surface_staged_base_drift_at_flush[function] — test source atlib/sql/src/statement/execute.zig:2362in nearest public ownerlib.sql.src.statement.executelib.sql.src.statement.execute.test_prepared_statements_update_assigned_columns_by_rowid[function] — test source atlib/sql/src/statement/execute.zig:1722in nearest public ownerlib.sql.src.statement.executelib.sql.src.statement.execute.test_prepared_statements_update_rows_matching_predicates[function] — test source atlib/sql/src/statement/execute.zig:1796in nearest public ownerlib.sql.src.statement.executelib.sql.src.statement.execute.test_prepared_statements_use_analyzed_distribution_to_avoid_unselective_literal_index[function] — test source atlib/sql/src/statement/execute.zig:3468in nearest public ownerlib.sql.src.statement.executelib.sql.src.statement.execute.test_prepared_statements_use_analyzed_stats_to_prefer_covered_index[function] — test source atlib/sql/src/statement/execute.zig:3374in nearest public ownerlib.sql.src.statement.executelib.sql.src.statement.execute.test_prepared_statements_use_and_predicates_with_composite_index_prefixes[function] — test source atlib/sql/src/statement/execute.zig:3097in nearest public ownerlib.sql.src.statement.executelib.sql.src.statement.execute.test_prepared_statements_use_bound_distribution_for_runtime_access[function] — test source atlib/sql/src/statement/execute.zig:3564in nearest public ownerlib.sql.src.statement.executelib.sql.src.statement.execute.test_prepared_statements_use_composite_index_after_checkpoint_reopen[function] — test source atlib/sql/src/statement/execute.zig:3245in nearest public ownerlib.sql.src.statement.executelib.sql.src.statement.execute.test_prepared_statements_use_composite_prefix_distribution_for_runtime_range_access[function] — test source atlib/sql/src/statement/execute.zig:3670in nearest public ownerlib.sql.src.statement.executelib.sql.src.statement.execute.test_prepared_statements_use_large_composite_index_after_checkpoint_reopen[function] — test source atlib/sql/src/statement/execute.zig:3303in nearest public ownerlib.sql.src.statement.executelib.sql.src.statement.execute.test_sorted_cursor_allocation_failure_leaves_cleanup_empty_and_retryable[function] — test source atlib/sql/src/statement/execute.zig:1471in nearest public ownerlib.sql.src.statement.execute
Audit
| Definitions | 31 |
|---|---|
| Public names | 31 |
| Members | 49 |
| Version | 26.7.0 |
| Revision | daab053ee433 |