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/oracle pk columns are no longer supported #5284

Closed

Conversation

isharpever
Copy link
Contributor

  • I have registered the PR changes.

Ⅰ. Describe what this PR did

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

Ⅱ. 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
io.seata.rm.datasource.exec.OracleInsertExecutorTest#testGetPkValues_SinglePk
io.seata.rm.datasource.exec.OracleInsertExecutorTest#testGetPkValues_MultiPk

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

@CLAassistant
Copy link

CLAassistant commented Feb 2, 2023

CLA assistant check
All committers have signed the CLA.

@codecov-commenter
Copy link

codecov-commenter commented Feb 2, 2023

Codecov Report

Merging #5284 (6397724) into develop (cee99cd) will increase coverage by 0.06%.
The diff coverage is 96.29%.

📣 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    #5284      +/-   ##
=============================================
+ Coverage      48.73%   48.79%   +0.06%     
- Complexity      4159     4174      +15     
=============================================
  Files            743      743              
  Lines          26590    26615      +25     
  Branches        3321     3330       +9     
=============================================
+ Hits           12958    12987      +29     
+ Misses         12232    12226       -6     
- Partials        1400     1402       +2     
Impacted Files Coverage Δ
...o/seata/rm/datasource/exec/BaseInsertExecutor.java 63.43% <88.88%> (+1.50%) ⬆️
...m/datasource/exec/oracle/OracleInsertExecutor.java 81.48% <100.00%> (+7.79%) ⬆️
...urce/exec/postgresql/PostgresqlInsertExecutor.java 62.79% <100.00%> (+11.36%) ⬆️
...er/src/main/java/io/seata/server/ServerRunner.java 50.00% <0.00%> (-15.39%) ⬇️
...torage/file/store/FileTransactionStoreManager.java 59.16% <0.00%> (-0.65%) ⬇️
...erver/storage/file/session/FileSessionManager.java 48.40% <0.00%> (+0.63%) ⬆️
...in/java/io/seata/server/session/GlobalSession.java 79.77% <0.00%> (+0.76%) ⬆️
.../java/io/seata/server/coordinator/DefaultCore.java 50.58% <0.00%> (+2.35%) ⬆️
...o/seata/server/session/AbstractSessionManager.java 64.17% <0.00%> (+2.98%) ⬆️

@funky-eyes
Copy link
Contributor

Can you separate the oracle and pgsql modified code into 2 pr commits? This will make it easier for us to review

@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
@funky-eyes funky-eyes added this to the 1.7.0 milestone Feb 2, 2023
@isharpever
Copy link
Contributor Author

Can you separate the oracle and pgsql modified code into 2 pr commits? This will make it easier for us to review

ok

@funky-eyes
Copy link
Contributor

close by #5288 #5287

@funky-eyes funky-eyes closed this Feb 2, 2023
@funky-eyes funky-eyes removed this from the 1.7.0 milestone Feb 2, 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.

4 participants