-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmisc.go
More file actions
167 lines (141 loc) · 4.93 KB
/
Copy pathmisc.go
File metadata and controls
167 lines (141 loc) · 4.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
package ast
// TransactionType is the DEFERRED/IMMEDIATE/EXCLUSIVE qualifier of BEGIN.
type TransactionType int
const (
TxnDeferred TransactionType = iota
TxnImmediate
TxnExclusive
)
// BeginStmt is BEGIN [DEFERRED|IMMEDIATE|EXCLUSIVE] [TRANSACTION [name]].
//
// cmd ::= BEGIN transtype trans_opt.
type BeginStmt struct {
Span
Type TransactionType `json:"type,omitempty"`
// HasType and HasTransaction record keywords that carry no meaning but
// are part of the source: "trans_opt ::= TRANSACTION" has no name, so
// Name alone cannot say whether the keyword was written.
HasType bool `json:"hasType,omitempty"`
HasTransaction bool `json:"hasTransaction,omitempty"`
Name *Ident `json:"name,omitempty"`
}
func (*BeginStmt) stmtNode() {}
func (n *BeginStmt) Children() []Node { return nodes(n.Name) }
// CommitStmt is COMMIT or END, optionally followed by TRANSACTION [name].
//
// cmd ::= COMMIT|END trans_opt.
type CommitStmt struct {
Span
Keyword string `json:"keyword"` // "COMMIT" or "END"
HasTransaction bool `json:"hasTransaction,omitempty"`
Name *Ident `json:"name,omitempty"`
}
func (*CommitStmt) stmtNode() {}
func (n *CommitStmt) Children() []Node { return nodes(n.Name) }
// RollbackStmt is ROLLBACK, with or without a savepoint.
//
// cmd ::= ROLLBACK trans_opt.
// cmd ::= ROLLBACK trans_opt TO savepoint_opt nm.
type RollbackStmt struct {
Span
HasTransaction bool `json:"hasTransaction,omitempty"`
Name *Ident `json:"name,omitempty"` // TRANSACTION <name>
Savepoint *Ident `json:"savepoint,omitempty"` // TO [SAVEPOINT] <name>
SavepointKeyword bool `json:"savepointKeyword,omitempty"`
}
func (*RollbackStmt) stmtNode() {}
func (n *RollbackStmt) Children() []Node { return nodes(n.Name, n.Savepoint) }
// SavepointStmt is SAVEPOINT <name>.
//
// cmd ::= SAVEPOINT nm.
type SavepointStmt struct {
Span
Name *Ident `json:"name"`
}
func (*SavepointStmt) stmtNode() {}
func (n *SavepointStmt) Children() []Node { return nodes(n.Name) }
// ReleaseStmt is RELEASE [SAVEPOINT] <name>.
//
// cmd ::= RELEASE savepoint_opt nm.
type ReleaseStmt struct {
Span
SavepointKeyword bool `json:"savepointKeyword,omitempty"`
Name *Ident `json:"name"`
}
func (*ReleaseStmt) stmtNode() {}
func (n *ReleaseStmt) Children() []Node { return nodes(n.Name) }
// AttachStmt is ATTACH [DATABASE] expr AS expr [KEY expr].
//
// cmd ::= ATTACH database_kw_opt expr AS expr key_opt.
type AttachStmt struct {
Span
HasDatabase bool `json:"hasDatabase,omitempty"`
File Expr `json:"file"`
Name Expr `json:"name"`
Key Expr `json:"key,omitempty"`
}
func (*AttachStmt) stmtNode() {}
func (n *AttachStmt) Children() []Node { return nodes(n.File, n.Name, n.Key) }
// DetachStmt is DETACH [DATABASE] expr.
//
// cmd ::= DETACH database_kw_opt expr.
type DetachStmt struct {
Span
HasDatabase bool `json:"hasDatabase,omitempty"`
Name Expr `json:"name"`
}
func (*DetachStmt) stmtNode() {}
func (n *DetachStmt) Children() []Node { return nodes(n.Name) }
// PragmaStmt is a PRAGMA in any of its three value spellings.
//
// cmd ::= PRAGMA nm dbnm.
// cmd ::= PRAGMA nm dbnm EQ nmnum. / PRAGMA nm dbnm EQ minus_num.
// cmd ::= PRAGMA nm dbnm LP nmnum RP. / PRAGMA nm dbnm LP minus_num RP.
type PragmaStmt struct {
Span
Name *QualifiedName `json:"name"`
Value string `json:"value,omitempty"` // as written, "-" included
Paren bool `json:"paren,omitempty"` // the LP ... RP spelling
HasValue bool `json:"hasValue,omitempty"`
}
func (*PragmaStmt) stmtNode() {}
func (n *PragmaStmt) Children() []Node { return nodes(n.Name) }
// VacuumStmt is VACUUM [schema] [INTO expr].
//
// cmd ::= VACUUM vinto. / cmd ::= VACUUM nm vinto.
type VacuumStmt struct {
Span
Schema *Ident `json:"schema,omitempty"`
Into Expr `json:"into,omitempty"`
}
func (*VacuumStmt) stmtNode() {}
func (n *VacuumStmt) Children() []Node { return nodes(n.Schema, n.Into) }
// AnalyzeStmt is ANALYZE [name [. name]].
//
// cmd ::= ANALYZE. / cmd ::= ANALYZE nm dbnm.
type AnalyzeStmt struct {
Span
Name *QualifiedName `json:"name,omitempty"`
}
func (*AnalyzeStmt) stmtNode() {}
func (n *AnalyzeStmt) Children() []Node { return nodes(n.Name) }
// ReindexStmt is REINDEX [name [. name]].
//
// cmd ::= REINDEX. / cmd ::= REINDEX nm dbnm.
type ReindexStmt struct {
Span
Name *QualifiedName `json:"name,omitempty"`
}
func (*ReindexStmt) stmtNode() {}
func (n *ReindexStmt) Children() []Node { return nodes(n.Name) }
// ExplainStmt wraps another statement in EXPLAIN or EXPLAIN QUERY PLAN.
//
// ecmd ::= explain cmdx SEMI.
// explain ::= EXPLAIN. / explain ::= EXPLAIN QUERY PLAN.
type ExplainStmt struct {
Span
QueryPlan bool `json:"queryPlan,omitempty"`
Stmt Stmt `json:"stmt"`
}
func (*ExplainStmt) stmtNode() {}
func (n *ExplainStmt) Children() []Node { return nodes(n.Stmt) }