{"record":{"id":"b113d75d9fd32762","repo":"MyCATApache/Mycat-Server","slug":"parent-relevant-column-can-t-be-updated-table","errorCode":null,"errorMessage":"\"Parent relevant column can't be updated \" + tableName + \"->\" + joinKey","messagePattern":"\"Parent relevant column can't be updated \" \\+ tableName \\+ \"->\" \\+ joinKey","errorType":"exception","errorClass":"SQLNonTransientException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/route/parser/druid/impl/DruidUpdateParser.java","lineNumber":241,"sourceCode":"                if (column.contains(StringUtil.TABLE_COLUMN_SEPARATOR)) {\n                    column = column.substring(column.indexOf(\".\") + 1).trim().toUpperCase();\n                }\n                if (partitionColumn != null && partitionColumn.equals(column)) {\n                    boolean canUpdate;\n                    canUpdate = ((update.getWhere() != null) && shardColCanBeUpdated(update.getWhere(),\n                            partitionColumn, item.getValue(), false));\n\n                    if (!canUpdate) {\n                        String msg = \"Sharding column can't be updated \" + tableName + \"->\" + partitionColumn;\n                        LOGGER.warn(msg);\n                        throw new SQLNonTransientException(msg);\n                    }\n                }\n                if (hasParent) {\n                    if (column.equals(joinKey)) {\n                        String msg = \"Parent relevant column can't be updated \" + tableName + \"->\" + joinKey;\n                        LOGGER.warn(msg);\n                        throw new SQLNonTransientException(msg);\n                    }\n                    rrs.setCacheAble(true);\n                }\n            }\n        }\n    }\n}\n","sourceCodeStart":223,"sourceCodeEnd":249,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/route/parser/druid/impl/DruidUpdateParser.java#L223-L249","documentation":"When a table has a parent (child table of an ER-join relationship), the joinKey column linking it to the parent must stay consistent for Mycat's ER routing. confirmShardColumnNotUpdated rejects any UPDATE whose SET clause modifies the joinKey with SQLNonTransientException, because it would break child-row co-location with the parent.","triggerScenarios":"An UPDATE on a child table (configured with <childTable parent=\"...\" joinKey=\"...\">) whose SET clause assigns to the joinKey column (e.g. `UPDATE order_detail SET order_id=999 WHERE ...`).","commonSituations":"Re-parenting child rows to a different parent row; data-fix scripts rewriting foreign-key columns on ER-sharded child tables; ORMs syncing the whole entity including the FK.","solutions":["Exclude the joinKey from the SET clause; re-parent via DELETE from the old parent's child set + INSERT under the new parent","Update only non-join-key columns in the statement","Restructure ER relations if re-parenting is a frequent business operation"],"exampleFix":"-- before\nUPDATE order_detail SET order_id = 999 WHERE detail_id = 55;\n-- after\nINSERT INTO order_detail (detail_id, order_id, ...) VALUES (55, 999, ...);\nDELETE FROM order_detail WHERE detail_id = 55; -- remove from old parent's shard","handlingStrategy":"validation","validationCode":"if (isChildTable(table) && updateSetColumns.contains(childConfig.getJoinKey())) {\n    throw new IllegalArgumentException(\"joinKey \" + childConfig.getJoinKey() + \" is not updatable\");\n}","typeGuard":null,"tryCatchPattern":"try { executeUpdate(sql); } catch (SQLNonTransientException e) { if (e.getMessage().startsWith(\"Parent relevant column can't be updated\")) { doDeleteInsertInstead(); } else throw e; }","preventionTips":["Exclude joinKey columns from entity update statements","Re-parent child rows via delete+insert","Configure join keys on immutable identifier columns","Filter ORM update payloads to mutable business fields only"],"tags":["mysql","sharding","er-join","update"],"backgroundTag":"unsupported-operation","analyzedSha":"65f8d8beb752f935752f2a0eec0ab017facab9ef","analyzedAt":"2026-09-11T00:12:21.696Z","contentChangedAt":"2026-09-11T00:12:21.696Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}