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: After 1.6.0, auto-increment of pgsql pk columns are no longer supported #5287

Merged

Conversation

isharpever
Copy link
Contributor

@isharpever isharpever commented Feb 2, 2023

  • I have registered the PR changes.

Ⅰ. Describe what this PR did

fix:1.6.0~1.6.1,AT模式,当insert语句不包含主键列时,无法获取到pgsql的自增主键值。

Ⅱ. Does this pull request fix one issue?

fixes #5264

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

添加下面几个单测
io.seata.rm.datasource.exec.PostgresqlInsertExecutorTest#testGetPkValues_SinglePk
io.seata.rm.datasource.exec.PostgresqlInsertExecutorTest#testGetPkValues_MultiPk
io.seata.rm.datasource.exec.PostgresqlInsertExecutorTest#testContainsAnyPK

Ⅳ. Describe how to verify it

集成测试验证了下面几种情况

    /*
     * 单主键场景
     * 表: single
     * 列: id, name
     * 主键: id
     */
    // insert columns为空:从插入行获取主键值
    jdbcTemplate.update("insert into single values(1, ?)", name);

    // insert columns包含主键:从插入行获取主键值
    jdbcTemplate.update("insert into single(id, name) values(2, ?)", name);

    // insert columns不是空, 且不包含主键:获取自增值
    jdbcTemplate.update("insert into single(name) values(?)", name);

    /*
     * 多主键场景
     * 表: multi
     * 列: id1, id2, name
     * 联合主键: (id1, id2)
     */
    // insert columns为空:从插入行获取全部主键值
    jdbcTemplate.update("insert into multi values(1, 1, ?)", name);

    // insert columns包含全部主键:从插入行获取全部主键值
    jdbcTemplate.update("insert into multi(id1, id2, name) values(2, 2, ?)", name);

    // insert columns包含部分主键:从插入行获取存在的主键值,其他获取自增值
    jdbcTemplate.update("insert into multi(id1, name) values(3, ?)", name);
    jdbcTemplate.update("insert into multi(id2, name) values(4, ?)", name);

    // insert columns不是空, 且不包含主键:全部主键都获取自增值
    jdbcTemplate.update("insert into multi(name) values(?)", name);

Ⅴ. Special notes for reviews

@codecov-commenter
Copy link

codecov-commenter commented Feb 2, 2023

Codecov Report

Merging #5287 (8e03b4f) into develop (cee99cd) will increase coverage by 0.01%.
The diff coverage is 94.73%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Impacted file tree graph

@@              Coverage Diff              @@
##             develop    #5287      +/-   ##
=============================================
+ Coverage      48.73%   48.74%   +0.01%     
- Complexity      4159     4169      +10     
=============================================
  Files            743      743              
  Lines          26590    26608      +18     
  Branches        3321     3327       +6     
=============================================
+ Hits           12958    12970      +12     
- Misses         12232    12238       +6     
  Partials        1400     1400              
Impacted Files Coverage Δ
...urce/exec/postgresql/PostgresqlInsertExecutor.java 67.92% <94.73%> (+16.49%) ⬆️
...er/src/main/java/io/seata/server/ServerRunner.java 50.00% <0.00%> (-15.39%) ⬇️
...torage/file/store/FileTransactionStoreManager.java 58.52% <0.00%> (-1.29%) ⬇️
...o/seata/server/coordinator/DefaultCoordinator.java 46.61% <0.00%> (+0.39%) ⬆️
...o/seata/rm/datasource/exec/BaseInsertExecutor.java 62.38% <0.00%> (+0.45%) ⬆️

@isharpever isharpever force-pushed the fix_1.6.1_pgsql_pk_auto_increment branch from 40e3342 to 0729436 Compare February 2, 2023 08:16
@funky-eyes funky-eyes added this to the 1.7.0 milestone Feb 2, 2023
@funky-eyes funky-eyes added type: bug Category issues or prs related to bug. first-time contributor first-time contributor module/rm-datasource rm-datasource module labels Feb 2, 2023
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.

LGTM

@funky-eyes funky-eyes merged commit 9464294 into apache:develop Feb 3, 2023
isharpever added a commit to isharpever/seata that referenced this pull request Feb 3, 2023
l81893521 pushed a commit to l81893521/seata that referenced this pull request Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
first-time contributor first-time contributor module/rm-datasource rm-datasource module type: bug Category issues or prs related to bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants