Skip to content

Commit f26a27e

Browse files
akoclaude
andcommitted
fix: bare STATUS and SHOW STATUS commands now work (issue #470)
Three problems fixed: 1. Grammar: add standalone `statusStatement: STATUS ;` wired into `utilityStatement`, so `STATUS` parses outside of a SHOW context. 2. Visitor (ExitShowStatement): `SHOW STATUS` (without CATALOG) was silently dropped because the STATUS token was only checked inside the CATALOG branch. Added a new `ctx.STATUS() != nil` branch (after CATALOG so SHOW CATALOG STATUS is unaffected) that emits StatusStmt. 3. Visitor (ExitHelpStatement): removed dead `case "status"` — STATUS is a lexer keyword so it can never match IDENTIFIER, making this branch unreachable. Both `STATUS;` and `SHOW STATUS;` now print connection status. `SHOW CATALOG STATUS` is unaffected. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent f70a741 commit f26a27e

8 files changed

Lines changed: 9646 additions & 9465 deletions

File tree

mdl/grammar/MDLParser.g4

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3467,6 +3467,7 @@ limitOffsetClause
34673467
utilityStatement
34683468
: connectStatement
34693469
| disconnectStatement
3470+
| statusStatement
34703471
| updateStatement
34713472
| checkStatement
34723473
| buildStatement
@@ -3497,6 +3498,10 @@ disconnectStatement
34973498
: DISCONNECT
34983499
;
34993500

3501+
statusStatement
3502+
: STATUS
3503+
;
3504+
35003505
updateStatement
35013506
: UPDATE
35023507
| REFRESH CATALOG FULL? SOURCE_KW? FORCE? BACKGROUND?

mdl/grammar/parser/MDLParser.interp

Lines changed: 2 additions & 1 deletion
Large diffs are not rendered by default.

mdl/grammar/parser/mdl_parser.go

Lines changed: 9584 additions & 9460 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mdl/grammar/parser/mdlparser_base_listener.go

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mdl/grammar/parser/mdlparser_listener.go

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mdl/visitor/visitor_connection.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ func (b *Builder) ExitDisconnectStatement(ctx *parser.DisconnectStatementContext
2828
b.statements = append(b.statements, &ast.DisconnectStmt{})
2929
}
3030

31+
// ExitStatusStatement is called when exiting the statusStatement production (bare STATUS).
32+
func (b *Builder) ExitStatusStatement(ctx *parser.StatusStatementContext) {
33+
b.statements = append(b.statements, &ast.StatusStmt{})
34+
}
35+
3136
// ----------------------------------------------------------------------------
3237
// Module Statements
3338
// ----------------------------------------------------------------------------

mdl/visitor/visitor_connection_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,37 @@ func TestDisconnect(t *testing.T) {
4040
t.Fatalf("Expected DisconnectStmt, got %T", prog.Statements[0])
4141
}
4242
}
43+
44+
func TestStatus_BareKeyword(t *testing.T) {
45+
prog, errs := Build(`STATUS;`)
46+
if len(errs) > 0 {
47+
t.Fatalf("Parse errors for bare STATUS: %v", errs)
48+
}
49+
if _, ok := prog.Statements[0].(*ast.StatusStmt); !ok {
50+
t.Fatalf("Expected StatusStmt, got %T", prog.Statements[0])
51+
}
52+
}
53+
54+
func TestStatus_ShowStatus(t *testing.T) {
55+
prog, errs := Build(`SHOW STATUS;`)
56+
if len(errs) > 0 {
57+
t.Fatalf("Parse errors for SHOW STATUS: %v", errs)
58+
}
59+
if _, ok := prog.Statements[0].(*ast.StatusStmt); !ok {
60+
t.Fatalf("Expected StatusStmt for SHOW STATUS, got %T", prog.Statements[0])
61+
}
62+
}
63+
64+
func TestStatus_ShowCatalogStatusUnaffected(t *testing.T) {
65+
prog, errs := Build(`SHOW CATALOG STATUS;`)
66+
if len(errs) > 0 {
67+
t.Fatalf("Parse errors for SHOW CATALOG STATUS: %v", errs)
68+
}
69+
stmt, ok := prog.Statements[0].(*ast.ShowStmt)
70+
if !ok {
71+
t.Fatalf("Expected ShowStmt, got %T", prog.Statements[0])
72+
}
73+
if stmt.ObjectType != ast.ShowCatalogStatus {
74+
t.Errorf("Expected ShowCatalogStatus, got %v", stmt.ObjectType)
75+
}
76+
}

mdl/visitor/visitor_query.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,15 @@ func (b *Builder) ExitShowStatement(ctx *parser.ShowStatementContext) {
217217
} else if ctx.VERSION() != nil {
218218
b.statements = append(b.statements, &ast.ShowStmt{ObjectType: ast.ShowVersion})
219219
} else if ctx.CATALOG() != nil {
220-
// Check for SHOW CATALOG STATUS
220+
// SHOW CATALOG STATUS or SHOW CATALOG TABLES
221221
if ctx.STATUS() != nil {
222222
b.statements = append(b.statements, &ast.ShowStmt{ObjectType: ast.ShowCatalogStatus})
223223
} else {
224-
// SHOW CATALOG TABLES (or other catalog show commands)
225224
b.statements = append(b.statements, &ast.ShowStmt{ObjectType: ast.ShowCatalogTables})
226225
}
226+
} else if ctx.STATUS() != nil {
227+
// SHOW STATUS — print connection status (path, version, module count)
228+
b.statements = append(b.statements, &ast.StatusStmt{})
227229
} else if ctx.CALLERS() != nil {
228230
// SHOW CALLERS OF Module.Microflow [TRANSITIVE]
229231
if qn := ctx.QualifiedName(); qn != nil {
@@ -1033,8 +1035,6 @@ func (b *Builder) ExitHelpStatement(ctx *parser.HelpStatementContext) {
10331035
b.statements = append(b.statements, stmt)
10341036
case "exit", "quit":
10351037
b.statements = append(b.statements, &ast.ExitStmt{})
1036-
case "status":
1037-
b.statements = append(b.statements, &ast.StatusStmt{})
10381038
}
10391039
}
10401040
}

0 commit comments

Comments
 (0)