aboutsummaryrefslogtreecommitdiff
path: root/contrib/pgstattuple/pgstattuple.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2009-03-31 22:54:31 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2009-03-31 22:54:31 +0000
commitc029a6a49e3782ec5f1a61eb9a495ebd2a56077d (patch)
treefb92a2d210a1086b1fe7c4b83123c1f729ea57ec /contrib/pgstattuple/pgstattuple.c
parent572b60a3bd2af3c3ef75216cf6378025d7d317b1 (diff)
downloadpostgresql-c029a6a49e3782ec5f1a61eb9a495ebd2a56077d.tar.gz
postgresql-c029a6a49e3782ec5f1a61eb9a495ebd2a56077d.zip
Fix contrib/pgstattuple and contrib/pageinspect to prevent attempts to read
temporary tables of other sessions; that is unsafe because of the way our buffer management works. Per report from Stuart Bishop. This is redundant with the bufmgr.c checks in HEAD, but not at all redundant in the back branches.
Diffstat (limited to 'contrib/pgstattuple/pgstattuple.c')
-rw-r--r--contrib/pgstattuple/pgstattuple.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/contrib/pgstattuple/pgstattuple.c b/contrib/pgstattuple/pgstattuple.c
index f4c046ca8c5..c2c5d11e5a6 100644
--- a/contrib/pgstattuple/pgstattuple.c
+++ b/contrib/pgstattuple/pgstattuple.c
@@ -1,5 +1,5 @@
/*
- * $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.36 2008/06/19 00:46:03 alvherre Exp $
+ * $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.37 2009/03/31 22:54:31 tgl Exp $
*
* Copyright (c) 2001,2002 Tatsuo Ishii
*
@@ -199,6 +199,16 @@ pgstat_relation(Relation rel, FunctionCallInfo fcinfo)
{
const char *err;
+ /*
+ * 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")));
+
switch (rel->rd_rel->relkind)
{
case RELKIND_RELATION: