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: error image when use null value as image query condition in insert on duplicate #5031

Conversation

renliangyu857
Copy link
Contributor

…ecutor

  • I have registered the PR changes.

Ⅰ. Describe what this PR did

Ⅱ. Does this pull request fix one issue?

fixes #4956

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

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@lgtm-com
Copy link

lgtm-com bot commented Oct 28, 2022

This pull request introduces 1 alert when merging 6128575 into e10e36c - view on LGTM.com

new alerts:

  • 1 for Dereferenced variable may be null

@renliangyu857 renliangyu857 changed the title bugfix: error image fro use index null value in insert on duplicate ex… bugfix: error image when use null value as image query condition in insert on duplicate ex… Oct 28, 2022
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 @slievrly @jsbxyyx PTAL

@funky-eyes funky-eyes added this to the 1.6.0 milestone Oct 31, 2022
@funky-eyes funky-eyes changed the title bugfix: error image when use null value as image query condition in insert on duplicate ex… bugfix: error image when use null value as image query condition in insert on duplicate Oct 31, 2022
@codecov-commenter
Copy link

codecov-commenter commented Nov 1, 2022

Codecov Report

Merging #5031 (78ade4e) into develop (f0e25a6) will decrease coverage by 0.01%.
The diff coverage is 41.66%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop    #5031      +/-   ##
=============================================
- Coverage      49.42%   49.40%   -0.02%     
+ Complexity      4125     4124       -1     
=============================================
  Files            734      734              
  Lines          26054    26058       +4     
  Branches        3220     3221       +1     
=============================================
- Hits           12877    12874       -3     
- Misses         11803    11805       +2     
- Partials        1374     1379       +5     
Impacted Files Coverage Δ
...ec/mysql/MySQLInsertOnDuplicateUpdateExecutor.java 32.47% <41.66%> (+1.94%) ⬆️
...n/src/main/java/io/seata/common/util/IdWorker.java 77.08% <0.00%> (-6.25%) ⬇️
...in/java/io/seata/server/session/GlobalSession.java 78.68% <0.00%> (-0.78%) ⬇️
...torage/file/store/FileTransactionStoreManager.java 55.62% <0.00%> (-0.65%) ⬇️
...erver/storage/file/session/FileSessionManager.java 49.04% <0.00%> (-0.64%) ⬇️

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.

lQLPJxbYbtWxawXNATrNBS-w7HzuqrL9_4EDY6uH-8CFAA_1327_314
需要顺便把上述去重后多余的or去掉
其次https://github.com/seata/seata/pull/5028/files 依赖此pr,否者当存在uk且没有默认值是,会出现is "null"的条件导致sql报错
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''NULL' ) OR (test_id2 is 'NULL' ) FOR UPDATE' at line 1

@renliangyu857
Copy link
Contributor Author

1、问题
insert on duplicate update语句中DB对于null值唯一索引或主键不会进行匹配,所以索引值为空或null时,不应该作为查询前置镜像的条件。
2、测试
建表语句:
CREATE TABLE t_unique (
id int(11) NOT NULL,
a int(11) DEFAULT NULL,
b int(11) DEFAULT NULL,
PRIMARY KEY (id),
UNIQUE KEY a (a)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
insert into t_unique(id,b) values(1,1)
测试Case:

  1. insert into t_unique(id,b) values(1,2) on duplicate key update b = 5
    这种情况正确的查询条件应该是只有where id = 1
    2)insert into t_unique(id,a,b) values(1,null,2) on duplicate key update b = 5
    这种情况识别到值为NULL对象,正确的查询条件应该是只有where id = 1

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.

问题记录: insert on duplicate 中存在从tablematedata读取唯一索引的时候没有判断是否需要加上转义符,假设这个所以是一个关键字,此时前镜像查询的sql会报错

Copy link
Contributor

@caohdgege caohdgege left a comment

Choose a reason for hiding this comment

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

LGTM

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.

When the unique index has a default null image sql error
5 participants