You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/08/14 07:43:21 UTC

[GitHub] [shardingsphere] whg903 opened a new issue #6839: when using h2 database mode=MySQL ColumnMetaDataLoader.generateEmptyResultSQL get wrong result

whg903 opened a new issue #6839:
URL: https://github.com/apache/shardingsphere/issues/6839


   with shardingspere 4.1.0 or 4.1.1,
   spring.datasource.url=jdbc:h2:mem:db;MODE=MySQL;DB_CLOSE_DELAY=-1
   the error is :
   Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "t_order" not found; SQL statement:
   SELECT * FROM "t_order" WHERE 1 != 1; [42102-199]
   	at org.h2.message.DbException.getJdbcSQLException(DbException.java:451)
   	... ...
   	at org.apache.shardingsphere.sql.parser.binder.metadata.column.ColumnMetaDataLoader.load(ColumnMetaDataLoader.java:75)
   	at org.apache.shardingsphere.sql.parser.binder.metadata.table.TableMetaDataLoader.load(TableMetaDataLoader.java:46)
   	at org.apache.shardingsphere.core.metadata.ShardingMetaDataLoader.load(ShardingMetaDataLoader.java:83)
   	at org.apache.shardingsphere.core.metadata.ShardingMetaDataLoader.loadShardingSchemaMetaData(ShardingMetaDataLoader.java:134)
   	at org.apache.shardingsphere.core.metadata.ShardingMetaDataLoader.load(ShardingMetaDataLoader.java:125)
   	at org.apache.shardingsphere.shardingjdbc.jdbc.core.context.ShardingRuntimeContext.loadSchemaMetaData(ShardingRuntimeContext.java:65)
   
   in H2 MySQL compatible mode, should use ` for table or field name
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tuohai666 edited a comment on issue #6839: when using h2 database mode=MySQL ColumnMetaDataLoader.generateEmptyResultSQL get wrong result

Posted by GitBox <gi...@apache.org>.
tuohai666 edited a comment on issue #6839:
URL: https://github.com/apache/shardingsphere/issues/6839#issuecomment-675834181


   @whg903
   I found that integrated test of ShardingSphere has already used MODE=MySQ, and didn't meet problem.
   It seems like version 1.4.196 is OK. What's your h2 version?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero edited a comment on issue #6839: when using h2 database mode=MySQL ColumnMetaDataLoader.generateEmptyResultSQL get wrong result

Posted by GitBox <gi...@apache.org>.
tristaZero edited a comment on issue #6839:
URL: https://github.com/apache/shardingsphere/issues/6839#issuecomment-674341875


   @whg903 Hi, I am glad to see your debugging result instead of just a question or pointless exception info, nice!
   
   After a glance at`ColumnMetaDataLoader.generateEmpytResultSQL`.  My feeling is that it is an excellent work by using literal judgment and handling. What's more, It seems to affect your issue. Maybe we can ping the author of this function to give us an explanation. Thanks, @tuohai666 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] whg903 commented on issue #6839: when using h2 database mode=MySQL ColumnMetaDataLoader.generateEmptyResultSQL get wrong result

Posted by GitBox <gi...@apache.org>.
whg903 commented on issue #6839:
URL: https://github.com/apache/shardingsphere/issues/6839#issuecomment-675829595


   OK, I'll try submit pull request this weekend, tks.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] whg903 commented on issue #6839: when using h2 database mode=MySQL ColumnMetaDataLoader.generateEmptyResultSQL get wrong result

Posted by GitBox <gi...@apache.org>.
whg903 commented on issue #6839:
URL: https://github.com/apache/shardingsphere/issues/6839#issuecomment-675791209


   I feel disappointed for won't fix this bug. 
   Version 4.0.0 is ok, but 4.1.0+ has this problem, that's important for unit test.
   Why not change "String databaseType" to "DatabaseType databaseType" of TableMetaDataLoader.load and ColumnMetaDataLoader.load, then can use "instanceof BranchDatabaseType" and "BranchDatabaseType.getTrunkDatabaseType" to get actual database type info.
   If H2 mysql mode is not supported,  what's  the use of H2DatabaseType.getTrunkDatabaseType?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] whg903 commented on issue #6839: when using h2 database mode=MySQL ColumnMetaDataLoader.generateEmptyResultSQL get wrong result

Posted by GitBox <gi...@apache.org>.
whg903 commented on issue #6839:
URL: https://github.com/apache/shardingsphere/issues/6839#issuecomment-675875872


   @tuohai666 Thank you very much.
   After test more, I finally found:
   1. h2 1.4.196 and before not support mysql ` ` syntax.
   2. h2 1.4.197~1.4199 support `` but not ""
   3. h2 1.4.200 all is ok
   Unfortunately the version i am using is 1.4.199.
   After update to 1.4.200 , the problem disappeared
   I can't find  related issue or pr in changelog of h2 1.4.200.
    


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero edited a comment on issue #6839: when using h2 database mode=MySQL ColumnMetaDataLoader.generateEmptyResultSQL get wrong result

Posted by GitBox <gi...@apache.org>.
tristaZero edited a comment on issue #6839:
URL: https://github.com/apache/shardingsphere/issues/6839#issuecomment-674341875


   @whg903 Hi, I am glad to see your debugging result instead of just a question or pointless exception info, nice!
   
   After a glance at`ColumnMetaDataLoader.generateEmpytResultSQL`,  my feeling is that it is an excellent work by using literal judgment and handling. What's more, It seems to affect your issue. Maybe we can ping the author of this function to give us an explanation. Thanks, @tuohai666 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tuohai666 closed issue #6839: when using h2 database mode=MySQL ColumnMetaDataLoader.generateEmptyResultSQL get wrong result

Posted by GitBox <gi...@apache.org>.
tuohai666 closed issue #6839:
URL: https://github.com/apache/shardingsphere/issues/6839


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tuohai666 commented on issue #6839: when using h2 database mode=MySQL ColumnMetaDataLoader.generateEmptyResultSQL get wrong result

Posted by GitBox <gi...@apache.org>.
tuohai666 commented on issue #6839:
URL: https://github.com/apache/shardingsphere/issues/6839#issuecomment-675828578


   @whg903 You are right, let's reopen this issue. Since you have analyzed this problem, would you like to submit a pull request?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] whg903 commented on issue #6839: when using h2 database mode=MySQL ColumnMetaDataLoader.generateEmptyResultSQL get wrong result

Posted by GitBox <gi...@apache.org>.
whg903 commented on issue #6839:
URL: https://github.com/apache/shardingsphere/issues/6839#issuecomment-674055887


   @Lucas-307
   I'm sure the table t_order has been created.
   I test with sql [select * from t_order where 1 != 1] got ok,  but with [select * from "t_order" where 1 != 1] got fail.
   So, it may be fault of ColumnMetaDataLoader.generateEmpytResultSQL, it add synatx ["] around table name.
   In h2 mysql mode, should use [`] but not ["]. 
   Should pass databaseType.getTrunkDatabaseType() to method generateEmptyResultSQL?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] Lucas-307 commented on issue #6839: when using h2 database mode=MySQL ColumnMetaDataLoader.generateEmptyResultSQL get wrong result

Posted by GitBox <gi...@apache.org>.
Lucas-307 commented on issue #6839:
URL: https://github.com/apache/shardingsphere/issues/6839#issuecomment-674331208


   @whg903 Yes, I think you are right. Please Let @tristaZero to give a look.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tuohai666 commented on issue #6839: when using h2 database mode=MySQL ColumnMetaDataLoader.generateEmptyResultSQL get wrong result

Posted by GitBox <gi...@apache.org>.
tuohai666 commented on issue #6839:
URL: https://github.com/apache/shardingsphere/issues/6839#issuecomment-675911964


   It seems like H2 decide to support both from 1.4.200. So, let's change to 1.4.200 to resolve this problem. What do you think?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tuohai666 commented on issue #6839: when using h2 database mode=MySQL ColumnMetaDataLoader.generateEmptyResultSQL get wrong result

Posted by GitBox <gi...@apache.org>.
tuohai666 commented on issue #6839:
URL: https://github.com/apache/shardingsphere/issues/6839#issuecomment-674769387


   ColumnMetaDataLoader in SQL Parser module only accept database type input, no more information (MODE=MySQL) will be transferred.
   If ColumnMetaDataLoader receive an H2 type, delimiter (") will be added.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tuohai666 commented on issue #6839: when using h2 database mode=MySQL ColumnMetaDataLoader.generateEmptyResultSQL get wrong result

Posted by GitBox <gi...@apache.org>.
tuohai666 commented on issue #6839:
URL: https://github.com/apache/shardingsphere/issues/6839#issuecomment-675834181


   I found that integrated test of ShardingSphere has already used MODE=MySQ, and didn't meet problem.
   It seems like version 1.4.196 is OK. What's your h2 version?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on issue #6839: when using h2 database mode=MySQL ColumnMetaDataLoader.generateEmptyResultSQL get wrong result

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #6839:
URL: https://github.com/apache/shardingsphere/issues/6839#issuecomment-674341875


   @whg903 Hi, I am glad to see your debugging result instead of just a question or pointless exception info, nice!
   I give a glance at`ColumnMetaDataLoader.generateEmpytResultSQL`.  My feeling is that it is an excellent work by using literal judgment and handling. What's more, It seems to affect your issue. Maybe we can ping the author of this function to give us an explanation. Thanks @tuohai666 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tuohai666 commented on issue #6839: when using h2 database mode=MySQL ColumnMetaDataLoader.generateEmptyResultSQL get wrong result

Posted by GitBox <gi...@apache.org>.
tuohai666 commented on issue #6839:
URL: https://github.com/apache/shardingsphere/issues/6839#issuecomment-675841825


   Strange, I have tested from 1.1.x to 1.4.x, but can't reproduce this problem.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero edited a comment on issue #6839: when using h2 database mode=MySQL ColumnMetaDataLoader.generateEmptyResultSQL get wrong result

Posted by GitBox <gi...@apache.org>.
tristaZero edited a comment on issue #6839:
URL: https://github.com/apache/shardingsphere/issues/6839#issuecomment-674341875


   @whg903 Hi, I am glad to see your debugging result instead of just a question or pointless exception info, nice!
   
   After a glance at'ColumnMetaDataLoader.generateEmpytResultSQL`, I feel that it is a little bit rough to use literal judgment and handling. What's more, It seems to affect your issue. Maybe we can ping the author of this function to give us an explanation. Thanks, @tuohai666 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tuohai666 closed issue #6839: when using h2 database mode=MySQL ColumnMetaDataLoader.generateEmptyResultSQL get wrong result

Posted by GitBox <gi...@apache.org>.
tuohai666 closed issue #6839:
URL: https://github.com/apache/shardingsphere/issues/6839


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero edited a comment on issue #6839: when using h2 database mode=MySQL ColumnMetaDataLoader.generateEmptyResultSQL get wrong result

Posted by GitBox <gi...@apache.org>.
tristaZero edited a comment on issue #6839:
URL: https://github.com/apache/shardingsphere/issues/6839#issuecomment-674341875


   @whg903 Hi, I am glad to see your debugging result instead of just a question or pointless exception info, nice!
   
   After a glance at`ColumnMetaDataLoader.generateEmpytResultSQL`,  my feeling is that it is not an excellent work by using literal judgment and handling. What's more, It seems to affect your issue. Maybe we can ping the author of this function to give us an explanation. Thanks, @tuohai666 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero edited a comment on issue #6839: when using h2 database mode=MySQL ColumnMetaDataLoader.generateEmptyResultSQL get wrong result

Posted by GitBox <gi...@apache.org>.
tristaZero edited a comment on issue #6839:
URL: https://github.com/apache/shardingsphere/issues/6839#issuecomment-674341875


   @whg903 Hi, I am glad to see your debugging result instead of just a question or pointless exception info, nice!
   
   I give a glance at`ColumnMetaDataLoader.generateEmpytResultSQL`.  My feeling is that it is an excellent work by using literal judgment and handling. What's more, It seems to affect your issue. Maybe we can ping the author of this function to give us an explanation. Thanks @tuohai666 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] Lucas-307 commented on issue #6839: when using h2 database mode=MySQL ColumnMetaDataLoader.generateEmptyResultSQL get wrong result

Posted by GitBox <gi...@apache.org>.
Lucas-307 commented on issue #6839:
URL: https://github.com/apache/shardingsphere/issues/6839#issuecomment-673988802


   @whg903 ,From the stack log, I think it's cause by you didn't init h2 database. you should create table "t_order" first.
   `Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "t_order" not found`
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org