From aba1986f1348d20e13d8435298de6a82dd8cdbe5 Mon Sep 17 00:00:00 2001 From: 7ttp <117663341+7ttp@users.noreply.github.com> Date: Thu, 22 Jan 2026 00:07:48 +0530 Subject: [PATCH] fix: parser incorrectly treats 'atomic' in identifiers as BEGIN ATOMIC keyword --- pkg/parser/state.go | 7 +++++++ pkg/parser/state_test.go | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/pkg/parser/state.go b/pkg/parser/state.go index f32a671315..ebe0397371 100644 --- a/pkg/parser/state.go +++ b/pkg/parser/state.go @@ -48,6 +48,13 @@ func (s *ReadyState) Next(r rune, data []byte) State { case 'C': offset := len(data) - len(BEGIN_ATOMIC) if offset >= 0 && strings.EqualFold(string(data[offset:]), BEGIN_ATOMIC) { + // Check if ATOMIC is preceded by whitespace (word boundary) + if offset > 0 { + prevRune, _ := utf8.DecodeLastRune(data[:offset]) + if !unicode.IsSpace(prevRune) { + return s + } + } return &AtomicState{prev: s, delimiter: []byte(END_ATOMIC)} } } diff --git a/pkg/parser/state_test.go b/pkg/parser/state_test.go index bae10fe190..4b0fea5a0d 100644 --- a/pkg/parser/state_test.go +++ b/pkg/parser/state_test.go @@ -167,4 +167,9 @@ END ;`} checkSplit(t, sql) }) + + t.Run("atomic in identifier", func(t *testing.T) { + sql := []string{"create table public.atomic_test (id int);", " select 1;"} + checkSplit(t, sql) + }) }