Prevent extension creation in temporary schemas - Mailing list pgsql-hackers

From Michael Paquier
Subject Prevent extension creation in temporary schemas
Date
Msg-id 20190107032612.GB22498@paquier.xyz
Whole thread Raw
Responses Re: Prevent extension creation in temporary schemas  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
Hi all,

While looking at another bug I have noticed that it is possible to
create an extension directly using a temporary schema, which is
crazy.  A simple example:
=# create extension pg_prewarm with schema pg_temp_3;
CREATE EXTENSION
=# \dx pg_prewarm
           List of installed extensions
    Name    | Version |  Schema   |      Description
------------+---------+-----------+-----------------------
 pg_prewarm | 1.2     | pg_temp_3 | prewarm relation data
(1 row)

When also creating some extensions, like pageinspect, then the error
message gets a bit crazier, complaining about things not existing.
This combination makes no actual sense, so wouldn't it be better to
restrict the case?  When trying to use ALTER EXTENSION SET SCHEMA we
already have a similar error:
=# alter extension pageinspect set schema pg_temp_3;
ERROR:  0A000: cannot move objects into or out of temporary schemas
LOCATION:  CheckSetNamespace, namespace.c:2954

Attached is an idea of patch, the test case is a bit bulky to remain
portable though.

Thoughts?
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: "Karl O. Pinc"
Date:
Subject: Doc client_min_messages patch vis. INFO message severity
Next
From: Amit Langote
Date:
Subject: Re: [Sender Address Forgery]Re: error message when subscriptiontarget is a partitioned table