1. The following error occurs
2017-02-27 19:58:41,765 [WARN ][$_NIOREACTOR-2-RW] ServerConnection [id=4, schema=TESTDB, host=127.0.0.1, user=root,txIsolation=3, autocommit=true, schema=TESTDB]create view v_address as select address from t_gaojs err:java.sql.SQLSyntaxErrorException: op table not in schema----VIEW java.sql.SQLSyntaxErrorException: op table not in schema----VIEW
at io.mycat.route.util.RouterUtil.routeToDDLNode(RouterUtil.java:221)
at io.mycat.route.impl.AbstractRouteStrategy.route(AbstractRouteStrategy.java:70)
at io.mycat.route.RouteService.route(RouteService.java:133)
at io.mycat.server.ServerConnection.routeEndExecuteSQL(ServerConnection.java:276)
at io.mycat.server.ServerConnection.execute(ServerConnection.java:222)
at io.mycat.server.ServerQueryHandler.query(ServerQueryHandler.java:136)
Obviously, View is not configured in Schema, and View is regarded as the name of the table. Let me debug it.
See how to get the table name
Find the root cause of the error, the getTableName in RouterUtil failed to parse, and I want to modify it
Solution 1: add Create View branch to routeToDDLNode in RouterUtil for judgment
Option 2: Execute the Change Value operation in Debug mode
then change Value to bypass the error,
Then configure it, deliberately misconfigure the dataNode, and try the consequences
<table name="t_gaojs" dataNode="dn1,dn2,dn3" rule="auto-sharding-long" />
<table name="V_ADDRESS" dataNode="dn1" rule="auto-sharding-long" />
Caused by: io.mycat.config.util.ConfigException: Illegal table conf : table [ V_ADDRESS ] rule function [ rang-long ] partition size : 3 > table datanode size : 1, please make sure table datanode size = function partition size
I don't know why it is 3 here. Obviously, I didn't configure the number 3 for rang-long. If we need to
investigate further, keep it consistent and see if it is OK. The experimental result is OK.
<table name="t_gaojs" dataNode="dn1,dn2,dn3" rule="auto-sharding-long" />
<table name="V_ADDRESS" dataNode="dn1,dn2,dn3" rule="auto-sharding-long" />