pub enum Statement {
Show 19 variants
Query(QueryRef),
CreateTable(CreateTableRef),
CreateView(CreateViewRef),
DropTable(DropTableRef),
Schema(SchemaRef),
Sequence(SequenceRef),
Type(TypeRef),
Alter(AlterRef),
Index(IndexRef),
Insert(InsertRef),
Update(InsertRef),
Delete(InsertRef),
Set(SettingRef),
Reset(SettingRef),
Checkpoint(StrRef),
Attach(AttachRef),
Detach {
name: StrRef,
if_exists: bool,
},
Transaction(Transaction),
Explain {
query: QueryRef,
analyze: bool,
statistics: bool,
codegen: bool,
},
}Expand description
One statement.
Seven of the twenty seven the grammar reaches. The rest are a transform error naming the rule
rather than a variant that nothing fills in, so that adding one is a compile error somewhere
useful rather than a silent todo!().
Variants§
Query(QueryRef)
A query, meaning a SELECT or a set operation over two of them.
CreateTable(CreateTableRef)
CREATE TABLE.
CreateView(CreateViewRef)
CREATE VIEW.
DropTable(DropTableRef)
DROP TABLE or DROP VIEW, which are one rule in the grammar and one statement here.
Schema(SchemaRef)
CREATE SCHEMA or DROP SCHEMA.
Sequence(SequenceRef)
CREATE SEQUENCE or DROP SEQUENCE.
Type(TypeRef)
CREATE TYPE or DROP TYPE.
Alter(AlterRef)
ALTER TABLE or ALTER VIEW.
Index(IndexRef)
CREATE INDEX or DROP INDEX.
Insert(InsertRef)
INSERT INTO.
Update(InsertRef)
UPDATE, held as an Insert whose columns are the ones SET names and whose source is
SELECT *, condition, value, ... FROM table, one value per named column.
The binder knows how wide the table is and the transform does not, so the source carries the table’s columns, whether the row matched, and the new values side by side, and the binder picks each column’s new value or its old one out of them.
Delete(InsertRef)
DELETE FROM and TRUNCATE, held the same way as Statement::Update with no columns.
Set(SettingRef)
SET name = value.
Reset(SettingRef)
RESET name, which is the same shape with nothing on the right of it.
Checkpoint(StrRef)
CHECKPOINT or FORCE CHECKPOINT, and the database it names, which is NONE when it names
none and means the default one.
Attach(AttachRef)
ATTACH.
Detach
DETACH, with the database it names and whether IF EXISTS was written.
Transaction(Transaction)
BEGIN, COMMIT or ROLLBACK, under any of the spellings the grammar takes for each.
Explain
EXPLAIN over a query, and whether ANALYZE was asked for.
The query rather than a statement, because the grammar lets every statement be explained
and a plan is the only thing there is to show. EXPLAIN INSERT is a refusal rather than a
plan of the source, since the source is not what the statement does.
ANALYZE means the query is run and the plan is printed with what happened on it, so it is
a flag on the same statement rather than a statement of its own. Everything between the
parser and the printer is the same either way, which is the point: the analyzed plan has to
be the plan that ran.
STATISTICS asks for the section that says what the planner knew, which is what
spec/stats/05-every-query.md section 5.1.1 asks EXPLAIN to print. It is a flag for the
same reason ANALYZE is: it changes what goes on the end of the output and nothing before
it.
CODEGEN asks for what the compiled engine would run instead of the plan: its stages and
the QIR it generated for them, or the reason it refuses the query.