Re: What db objects can only be created with superuser? - Mailing list pgsql-hackers

From Kirill Reshke
Subject Re: What db objects can only be created with superuser?
Date
Msg-id CALdSSPjB+GAvCZ40v8_31RV-ccQ11W6QrmEP=4zPYESTgdfA1g@mail.gmail.com
Whole thread Raw
In response to What db objects can only be created with superuser?  (Yash Jain <jainism987e@gmail.com>)
List pgsql-hackers
On Tue, 26 Nov 2024 at 12:59, Yash Jain <jainism987e@gmail.com> wrote:
>
> Hi all,
> I noticed that in the CREATE EXTENSION code, the permission is elevated to the superuser who creates and owns all of
theextension objects.
 
> I was wondering why this elevation is done.
> I understand that the C-based functions can only be created by a superuser. Are there any other db objects that
requiresuperuser? Or is C-based functions the only one?
 
>
> I am hacking around the extension code (locally for my own purpose), and seeking information on this. Thank you.

Hi! This is a more pgsql-general list question.

Objects that created during extension install script will be owned by
superuser (except when extension control file uses superuser=false)

Try this:

 create extension dblink ;

then
select * from pg_depend where deptype = 'e' and refobjid = (select oid
from pg_extension where extname = 'dblink');

You will see a bunch of functions, types and foreign server objects,
all owned by superuser.

For example, for foreign server you can verify it like this:

db2=> select fdwowner from pg_foreign_data_wrapper where fdwname = 'dblink_fdw';
 fdwowner
----------
       10
(1 row)


-- 
Best regards,
Kirill Reshke



pgsql-hackers by date:

Previous
From: Melih Mutlu
Date:
Subject: Re: Separate memory contexts for relcache and catcache
Next
From: Dmitry Nikitin
Date:
Subject: Re: [PATCH] Missing Assert in the code