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

Commitb64c585

Browse files
committed
Fix assertion failure in pg_prewarm() on objects without storage.
An assertion test added in commit049ef33 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 errorin that case, so there was no ill effect in practice.This commit fixes the issue by having pg_prewarm() raise an error earlyif the specified object has no storage. This approach is similar tothe fix in commit4623d71 for pg_freespacemap.Back-patched to v17, where the issue was introduced.Author: Masahiro Ikeda <ikedamsh@oss.nttdata.com>Reviewed-by: Dilip Kumar <dilipbalaut@gmail.com>Reviewed-by: Richard Guo <guofenglinux@gmail.com>Reviewed-by: Fujii Masao <masao.fujii@gmail.com>Discussion:https://postgr.es/m/e082e6027610fd0a4091ae6d033aa117@oss.nttdata.comBackpatch-through: 17
1 parent290e8ab commitb64c585

File tree

5 files changed

+35
-0
lines changed

5 files changed

+35
-0
lines changed

‎contrib/pg_prewarm/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ EXTENSION = pg_prewarm
1010
DATA = pg_prewarm--1.1--1.2.sql pg_prewarm--1.1.sql pg_prewarm--1.0--1.1.sql
1111
PGFILEDESC = "pg_prewarm - preload relation data into system buffer cache"
1212

13+
REGRESS = pg_prewarm
14+
1315
TAP_TESTS = 1
1416

1517
ifdefUSE_PGXS
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
-- Test pg_prewarm extension
2+
CREATE EXTENSION pg_prewarm;
3+
-- pg_prewarm() should fail if the target relation has no storage.
4+
CREATE TABLE test (c1 int) PARTITION BY RANGE (c1);
5+
SELECT pg_prewarm('test', 'buffer');
6+
ERROR: relation "test" does not have storage
7+
DETAIL: This operation is not supported for partitioned tables.
8+
-- Cleanup
9+
DROP TABLE test;
10+
DROP EXTENSION pg_prewarm;

‎contrib/pg_prewarm/meson.build

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ tests += {
2929
'name':'pg_prewarm',
3030
'sd':meson.current_source_dir(),
3131
'bd':meson.current_build_dir(),
32+
'regress': {
33+
'sql': [
34+
'pg_prewarm',
35+
],
36+
},
3237
'tap': {
3338
'tests': [
3439
't/001_basic.pl',

‎contrib/pg_prewarm/pg_prewarm.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,14 @@ pg_prewarm(PG_FUNCTION_ARGS)
128128
if (aclresult!=ACLCHECK_OK)
129129
aclcheck_error(aclresult,get_relkind_objtype(rel->rd_rel->relkind),get_rel_name(relOid));
130130

131+
/* Check that the relation has storage. */
132+
if (!RELKIND_HAS_STORAGE(rel->rd_rel->relkind))
133+
ereport(ERROR,
134+
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
135+
errmsg("relation \"%s\" does not have storage",
136+
RelationGetRelationName(rel)),
137+
errdetail_relkind_not_supported(rel->rd_rel->relkind)));
138+
131139
/* Check that the fork exists. */
132140
if (!smgrexists(RelationGetSmgr(rel),forkNumber))
133141
ereport(ERROR,

‎contrib/pg_prewarm/sql/pg_prewarm.sql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
-- Test pg_prewarm extension
2+
CREATE EXTENSION pg_prewarm;
3+
4+
-- pg_prewarm() should fail if the target relation has no storage.
5+
CREATETABLEtest (c1int) PARTITION BY RANGE (c1);
6+
SELECT pg_prewarm('test','buffer');
7+
8+
-- Cleanup
9+
DROPTABLE test;
10+
DROP EXTENSION pg_prewarm;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp