aboutsummaryrefslogtreecommitdiff
path: root/contrib/pgstattuple/pgstatindex.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/pgstattuple/pgstatindex.c')
-rw-r--r--contrib/pgstattuple/pgstatindex.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/contrib/pgstattuple/pgstatindex.c b/contrib/pgstattuple/pgstatindex.c
index dfb162d5e45..b00ae5b766b 100644
--- a/contrib/pgstattuple/pgstatindex.c
+++ b/contrib/pgstattuple/pgstatindex.c
@@ -1,5 +1,5 @@
/*
- * $PostgreSQL: pgsql/contrib/pgstattuple/pgstatindex.c,v 1.11 2008/05/17 01:28:22 adunstan Exp $
+ * $PostgreSQL: pgsql/contrib/pgstattuple/pgstatindex.c,v 1.12 2009/03/31 22:54:31 tgl Exp $
*
*
* pgstatindex
@@ -108,6 +108,16 @@ pgstatindex(PG_FUNCTION_ARGS)
RelationGetRelationName(rel));
/*
+ * Reject attempts to read non-local temporary relations; we would
+ * be likely to get wrong data since we have no visibility into the
+ * owning session's local buffers.
+ */
+ if (RELATION_IS_OTHER_TEMP(rel))
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot access temporary tables of other sessions")));
+
+ /*
* Read metapage
*/
{
@@ -262,6 +272,8 @@ pg_relpages(PG_FUNCTION_ARGS)
relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
rel = relation_openrv(relrv, AccessShareLock);
+ /* note: this will work OK on non-local temp tables */
+
relpages = RelationGetNumberOfBlocks(rel);
relation_close(rel, AccessShareLock);