Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a5ab892

Browse files
committed
Make bms_prev_member work correctly with a 64 bit bitmapword
5c06752 erroneously had coded bms_prev_member assuming that a bitmapword would always hold 32 bits and started it's search on what it thought was the highest 8-bits of the word. This was not the case if bitmapwords were 64 bits. In passing add a test to exercise this function a little. Previously there was no coverage at all. David Rowly
1 parent 9975c12 commit a5ab892

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

src/backend/nodes/bitmapset.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1167,7 +1167,7 @@ bms_prev_member(const Bitmapset *a, int prevbit)
11671167
if (w != 0)
11681168
{
11691169
int result;
1170-
int shift = 24;
1170+
int shift = BITS_PER_BITMAPWORD - 8;
11711171
result = wordnum * BITS_PER_BITMAPWORD;
11721172

11731173
while ((w >> shift) == 0)

src/test/regress/expected/partition_prune.out

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1747,6 +1747,29 @@ explain (analyze, costs off, summary off, timing off) execute ab_q3 (2, 2);
17471747
Filter: ((b >= $1) AND (b <= $2) AND (a < $0))
17481748
(10 rows)
17491749

1750+
-- Test a backwards Append scan
1751+
create table list_part (a int) partition by list (a);
1752+
create table list_part1 partition of list_part for values in (1);
1753+
create table list_part2 partition of list_part for values in (2);
1754+
create table list_part3 partition of list_part for values in (3);
1755+
create table list_part4 partition of list_part for values in (4);
1756+
insert into list_part select generate_series(1,4);
1757+
begin;
1758+
-- Don't select an actual value out of the table as the order of the Append's
1759+
-- subnodes may not be stable.
1760+
declare cur SCROLL CURSOR for select 1 from list_part where a > (select 1) and a < (select 4);
1761+
-- move beyond the final row
1762+
move 3 from cur;
1763+
-- Ensure we get two rows.
1764+
fetch backward all from cur;
1765+
?column?
1766+
----------
1767+
1
1768+
1
1769+
(2 rows)
1770+
1771+
commit;
1772+
drop table list_part;
17501773
-- Parallel append
17511774
-- Suppress the number of loops each parallel node runs for. This is because
17521775
-- more than one worker may run the same parallel node if timing conditions

src/test/regress/sql/partition_prune.sql

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,31 @@ execute ab_q3 (1, 8);
359359

360360
explain (analyze, costs off, summary off, timing off) execute ab_q3 (2, 2);
361361

362+
-- Test a backwards Append scan
363+
create table list_part (a int) partition by list (a);
364+
create table list_part1 partition of list_part for values in (1);
365+
create table list_part2 partition of list_part for values in (2);
366+
create table list_part3 partition of list_part for values in (3);
367+
create table list_part4 partition of list_part for values in (4);
368+
369+
insert into list_part select generate_series(1,4);
370+
371+
begin;
372+
373+
-- Don't select an actual value out of the table as the order of the Append's
374+
-- subnodes may not be stable.
375+
declare cur SCROLL CURSOR for select 1 from list_part where a > (select 1) and a < (select 4);
376+
377+
-- move beyond the final row
378+
move 3 from cur;
379+
380+
-- Ensure we get two rows.
381+
fetch backward all from cur;
382+
383+
commit;
384+
385+
drop table list_part;
386+
362387
-- Parallel append
363388

364389
-- Suppress the number of loops each parallel node runs for. This is because

0 commit comments

Comments
 (0)