← 返回首页
gh-93421: Fix sqlite3 cursor `.rowcount` for UPDATE ... RETURNING queries by erlend-aasland · Pull Request #93520 · python/cpython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

gh-93421: Fix sqlite3 cursor .rowcount for UPDATE ... RETURNING queries#93520

Closed
erlend-aasland wants to merge 9 commits into
python:mainfrom
erlend-aasland:sqlite-changes
Closed

gh-93421: Fix sqlite3 cursor .rowcount for UPDATE ... RETURNING queries#93520
erlend-aasland wants to merge 9 commits into
python:mainfrom
erlend-aasland:sqlite-changes

Conversation

erlend-aasland commented Jun 5, 2022
edited
Loading

Copy link
Copy Markdown
Contributor

Resolves #93421

erlend-aasland added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jun 5, 2022

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @erlend-aasland for commit 5819902 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jun 5, 2022
erlend-aasland self-assigned this Jun 5, 2022
erlend-aasland added needs backport to 3.10 only security fixes needs backport to 3.11 only security fixes labels Jun 5, 2022
erlend-aasland added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jun 5, 2022

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @erlend-aasland for commit 5165a3a 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jun 5, 2022
erlend-aasland added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jun 5, 2022

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @erlend-aasland for commit 1da6390 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jun 5, 2022

Copy link
Copy Markdown
Contributor Author

FYI, the failing buildbot are also failing on main; they are unrelated to this PR.

ghost commented Jun 6, 2022

Copy link
Copy Markdown

Haven't checked this method for problems.
Please consider using sqlite3_total_changes64(), I'm afraid sqlite3_total_changes() will be easier to get wrong result.

total_changes doc:

The two functions are identical except for the type of the return value and that if the number of rows modified by the connection exceeds the maximum value supported by type "int", then the return value of sqlite3_total_changes() is undefined.

Copy link
Copy Markdown
Contributor Author

Haven't checked this method for problems.

Please do; I appreciate your review.

Please consider using sqlite3_total_changes64(), I'm afraid sqlite3_total_changes() will be easier to get wrong result.

Yes, I will make sure the 64-bit version is used, when available. Thanks for the heads-up!

Copy link
Copy Markdown
Contributor Author

FTR, I will revert the DML check change in this PR; that is cleaner.

ghost commented Jun 7, 2022
edited by ghost
Loading

Copy link
Copy Markdown

Just found sqlite3_total_changes64() is a very new function, added in 3.37.0 (2021-11-27)

If change one row per second, it will overflow after 68 years:

>>> (2**31-1)/3600/24/365 68.09625973490614

Not afraid of you laughing, I hope a program can run 1000 years (or forever) without errors, in theory we can achieve this goal.

Copy link
Copy Markdown
Contributor Author

Just found sqlite3_total_changes64() is a very new function, added in 3.37.0 (2021-11-27)

Yes, both of the 64-bit changes APIs were added in 3.37.0.

Not afraid of you laughing, I hope a program can run 1000 years (or forever) without errors, in theory we can achieve this goal.

Absolutely. But I also like to keep in mind that perfect is the enemy of good. IMO, a some of the sqlite3 issues have fallen to this; the proposed solution is not perfect, so we're stuck with API pains and bugs. A pragmatic view may, in some cases, be beneficial.

For the record: for now, I think my alternative PR is the better solution for this issue.

Copy link
Copy Markdown
Contributor Author

Closing in favour of gh-93526

erlend-aasland deleted the sqlite-changes branch June 7, 2022 22:49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

SQLite rowcount is corrupted when combining UPDATE RETURNING w/ table that is dropped and recreated

2 participants

Footer

© 2026 GitHub, Inc.