You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "zc2003 (via GitHub)" <gi...@apache.org> on 2024/12/02 04:31:54 UTC

[I] sharding jdbc try to rewrite my sql two values [shardingsphere]

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

   ## Bug Report
   
   **For English only**, other languages will not accept.
   
   Before report a bug, make sure you have:
   
   - Searched open and closed [GitHub issues](https://github.com/apache/shardingsphere/issues).
   - Read documentation: [ShardingSphere Doc](https://shardingsphere.apache.org/document/current/en/overview).
   
   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?
   sharding jdbc 5.4.1
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   sharding jdbc
   
   ### Expected behavior
   I want to my insert sql execute like this:
   insert into t_user_info (p_id, user_name) values(1,1)
   
   
   ### Actual behavior
   sharding jdbc try to rewrite my sql like this:
   insert into t_user_info (p_id, user_name) values(1,1)(1,1)
   
   
   ### Reason analyze (If you can)
   I config sharding jdbc to manage 2 tables:t_user_info,t_user_bill。
   when executing t_user_info's insert sql :insert into t_user_info (p_id, user_name) values(1,1), sharding use 2 decocrators according to 2 tables trying to decorate the insert sql.Maybe the decorator of table t_user_bill should not be used to the t_user_info's insert sql.
   
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   exception occur etc.
   1.I create table t_user_info,t_user_bill seperately in two database.
   CREATE TABLE "t_user_info" (
     "p_id" int8 NOT NULL,
     "user_name" int4,
     CONSTRAINT "t_user_info_pkey" PRIMARY KEY ("p_id")
   );
   CREATE TABLE "t_user_bill" (
     "p_id" int8 NOT NULL,
     "user_name" int4,
     "bill_no" int4,
     CONSTRAINT "t_user_bill_pkey" PRIMARY KEY ("p_id")
   );
   
   2.I import sharding jdbc, configure 2 tables sharding route/rules ,and use a Configuration class to create a sharding jdbc datasource.
   3.I construct a query sql, and a insert sql of table t_user_info.
   ![image](https://github.com/user-attachments/assets/3f07e963-8865-4293-a0a0-089b324ad033)
   4.The query sql is OK,but the insert sql is failed.
   
   5.when sharding jdbc create rewrite context in class “SQLRewriteEntry”,it use 2 decorator separately to 2 tables to change the insert sql, then create 2 “ShardingInsertValuesTokenGenerator” in class “ShardingTokenGenerateBuilder”。
   6.when build the rewrited insert sql in class “AbstractSQLBuilder”,there are two value tokens,when getting conjuncation char between the two value tokens from sql,“subString”method occurs access index out of range error.
   Error happened in method “getConjunctionText”
   ### 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: notifications-unsubscribe@shardingsphere.apache.org.apache.org

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


Re: [I] sharding jdbc try to rewrite my sql two values [shardingsphere]

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

   rules:
     - !SINGLE
       tables:
         - ds0.t_user_info
         - ds1.t_user_bill
   
   
   While recreating this as ds0 holds t_user_info and ds1 holds t_user_bill I creted them as single tables 
   this does not generates the Error could you give the yaml config that you've used.


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


Re: [I] sharding jdbc try to rewrite my sql two values [shardingsphere]

Posted by "terrymanu (via GitHub)" <gi...@apache.org>.
terrymanu closed issue #33877: sharding jdbc try to rewrite my sql two values
URL: https://github.com/apache/shardingsphere/issues/33877


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


Re: [I] sharding jdbc try to rewrite my sql two values [shardingsphere]

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

   my sql or `MySQL`?


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


Re: [I] sharding jdbc try to rewrite my sql two values [shardingsphere]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #33877:
URL: https://github.com/apache/shardingsphere/issues/33877#issuecomment-2529721130

   There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.


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