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: handle nil pointer for column_current_time_count_limit (#9315)
zll600ea9fd01e2c4f
diff --git a/backend/plugin/advisor/mysqlwip/advisor_column_current_time_count_limit.go b/backend/plugin/advisor/mysqlwip/advisor_column_current_time_count_limit.goindex 2a7b4e8e1d..506e746770 100644--- a/backend/plugin/advisor/mysqlwip/advisor_column_current_time_count_limit.go+++ b/backend/plugin/advisor/mysqlwip/advisor_column_current_time_count_limit.go@@ -177,6 +177,9 @@ func (checker *columnCurrentTimeCountLimitChecker) checkTime(tableName string, _func (*columnCurrentTimeCountLimitChecker) isDefaultCurrentTime(ctx mysql.IFieldDefinitionContext) bool {for _, attr := range ctx.AllColumnAttribute() {+ if attr == nil || attr.GetValue() == nil {+ continue+ }if attr.GetValue().GetTokenType() == mysql.MySQLParserDEFAULT_SYMBOL && attr.NOW_SYMBOL() != nil {return true}@@ -186,6 +189,9 @@ func (*columnCurrentTimeCountLimitChecker) isDefaultCurrentTime(ctx mysql.IFieldfunc (*columnCurrentTimeCountLimitChecker) isOnUpdateCurrentTime(ctx mysql.IFieldDefinitionContext) bool {for _, attr := range ctx.AllColumnAttribute() {+ if attr == nil || attr.GetValue() == nil {+ continue+ }if attr.GetValue().GetTokenType() == mysql.MySQLParserON_SYMBOL && attr.NOW_SYMBOL() != nil {return true}diff --git a/backend/plugin/advisor/mysqlwip/test/column_current_time_count_limit.yaml b/backend/plugin/advisor/mysqlwip/test/column_current_time_count_limit.yamlindex 920718777e..964007036d 100644--- a/backend/plugin/advisor/mysqlwip/test/column_current_time_count_limit.yaml+++ b/backend/plugin/advisor/mysqlwip/test/column_current_time_count_limit.yaml@@ -1,4 +1,43 @@-- statement: CREATE TABLE t(a timestamp, b timestamp);+- statement: |+ CREATE TABLE userTable(+ id INT NOT NULL,+ name VARCHAR(255) CHARSET ascii,+ roomId INT,+ time_created TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',+ time_updated TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',+ content BLOB NOT NULL COMMENT 'comment',+ json_content JSON NOT NULL COMMENT 'comment',+ INDEX idx1(name),+ UNIQUE KEY uk1(id, name),+ FOREIGN KEY fk1(roomId) REFERENCES room(id),+ INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_bin;+ want:+ - status: WARN+ code: 419+ title: column.current-time-count-limit+ content: Table `userTable` has 2 ON UPDATE CURRENT_TIMESTAMP() columns. The count greater than 1.+ line: 6+ details: ""+- statement: |+ CREATE TABLE user(+ id INT PRIMARY KEY COMMENT 'comment',+ name VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'comment',+ room_id INT NOT NULL DEFAULT 0 COMMENT 'comment',+ creator_id INT NOT NULL DEFAULT 0 COMMENT 'comment',+ created_ts TIMESTAMP NOT NULL DEFAULT NOW() COMMENT 'comment',+ updater_id INT NOT NULL DEFAULT 0 COMMENT 'comment',+ updated_ts TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',+ INDEX idx_user_name(name),+ UNIQUE KEY uk_user_id_name(id, name)+ ) ENGINE = INNODB COMMENT 'comment';+ want:+ - status: SUCCESS+ code: 0+ title: OK+ content: ""+ line: 0+ details: ""+- statement: CREATE TABLE t(a timestamp, b timestamp)want:- status: SUCCESScode: 0