Skip to content

Fix unique constraint violation when NULLS NOT DISTINCT - #10150

Open
kpan2034 wants to merge 1 commit into
mainfrom
kpan/fix-duplicate-nulls-not-distinct
Open

Fix unique constraint violation when NULLS NOT DISTINCT#10150
kpan2034 wants to merge 1 commit into
mainfrom
kpan/fix-duplicate-nulls-not-distinct

Conversation

@kpan2034

@kpan2034 kpan2034 commented Jun 26, 2026

Copy link
Copy Markdown
Member

When inserting into a compressed chunk, it was possible to violate a unique constraint specifying NULLS NOT DISTINCT.
decompress_batches_scan would incorrectly filter these rows out and skip checking constraints against rows containing NULLs.

Fixes #10057.

Disable-check: force-changelog-file

When inserting into a compressed chunk, it was possible to violate a
unique constraint specifying NULLS NOT DISTINCT.
`decompress_batches_scan` would incorrectly filter these rows out and
skip checking constraints against rows containing NULLs.

Fixes #10057.
@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

-- test that this is correctly handled when using table scan
-- see https://github.com/timescale/timescaledb/issues/10057
SELECT count(compress_chunk(c)) FROM show_chunks('nulls_not_distinct') c;
set timescaledb.enable_dml_decompression_tuple_filtering to off;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This kinda feels weird. Could we add a test case where we drop the compressed chunk index and test that works correctly now as well? Reading the issue seems that also caused the issue.

@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to lack of activity. This pull request will be closed in 30 days.

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.

unique constraint violated with compressed INSERT

2 participants