{"record":{"id":"baa3d9c2c99f68da","repo":"MyCATApache/Mycat-Server","slug":"table-rule-coulmns-has-multi-values-columnsele-g","errorCode":null,"errorMessage":"table rule coulmns has multi values:${columnsEle.getTextContent()}","messagePattern":"table rule coulmns has multi values:(.+?)","errorType":"exception","errorClass":"ConfigException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/config/loader/xml/XMLRuleLoader.java","lineNumber":166,"sourceCode":"\t\t\t\tAbstractPartitionAlgorithm func = functions.get(funName);\r\n\t\t\t\tif (func == null) {\r\n\t\t\t\t\tthrow new ConfigException(\"can't find function of name :\"\r\n\t\t\t\t\t\t\t+ funName);\r\n\t\t\t\t}\r\n\t\t\t\trule.setRuleAlgorithm(func);\r\n\t\t\t\t//保存到tableRules\r\n\t\t\t\ttableRules.put(name, new TableRuleConfig(name, rule));\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tprivate RuleConfig loadRule(Element element) throws SQLSyntaxErrorException {\r\n\t\t//读取columns\r\n\t\tElement columnsEle = ConfigUtil.loadElement(element, \"columns\");\r\n\t\tString column = columnsEle.getTextContent();\r\n\t\tString[] columns = SplitUtil.split(column, ',', true);\r\n\t\tif (columns.length > 1) {\r\n\t\t\tthrow new ConfigException(\"table rule coulmns has multi values:\"\r\n\t\t\t\t\t+ columnsEle.getTextContent());\r\n\t\t}\r\n\t\t//读取algorithm\r\n\t\tElement algorithmEle = ConfigUtil.loadElement(element, \"algorithm\");\r\n\t\tString algorithm = algorithmEle.getTextContent();\r\n\t\treturn new RuleConfig(column.toUpperCase(), algorithm);\r\n\t}\r\n\r\n\t/**\r\n\t * function标签结构：\r\n\t * <function name=\"partbymonth\" class=\"io.mycat.route.function.PartitionByMonth\">\r\n\t *     <property name=\"dateFormat\">yyyy-MM-dd</property>\r\n\t *     <property name=\"sBeginDate\">2015-01-01</property>\r\n\t * </function>\r\n\t * @param root\r\n\t * @throws ClassNotFoundException\r\n\t * @throws InstantiationException\r\n\t * @throws IllegalAccessException\r","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/config/loader/xml/XMLRuleLoader.java#L148-L184","documentation":"loadRule reads the <columns> element of a tableRule and splits its text on commas. MyCat's rule loading (this version) supports only one sharding column per rule, so a comma-separated column list throws this ConfigException. Note the typo 'coulmns' is in the original message.","triggerScenarios":"A rule.xml <rule> block with <columns>col1,col2</columns>; loadRule -> SplitUtil.split yields length > 1 and throws.","commonSituations":"Trying to shard on multiple columns by listing them comma-separated; copied config from projects supporting composite columns; accidental trailing/inappropriate comma lists.","solutions":["Specify a single column in <columns> and restart.","For composite sharding, write a custom AbstractPartitionAlgorithm that takes the row and computes from multiple fields, or precompute a combined sharding column upstream.","Define separate tableRules only if the schema genuinely needs distinct single-column rules."],"exampleFix":"// before (rule.xml)\n<rule>\n  <columns>cust_id,order_date</columns>\n  <algorithm>hash-int</algorithm>\n</rule>\n// after\n<rule>\n  <columns>cust_id</columns>\n  <algorithm>hash-int</algorithm>\n</rule>","handlingStrategy":"validation","validationCode":"// Ensure every rule's <columns> holds a single value\nNodeList cols = doc.getElementsByTagName(\"columns\");\nfor (int i = 0; i < cols.getLength(); i++) {\n    String v = cols.item(i).getTextContent().trim();\n    if (v.contains(\",\")) throw new IllegalStateException(\"multi-column rule unsupported: \" + v);\n}","typeGuard":null,"tryCatchPattern":"try {\n    ruleLoader.load();\n} catch (ConfigException e) {\n    if (e.getMessage().contains(\"coulmns has multi values\")) {\n        LOG.error(\"Single sharding column only: {}\", e.getMessage());\n    }\n    throw e;\n}","preventionTips":["Never comma-separate columns in <columns>; this version supports one column per rule.","Implement composite sharding in the algorithm class instead.","Lint rule.xml for commas inside <columns> in CI."],"tags":["configuration","xml","sharding","unsupported-operation"],"backgroundTag":"invalid-config-value","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"}