Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat: enable advanced feature for cockroachdb (#13760)
h3n4le3ede57d04d3
diff --git a/backend/api/lsp/completion.go b/backend/api/lsp/completion.goindex a2efbaa8ad..a80026aead 100644--- a/backend/api/lsp/completion.go+++ b/backend/api/lsp/completion.go@@ -52,7 +52,7 @@ func (h *Handler) handleTextDocumentCompletion(ctx context.Context, _ *jsonrpc2.switch engine {case storepb.Engine_MYSQL, storepb.Engine_TIDB, storepb.Engine_MARIADB, storepb.Engine_OCEANBASE, storepb.Engine_CLICKHOUSE, storepb.Engine_STARROCKS, storepb.Engine_DORIS:// Nothing.- case storepb.Engine_POSTGRES, storepb.Engine_REDSHIFT, storepb.Engine_RISINGWAVE:+ case storepb.Engine_POSTGRES, storepb.Engine_REDSHIFT, storepb.Engine_RISINGWAVE, storepb.Engine_COCKROACHDB:// Nothing.case storepb.Engine_MSSQL:case storepb.Engine_ORACLE, storepb.Engine_DM, storepb.Engine_OCEANBASE_ORACLE, storepb.Engine_SNOWFLAKE:diff --git a/backend/plugin/parser/mysql/diagnose.go b/backend/plugin/parser/mysql/diagnose.goindex c1779eaa22..1f3219f48a 100644--- a/backend/plugin/parser/mysql/diagnose.go+++ b/backend/plugin/parser/mysql/diagnose.go@@ -34,7 +34,7 @@ func Diagnose(_ context.Context, _ base.DiagnoseContext, statement string) ([]bafunc parseMySQLStatement(statement string) *base.SyntaxError {trimmedStatement := strings.TrimRightFunc(statement, unicode.IsSpace)- if !strings.HasSuffix(trimmedStatement, ";") {+ if len(trimmedStatement) > 0 && !strings.HasSuffix(trimmedStatement, ";") {// Add a semicolon to the end of the statement to allow users to omit the semicolon// for the last statement in the script.statement += ";"diff --git a/backend/plugin/parser/pg/completion.go b/backend/plugin/parser/pg/completion.goindex 3464ce7b97..3b14d16ce8 100644--- a/backend/plugin/parser/pg/completion.go+++ b/backend/plugin/parser/pg/completion.go@@ -27,6 +27,7 @@ func init() {base.RegisterCompleteFunc(store.Engine_RISINGWAVE, Completion)base.RegisterCompleteFunc(store.Engine_DM, Completion)base.RegisterCompleteFunc(store.Engine_SNOWFLAKE, Completion)+ base.RegisterCompleteFunc(store.Engine_COCKROACHDB, Completion)}// Completion is the entry point of PostgreSQL code completion.diff --git a/backend/plugin/parser/pg/diagnose.go b/backend/plugin/parser/pg/diagnose.goindex 9000506c36..40d95f0b53 100644--- a/backend/plugin/parser/pg/diagnose.go+++ b/backend/plugin/parser/pg/diagnose.go@@ -16,6 +16,7 @@ func init() {base.RegisterDiagnoseFunc(store.Engine_POSTGRES, Diagnose)base.RegisterDiagnoseFunc(store.Engine_REDSHIFT, Diagnose)base.RegisterDiagnoseFunc(store.Engine_RISINGWAVE, Diagnose)+ base.RegisterDiagnoseFunc(store.Engine_COCKROACHDB, Diagnose)}func Diagnose(_ context.Context, _ base.DiagnoseContext, statement string) ([]base.Diagnostic, error) {@@ -32,7 +33,7 @@ func Diagnose(_ context.Context, _ base.DiagnoseContext, statement string) ([]ba// Use the PostgreSQL parser based on antlr4.func parsePostgreSQLStatement(statement string) *base.SyntaxError {trimmedStatement := strings.TrimRightFunc(statement, unicode.IsSpace)- if !strings.HasSuffix(trimmedStatement, ";") {+ if len(trimmedStatement) > 0 && !strings.HasSuffix(trimmedStatement, ";") {// Add a semicolon to the end of the statement to allow users to omit the semicolon// for the last statement in the script.statement += ";"diff --git a/backend/plugin/parser/pg/differ.go b/backend/plugin/parser/pg/differ.goindex e5f1a31d79..627920530d 100644--- a/backend/plugin/parser/pg/differ.go+++ b/backend/plugin/parser/pg/differ.go@@ -21,6 +21,7 @@ import (func init() {base.RegisterSchemaDiffFunc(storepb.Engine_POSTGRES, SchemaDiff)+ base.RegisterSchemaDiffFunc(storepb.Engine_COCKROACHDB, SchemaDiff)}// diffNode defines different modification types as the safe change order.diff --git a/backend/plugin/parser/pg/query.go b/backend/plugin/parser/pg/query.goindex 9ccd08e4fc..c7c266d57f 100644--- a/backend/plugin/parser/pg/query.go+++ b/backend/plugin/parser/pg/query.go@@ -22,9 +22,11 @@ func init() {base.RegisterQueryValidator(storepb.Engine_POSTGRES, validateQuery)base.RegisterQueryValidator(storepb.Engine_REDSHIFT, validateQuery)base.RegisterQueryValidator(storepb.Engine_RISINGWAVE, validateQuery)+ base.RegisterQueryValidator(storepb.Engine_COCKROACHDB, validateQuery)base.RegisterExtractResourceListFunc(storepb.Engine_POSTGRES, ExtractResourceList)base.RegisterExtractResourceListFunc(storepb.Engine_REDSHIFT, ExtractResourceList)base.RegisterExtractResourceListFunc(storepb.Engine_RISINGWAVE, ExtractResourceList)+ base.RegisterExtractResourceListFunc(storepb.Engine_COCKROACHDB, ExtractResourceList)}// validateQuery validates the SQL statement for SQL editor.diff --git a/backend/plugin/parser/pg/query_span.go b/backend/plugin/parser/pg/query_span.goindex c316ad181a..339fc718f9 100644--- a/backend/plugin/parser/pg/query_span.go+++ b/backend/plugin/parser/pg/query_span.go@@ -13,6 +13,7 @@ func init() {base.RegisterGetQuerySpan(storepb.Engine_POSTGRES, GetQuerySpan)base.RegisterGetQuerySpan(storepb.Engine_REDSHIFT, GetQuerySpan)base.RegisterGetQuerySpan(storepb.Engine_RISINGWAVE, GetQuerySpan)+ base.RegisterGetQuerySpan(storepb.Engine_COCKROACHDB, GetQuerySpan)}// GetQuerySpan returns the query span for the given statement.diff --git a/backend/plugin/parser/pg/resource_change.go b/backend/plugin/parser/pg/resource_change.goindex 3da599448a..e809cab3fe 100644--- a/backend/plugin/parser/pg/resource_change.go+++ b/backend/plugin/parser/pg/resource_change.go@@ -12,6 +12,7 @@ import (func init() {base.RegisterExtractChangedResourcesFunc(storepb.Engine_POSTGRES, extractChangedResources)+ base.RegisterExtractChangedResourcesFunc(storepb.Engine_COCKROACHDB, extractChangedResources)}func extractChangedResources(database string, schema string, dbSchema *model.DBSchema, asts any, statement string) (*base.ChangeSummary, error) {diff --git a/backend/plugin/parser/pg/split.go b/backend/plugin/parser/pg/split.goindex ad8e045bb0..da8ec288c2 100644--- a/backend/plugin/parser/pg/split.go+++ b/backend/plugin/parser/pg/split.go@@ -16,6 +16,7 @@ func init() {base.RegisterSplitterFunc(storepb.Engine_POSTGRES, SplitSQL)base.RegisterSplitterFunc(storepb.Engine_REDSHIFT, SplitSQL)base.RegisterSplitterFunc(storepb.Engine_RISINGWAVE, SplitSQL)+ base.RegisterSplitterFunc(storepb.Engine_COCKROACHDB, SplitSQL)}// SplitSQL splits the given SQL statement into multiple SQL statements.diff --git a/backend/plugin/parser/plsql/diagnose.go b/backend/plugin/parser/plsql/diagnose.goindex ce4b41999e..5b2478a841 100644--- a/backend/plugin/parser/plsql/diagnose.go+++ b/backend/plugin/parser/plsql/diagnose.go@@ -31,7 +31,7 @@ func Diagnose(_ context.Context, _ base.DiagnoseContext, statement string) ([]ba// ParsePLSQL parses the given PLSQL.func parsePLSQLStatement(statement string) *base.SyntaxError {trimmedStatement := strings.TrimRightFunc(statement, unicode.IsSpace)- if !strings.HasSuffix(trimmedStatement, ";") {+ if len(trimmedStatement) > 0 && !strings.HasSuffix(trimmedStatement, ";") {// Add a semicolon to the end of the statement to allow users to omit the semicolon// for the last statement in the script.statement += ";"diff --git a/backend/plugin/parser/snowflake/diagnose.go b/backend/plugin/parser/snowflake/diagnose.goindex c0a8dc3649..c6876e9bfa 100644--- a/backend/plugin/parser/snowflake/diagnose.go+++ b/backend/plugin/parser/snowflake/diagnose.go@@ -28,7 +28,7 @@ func Diagnose(_ context.Context, _ base.DiagnoseContext, statement string) ([]bafunc parseSnowflakeStatement(statement string) *base.SyntaxError {trimmedStatement := strings.TrimRightFunc(statement, unicode.IsSpace)- if !strings.HasSuffix(trimmedStatement, ";") {+ if len(trimmedStatement) > 0 && !strings.HasSuffix(trimmedStatement, ";") {// Add a semicolon to the end of the statement to allow users to omit the semicolon// for the last statement in the script.statement += ";"diff --git a/backend/plugin/parser/tsql/diagnose.go b/backend/plugin/parser/tsql/diagnose.goindex 5191b2160d..f80a2448cd 100644--- a/backend/plugin/parser/tsql/diagnose.go+++ b/backend/plugin/parser/tsql/diagnose.go@@ -28,7 +28,7 @@ func Diagnose(_ context.Context, _ base.DiagnoseContext, statement string) ([]bafunc parseTSQLStatement(statement string) *base.SyntaxError {trimmedStatement := strings.TrimRightFunc(statement, unicode.IsSpace)- if !strings.HasSuffix(trimmedStatement, ";") {+ if len(trimmedStatement) > 0 && !strings.HasSuffix(trimmedStatement, ";") {// Add a semicolon to the end of the statement to allow users to omit the semicolon// for the last statement in the script.statement += ";"