Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: update join condition placeholder param error #5052

Conversation

renliangyu857
Copy link
Contributor

  • I have registered the PR changes.

Ⅰ. Describe what this PR did

Ⅱ. Does this pull request fix one issue?

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@funky-eyes funky-eyes added this to the 1.6.0 milestone Nov 4, 2022
@funky-eyes funky-eyes changed the title bugfix:update join condition placeholder param error bugfix: update join condition placeholder param error Nov 5, 2022
@codecov-commenter
Copy link

codecov-commenter commented Nov 5, 2022

Codecov Report

Merging #5052 (284dc51) into develop (acf880a) will decrease coverage by 0.01%.
The diff coverage is 59.09%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop    #5052      +/-   ##
=============================================
- Coverage      49.29%   49.27%   -0.02%     
- Complexity      4126     4131       +5     
=============================================
  Files            736      736              
  Lines          26130    26165      +35     
  Branches        3226     3231       +5     
=============================================
+ Hits           12880    12894      +14     
- Misses         11870    11888      +18     
- Partials        1380     1383       +3     
Impacted Files Coverage Δ
...ata/sqlparser/druid/mysql/BaseMySQLRecognizer.java 63.82% <0.00%> (-7.60%) ⬇️
...a/sqlparser/druid/mysql/MySQLUpdateRecognizer.java 64.28% <0.00%> (-2.74%) ⬇️
...datasource/exec/mysql/MySQLUpdateJoinExecutor.java 78.88% <73.52%> (-3.35%) ⬇️
.../rm/datasource/exec/BaseTransactionalExecutor.java 56.47% <100.00%> (ø)
...n/src/main/java/io/seata/common/util/IdWorker.java 77.08% <0.00%> (-6.25%) ⬇️
...erver/storage/file/session/FileSessionManager.java 49.68% <0.00%> (+0.63%) ⬆️

@renliangyu857
Copy link
Contributor Author

renliangyu857 commented Nov 11, 2022

一、问题
未考虑到update join语句中,join条件为占位符的情况,如update t inner join t1 on t.id = t1.id and t1.a = ? set t.a = 2
二、解决方案
1、新增JoinRecognizer接口
2、根据条件中的占位符位置从ParametersHolder中获取条件占位符参数
3、填充到查询SQL语句中
三、测试Case

  • CREATE TABLE t1 (

id int(11) NOT NULL,
a int(11) DEFAULT NULL,
b int(11) DEFAULT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
insert into t1 values(1,1,1);
insert into t1 values(2,2,2);

  • CREATE TABLE t2 (

id int(11) NOT NULL,
a int(11) DEFAULT NULL,
b int(11) DEFAULT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
insert into t2 values(1,1,1);
insert into t2 values(2,2,2);

  • update t1 inner join t2 on t1.id = t2.id and t2.a = ? set t1.a = 5

ps.setObject(1,2)

Copy link
Contributor

@funky-eyes funky-eyes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@l81893521 l81893521 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update order_tbl o
inner join account_tbl a on o.user_id = a.user_id and a.user_id = 'U100002'
set o.order_status = 1;

test failed

Copy link
Contributor

@l81893521 l81893521 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@l81893521 l81893521 merged commit 56fb4da into apache:develop Nov 21, 2022
Copy link
Member

@slievrly slievrly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

zw201913 pushed a commit to zw201913/seata that referenced this pull request Dec 12, 2022
…o 1114_for_5073

* '1114_for_5073' of https://github.com/zw201913/seata:
  bugfix: hikari datasource auto proxy fail (apache#5134)
  bugfix: rollback active xa connection fail (apache#5131)
  optimize: support oracle on delete tccfence logs  (apache#5124)
  feature: support passing `contextPath` parameter to Nacos client (apache#5111)
  bugfix:NPE caused when there is no @GlobalTransactional annotation on the RM side  (apache#5109)
  bugfix: Druid disable oracle implicit cache (apache#5098)
  bugfix: fix access key loss after server restart (apache#5097)
  optimize: remove druid dependency in ConnectionProxy (apache#5104)
  bugfix:fix ClassNotFoundException during the ZK unit test (apache#5101)
  bugfix: fix when seata and jpa are used together, their AutoConfiguration order is incorrect (apache#5092)
  optimize: lock priority attempts to insert (apache#4681)
  bugfix: update join condition placeholder param error (apache#5052)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants