Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
progress
  • Loading branch information
psteinroe committed Sep 26, 2025
commit 9022ea7a5e598ba78503adfe410d3665d80e6c5c
2 changes: 1 addition & 1 deletion crates/pgt_statement_splitter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ mod tests {
assert_eq!(
self.result.ranges.len(),
expected.len(),
"Expected {} statements for input {}, got {}: {:?}",
"Expected {} statements for input\n{}\ngot {}:\n{:?}",
expected.len(),
self.input,
self.result.ranges.len(),
Expand Down
20 changes: 18 additions & 2 deletions crates/pgt_statement_splitter/src/splitter/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,17 @@ pub(crate) fn case(p: &mut Splitter) {
}

pub(crate) fn unknown(p: &mut Splitter, exclude: &[SyntaxKind]) {
let mut in_atomic = false;
loop {
match p.current() {
SyntaxKind::SEMICOLON => {
if in_atomic {
// only end the statement if the next non-trivia token is not END
// this is to handle cases like BEGIN ATOMIC SELECT ...; END;
p.advance();
break;
}
p.advance();
break;
}
SyntaxKind::EOF => {
break;
Expand Down Expand Up @@ -257,7 +263,6 @@ pub(crate) fn unknown(p: &mut Splitter, exclude: &[SyntaxKind]) {
}
p.advance();
}

Some(SyntaxKind::CREATE_KW) => {
let prev = p.look_back(true);
if [
Expand All @@ -275,6 +280,17 @@ pub(crate) fn unknown(p: &mut Splitter, exclude: &[SyntaxKind]) {

p.advance();
}
Some(SyntaxKind::ATOMIC_KW) => {
if p.look_back(true) == Some(SyntaxKind::BEGIN_KW) {
// BEGIN ATOMIC ... END;
in_atomic = true;
}
p.advance();
}
Some(SyntaxKind::END_KW) => {
in_atomic = false;
p.advance();
}
Some(_) => {
break;
}
Expand Down
Loading