From 8d1c2ca39051126ef1a643f195ac6c0ddf83b20e Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 31 Mar 2009 22:56:18 +0000 Subject: [PATCH] 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. --- contrib/pgstattuple/pgstattuple.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/contrib/pgstattuple/pgstattuple.c b/contrib/pgstattuple/pgstattuple.c index e2fab7863e..40fe4f1961 100644 --- a/contrib/pgstattuple/pgstattuple.c +++ b/contrib/pgstattuple/pgstattuple.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.17 2004/10/15 22:39:38 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.17.4.1 2009/03/31 22:56:18 tgl Exp $ * * Copyright (c) 2001,2002 Tatsuo Ishii * @@ -116,6 +116,16 @@ pgstattuple_real(Relation rel) int i; 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 */ -- 2.50.1