Skip to content

Commit 5ce7116

Browse files
authored
Merge pull request #116 from cvng/feat/txn-stmt-begin
2 parents 921804f + 39e5cc2 commit 5ce7116

40 files changed

+11247
-1
lines changed

.cargo/config.toml

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[alias]
2+
snap = "insta test"
23
xtask = "run --package xtask --"

crates/codegen/src/get_node_properties.rs

+1
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ fn custom_handlers(node: &Node) -> TokenStream {
486486
},
487487
"TransactionStmt" => quote! {
488488
match n.kind() {
489+
protobuf::TransactionStmtKind::TransStmtBegin => tokens.push(TokenProperty::from(Token::BeginP)),
489490
protobuf::TransactionStmtKind::TransStmtCommit => tokens.push(TokenProperty::from(Token::Commit)),
490491
_ => panic!("Unknown TransactionStmt {:#?}", n.kind())
491492
}

crates/parser/tests/skipped.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
advisory_lock
21
aggregates
32
alter_generic
43
alter_operator
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
source: crates/parser/tests/statement_parser_test.rs
3+
description: "--\n-- ADVISORY LOCKS\n--\n\nBEGIN;"
4+
---
5+
Parse {
6+
cst: SourceFile@0..31
7+
SqlComment@0..2 "--"
8+
Newline@2..3 "\n"
9+
SqlComment@3..20 "-- ADVISORY LOCKS"
10+
Newline@20..21 "\n"
11+
SqlComment@21..23 "--"
12+
Newline@23..25 "\n\n"
13+
TransactionStmt@25..31
14+
BeginP@25..30 "BEGIN"
15+
Ascii59@30..31 ";"
16+
,
17+
errors: [],
18+
stmts: [
19+
RawStmt {
20+
stmt: TransactionStmt(
21+
TransactionStmt {
22+
kind: TransStmtBegin,
23+
options: [],
24+
savepoint_name: "",
25+
gid: "",
26+
chain: false,
27+
},
28+
),
29+
range: 24..30,
30+
},
31+
],
32+
}

crates/parser/tests/snapshots/statements/valid/[email protected]

+363
Large diffs are not rendered by default.

crates/parser/tests/snapshots/statements/valid/[email protected]

+487
Large diffs are not rendered by default.

crates/parser/tests/snapshots/statements/valid/[email protected]

+361
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
source: crates/parser/tests/statement_parser_test.rs
3+
description: ROLLBACK;
4+
---
5+
Parse {
6+
cst: SourceFile@0..9
7+
Rollback@0..8 "ROLLBACK"
8+
Ascii59@8..9 ";"
9+
,
10+
errors: [],
11+
stmts: [],
12+
}

crates/parser/tests/snapshots/statements/valid/[email protected]

+487
Large diffs are not rendered by default.

crates/parser/tests/snapshots/statements/valid/[email protected]

+683
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
---
2+
source: crates/parser/tests/statement_parser_test.rs
3+
description: "SELECT count(*) FROM pg_locks WHERE locktype = 'advisory';"
4+
---
5+
Parse {
6+
cst: SourceFile@0..58
7+
SelectStmt@0..58
8+
Select@0..6 "SELECT"
9+
Whitespace@6..7 " "
10+
ResTarget@7..14
11+
FuncCall@7..14
12+
Ident@7..12 "count"
13+
Ascii40@12..13 "("
14+
Ascii42@13..14 "*"
15+
Ascii41@14..15 ")"
16+
Whitespace@15..16 " "
17+
From@16..20 "FROM"
18+
Whitespace@20..21 " "
19+
RangeVar@21..29
20+
Ident@21..29 "pg_locks"
21+
Whitespace@29..30 " "
22+
Where@30..35 "WHERE"
23+
Whitespace@35..36 " "
24+
AExpr@36..57
25+
ColumnRef@36..44
26+
Ident@36..44 "locktype"
27+
Whitespace@44..45 " "
28+
Ascii61@45..46 "="
29+
Whitespace@46..47 " "
30+
AConst@47..57
31+
Sconst@47..57 "'advisory'"
32+
Ascii59@57..58 ";"
33+
,
34+
errors: [],
35+
stmts: [
36+
RawStmt {
37+
stmt: SelectStmt(
38+
SelectStmt {
39+
distinct_clause: [],
40+
into_clause: None,
41+
target_list: [
42+
Node {
43+
node: Some(
44+
ResTarget(
45+
ResTarget {
46+
name: "",
47+
indirection: [],
48+
val: Some(
49+
Node {
50+
node: Some(
51+
FuncCall(
52+
FuncCall {
53+
funcname: [
54+
Node {
55+
node: Some(
56+
String(
57+
String {
58+
sval: "count",
59+
},
60+
),
61+
),
62+
},
63+
],
64+
args: [],
65+
agg_order: [],
66+
agg_filter: None,
67+
over: None,
68+
agg_within_group: false,
69+
agg_star: true,
70+
agg_distinct: false,
71+
func_variadic: false,
72+
funcformat: CoerceExplicitCall,
73+
location: 7,
74+
},
75+
),
76+
),
77+
},
78+
),
79+
location: 7,
80+
},
81+
),
82+
),
83+
},
84+
],
85+
from_clause: [
86+
Node {
87+
node: Some(
88+
RangeVar(
89+
RangeVar {
90+
catalogname: "",
91+
schemaname: "",
92+
relname: "pg_locks",
93+
inh: true,
94+
relpersistence: "p",
95+
alias: None,
96+
location: 21,
97+
},
98+
),
99+
),
100+
},
101+
],
102+
where_clause: Some(
103+
Node {
104+
node: Some(
105+
AExpr(
106+
AExpr {
107+
kind: AexprOp,
108+
name: [
109+
Node {
110+
node: Some(
111+
String(
112+
String {
113+
sval: "=",
114+
},
115+
),
116+
),
117+
},
118+
],
119+
lexpr: Some(
120+
Node {
121+
node: Some(
122+
ColumnRef(
123+
ColumnRef {
124+
fields: [
125+
Node {
126+
node: Some(
127+
String(
128+
String {
129+
sval: "locktype",
130+
},
131+
),
132+
),
133+
},
134+
],
135+
location: 36,
136+
},
137+
),
138+
),
139+
},
140+
),
141+
rexpr: Some(
142+
Node {
143+
node: Some(
144+
AConst(
145+
AConst {
146+
isnull: false,
147+
location: 47,
148+
val: Some(
149+
Sval(
150+
String {
151+
sval: "advisory",
152+
},
153+
),
154+
),
155+
},
156+
),
157+
),
158+
},
159+
),
160+
location: 45,
161+
},
162+
),
163+
),
164+
},
165+
),
166+
group_clause: [],
167+
group_distinct: false,
168+
having_clause: None,
169+
window_clause: [],
170+
values_lists: [],
171+
sort_clause: [],
172+
limit_offset: None,
173+
limit_count: None,
174+
limit_option: Default,
175+
locking_clause: [],
176+
with_clause: None,
177+
op: SetopNone,
178+
all: false,
179+
larg: None,
180+
rarg: None,
181+
},
182+
),
183+
range: 0..57,
184+
},
185+
],
186+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
source: crates/parser/tests/statement_parser_test.rs
3+
description: BEGIN;
4+
---
5+
Parse {
6+
cst: SourceFile@0..6
7+
TransactionStmt@0..6
8+
BeginP@0..5 "BEGIN"
9+
Ascii59@5..6 ";"
10+
,
11+
errors: [],
12+
stmts: [
13+
RawStmt {
14+
stmt: TransactionStmt(
15+
TransactionStmt {
16+
kind: TransStmtBegin,
17+
options: [],
18+
savepoint_name: "",
19+
gid: "",
20+
chain: false,
21+
},
22+
),
23+
range: 0..5,
24+
},
25+
],
26+
}

0 commit comments

Comments
 (0)