mirror of
https://github.com/postgres/postgres.git
synced 2025-05-30 00:02:11 -04:00
Make bms_prev_member work correctly with a 64 bit bitmapword
5c067521 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
This commit is contained in:
parent
9975c128a1
commit
a5ab8928d7
@ -1167,7 +1167,7 @@ bms_prev_member(const Bitmapset *a, int prevbit)
|
||||
if (w != 0)
|
||||
{
|
||||
int result;
|
||||
int shift = 24;
|
||||
int shift = BITS_PER_BITMAPWORD - 8;
|
||||
result = wordnum * BITS_PER_BITMAPWORD;
|
||||
|
||||
while ((w >> shift) == 0)
|
||||
|
@ -1747,6 +1747,29 @@ explain (analyze, costs off, summary off, timing off) execute ab_q3 (2, 2);
|
||||
Filter: ((b >= $1) AND (b <= $2) AND (a < $0))
|
||||
(10 rows)
|
||||
|
||||
-- Test a backwards Append scan
|
||||
create table list_part (a int) partition by list (a);
|
||||
create table list_part1 partition of list_part for values in (1);
|
||||
create table list_part2 partition of list_part for values in (2);
|
||||
create table list_part3 partition of list_part for values in (3);
|
||||
create table list_part4 partition of list_part for values in (4);
|
||||
insert into list_part select generate_series(1,4);
|
||||
begin;
|
||||
-- Don't select an actual value out of the table as the order of the Append's
|
||||
-- subnodes may not be stable.
|
||||
declare cur SCROLL CURSOR for select 1 from list_part where a > (select 1) and a < (select 4);
|
||||
-- move beyond the final row
|
||||
move 3 from cur;
|
||||
-- Ensure we get two rows.
|
||||
fetch backward all from cur;
|
||||
?column?
|
||||
----------
|
||||
1
|
||||
1
|
||||
(2 rows)
|
||||
|
||||
commit;
|
||||
drop table list_part;
|
||||
-- Parallel append
|
||||
-- Suppress the number of loops each parallel node runs for. This is because
|
||||
-- more than one worker may run the same parallel node if timing conditions
|
||||
|
@ -359,6 +359,31 @@ execute ab_q3 (1, 8);
|
||||
|
||||
explain (analyze, costs off, summary off, timing off) execute ab_q3 (2, 2);
|
||||
|
||||
-- Test a backwards Append scan
|
||||
create table list_part (a int) partition by list (a);
|
||||
create table list_part1 partition of list_part for values in (1);
|
||||
create table list_part2 partition of list_part for values in (2);
|
||||
create table list_part3 partition of list_part for values in (3);
|
||||
create table list_part4 partition of list_part for values in (4);
|
||||
|
||||
insert into list_part select generate_series(1,4);
|
||||
|
||||
begin;
|
||||
|
||||
-- Don't select an actual value out of the table as the order of the Append's
|
||||
-- subnodes may not be stable.
|
||||
declare cur SCROLL CURSOR for select 1 from list_part where a > (select 1) and a < (select 4);
|
||||
|
||||
-- move beyond the final row
|
||||
move 3 from cur;
|
||||
|
||||
-- Ensure we get two rows.
|
||||
fetch backward all from cur;
|
||||
|
||||
commit;
|
||||
|
||||
drop table list_part;
|
||||
|
||||
-- Parallel append
|
||||
|
||||
-- Suppress the number of loops each parallel node runs for. This is because
|
||||
|
Loading…
x
Reference in New Issue
Block a user