{"record":{"id":"ecf16223619bc0ef","repo":"MyCATApache/Mycat-Server","slug":"global-table-is-not-supported-in-multi-table-relat","errorCode":null,"errorMessage":"global table is not supported in multi table related update ","messagePattern":"global table is not supported in multi table related update ","errorType":"exception","errorClass":"SQLNonTransientException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/route/parser/druid/impl/DruidUpdateParser.java","lineNumber":72,"sourceCode":"\n\n        confirmShardColumnNotUpdated(update, schema, tableName, partitionColumn, joinKey, rrs);\n\n//\t\tif(ctx.getTablesAndConditions().size() > 0) {\n//\t\t\tMap<String, Set<ColumnRoutePair>> map = ctx.getTablesAndConditions().get(tableName);\n//\t\t\tif(map != null) {\n//\t\t\t\tfor(Map.Entry<String, Set<ColumnRoutePair>> entry : map.entrySet()) {\n//\t\t\t\t\tString column = entry.getKey();\n//\t\t\t\t\tSet<ColumnRoutePair> value = entry.getValue();\n//\t\t\t\t\tif(column.toUpperCase().equals(anObject))\n//\t\t\t\t}\n//\t\t\t}\n//\t\t\t\n//\t\t}\n//\t\tSystem.out.println();\n\n        if (schema.getTables().get(tableName).isGlobalTable() && ctx.getRouteCalculateUnit().getTablesAndConditions().size() > 1) {\n            throw new SQLNonTransientException(\"global table is not supported in multi table related update \" + tableName);\n        }\n\n        //在解析SQL时清空该表的主键缓存\n        TableConfig tableConfig = schema.getTables().get(tableName);\n        if (tableConfig != null && !tableConfig.primaryKeyIsPartionKey()) {\n            String cacheName = schema.getName() +\"_\" + tableName;\n            cacheName = cacheName.toUpperCase();\n            for (CachePool value : MycatServer.getInstance().getCacheService().getAllCachePools().values()) {\n                value.clearCache(cacheName);\n                value.getCacheStatic().reset();\n            }\n        }\n    }\n    \n    /**\n     * 获取更新的表数\n     * @author lian\n     * @date 2016年11月2日","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/route/parser/druid/impl/DruidUpdateParser.java#L54-L90","documentation":"Mycat rejects an UPDATE on a global table when the statement's routing conditions involve more than one table. Global tables are replicated identically on every node, and a multi-table related update makes it ambiguous which node copy should be modified. The message names the offending global table.","triggerScenarios":"statementParse on an UPDATE where schema.getTables().get(tableName).isGlobalTable() is true AND ctx.getRouteCalculateUnit().getTablesAndConditions() contains more than one table — i.e. a multi-table UPDATE that includes a global table.","commonSituations":"Updating a dictionary/reference table (configured with global=\"true\") inside a joined UPDATE; mis-marking a large sharded table as global; legacy SQL ported from single-node MySQL.","solutions":["Issue the update on the global table alone, in its own single-table UPDATE statement","Remove global=\"true\" from the table config if the table is not truly a replicated reference table","Restructure the SQL so conditions on other tables are resolved first and the global-table update is issued separately"],"exampleFix":"// before\nUPDATE dict d JOIN orders o ON d.id=o.dict_id SET d.label='x';\n// after\nUPDATE dict SET label='x' WHERE id IN (SELECT dict_id FROM orders);\n-- or run the single-table update separately","handlingStrategy":"validation","validationCode":"TableConfig tc = schema.getTables().get(tableName);\nif (tc != null && tc.isGlobalTable() && ctx.getRouteCalculateUnit().getTablesAndConditions().size() > 1) {\n    throw new SQLNonTransientException(\"global table in multi-table update: \" + tableName);\n}","typeGuard":null,"tryCatchPattern":"try { router.route(...) } catch (SQLNonTransientException e) { if (e.getMessage().startsWith(\"global table is not supported\")) { splitIntoSingleTableUpdates(); } }","preventionTips":["Keep global-table updates as standalone single-table statements","Audit table configs: only mark truly replicated reference tables as global","Ban joined updates involving global tables in code review/SQL lint"],"tags":["mysql","sharding","global-table"],"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"}