summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2009-03-31 22:56:28 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2009-03-31 22:56:28 +0000
commited00200dacf01264ed6116b2b2018b3de0a79a35 (patch)
tree8d7ea1220571f7ffb4a1aab7ce0a52e9ccdfb71d
parente3c0d679dca9743805e2145f654d06e09950f2d3 (diff)
downloadpostgresql-ed00200dacf01264ed6116b2b2018b3de0a79a35.tar.gz
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.
-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 31de26aa3f..bac41ceabc 100644
--- a/contrib/pgstattuple/pgstattuple.c
+++ b/contrib/pgstattuple/pgstattuple.c
@@ -1,5 +1,5 @@
/*
- * $Header: /cvsroot/pgsql/contrib/pgstattuple/pgstattuple.c,v 1.12.4.1 2004/10/13 22:22:00 tgl Exp $
+ * $Header: /cvsroot/pgsql/contrib/pgstattuple/pgstattuple.c,v 1.12.4.2 2009/03/31 22:56:28 tgl Exp $
*
* Copyright (c) 2001,2002 Tatsuo Ishii
*
@@ -118,6 +118,16 @@ pgstattuple_real(Relation rel)
Datum result;
/*
+ * 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 (isOtherTempNamespace(RelationGetNamespace(rel)))
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot access temporary tables of other sessions")));
+
+ /*
* Build a tuple description for a pgstattupe_type tuple
*/
tupdesc = RelationNameGetTupleDesc(DUMMY_TUPLE);