-
Notifications
You must be signed in to change notification settings - Fork 845
fix: avoid committing new snapshot if table not changed #19174
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
Merged
bohutang
merged 8 commits into
databendlabs:main
from
dantengsky:fix/merge-into-should-not-commit-new-snapshot
Jan 4, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e9a725e
fix: avoid commiting new snapshot if table not changed
dantengsky 7cc197d
add logic test
dantengsky f840d1e
refine code comments
dantengsky fc4e764
refine code comment
dantengsky a5665c6
tweak logic test
dantengsky 671c63a
fix typo
dantengsky d49c3ab
fix logic test
dantengsky d6140da
Merge branch 'main' into fix/merge-into-should-not-commit-new-snapshot
youngsofun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
105 changes: 105 additions & 0 deletions
105
tests/sqllogictests/suites/base/issues/issue_19173.test
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| # https://github.com/datafuselabs/databend/issues/19173 | ||
|
|
||
| statement ok | ||
| create or replace database issue_19173; | ||
|
|
||
| statement ok | ||
| use issue_19173; | ||
|
|
||
| statement ok | ||
| create or replace table target (c int); | ||
|
|
||
| statement ok | ||
| create or replace table empty like target; | ||
|
|
||
| # mutations in autocommit mode | ||
|
|
||
| statement ok | ||
| merge into target using (select c from empty) s on s.c = target.c when matched then update * when not matched then insert *; | ||
|
|
||
| query I | ||
| select count() from fuse_snapshot('issue_19173', 'target'); | ||
| ---- | ||
| 0 | ||
|
|
||
| statement ok | ||
| delete from target where c = 1; | ||
|
|
||
| query I | ||
| select count() from fuse_snapshot('issue_19173', 'target'); | ||
| ---- | ||
| 0 | ||
|
|
||
| statement ok | ||
| update target set c =2 where c = 1; | ||
|
|
||
| query I | ||
| select count() from fuse_snapshot('issue_19173', 'target'); | ||
| ---- | ||
| 0 | ||
|
|
||
| statement ok | ||
| insert into target select * from empty; | ||
|
|
||
| query I | ||
| select count() from fuse_snapshot('issue_19173', 'target'); | ||
| ---- | ||
| 0 | ||
|
|
||
| # mutations inside explicit transactions | ||
|
|
||
| statement ok | ||
| begin transaction; | ||
|
|
||
| statement ok | ||
| merge into target using (select c from empty) s on s.c = target.c when matched then update * when not matched then insert *; | ||
|
|
||
| statement ok | ||
| commit; | ||
|
|
||
| query I | ||
| select count() from fuse_snapshot('issue_19173', 'target'); | ||
| ---- | ||
| 0 | ||
|
|
||
| statement ok | ||
| begin transaction; | ||
|
|
||
| statement ok | ||
| delete from target where c = 1; | ||
|
|
||
| statement ok | ||
| commit; | ||
|
|
||
| query I | ||
| select count() from fuse_snapshot('issue_19173', 'target'); | ||
| ---- | ||
| 0 | ||
|
|
||
| statement ok | ||
| begin transaction; | ||
|
|
||
| statement ok | ||
| update target set c =2 where c = 1; | ||
|
|
||
| statement ok | ||
| commit; | ||
|
|
||
| query I | ||
| select count() from fuse_snapshot('issue_19173', 'target'); | ||
| ---- | ||
| 0 | ||
|
|
||
| statement ok | ||
| begin transaction; | ||
|
|
||
| statement ok | ||
| insert into target select * from empty; | ||
|
|
||
| statement ok | ||
| commit; | ||
|
|
||
| query I | ||
| select count() from fuse_snapshot('issue_19173', 'target'); | ||
| ---- | ||
| 0 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.