Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: identify EXPLAIN statement (#2173)
rebelice612b2cef4298
diff --git a/plugin/parser/ast/explain_stmt.go b/plugin/parser/ast/explain_stmt.gonew file mode 100644index 0000000000..ef0c03abe5--- /dev/null+++ b/plugin/parser/ast/explain_stmt.go@@ -0,0 +1,6 @@+package ast++// ExplainStmt is the struct for explain statement.+type ExplainStmt struct {+ node+}diff --git a/plugin/parser/engine/pg/convert.go b/plugin/parser/engine/pg/convert.goindex 750342e67a..2f5dfbcd8a 100644--- a/plugin/parser/engine/pg/convert.go+++ b/plugin/parser/engine/pg/convert.go@@ -321,6 +321,8 @@ func convert(node *pgquery.Node, text string) (res ast.Node, err error) {},}, nil}+ case *pgquery.Node_ExplainStmt:+ return &ast.ExplainStmt{}, nilcase *pgquery.Node_InsertStmt:insertStmt := &ast.InsertStmt{Table: convertRangeVarToTableName(in.InsertStmt.Relation, ast.TableTypeBaseTable),diff --git a/plugin/parser/engine/pg/convert_test.go b/plugin/parser/engine/pg/convert_test.goindex 3f2a7c5bcf..1474859d93 100644--- a/plugin/parser/engine/pg/convert_test.go+++ b/plugin/parser/engine/pg/convert_test.go@@ -1220,6 +1220,22 @@ func TestSetSchemaStmt(t *testing.T) {runTests(t, tests)}+func TestExplainStmt(t *testing.T) {+ tests := []testData{+ {+ stmt: "EXPLAIN SELECT * FROM tech_book",+ want: []ast.Node{+ &ast.ExplainStmt{},+ },+ textList: []string{+ "EXPLAIN SELECT * FROM tech_book",+ },+ },+ }++ runTests(t, tests)+}+func TestAlterColumnType(t *testing.T) {tests := []testData{{