Re: Quirk of pg_temp schemas ... - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Quirk of pg_temp schemas ...
Date
Msg-id YRMbSbMT/hdFXnYw@paquier.xyz
Whole thread Raw
In response to Re: Quirk of pg_temp schemas ...  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Tue, Aug 10, 2021 at 11:30:35AM -0400, Tom Lane wrote:
> Greg Stark <stark@mit.edu> writes:
>> While fixing up a patch I had dealing with temporary tables I noticed
>> a bit of a quirk with pg_temp schemas. Namely that we have no actual
>> meta data marking them as temporary aside from their names. And we
>> don't do anything to protect that -- superuser can happily issue ALTER
>> SCHEMA RENAME to rename it to a name that doesn't match pg_temp*.

The fun does not stop here.  Here is one: drop the existing temporary
schema as superuser, keep the connection that dropped it opened, and
play with various temporary objects, even types or functions.

> This seems to me to be not very different from the 1001 other ways that
> a superuser can break a database.  If *non* superusers could rename
> those schemas then I'd agree there's a problem to be solved.

If non-superusers could do anything that change what's stored in
pg_namespace and make things inconsistent with the backend-specific
state stored in memory, we are in trouble.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: ECPG bug fix: DECALRE STATEMENT and DEALLOCATE, DESCRIBE
Next
From: Peter Geoghegan
Date:
Subject: Re: Next Steps with Hash Indexes