{"record":{"id":"ac8d3b625edb6071","repo":"MyCATApache/Mycat-Server","slug":"mycat-parse-error-on-sql","errorCode":null,"errorMessage":"mycat parse error on sql:","messagePattern":"mycat parse error on sql:","errorType":"exception","errorClass":"SQLNonTransientException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/route/impl/DruidMycatRouteStrategy.java","lineNumber":300,"sourceCode":"\t\t\t} else {\n\t\t\t\t// the last one\n\t\t\t\tRouteResultset rrsTemp = new RouteResultset(remingSql, sqlType);\n\t\t\t\tRouteResultset tempRrs = routeNormalSqlWithAST0(schema, remingSql, rrsTemp, charset, cachePool, sqlType,\n\t\t\t\t\t\tsc);\n\t\t\t\tallNodes.addAll(Arrays.asList(tempRrs.getNodes()));\n\t\t\t\trrs = rrsTemp;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} while (true);\n\n\t\tif (allNodes.size() >= 1) {\n\t\t\t// merge\n\t\t\trrs.setStatement(stmt);\n\t\t\trrs.setNodes(allNodes.toArray(new RouteResultsetNode[0]));\n\t\t\trrs.mergeSameNode();\n\t\t\treturn rrs;\n\t\t} else {\n\t\t\tthrow new SQLNonTransientException(\"mycat parse error on sql:\" + stmt);\n\t\t}\n\t}\n\t/**\n\t * 子查询中存在关联查询的情况下,检查关联字段是否是分片字段\n\t * @param rulemap\n\t * @param ships\n\t * @return\n\t */\n\tprivate boolean checkRuleField(Map<String,RuleConfig> rulemap,MycatSchemaStatVisitor visitor){\n\n\t\tif(!MycatServer.getInstance().getConfig().getSystem().isSubqueryRelationshipCheck()){\n\t\t\treturn true;\n\t\t}\n\n\t\tSet<Relationship> ships = visitor.getRelationships();\n\t\tIterator<Relationship> iter = ships.iterator();\n\t\twhile(iter.hasNext()){\n\t\t\tRelationship ship = iter.next();","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/route/impl/DruidMycatRouteStrategy.java#L282-L318","documentation":"In routeMultiSqlWithAST, after aggregating route nodes for a multi-node statement, Mycat throws SQLNonTransientException when the merged route resultset yields no valid nodes — i.e. the statement could not be routed to any datanode, described as a parse/route failure on the given SQL. It signals the router produced no actionable routing plan for the statement.","triggerScenarios":"A statement routed through the multi-statement route path whose routing computation produced zero nodes (allNodes empty), typically because the SQL references no routable table or the route calculation failed, followed by the else branch throwing 'mycat parse error on sql:'.","commonSituations":"SQL referencing tables missing from the schema config; statements Mycat cannot classify into a supported route type; misconfigured dataHost/datanode leaving no available nodes; typos in table names in schema.xml.","solutions":["Verify the SQL only references tables declared in schema.xml and that the schema is the one the connection selected.","Check datanode/dataHost configuration and backend availability so route computation yields nodes.","Log the full SQL from the exception and simplify it to a form Mycat's router supports (simple DML against a known table).","Upgrade Mycat or apply patches if the statement is a supported form that the router fails to classify."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// ensure the statement references a table configured in schema.xml before routing\nTableConfig tc = MycatServer.getInstance().getConfig().getSchemas()\n    .get(currentSchema).getTables().get(tableName.toUpperCase());\nif (tc == null) throw new IllegalArgumentException(\"Table not configured in Mycat schema: \" + tableName);","typeGuard":null,"tryCatchPattern":"try { rrs = routeMulti(stmt); } catch (SQLNonTransientException e) {\n    if (e.getMessage().startsWith(\"mycat parse error on sql:\")) {\n        log.error(\"Unroutable statement: {}\", stmt, e);\n        throw new IllegalArgumentException(\"Simplify SQL or fix schema.xml: \" + stmt);\n    } else throw e;\n}","preventionTips":["Validate table names against schema.xml before routing.","Keep dataNode/dataHost configuration consistent and healthy.","Log full SQL on route failures to identify unsupported constructs.","Keep Mycat version updated for router fixes."],"tags":["sql","routing","configuration"],"backgroundTag":"sql-query-failed","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"}