From: Tom Lane Date: Tue, 31 Mar 2009 22:56:18 +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=b040fcf0e9c82c6f05d888ef3fceb492b3bb154c;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 56152b8126..16c911f6ad 100644 --- a/contrib/pgstattuple/pgstattuple.c +++ b/contrib/pgstattuple/pgstattuple.c @@ -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 */