aboutsummaryrefslogtreecommitdiff
path: root/contrib/pageinspect/gistfuncs.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/pageinspect/gistfuncs.c')
-rw-r--r--contrib/pageinspect/gistfuncs.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/contrib/pageinspect/gistfuncs.c b/contrib/pageinspect/gistfuncs.c
index 10d6dd44d4e..a31cff47fea 100644
--- a/contrib/pageinspect/gistfuncs.c
+++ b/contrib/pageinspect/gistfuncs.c
@@ -14,6 +14,7 @@
#include "access/htup.h"
#include "access/relation.h"
#include "catalog/namespace.h"
+#include "catalog/pg_am_d.h"
#include "funcapi.h"
#include "miscadmin.h"
#include "pageinspect.h"
@@ -28,6 +29,8 @@ PG_FUNCTION_INFO_V1(gist_page_opaque_info);
PG_FUNCTION_INFO_V1(gist_page_items);
PG_FUNCTION_INFO_V1(gist_page_items_bytea);
+#define IS_GIST(r) ((r)->rd_rel->relam == GIST_AM_OID)
+
#define ItemPointerGetDatum(X) PointerGetDatum(X)
@@ -174,6 +177,12 @@ gist_page_items(PG_FUNCTION_ARGS)
/* Open the relation */
indexRel = index_open(indexRelid, AccessShareLock);
+ if (!IS_GIST(indexRel))
+ ereport(ERROR,
+ (errcode(ERRCODE_WRONG_OBJECT_TYPE),
+ errmsg("\"%s\" is not a %s index",
+ RelationGetRelationName(indexRel), "GiST")));
+
page = get_page_from_raw(raw_page);
/* Avoid bogus PageGetMaxOffsetNumber() call with deleted pages */