{"record":{"id":"3dc1770e1ef70d28","repo":"MyCATApache/Mycat-Server","slug":"can-t-suport-district-table-tablename-schema-3dc177","errorCode":null,"errorMessage":"can't suport district table  + tableName +  schema: + schema.getName() +  for global table ","messagePattern":"can't suport district table  \\+ tableName \\+  schema: \\+ schema\\.getName\\(\\) \\+  for global table ","errorType":"exception","errorClass":"SQLNonTransientException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/route/util/RouterUtil.java","lineNumber":1441,"sourceCode":"        LayerCachePool cachePool, boolean isSelect, Map.Entry<String, Map<String, Set<ColumnRoutePair>>> entry) throws SQLNonTransientException {\r\n\r\n\r\n        String tableName = null;\r\n        if (entry != null) {\r\n            tableName = entry.getKey().toUpperCase();\r\n        } else {\r\n            List<String> tables = rrs.getTables();\r\n            tableName = tables.get(0);\r\n        }\r\n        TableConfig tableConfig = schema.getTables().get(tableName);\r\n        if(tableConfig == null) {\r\n            String msg = \"can't find table define in schema \" + tableName + \" schema:\" + schema.getName();\r\n            LOGGER.warn(msg);\r\n            throw new SQLNonTransientException(msg);\r\n        }\r\n        if(tableConfig.isGlobalTable()){\r\n            String msg = \"can't suport district table  \" + tableName + \" schema:\" + schema.getName() + \" for global table \";\r\n            LOGGER.warn(msg);\r\n            throw new SQLNonTransientException(msg);\r\n        }\r\n        String partionCol = tableConfig.getPartitionColumn();\r\n    //  String primaryKey = tableConfig.getPrimaryKey();\r\n        //boolean isLoadData=false;\r\n    \r\n        Set<String> tablesRouteSet = new HashSet<String>();\r\n    \r\n        List<String> dataNodes = tableConfig.getDataNodes();\r\n        if(dataNodes.size()>1){\r\n            String msg = \"can't suport district table  \" + tableName + \" schema:\" + schema.getName() + \" for mutiple dataNode \" + dataNodes;\r\n            LOGGER.warn(msg);\r\n            throw new SQLNonTransientException(msg);\r\n        }\r\n        String dataNode = dataNodes.get(0);\r\n    \r\n        RouteResultsetNode[] nodes = null;\r\n        //主键查找缓存暂时不实现\r","sourceCodeStart":1423,"sourceCodeEnd":1459,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/route/util/RouterUtil.java#L1423-L1459","documentation":"When routing a district (dist) table, RouterUtil checks tableConfig.isGlobalTable() and refuses the operation: global tables are replicated to all nodes and have no district partitioning, so a district-table route is meaningless. It throws SQLNonTransientException naming the table and schema.","triggerScenarios":"Invoking the district-table routing method (routeToDistTable) on a table declared with type=\"global\" in schema.xml — e.g. a JOIN or query path that treats the global table as a dist table.","commonSituations":"Table recently changed from global to sharded (or vice versa) in schema.xml; JOIN routing logic misidentifies a global table as a district table; developer copied a dist-table route call for a replicated lookup table.","solutions":["Remove type=\"global\" from the table in schema.xml if it should be district/sharded, then reload","Keep the table global and route via normal global-table logic instead of routeToDistTable","Update application SQL/ORM so global tables are not passed through the dist-table routing path"],"exampleFix":"// before (schema.xml)\n<table name=\"dict\" type=\"global\" dataNode=\"dn1,dn2\"/>\n// routed as district table\n// after\n<table name=\"dict\" dataNode=\"dn1,dn2\" rule=\"mod-rule\"/> // non-global, or use normal route","handlingStrategy":"validation","validationCode":"// verify the table is not global before district routing\n// (via MyCat management port)\n// mysql -uuser -p -P9066 -> show @@schema; / inspect schema.xml\nboolean isGlobal = schemaXmlTableEntry(tableName).attr(\"type\").equals(\"global\");\nif (isGlobal) throw new IllegalStateException(\"Use normal routing for global table \" + tableName);","typeGuard":null,"tryCatchPattern":"try {\n    execute(sql);\n} catch (SQLNonTransientException e) {\n    if (e.getMessage().contains(\"can't suport district table\"))\n        throw new IllegalStateException(\"Global table cannot use district routing: \" + e.getMessage(), e);\n    throw e;\n}","preventionTips":["Keep global tables out of district-table routing paths in application code","Review schema.xml type attributes when converting tables between global/sharded/dist"],"tags":["sql","routing","global-table","dist-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"}