Files
Fujii Masao 5bbbafac0f Fix assertion failure in pg_prewarm() on objects without storage.
An assertion test added in commit 93393e7 could fail when pg_prewarm()
was called on objects without storage, such as partitioned tables.
This resulted in the following failure in assert-enabled builds:

    Failed Assert("RelFileNumberIsValid(rlocator.relNumber)")

Note that, in non-assert builds, pg_prewarm() just failed with an error
in that case, so there was no ill effect in practice.

This commit fixes the issue by having pg_prewarm() raise an error early
if the specified object has no storage. This approach is similar to
the fix in commit fb7767134 for pg_freespacemap.

Back-patched to v17, where the issue was introduced.

Author: Masahiro Ikeda <[email protected]>
Reviewed-by: Dilip Kumar <[email protected]>
Reviewed-by: Richard Guo <[email protected]>
Reviewed-by: Fujii Masao <[email protected]>
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 17
2025-05-29 17:50:32 +09:00

11 lines
380 B
Plaintext

-- Test pg_prewarm extension
CREATE EXTENSION pg_prewarm;
-- pg_prewarm() should fail if the target relation has no storage.
CREATE TABLE test (c1 int) PARTITION BY RANGE (c1);
SELECT pg_prewarm('test', 'buffer');
ERROR: relation "test" does not have storage
DETAIL: This operation is not supported for partitioned tables.
-- Cleanup
DROP TABLE test;
DROP EXTENSION pg_prewarm;