gaojingsong 阅读(675) 评论(0)

1、出现如下错误

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)

很明显是说View在Schema中没有配置,把View当做表名字了,看看我来Debug一番


 

看看如何获取表名字的



 找到错误根源了RouterUtil中的getTableName解析失败,想修改

方案一:RouterUtil中的routeToDDLNode增加Create View分支进行判断

方案二:Debug模式执行Change Value操作



 那就change Value绕过错误,



 

那就配置吧,故意配错dataNode,来尝尝后果

<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

我也不知道为何此处是3,很明显rang-long我没有配置数字3,有待深究

 那就保持一致,看看能否OK,实验结果是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" />



 

 

  • 大小: 102.9 KB
  • 大小: 98.9 KB
  • 大小: 81 KB
  • 大小: 72.3 KB
  • 大小: 74.5 KB
  • 大小: 51.8 KB