Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: add UnconvertedStmt instead of nil (#2351)

rebelicee3a0d6928f3d
diff --git a/plugin/parser/ast/unconverted_stmt.go b/plugin/parser/ast/unconverted_stmt.go
new file mode 100644
index 0000000000..4d6039c860
--- /dev/null
+++ b/plugin/parser/ast/unconverted_stmt.go
@@ -0,0 +1,8 @@
+package ast
+
+// UnconvertedStmt is the struct for unconverted statement definition.
+// TODO(rebelice): remove it.
+// We define this because we can not convert all statement types now.
+type UnconvertedStmt struct {
+ node
+}
diff --git a/plugin/parser/engine/pg/convert.go b/plugin/parser/engine/pg/convert.go
index 0db1256c7a..3e0db0d183 100644
--- a/plugin/parser/engine/pg/convert.go
+++ b/plugin/parser/engine/pg/convert.go
@@ -362,6 +362,8 @@ func convert(node *pgquery.Node, statement parser.SingleSQL) (res ast.Node, err
}
return &copyStmt, nil
+ default:
+ return &ast.UnconvertedStmt{}, nil
}
return nil, nil
diff --git a/plugin/parser/engine/pg/convert_test.go b/plugin/parser/engine/pg/convert_test.go
index 6e3020ad7e..e6035b8cdc 100644
--- a/plugin/parser/engine/pg/convert_test.go
+++ b/plugin/parser/engine/pg/convert_test.go
@@ -1520,3 +1520,20 @@ func TestCopyStmt(t *testing.T) {
runTests(t, tests)
}
+
+func TestUnconvertStmt(t *testing.T) {
+ tests := []testData{
+ {
+ stmt: "SHOW TABLES",
+ want: []ast.Node{&ast.UnconvertedStmt{}},
+ statementList: []parser.SingleSQL{
+ {
+ Text: "SHOW TABLES",
+ Line: 1,
+ },
+ },
+ },
+ }
+
+ runTests(t, tests)
+}