Skip to content

Commit

Permalink
Check if there are blocks left in columnar_scan_analyze_next_block
Browse files Browse the repository at this point in the history
In PG17, the outer loop in acquire_sample_rows() changed
from
while (BlockSampler_HasMore(&bs))
to
while (table_scan_analyze_next_block(scan, stream))

Relevant PG commit:
041b96802efa33d2bc9456f2ad946976b92b5ae1
postgres/postgres@041b968

It is expected that the scan_analyze_next_block function will
check if there are any blocks left. So we add that check in
columnar_scan_analyze_next_block

(cherry picked from commit 7eb0ad5)
(cherry picked from commit 196d0e7)
  • Loading branch information
naisila committed Nov 13, 2024
1 parent 5c89a81 commit a162533
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/backend/columnar/columnar_tableam.c
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,19 @@ columnar_scan_analyze_next_block(TableScanDesc scan,
* to pages boundaries. So not much to do here. We return true anyway
* so acquire_sample_rows() in analyze.c would call our
* columnar_scan_analyze_next_tuple() callback.
* In PG17, we return false in case there is no buffer left, since
* the outer loop changed in acquire_sample_rows(), and it is
* expected for the scan_analyze_next_block function to check whether
* there are any blocks left in the block sampler.
*/
#if PG_VERSION_NUM >= PG_VERSION_17
Buffer buf = read_stream_next_buffer(stream, NULL);

Check warning on line 1446 in src/backend/columnar/columnar_tableam.c

View check run for this annotation

Codecov / codecov/patch

src/backend/columnar/columnar_tableam.c#L1446

Added line #L1446 was not covered by tests
if (!BufferIsValid(buf))
{
return false;
}
ReleaseBuffer(buf);

Check warning on line 1451 in src/backend/columnar/columnar_tableam.c

View check run for this annotation

Codecov / codecov/patch

src/backend/columnar/columnar_tableam.c#L1451

Added line #L1451 was not covered by tests
#endif
return true;
}

Expand Down

0 comments on commit a162533

Please sign in to comment.