Skip to content

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

fix: relax walk-through validations from ERROR to WARNING (#18171)

Danny Xu820a32f33af1
diff --git a/backend/plugin/schema/mysql/testdata/walk_through.yaml b/backend/plugin/schema/mysql/testdata/walk_through.yaml
index c52aa47129..1a9bc36b0e 100644
--- a/backend/plugin/schema/mysql/testdata/walk_through.yaml
+++ b/backend/plugin/schema/mysql/testdata/walk_through.yaml
@@ -285,12 +285,12 @@
ignore_case_sensitive: false
want: ''
advice:
- status: 1
+ status: 2
code: 205
- title: Disallow the CREATE TABLE AS statement but "CREATE TABLE tvx SELECT (x,z)
- FROM (VALUES ROW(1,3,5), ROW(2,4,6)) AS v(x,y,z);" uses
- content: Disallow the CREATE TABLE AS statement but "CREATE TABLE tvx SELECT (x,z)
- FROM (VALUES ROW(1,3,5), ROW(2,4,6)) AS v(x,y,z);" uses
+ title: CREATE TABLE AS statement is used in "CREATE TABLE tvx SELECT (x,z) FROM
+ (VALUES ROW(1,3,5), ROW(2,4,6)) AS v(x,y,z);"
+ content: CREATE TABLE AS statement is used in "CREATE TABLE tvx SELECT (x,z) FROM
+ (VALUES ROW(1,3,5), ROW(2,4,6)) AS v(x,y,z);"
startPosition:
line: 1
- statement: 'CREATE TABLE t1(a int);
@@ -299,12 +299,12 @@
ignore_case_sensitive: false
want: ''
advice:
- status: 1
+ status: 2
code: 205
- title: Disallow the CREATE TABLE AS statement but "CREATE TABLE t2 (b INT) SELECT
- a FROM t1;" uses
- content: Disallow the CREATE TABLE AS statement but "CREATE TABLE t2 (b INT) SELECT
- a FROM t1;" uses
+ title: CREATE TABLE AS statement is used in "CREATE TABLE t2 (b INT) SELECT a FROM
+ t1;"
+ content: CREATE TABLE AS statement is used in "CREATE TABLE t2 (b INT) SELECT a
+ FROM t1;"
startPosition:
line: 2
- statement: "CREATE TABLE t1(\n a int\n);\nCREATE TABLE t2 LIKE t1;"
diff --git a/backend/plugin/schema/mysql/walk_through.go b/backend/plugin/schema/mysql/walk_through.go
index e805b6742e..a44d6a9cba 100644
--- a/backend/plugin/schema/mysql/walk_through.go
+++ b/backend/plugin/schema/mysql/walk_through.go
@@ -105,7 +105,7 @@ func (l *mysqlListener) EnterCreateTable(ctx *mysql.CreateTableContext) {
databaseName, tableName := mysqlparser.NormalizeMySQLTableName(ctx.TableName())
if databaseName != "" && !isCurrentDatabase(l.databaseMetadata, databaseName) {
l.advice = &storepb.Advice{
- Status: storepb.Advice_ERROR,
+ Status: storepb.Advice_WARNING,
Code: code.NotCurrentDatabase.Int32(),
Title: fmt.Sprintf("Database `%s` is not the current database `%s`", databaseName, l.databaseMetadata.DatabaseName()),
Content: fmt.Sprintf("Database `%s` is not the current database `%s`", databaseName, l.databaseMetadata.DatabaseName()),
@@ -141,10 +141,10 @@ func (l *mysqlListener) EnterCreateTable(ctx *mysql.CreateTableContext) {
if ctx.DuplicateAsQueryExpression() != nil {
l.advice = &storepb.Advice{
- Status: storepb.Advice_ERROR,
+ Status: storepb.Advice_WARNING,
Code: code.StatementCreateTableAs.Int32(),
- Title: fmt.Sprintf("Disallow the CREATE TABLE AS statement but \"%s\" uses", l.text),
- Content: fmt.Sprintf("Disallow the CREATE TABLE AS statement but \"%s\" uses", l.text),
+ Title: fmt.Sprintf("CREATE TABLE AS statement is used in \"%s\"", l.text),
+ Content: fmt.Sprintf("CREATE TABLE AS statement is used in \"%s\"", l.text),
StartPosition: &storepb.Position{Line: 0},
}
return
@@ -229,10 +229,10 @@ func (l *mysqlListener) EnterDropTable(ctx *mysql.DropTableContext) {
databaseName, tableName := mysqlparser.NormalizeMySQLTableRef(tableRef)
if databaseName != "" && !isCurrentDatabase(l.databaseMetadata, databaseName) {
l.advice = &storepb.Advice{
- Status: storepb.Advice_ERROR,
+ Status: storepb.Advice_WARNING,
Code: code.NotCurrentDatabase.Int32(),
- Title: fmt.Sprintf("Database `%s` is not the current database `%s`", databaseName, tableName),
- Content: fmt.Sprintf("Database `%s` is not the current database `%s`", databaseName, tableName),
+ Title: fmt.Sprintf("Database `%s` is not the current database `%s`", databaseName, l.databaseMetadata.DatabaseName()),
+ Content: fmt.Sprintf("Database `%s` is not the current database `%s`", databaseName, l.databaseMetadata.DatabaseName()),
StartPosition: &storepb.Position{Line: 0},
}
}
diff --git a/backend/plugin/schema/tidb/testdata/walk_through.yaml b/backend/plugin/schema/tidb/testdata/walk_through.yaml
index 5bc740eb26..6fc8d4ed8b 100644
--- a/backend/plugin/schema/tidb/testdata/walk_through.yaml
+++ b/backend/plugin/schema/tidb/testdata/walk_through.yaml
@@ -76,12 +76,11 @@
ignore_case_sensitive: false
want: ''
advice:
- status: 1
+ status: 2
code: 205
- title: Disallow the CREATE TABLE AS statement but "CREATE TABLE t as select *
- from t1;" uses
- content: Disallow the CREATE TABLE AS statement but "CREATE TABLE t as select
- * from t1;" uses
+ title: CREATE TABLE AS statement is used in "CREATE TABLE t as select * from t1;"
+ content: CREATE TABLE AS statement is used in "CREATE TABLE t as select * from
+ t1;"
startPosition:
line: 1
- statement: "\n\t\t\t\tCREATE TABLE t(a int, b int); \n\t\t\t\tCREATE INDEX idx_c\
diff --git a/backend/plugin/schema/tidb/walk_through.go b/backend/plugin/schema/tidb/walk_through.go
index b7cdfdab0f..1329bbaf78 100644
--- a/backend/plugin/schema/tidb/walk_through.go
+++ b/backend/plugin/schema/tidb/walk_through.go
@@ -931,9 +931,9 @@ func tidbCreateTable(d *model.DatabaseMetadata, node *tidbast.CreateTableStmt) *
}
if node.Select != nil {
- content := fmt.Sprintf("Disallow the CREATE TABLE AS statement but \"%s\" uses", node.Text())
+ content := fmt.Sprintf("CREATE TABLE AS statement is used in \"%s\"", node.Text())
return &storepb.Advice{
- Status: storepb.Advice_ERROR,
+ Status: storepb.Advice_WARNING,
Code: code.StatementCreateTableAs.Int32(),
Title: content,
Content: content,