Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

插入语句中 now() 报错 #64

Open
llg-software opened this issue Jul 20, 2018 · 0 comments
Open

插入语句中 now() 报错 #64

llg-software opened this issue Jul 20, 2018 · 0 comments

Comments

@llg-software
Copy link

llg-software commented Jul 20, 2018

<schema name="xhg_mycat" checkSQLschema="false" sqlMaxLimit="100">
        <!-- 表分片配置在这些 -->
        <table name="t_consumer" primaryKey="id" autoIncrement="true" dataNode="dn1"/>
		<table name="t_event_error" primaryKey="id" dataNode="dn1"/>
		<table name="t_event_receive" primaryKey="id" dataNode="dn1"/>
		<table name="t_event_source" primaryKey="id" dataNode="dn1"/>
    </schema>

t_consumer 配置了 autoIncrement="true" ,插入的时候报错,不配置这项就可以正常运行
mysql> insert into t_consumer(created_time,name,name2) values(now(),'aa','aa');
ERROR 1064 (HY000): com.alibaba.druid.sql.parser.ParserException: syntax error

mycat 日志
2018-07-20 17:50:10.414 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.net.FrontendConnection.query(FrontendConnection.java:288)) - ServerConnection [id=1, schema=xhg_mycat, host=127.0.0.1, user=mycat,txIsolation=3, autocommit=true, schema=xhg_mycat] insert into t_consumer(created_time,name,name2) values(now(),'aa','aa') 2018-07-20 17:50:10.414 DEBUG [$_NIOREACTOR-0-RW] (io.mycat.server.ServerQueryHandler.query(ServerQueryHandler.java:57)) - ServerConnection [id=1, schema=xhg_mycat, host=127.0.0.1, user=mycat,txIsolation=3, autocommit=true, schema=xhg_mycat]insert into t_consumer(created_time,name,name2) values(now(),'aa','aa') 2018-07-20 17:50:10.415 ERROR [Thread-1] (io.mycat.route.impl.DruidMycatRouteStrategy.routeNormalSqlWithAST(DruidMycatRouteStrategy.java:73)) - DruidMycatRouteStrategyError com.alibaba.druid.sql.parser.ParserException: syntax error at com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser.parseValueClause(MySqlStatementParser.java:2132) ~[druid-1.0.26.jar:1.0.26] at com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser.parseInsert(MySqlStatementParser.java:2022) ~[druid-1.0.26.jar:1.0.26] at com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser.parseInsert(MySqlStatementParser.java:193) ~[druid-1.0.26.jar:1.0.26] at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:199) ~[druid-1.0.26.jar:1.0.26] at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatement(SQLStatementParser.java:2065) ~[druid-1.0.26.jar:1.0.26] at io.mycat.route.impl.DruidMycatRouteStrategy.routeNormalSqlWithAST(DruidMycatRouteStrategy.java:70) ~[Mycat-server-1.6-RELEASE.jar:?] at io.mycat.route.impl.AbstractRouteStrategy.route(AbstractRouteStrategy.java:81) ~[Mycat-server-1.6-RELEASE.jar:?] at io.mycat.route.RouteService.route(RouteService.java:133) ~[Mycat-server-1.6-RELEASE.jar:?] at io.mycat.server.ServerConnection.routeEndExecuteSQL(ServerConnection.java:273) ~[Mycat-server-1.6-RELEASE.jar:?] at io.mycat.route.MyCATSequnceProcessor.executeSeq(MyCATSequnceProcessor.java:87) ~[Mycat-server-1.6-RELEASE.jar:?] at io.mycat.route.MyCATSequnceProcessor.access$200(MyCATSequnceProcessor.java:19) ~[Mycat-server-1.6-RELEASE.jar:?] at io.mycat.route.MyCATSequnceProcessor$ExecuteThread.run(MyCATSequnceProcessor.java:110) ~[Mycat-server-1.6-RELEASE.jar:?] 2018-07-20 17:50:10.415 WARN [Thread-1] (io.mycat.server.ServerConnection.routeEndExecuteSQL(ServerConnection.java:281)) - ServerConnection [id=1, schema=xhg_mycat, host=127.0.0.1, user=mycat,txIsolation=3, autocommit=true, schema=xhg_mycat]insert into t_consumer(ID,created_time,name,name2) values( 10002,now() err:java.sql.SQLSyntaxErrorException: com.alibaba.druid.sql.parser.ParserException: syntax error java.sql.SQLSyntaxErrorException: com.alibaba.druid.sql.parser.ParserException: syntax error at io.mycat.route.impl.DruidMycatRouteStrategy.routeNormalSqlWithAST(DruidMycatRouteStrategy.java:74) ~[Mycat-server-1.6-RELEASE.jar:?] at io.mycat.route.impl.AbstractRouteStrategy.route(AbstractRouteStrategy.java:81) ~[Mycat-server-1.6-RELEASE.jar:?] at io.mycat.route.RouteService.route(RouteService.java:133) ~[Mycat-server-1.6-RELEASE.jar:?] at io.mycat.server.ServerConnection.routeEndExecuteSQL(ServerConnection.java:273) ~[Mycat-server-1.6-RELEASE.jar:?] at io.mycat.route.MyCATSequnceProcessor.executeSeq(MyCATSequnceProcessor.java:87) ~[Mycat-server-1.6-RELEASE.jar:?] at io.mycat.route.MyCATSequnceProcessor.access$200(MyCATSequnceProcessor.java:19) ~[Mycat-server-1.6-RELEASE.jar:?] at io.mycat.route.MyCATSequnceProcessor$ExecuteThread.run(MyCATSequnceProcessor.java:110) ~[Mycat-server-1.6-RELEASE.jar:?] Caused by: com.alibaba.druid.sql.parser.ParserException: syntax error at com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser.parseValueClause(MySqlStatementParser.java:2132) ~[druid-1.0.26.jar:1.0.26] at com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser.parseInsert(MySqlStatementParser.java:2022) ~[druid-1.0.26.jar:1.0.26] at com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser.parseInsert(MySqlStatementParser.java:193) ~[druid-1.0.26.jar:1.0.26] at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:199) ~[druid-1.0.26.jar:1.0.26] at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatement(SQLStatementParser.java:2065) ~[druid-1.0.26.jar:1.0.26] at io.mycat.route.impl.DruidMycatRouteStrategy.routeNormalSqlWithAST(DruidMycatRouteStrategy.java:70) ~[Mycat-server-1.6-RELEASE.jar:?]

表结构

CREATE TABLE `t_consumer` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `created_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  `name` varchar(105) NOT NULL DEFAULT '' COMMENT '名字',
  `name2` varchar(106) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10019 DEFAULT CHARSET=utf8mb4;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant