Phixsura commented on issue #23764:
URL: 
https://github.com/apache/shardingsphere/issues/23764#issuecomment-4471190753

   PR #38698.
   
   Root cause: in 
`InsertClauseShardingConditionEngine.createShardingCondition`, the `instanceof 
SimpleExpressionSegment / CommonExpressionSegment / isNowExpression` chain has 
no branch for `TypeCastExpression` (a `ComplexExpressionSegment`). A PostgreSQL 
`?::int4` cast on the sharding key therefore falls through silently and the 
sharding value list ends up empty, which routes the INSERT to every shard.
   
   Fix unwraps nested `TypeCastExpression` to its underlying expression before 
the instanceof chain. Added three regression tests covering a TypeCast over a 
parameter marker, over a literal, and nested casts. Also enabled the `?::int4` 
case in `e2e-dml-insert.xml` that was previously commented out with `TODO Fix 
#23764`.
   
   `ConditionValue` / `WhereClauseShardingConditionEngine` have the same shape 
of gap for WHERE-clause casts; reported scenario is INSERT only, follow-up PR 
for the WHERE path.


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