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

Commit4b82664

Browse files
committed
Only allow heap in a number of contrib modules.
Contrib modules pgrowlocks, pgstattuple and some functionality inpageinspect currently only supports the heap table AM. As they are allconcerned with low-level details that aren't reasonably exposed viatableam, error out if invoked on a non heap relation.Author: Andres FreundDiscussion:https://postgr.es/m/20180703070645.wchpu5muyto5n647@alap3.anarazel.de
1 parentd45e401 commit4b82664

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

‎contrib/pageinspect/heapfuncs.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include"access/htup_details.h"
3131
#include"access/relation.h"
3232
#include"funcapi.h"
33+
#include"catalog/pg_am_d.h"
3334
#include"catalog/pg_type.h"
3435
#include"miscadmin.h"
3536
#include"utils/array.h"
@@ -318,6 +319,10 @@ tuple_data_split_internal(Oid relid, char *tupdata,
318319
raw_attrs=initArrayResult(BYTEAOID,CurrentMemoryContext, false);
319320
nattrs=tupdesc->natts;
320321

322+
if (rel->rd_rel->relam!=HEAP_TABLE_AM_OID)
323+
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
324+
errmsg("only heap AM is supported")));
325+
321326
if (nattrs< (t_infomask2&HEAP_NATTS_MASK))
322327
ereport(ERROR,
323328
(errcode(ERRCODE_DATA_CORRUPTED),

‎contrib/pgrowlocks/pgrowlocks.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include"access/tableam.h"
3131
#include"access/xact.h"
3232
#include"catalog/namespace.h"
33+
#include"catalog/pg_am_d.h"
3334
#include"catalog/pg_authid.h"
3435
#include"funcapi.h"
3536
#include"miscadmin.h"
@@ -101,6 +102,10 @@ pgrowlocks(PG_FUNCTION_ARGS)
101102
relrv=makeRangeVarFromNameList(textToQualifiedNameList(relname));
102103
rel=relation_openrv(relrv,AccessShareLock);
103104

105+
if (rel->rd_rel->relam!=HEAP_TABLE_AM_OID)
106+
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
107+
errmsg("only heap AM is supported")));
108+
104109
if (rel->rd_rel->relkind==RELKIND_PARTITIONED_TABLE)
105110
ereport(ERROR,
106111
(errcode(ERRCODE_WRONG_OBJECT_TYPE),

‎contrib/pgstattuple/pgstatapprox.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@
2020
#include"access/multixact.h"
2121
#include"access/htup_details.h"
2222
#include"catalog/namespace.h"
23+
#include"catalog/pg_am_d.h"
24+
#include"commands/vacuum.h"
2325
#include"funcapi.h"
2426
#include"miscadmin.h"
2527
#include"storage/bufmgr.h"
2628
#include"storage/freespace.h"
2729
#include"storage/procarray.h"
2830
#include"storage/lmgr.h"
2931
#include"utils/builtins.h"
30-
#include"commands/vacuum.h"
3132

3233
PG_FUNCTION_INFO_V1(pgstattuple_approx);
3334
PG_FUNCTION_INFO_V1(pgstattuple_approx_v1_5);
@@ -291,6 +292,10 @@ pgstattuple_approx_internal(Oid relid, FunctionCallInfo fcinfo)
291292
errmsg("\"%s\" is not a table or materialized view",
292293
RelationGetRelationName(rel))));
293294

295+
if (rel->rd_rel->relam!=HEAP_TABLE_AM_OID)
296+
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
297+
errmsg("only heap AM is supported")));
298+
294299
statapprox_heap(rel,&stat);
295300

296301
relation_close(rel,AccessShareLock);

‎contrib/pgstattuple/pgstattuple.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include"access/relscan.h"
3232
#include"access/tableam.h"
3333
#include"catalog/namespace.h"
34-
#include"catalog/pg_am.h"
34+
#include"catalog/pg_am_d.h"
3535
#include"funcapi.h"
3636
#include"miscadmin.h"
3737
#include"storage/bufmgr.h"
@@ -328,6 +328,11 @@ pgstat_heap(Relation rel, FunctionCallInfo fcinfo)
328328
pgstattuple_typestat= {0};
329329
SnapshotDataSnapshotDirty;
330330

331+
if (rel->rd_rel->relam!=HEAP_TABLE_AM_OID)
332+
ereport(ERROR,
333+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
334+
errmsg("only heap AM is supported")));
335+
331336
/* Disable syncscan because we assume we scan from block zero upwards */
332337
scan=table_beginscan_strat(rel,SnapshotAny,0,NULL, true, false);
333338
hscan= (HeapScanDesc)scan;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp