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

   Statement:
   
   ```
   update tablea
   set tablea.columna = tmp.columna
   from (values
   <foreach collection="list" item="item" separator=",">
        (
        #{item.id},
        #{item.columna}
        )
   </foreach>
   ) as TMP (id, columna)
   where tablea.id = tmp.id
   ```
   
   ## Bug Report
   
   Please pay attention on issues you submitted, because we maybe need more 
details. 
   If no response anymore and we cannot reproduce it on current information, we 
will **close it**.
   
   Please answer these questions before submitting your issue. Thanks!
   
   ### Which version of ShardingSphere did you use?
   
   5.4.0
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   
   Shardingsphere-JDBC 
   
   ### Expected behavior
   
   Correct insert behaviour
   
   ### Actual behavior
   
   NoSuchTableException is thrown at ShardingSphereMetaDataValidateUtils line 
56 with message table tmp does not exist
   
   ```
   public static void validateTableExist(final SQLStatementContext 
sqlStatementContext, final ShardingSphereDatabase database) {
           String defaultSchemaName = 
DatabaseTypeEngine.getDefaultSchemaName(sqlStatementContext.getDatabaseType(), 
database.getName());
           ShardingSphereSchema schema = 
sqlStatementContext.getTablesContext().getSchemaName().map(database::getSchema).orElseGet(()
 -> database.getSchema(defaultSchemaName));
           for (String each : 
sqlStatementContext.getTablesContext().getTableNames()) {
               if (!EXCLUDE_VALIDATE_TABLES.contains(each.toUpperCase()) && 
!schema.containsTable(each)) {
                   throw new NoSuchTableException(each);
               }
           }
       }
   }
   ```
   
   The validateTableExist checks whether the table is present in the schema, 
but of course in the case of a TMP alias table an exception will be thrown.
   
   ### Reason analyze (If you can)
   
   TMP table that appears in the where condition must have triggered the parser 
thinking that is is a table that needs to be validated from the schema, failing 
to recognise it as a temporary alias.
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule 
configuration, when exception occur etc.
   
   any update statement of the above kind should trigger the problem.
   
   ### Example codes for reproduce this issue (such as a github link).
   


-- 
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: 
[email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to