Skip to content

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

fix: hanle nil pointer for table_no_fk (#9320)

zll6004320d799c082
diff --git a/backend/plugin/advisor/mysqlwip/advisor_table_no_fk.go b/backend/plugin/advisor/mysqlwip/advisor_table_no_fk.go
index 6633b6f715..ec9ca26181 100644
--- a/backend/plugin/advisor/mysqlwip/advisor_table_no_fk.go
+++ b/backend/plugin/advisor/mysqlwip/advisor_table_no_fk.go
@@ -85,8 +85,17 @@ func (checker *tableNoFKChecker) EnterCreateTable(ctx *mysql.CreateTableContext)
// EnterAlterTable is called when production alterTable is entered.
func (checker *tableNoFKChecker) EnterAlterTable(ctx *mysql.AlterTableContext) {
+ if ctx.TableRef() == nil {
+ return
+ }
_, tableName := mysqlparser.NormalizeMySQLTableRef(ctx.TableRef())
+ if ctx.AlterTableActions() == nil || ctx.AlterTableActions().AlterCommandList() == nil {
+ return
+ }
+ if ctx.AlterTableActions().AlterCommandList().AlterList() == nil {
+ return
+ }
for _, option := range ctx.AlterTableActions().AlterCommandList().AlterList().AllAlterListItem() {
switch {
// ADD CONSTRANIT