MyCATApache/Mycat-Server · error · SQLNonTransientException

Parent relevant column can't be updated ->

Error message

Parent relevant column can't be updated ->

What it means

For child tables in an ER (parent-child) sharding relationship, the join key column that links to the parent cannot be updated — doing so would move the child row to a different shard than its parent. Mycat throws this when the SET clause targets the table's joinKey while the schema declares a parent table (hasParent).

Solutions

  1. Remove the join key from the SET clause if the parent link is unchanged
  2. Delete and re-insert the child row to move it to a different parent
  3. Redesign the schema so the ER join key is immutable (use a surrogate PK for parent links)
  4. Update parent linkage in the application with coordinated delete+insert

Example fix

// before
UPDATE order_item SET order_id=200 WHERE item_id=1;
// after
DELETE FROM order_item WHERE item_id=1;
INSERT INTO order_item(item_id,order_id,...) VALUES(1,200,...);
Defensive patterns

Strategy: validation

Validate before calling

TableConfig tc = schema.getTables().get(tableName);
if (tc != null && tc.getParentTC() != null && setColumns.contains(tc.getJoinKey())) {
    throw new IllegalArgumentException("ER join key " + tc.getJoinKey() + " is immutable");
}

Try / catch

try { router.route(...) } catch (SQLNonTransientException e) { if (e.getMessage().startsWith("Parent relevant column can't be updated")) { performDeleteInsertInstead(); } }

Prevention

When it happens

Trigger: UPDATE on an ER child table (TableConfig with parentTable configured) where a SET item names the joinKey column, detected in confirmShardColumnNotUpdated via column.equals(joinKey).

Common situations: Re-parenting a child row (e.g. changing order_id on order_item) through UPDATE; schema configs where the join key was chosen as a mutable business field; ORM save() rewrites that include the FK in SET.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of MyCATApache/Mycat-Server@65f8d8beb7 (2026-09-11). Data as JSON: /api/errors/8a946ffb3b9cc73e. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/io/mycat/route/parser/druid/impl/DruidUpdateParser.java:241

                if (column.contains(StringUtil.TABLE_COLUMN_SEPARATOR)) {
                    column = column.substring(column.indexOf(".") + 1).trim().toUpperCase();
                }
                if (partitionColumn != null && partitionColumn.equals(column)) {
                    boolean canUpdate;
                    canUpdate = ((update.getWhere() != null) && shardColCanBeUpdated(update.getWhere(),
                            partitionColumn, item.getValue(), false));

                    if (!canUpdate) {
                        String msg = "Sharding column can't be updated " + tableName + "->" + partitionColumn;
                        LOGGER.warn(msg);
                        throw new SQLNonTransientException(msg);
                    }
                }
                if (hasParent) {
                    if (column.equals(joinKey)) {
                        String msg = "Parent relevant column can't be updated " + tableName + "->" + joinKey;
                        LOGGER.warn(msg);
                        throw new SQLNonTransientException(msg);
                    }
                    rrs.setCacheAble(true);
                }
            }
        }
    }
}

View on GitHub (pinned to 65f8d8beb7)