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

   ## Bug Report
   
   ### Which version of ShardingSphere did you use?
   
   shardingsphere-proxy 5.5.2
   postgres 17.2 as backend
   
   ### Expected behavior
   
   insertion succeed in all three types of timestamp.
   
   ### Actual behavior
   
   `TIMESTAMP '...'` is a typed literal of PG, should be routed as a normal 
literal, instead of an error.
   Furthermore, we suggest supporting routing `make_timestamp()` when its 
arguments are all literals.
   
   ```sql
   testdb=> CREATE SHARDING TABLE RULE t100 ( 
STORAGE_UNITS(ds_0,ds_1,ds_2,ds_3,ds_4), SHARDING_COLUMN=colocated_key, 
TYPE(NAME="AUTO_INTERVAL", PROPERTIES( "datetime-lower"="1970-01-01 00:00:00", 
"datetime-upper"="1980-01-01 00:00:00", "sharding-seconds"="86400" )) ); 
   SUCCESS 
   
   testdb=> create table t100 ( vkey int4 , pkey int4 , c0 numeric , 
colocated_key timestamp ); 
   CREATE TABLE 
   
   testdb=> INSERT INTO t100 (vkey, pkey, c0, colocated_key) VALUES (2, 12000, 
-479737441.3639, TIMESTAMP '1973-06-03 10:30:01'); 
   ERROR: Please check your sharding conditions 
'ShardingConditions(conditions=[ShardingCondition(values=[], startIndex=0)], 
sqlStatementContext=org.apache.shardingsphere.infra.binder.context.statement.dml.InsertStatementContext@5f864204,
 rule=org.apache.shardingsphere.sharding.rule.ShardingRule@1ec5ef0e, 
subqueryContainsShardingCondition=true)' to avoid same record in table 't100' 
routing to multiple data nodes.
   
   testdb=> insert into t100 (vkey, pkey, c0, colocated_key) values 
   (2, 12000, -479737441.3639, make_timestamp(1973, 6, 3, 10, 30, 1));
   ERROR:  Please check your sharding conditions 
'ShardingConditions(conditions=[ShardingCondition(values=[], startIndex=0)], 
sqlStatementContext=org.apache.shardingsphere.infra.binder.context.statement.dml.InsertStatementContext@87683f2,
 rule=org.apache.shardingsphere.sharding.rule.ShardingRule@79a00d3b, 
subqueryContainsShardingCondition=true)' to avoid same record in table 't100' 
routing to multiple data nodes.
   
   testdb=> insert into t100 (vkey, pkey, c0, colocated_key) values 
   (2, 12000, -479737441.3639,'1973-06-03 10:30:01');
   INSERT 0 1
   ```
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule 
configuration, when exception occur etc.
   
   
[ss_postgres.zip](https://github.com/user-attachments/files/24228864/ss_postgres.zip)
   
   run `docker compose up -d` in this file.
   
   SQL to execute are shown above
   


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