postgres.git / summary / log / commit / refs

commit    af4ebb272e21dec5cb59223ea2ac95d82900ad77
Author:   Tom Lane <tgl@sss.pgh.pa.us>
Date:     Tue Mar 31 22:56:05 2009 +0000
First released in: 8.4.0, 7.4.26, 8.0.22, 8.1.18, 8.2.14, 8.3.8

    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 cb79fadedb4..52018df8a51 100644 --- a/contrib/pgstattuple/pgstattuple.c +++ b/contrib/pgstattuple/pgstattuple.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.20 2005/10/15 02:49:06 momjian Exp $ + * $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.20.2.1 2009/03/31 22:56:05 tgl Exp $ * * Copyright (c) 2001,2002 Tatsuo Ishii * @@ -115,6 +115,16 @@ pgstattuple_real(Relation rel, FunctionCallInfo fcinfo) 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 descriptor for our result type */ if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE) elog(ERROR, "return type must be a row type"); [parent: 7daa32daa9b2]