You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "shashankrnr32 (via GitHub)" <gi...@apache.org> on 2023/03/09 05:49:46 UTC

[GitHub] [shardingsphere] shashankrnr32 opened a new issue, #24517: SQL Rewrite on information_schema tables causes the executor to throw "Table does not exist"

shashankrnr32 opened a new issue, #24517:
URL: https://github.com/apache/shardingsphere/issues/24517

   ## Bug Report
   
   Thanks team for creating this project. Noticed an issue with SQL Parser & Rewriting engine with respect to information_schema tables. Noticed that information_schema support is still in experimental stage. 
   
   If this issue is already reported or is already picked up to be fixed, please feel free to close the issue and point it to the right issue/PR in the project. Also, feel free to correct me in case i have used any of the terms wrong w.r.t this project.
   
   ### Which version of ShardingSphere did you use?
   5.2.1
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-JDBC (From the Spring Boot Start
   
   ### Expected behavior
   Executing Query on Information Schema tables results in rewriting of SQL which removes `owner` from the query and executes it with just the value
   
   **Sample Query:**
   
   Logical Query
   
   ```
   SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, COLUMN_KEY, EXTRA, COLLATION_NAME, ORDINAL_POSITION FROM information_schema.columns WHERE TABLE_SCHEMA=? AND TABLE_NAME IN ('columns', 'schema_data_statistics') ORDER BY ORDINAL_POSITION
   ```
   
   After SQL Rewrite
   ```
   SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, COLUMN_KEY, EXTRA, COLLATION_NAME, ORDINAL_POSITION FROM columns WHERE TABLE_SCHEMA=? AND TABLE_NAME IN ('columns', 'schema_data_statistics') ORDER BY ORDINAL_POSITION
   ```
   
   The following error is seen
   
   ```
   Table 'test_table.columns' doesn't exist
   ```
   
   ### Actual behavior
   
   The actual expected behavior should be any one of these
   1. The `owner` should be added to the query in case of information_schema
   2. The SQL parser should consider the periods (`.`) in the table name as valid.
   
   ### Reason analyze (If you can)
   
   The SQLStatement Object parsed has this as the Table Segment when the above query is parsed by the engine.
   
   ```
   SimpleTableSegment(tableName=TableNameSegment(startIndex=119,
   stopIndex=125,
   identifier=IdentifierValue(value=columns,
   quoteCharacter=NONE)),
   owner=Optional[
     OwnerSegment(startIndex=100,
     stopIndex=117,
     identifier=IdentifierValue(value=information_schema,
     quoteCharacter=NONE),
     owner=Optional.empty)
   ]
   ```
   
   Also when parsing this, the engine wrongly identifies `information_schema` as a database. (See TablesContext object below)
   
   TablesContext Object of the same above query
   ```
   TablesContext(tables=[
     SimpleTableSegment(tableName=TableNameSegment(startIndex=119,
     stopIndex=125,
     identifier=IdentifierValue(value=columns,
     quoteCharacter=NONE)),
     owner=Optional[
       OwnerSegment(startIndex=100,
       stopIndex=117,
       identifier=IdentifierValue(value=information_schema,
       quoteCharacter=NONE),
       owner=Optional.empty)
     ],
     alias=Optional.empty)
   ],
   tableNames=[
     columns
   ],
   schemaNames=[
     information_schema
   ],
   databaseNames=[
     information_schema
   ],
   subqueryTables={
     
   })
   ```
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc
   Provided above.
   
   ### Example codes for reproduce this issue (such as a github link).
   NA


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org.apache.org

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


[GitHub] [shardingsphere] shashankrnr32 commented on issue #24517: SQL Rewrite on information_schema tables causes the executor to throw "Table does not exist"

Posted by "shashankrnr32 (via GitHub)" <gi...@apache.org>.
shashankrnr32 commented on issue #24517:
URL: https://github.com/apache/shardingsphere/issues/24517#issuecomment-1471285055

   Hi
   
   Thanks for the reply, But I dont see the latest version (5.3.1) of shardingsphere-jdbc-core-spring-boot-starter in Maven Repository. I can definitely try with the individual libraries (proxy/JDBC) in my setup. Is there a plan to release this package (Spring Boot Starter) for the latest version (5.3.1)?
   
   I will try it out and let you know if I face any issues.
   
   Thank you.
   
   
   


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

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


[GitHub] [shardingsphere] oulexue commented on issue #24517: SQL Rewrite on information_schema tables causes the executor to throw "Table does not exist"

Posted by "oulexue (via GitHub)" <gi...@apache.org>.
oulexue commented on issue #24517:
URL: https://github.com/apache/shardingsphere/issues/24517#issuecomment-1471474444

   5.3.1 has the same problem too


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

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


[GitHub] [shardingsphere] sandynz commented on issue #24517: SQL Rewrite on information_schema tables causes the executor to throw "Table does not exist"

Posted by "sandynz (via GitHub)" <gi...@apache.org>.
sandynz commented on issue #24517:
URL: https://github.com/apache/shardingsphere/issues/24517#issuecomment-1471473198

   Hi, there's no Spring Boot Starter any more in version 5.3.1. ShardingSphere provides a JDBC driver, you could try ShardingSphereDriver, refer to [JDBC Driver - Spring Boot]( https://shardingsphere.apache.org/document/5.3.1/en/user-manual/shardingsphere-jdbc/yaml-config/jdbc-driver/spring-boot/ ) for more details.


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

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


[GitHub] [shardingsphere] sandynz commented on issue #24517: SQL Rewrite on information_schema tables causes the executor to throw "Table does not exist"

Posted by "sandynz (via GitHub)" <gi...@apache.org>.
sandynz commented on issue #24517:
URL: https://github.com/apache/shardingsphere/issues/24517#issuecomment-1468087009

   Hi @shashankrnr32 , thanks for your feedback.
   
   I tested on proxy (master branch), there's no error:
   ```
   mysql> SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, COLUMN_KEY, EXTRA, COLLATION_NAME, ORDINAL_POSITION FROM information_schema.columns WHERE TABLE_SCHEMA='test1' AND TABLE_NAME IN ('columns', 'schema_data_statistics') ORDER BY ORDINAL_POSITION;
   Empty set (0.20 sec)
   ```
   
   Could you try new version, e.g. 5.3.1?
   


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

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