From: Tom Lane Date: Tue, 31 Mar 2009 22:56:28 +0000 (+0000) Subject: Fix contrib/pgstattuple and contrib/pageinspect to prevent attempts to read X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=05f6b356b956afa2dc6cdc8a0f36fa470d5aa8e3;p=users%2Fbernd%2Fpostgres.git 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. --- diff --git a/contrib/pgstattuple/pgstattuple.c b/contrib/pgstattuple/pgstattuple.c index cae971fb58..6e9b2d867c 100644 --- a/contrib/pgstattuple/pgstattuple.c +++ b/contrib/pgstattuple/pgstattuple.c @@ -117,6 +117,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 */