{"record":{"id":"c497bd86e9636990","repo":"vitessio/vitess","slug":"vt09016","errorCode":"VT09016","errorMessage":"VT09016","messagePattern":"VT09016","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtgate/planbuilder/operators/delete.go","lineNumber":408,"sourceCode":"\t\t// The query looks something like this - `UPDATE <child_table> SET <child_column_in_fk> = NULL [AND <another_child_column_in_fk> = NULL]... WHERE <child_columns_in_fk> IN (<bind variable for the output from SELECT>)`\n\t\tvalTuple := make(sqlparser.ValTuple, 0, len(fk.ChildColumns))\n\t\tupdExprs := make(sqlparser.UpdateExprs, 0, len(fk.ChildColumns))\n\t\tfor _, column := range fk.ChildColumns {\n\t\t\tvalTuple = append(valTuple, sqlparser.NewColName(column.String()))\n\t\t\tupdExprs = append(updExprs, &sqlparser.UpdateExpr{\n\t\t\t\tName: sqlparser.NewColName(column.String()),\n\t\t\t\tExpr: &sqlparser.NullVal{},\n\t\t\t})\n\t\t}\n\t\tcompExpr := sqlparser.NewComparisonExpr(sqlparser.InOp, valTuple, sqlparser.NewListArg(bvName), nil)\n\t\tchildStmt = &sqlparser.Update{\n\t\t\tExprs:      updExprs,\n\t\t\tComments:   parsedComments,\n\t\t\tTableExprs: []sqlparser.TableExpr{sqlparser.NewAliasedTableExpr(fk.Table.GetTableName(), \"\")},\n\t\t\tWhere:      &sqlparser.Where{Type: sqlparser.WhereClause, Expr: compExpr},\n\t\t}\n\tcase sqlparser.SetDefault:\n\t\tpanic(vterrors.VT09016())\n\t}\n\n\t// For the child statement of a DELETE query, we don't need to verify all the FKs on VTgate or ignore any foreign key explicitly.\n\tchildOp := createOpFromStmt(ctx, childStmt, false /* verifyAllFKs */, \"\" /* fkToIgnore */)\n\n\treturn &FkChild{\n\t\tBVName: bvName,\n\t\tCols:   cols,\n\t\tOp:     childOp,\n\t}\n}\n","sourceCodeStart":390,"sourceCodeEnd":420,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtgate/planbuilder/operators/delete.go#L390-L420","documentation":"VT09016 is thrown when an ON DELETE foreign-key action of SET DEFAULT is encountered while building the cascade plan for a DELETE in VTGate. Vitess's planner does not support cascading a delete to child rows by setting their FK columns to their default values, so it panics with this unsupported-feature error during plan construction in createFkChildForDelete.","triggerScenarios":"A DELETE statement targets a parent table that has a foreign key declared with ON DELETE SET DEFAULT, and FK cascade mode is enabled so planbuilder calls createFkCascadeOpForDelete, which reaches the sqlparser.SetDefault case in createFkChildForDelete.","commonSituations":"Schemas migrated from a plain MySQL deployment where ON DELETE SET DEFAULT was valid; ORMs or migration tools generating SET DEFAULT FK actions; users enabling foreign_key_mode/cascading DML in Vitess against such a schema.","solutions":["Change the foreign key definition to a supported action, e.g. ON DELETE CASCADE or ON DELETE SET NULL, then apply the migration","Drop the FK constraint's cascade action (ON DELETE RESTRICT/NO ACTION) and perform the child-table updates explicitly in the same transaction","If the default is never relied upon, use ON DELETE CASCADE instead so child rows are removed rather than defaulted"],"exampleFix":"// before\nCREATE TABLE child (id INT PRIMARY KEY, parent_id INT DEFAULT 0,\n  FOREIGN KEY (parent_id) REFERENCES parent(id) ON DELETE SET DEFAULT);\n// after\nCREATE TABLE child (id INT PRIMARY KEY, parent_id INT DEFAULT 0,\n  FOREIGN KEY (parent_id) REFERENCES parent(id) ON DELETE CASCADE);","handlingStrategy":"validation","validationCode":"-- before enabling cascading deletes, audit schema\nSELECT TABLE_NAME, CONSTRAINT_NAME, DELETE_RULE\nFROM information_schema.REFERENTIAL_CONSTRAINTS\nWHERE DELETE_RULE = 'SET DEFAULT';","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ban ON DELETE SET DEFAULT in schema review/migration linting","Add an information_schema check to CI migration tests for unsupported FK actions","Prefer ON DELETE CASCADE or explicit application-level child updates"],"tags":["vitess","planbuilder","foreign-key","unsupported-feature"],"backgroundTag":"unsupported-fk-cascade-action","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}