Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

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

Provide feedback

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

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3ec8a3b

Browse files
committed
Fix handling of NULLs when merging BRIN summaries
When merging BRIN summaries, union_tuples() did not correctly update thetarget hasnulls/allnulls flags. When merging all-NULL summary into asummary without any NULL values, the result had both flags set to false(instead of having hasnulls=true).This happened because the code only considered the hasnulls flags,ignoring the possibility the source summary has allnulls=true.Discovered while investigating issues with handling empty BRIN rangesand handling of NULL values, but it's a separate problem (has nothing todo with empty ranges).Fixed by considering both flags on the source summary, and updating thehasnulls flag on the target summary.Backpatch to 11. The bug exists since 9.5 (where BRIN indexes wereintroduced), but those releases are EOL already.Discussion:https://postgr.es/m/9d993d0d-e431-2196-9ccc-0554d0e60154%40enterprisedb.com
1 parent0791930 commit3ec8a3b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

‎src/backend/access/brin/brin.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1615,8 +1615,11 @@ union_tuples(BrinDesc *bdesc, BrinMemTuple *a, BrinTuple *b)
16151615

16161616
if (opcinfo->oi_regular_nulls)
16171617
{
1618+
/* Does the "b" summary represent any NULL values? */
1619+
boolb_has_nulls= (col_b->bv_hasnulls||col_b->bv_allnulls);
1620+
16181621
/* Adjust "hasnulls". */
1619-
if (!col_a->bv_hasnulls&&col_b->bv_hasnulls)
1622+
if (!col_a->bv_allnulls&&b_has_nulls)
16201623
col_a->bv_hasnulls= true;
16211624

16221625
/* If there are no values in B, there's nothing left to do. */
@@ -1628,12 +1631,17 @@ union_tuples(BrinDesc *bdesc, BrinMemTuple *a, BrinTuple *b)
16281631
* values from B into A, and we're done. We cannot run the
16291632
* operators in this case, because values in A might contain
16301633
* garbage. Note we already established that B contains values.
1634+
*
1635+
* Also adjust "hasnulls" in order not to forget the summary
1636+
* represents NULL values. This is not redundant with the earlier
1637+
* update, because that only happens when allnulls=false.
16311638
*/
16321639
if (col_a->bv_allnulls)
16331640
{
16341641
inti;
16351642

16361643
col_a->bv_allnulls= false;
1644+
col_a->bv_hasnulls= true;
16371645

16381646
for (i=0;i<opcinfo->oi_nstored;i++)
16391647
col_a->bv_values[i]=

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp