pub enum Statement {
Show 15 variants
Query(QueryRef),
CreateTable(CreateTableRef),
CreateView(CreateViewRef),
DropTable(DropTableRef),
Schema(SchemaRef),
Sequence(SequenceRef),
Alter(AlterRef),
Insert(InsertRef),
Update(InsertRef),
Delete(InsertRef),
Set(SettingRef),
Reset(SettingRef),
Checkpoint,
Transaction(Transaction),
Explain {
query: QueryRef,
analyze: bool,
statistics: 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.
Alter(AlterRef)
ALTER TABLE or ALTER VIEW.
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
CHECKPOINT or FORCE CHECKPOINT.
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.