diff --git a/parser/lexer.go b/parser/lexer.go index c379b029d0bac..dcfae1d1f5f54 100644 --- a/parser/lexer.go +++ b/parser/lexer.go @@ -101,6 +101,7 @@ func (s *Scanner) reset(sql string) { s.stmtStartPos = 0 s.inBangComment = false s.lastKeyword = 0 + s.identifierDot = false } func (s *Scanner) stmtText() string { diff --git a/parser/parser_test.go b/parser/parser_test.go index 1a69534777819..3857cba90f60a 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -7389,6 +7389,18 @@ func TestTTLTableOption(t *testing.T) { RunTest(t, table, false) } +func TestIssue45898(t *testing.T) { + p := parser.New() + p.ParseSQL("a.") + stmts, _, err := p.ParseSQL("select count(1) from t") + require.NoError(t, err) + var sb strings.Builder + restoreCtx := NewRestoreCtx(DefaultRestoreFlags, &sb) + sb.Reset() + stmts[0].Restore(restoreCtx) + require.Equal(t, "SELECT COUNT(1) FROM `t`", sb.String()) +} + func TestMultiStmt(t *testing.T) { p := parser.New() stmts, _, err := p.Parse("SELECT 'foo'; SELECT 'foo;bar','baz'; select 'foo' , 'bar' , 'baz' ;select 1", "", "")