Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix(catalog): set nil pointer for DEFAULT NULL (#3048)
rebelice243223626270
diff --git a/plugin/advisor/catalog/walk_through.go b/plugin/advisor/catalog/walk_through.goindex 978ec684f1..2b7cf24b96 100644--- a/plugin/advisor/catalog/walk_through.go+++ b/plugin/advisor/catalog/walk_through.go@@ -1192,11 +1192,13 @@ func (t *TableState) createColumn(ctx *FinderContext, column *tidbast.ColumnDef,case tidbast.ColumnOptionAutoIncrement:// we do not deal with AUTO-INCREMENTcase tidbast.ColumnOptionDefaultValue:- defaultValue, err := restoreNode(option.Expr, format.RestoreStringWithoutCharset)- if err != nil {- return err+ if option.Expr.GetType().GetType() != mysql.TypeNull {+ defaultValue, err := restoreNode(option.Expr, format.RestoreStringWithoutCharset)+ if err != nil {+ return err+ }+ col.defaultValue = &defaultValue}- col.defaultValue = &defaultValuecase tidbast.ColumnOptionUniqKey:if err := t.createIndex("", []string{col.name}, true /* unique */, model.IndexTypeBtree.String(), nil); err != nil {return errdiff --git a/plugin/advisor/catalog/walk_through_test.go b/plugin/advisor/catalog/walk_through_test.goindex 168eca4379..35961130bf 100644--- a/plugin/advisor/catalog/walk_through_test.go+++ b/plugin/advisor/catalog/walk_through_test.go@@ -301,7 +301,7 @@ func TestWalkThrough(t *testing.T) {CREATE TABLE t(a int PRIMARY KEY DEFAULT 1,b varchar(200) CHARACTER SET utf8mb4 NOT NULL UNIQUE,- c int auto_increment NULL COMMENT 'This is a comment',+ c int auto_increment NULL COMMENT 'This is a comment' DEFAULT NULL,d varchar(10) COLLATE utf8mb4_polish_ci,KEY idx_a (a),INDEX (b, a),