MyCATApache/Mycat-Server · error · SQLNonTransientException

mycat parse error on sql:

Error message

mycat parse error on sql:

What it means

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.

Solutions

  1. Verify the SQL only references tables declared in schema.xml and that the schema is the one the connection selected.
  2. Check datanode/dataHost configuration and backend availability so route computation yields nodes.
  3. Log the full SQL from the exception and simplify it to a form Mycat's router supports (simple DML against a known table).
  4. Upgrade Mycat or apply patches if the statement is a supported form that the router fails to classify.
Defensive patterns

Strategy: try-catch

Validate before calling

// ensure the statement references a table configured in schema.xml before routing
TableConfig tc = MycatServer.getInstance().getConfig().getSchemas()
    .get(currentSchema).getTables().get(tableName.toUpperCase());
if (tc == null) throw new IllegalArgumentException("Table not configured in Mycat schema: " + tableName);

Try / catch

try { rrs = routeMulti(stmt); } catch (SQLNonTransientException e) {
    if (e.getMessage().startsWith("mycat parse error on sql:")) {
        log.error("Unroutable statement: {}", stmt, e);
        throw new IllegalArgumentException("Simplify SQL or fix schema.xml: " + stmt);
    } else throw e;
}

Prevention

When it happens

Trigger: 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:'.

Common situations: 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.

Understand the failure class

Background: "query failed", "%w: SQL error" — wrapped database query errors in Go libraries explained — this error's family across 3 libraries.

Related errors


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

Appendix: source

Thrown at src/main/java/io/mycat/route/impl/DruidMycatRouteStrategy.java:300

			} else {
				// the last one
				RouteResultset rrsTemp = new RouteResultset(remingSql, sqlType);
				RouteResultset tempRrs = routeNormalSqlWithAST0(schema, remingSql, rrsTemp, charset, cachePool, sqlType,
						sc);
				allNodes.addAll(Arrays.asList(tempRrs.getNodes()));
				rrs = rrsTemp;
				break;
			}
		} while (true);

		if (allNodes.size() >= 1) {
			// merge
			rrs.setStatement(stmt);
			rrs.setNodes(allNodes.toArray(new RouteResultsetNode[0]));
			rrs.mergeSameNode();
			return rrs;
		} else {
			throw new SQLNonTransientException("mycat parse error on sql:" + stmt);
		}
	}
	/**
	 * 子查询中存在关联查询的情况下,检查关联字段是否是分片字段
	 * @param rulemap
	 * @param ships
	 * @return
	 */
	private boolean checkRuleField(Map<String,RuleConfig> rulemap,MycatSchemaStatVisitor visitor){

		if(!MycatServer.getInstance().getConfig().getSystem().isSubqueryRelationshipCheck()){
			return true;
		}

		Set<Relationship> ships = visitor.getRelationships();
		Iterator<Relationship> iter = ships.iterator();
		while(iter.hasNext()){
			Relationship ship = iter.next();

View on GitHub (pinned to 65f8d8beb7)