Skip to content

feat: support transaction begin #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[alias]
snap = "insta test"
xtask = "run --package xtask --"
1 change: 1 addition & 0 deletions crates/codegen/src/get_node_properties.rs
Original file line number Diff line number Diff line change
@@ -486,6 +486,7 @@ fn custom_handlers(node: &Node) -> TokenStream {
},
"TransactionStmt" => quote! {
match n.kind() {
protobuf::TransactionStmtKind::TransStmtBegin => tokens.push(TokenProperty::from(Token::BeginP)),
protobuf::TransactionStmtKind::TransStmtCommit => tokens.push(TokenProperty::from(Token::Commit)),
_ => panic!("Unknown TransactionStmt {:#?}", n.kind())
}
1 change: 0 additions & 1 deletion crates/parser/tests/skipped.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
advisory_lock
aggregates
alter_generic
alter_operator
32 changes: 32 additions & 0 deletions crates/parser/tests/snapshots/statements/valid/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
source: crates/parser/tests/statement_parser_test.rs
description: "--\n-- ADVISORY LOCKS\n--\n\nBEGIN;"
---
Parse {
cst: [email protected]
[email protected] "--"
[email protected] "\n"
[email protected] "-- ADVISORY LOCKS"
[email protected] "\n"
[email protected] "--"
[email protected] "\n\n"
[email protected]
[email protected] "BEGIN"
[email protected] ";"
,
errors: [],
stmts: [
RawStmt {
stmt: TransactionStmt(
TransactionStmt {
kind: TransStmtBegin,
options: [],
savepoint_name: "",
gid: "",
chain: false,
},
),
range: 24..30,
},
],
}
363 changes: 363 additions & 0 deletions crates/parser/tests/snapshots/statements/valid/[email protected]

Large diffs are not rendered by default.

487 changes: 487 additions & 0 deletions crates/parser/tests/snapshots/statements/valid/[email protected]

Large diffs are not rendered by default.

361 changes: 361 additions & 0 deletions crates/parser/tests/snapshots/statements/valid/[email protected]

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions crates/parser/tests/snapshots/statements/valid/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
source: crates/parser/tests/statement_parser_test.rs
description: ROLLBACK;
---
Parse {
cst: [email protected]
[email protected] "ROLLBACK"
[email protected] ";"
,
errors: [],
stmts: [],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
487 changes: 487 additions & 0 deletions crates/parser/tests/snapshots/statements/valid/[email protected]

Large diffs are not rendered by default.

683 changes: 683 additions & 0 deletions crates/parser/tests/snapshots/statements/valid/[email protected]

Large diffs are not rendered by default.

186 changes: 186 additions & 0 deletions crates/parser/tests/snapshots/statements/valid/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
---
source: crates/parser/tests/statement_parser_test.rs
description: "SELECT count(*) FROM pg_locks WHERE locktype = 'advisory';"
---
Parse {
cst: [email protected]
[email protected]
[email protected] "SELECT"
[email protected] " "
[email protected]
[email protected]
[email protected] "count"
[email protected] "("
[email protected] "*"
[email protected] ")"
[email protected] " "
[email protected] "FROM"
[email protected] " "
[email protected]
[email protected] "pg_locks"
[email protected] " "
[email protected] "WHERE"
[email protected] " "
[email protected]
[email protected]
[email protected] "locktype"
[email protected] " "
[email protected] "="
[email protected] " "
[email protected]
[email protected] "'advisory'"
[email protected] ";"
,
errors: [],
stmts: [
RawStmt {
stmt: SelectStmt(
SelectStmt {
distinct_clause: [],
into_clause: None,
target_list: [
Node {
node: Some(
ResTarget(
ResTarget {
name: "",
indirection: [],
val: Some(
Node {
node: Some(
FuncCall(
FuncCall {
funcname: [
Node {
node: Some(
String(
String {
sval: "count",
},
),
),
},
],
args: [],
agg_order: [],
agg_filter: None,
over: None,
agg_within_group: false,
agg_star: true,
agg_distinct: false,
func_variadic: false,
funcformat: CoerceExplicitCall,
location: 7,
},
),
),
},
),
location: 7,
},
),
),
},
],
from_clause: [
Node {
node: Some(
RangeVar(
RangeVar {
catalogname: "",
schemaname: "",
relname: "pg_locks",
inh: true,
relpersistence: "p",
alias: None,
location: 21,
},
),
),
},
],
where_clause: Some(
Node {
node: Some(
AExpr(
AExpr {
kind: AexprOp,
name: [
Node {
node: Some(
String(
String {
sval: "=",
},
),
),
},
],
lexpr: Some(
Node {
node: Some(
ColumnRef(
ColumnRef {
fields: [
Node {
node: Some(
String(
String {
sval: "locktype",
},
),
),
},
],
location: 36,
},
),
),
},
),
rexpr: Some(
Node {
node: Some(
AConst(
AConst {
isnull: false,
location: 47,
val: Some(
Sval(
String {
sval: "advisory",
},
),
),
},
),
),
},
),
location: 45,
},
),
),
},
),
group_clause: [],
group_distinct: false,
having_clause: None,
window_clause: [],
values_lists: [],
sort_clause: [],
limit_offset: None,
limit_count: None,
limit_option: Default,
locking_clause: [],
with_clause: None,
op: SetopNone,
all: false,
larg: None,
rarg: None,
},
),
range: 0..57,
},
],
}
26 changes: 26 additions & 0 deletions crates/parser/tests/snapshots/statements/valid/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
source: crates/parser/tests/statement_parser_test.rs
description: BEGIN;
---
Parse {
cst: [email protected]
[email protected]
[email protected] "BEGIN"
[email protected] ";"
,
errors: [],
stmts: [
RawStmt {
stmt: TransactionStmt(
TransactionStmt {
kind: TransStmtBegin,
options: [],
savepoint_name: "",
gid: "",
chain: false,
},
),
range: 0..5,
},
],
}
Loading