pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedPG 13 trusted extensions and pg_available_extensions
7+ messages / 4 participants
[nested] [flat]
* PG 13 trusted extensions and pg_available_extensions
@ 2020-09-23 15:28 Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>
2020-09-24 02:58 ` Re: PG 13 trusted extensions and pg_available_extensions Michael Paquier <michael@paquier.xyz>
0 siblings, 1 reply; 7+ messages in thread
From: Daniel Westermann (DWE) @ 2020-09-23 15:28 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Hi,
I was playing a bit with trusted extensions and wondered if there is a reason that the "trusted" flag is not exposed in pg_available_extensions.
I believe that information would be quite useful so one can easily identify extensions that can be installed as "normal" user.
Regards
Daniel
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: PG 13 trusted extensions and pg_available_extensions
2020-09-23 15:28 PG 13 trusted extensions and pg_available_extensions Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>
@ 2020-09-24 02:58 ` Michael Paquier <michael@paquier.xyz>
2020-09-24 03:15 ` Re: PG 13 trusted extensions and pg_available_extensions Julien Rouhaud <rjuju123@gmail.com>
0 siblings, 1 reply; 7+ messages in thread
From: Michael Paquier @ 2020-09-24 02:58 UTC (permalink / raw)
To: Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
On Wed, Sep 23, 2020 at 03:28:45PM +0000, Daniel Westermann (DWE) wrote:
> I was playing a bit with trusted extensions and wondered if there is
> a reason that the "trusted" flag is not exposed in pg_available_extensions.
> I believe that information would be quite useful so one can easily
> identify extensions that can be installed as "normal" user.
Adding the trusted flag makes sense for visibility. There is a bit
more that we could consider though? For example, what about
"relocatable" and "requires"?
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: PG 13 trusted extensions and pg_available_extensions
2020-09-23 15:28 PG 13 trusted extensions and pg_available_extensions Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>
2020-09-24 02:58 ` Re: PG 13 trusted extensions and pg_available_extensions Michael Paquier <michael@paquier.xyz>
@ 2020-09-24 03:15 ` Julien Rouhaud <rjuju123@gmail.com>
2020-09-25 06:51 ` Re: PG 13 trusted extensions and pg_available_extensions Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>
0 siblings, 1 reply; 7+ messages in thread
From: Julien Rouhaud @ 2020-09-24 03:15 UTC (permalink / raw)
To: Michael Paquier <michael@paquier.xyz>; +Cc: Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
On Thu, Sep 24, 2020 at 10:58 AM Michael Paquier <michael@paquier.xyz> wrote:
>
> On Wed, Sep 23, 2020 at 03:28:45PM +0000, Daniel Westermann (DWE) wrote:
> > I was playing a bit with trusted extensions and wondered if there is
> > a reason that the "trusted" flag is not exposed in pg_available_extensions.
> > I believe that information would be quite useful so one can easily
> > identify extensions that can be installed as "normal" user.
>
> Adding the trusted flag makes sense for visibility. There is a bit
> more that we could consider though? For example, what about
> "relocatable" and "requires"?
+1, and also the schema (for non relocatable extensions).
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: PG 13 trusted extensions and pg_available_extensions
2020-09-23 15:28 PG 13 trusted extensions and pg_available_extensions Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>
2020-09-24 02:58 ` Re: PG 13 trusted extensions and pg_available_extensions Michael Paquier <michael@paquier.xyz>
2020-09-24 03:15 ` Re: PG 13 trusted extensions and pg_available_extensions Julien Rouhaud <rjuju123@gmail.com>
@ 2020-09-25 06:51 ` Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>
2020-09-26 10:06 ` Re: PG 13 trusted extensions and pg_available_extensions Julien Rouhaud <rjuju123@gmail.com>
0 siblings, 1 reply; 7+ messages in thread
From: Daniel Westermann (DWE) @ 2020-09-25 06:51 UTC (permalink / raw)
To: Julien Rouhaud <rjuju123@gmail.com>; Michael Paquier <michael@paquier.xyz>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
On Thu, Sep 24, 2020 at 10:58 AM Michael Paquier <michael@paquier.xyz> wrote:
>>
>> On Wed, Sep 23, 2020 at 03:28:45PM +0000, Daniel Westermann (DWE) wrote:
>> > I was playing a bit with trusted extensions and wondered if there is
>> > a reason that the "trusted" flag is not exposed in pg_available_extensions.
>> > I believe that information would be quite useful so one can easily
>> > identify extensions that can be installed as "normal" user.
>>
>> Adding the trusted flag makes sense for visibility. There is a bit
>> more that we could consider though? For example, what about
>> "relocatable" and "requires"?
>+1, and also the schema (for non relocatable extensions).
+1
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: PG 13 trusted extensions and pg_available_extensions
2020-09-23 15:28 PG 13 trusted extensions and pg_available_extensions Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>
2020-09-24 02:58 ` Re: PG 13 trusted extensions and pg_available_extensions Michael Paquier <michael@paquier.xyz>
2020-09-24 03:15 ` Re: PG 13 trusted extensions and pg_available_extensions Julien Rouhaud <rjuju123@gmail.com>
2020-09-25 06:51 ` Re: PG 13 trusted extensions and pg_available_extensions Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>
@ 2020-09-26 10:06 ` Julien Rouhaud <rjuju123@gmail.com>
2020-09-26 14:11 ` Re: PG 13 trusted extensions and pg_available_extensions Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 7+ messages in thread
From: Julien Rouhaud @ 2020-09-26 10:06 UTC (permalink / raw)
To: Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>; +Cc: Michael Paquier <michael@paquier.xyz>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
On Fri, Sep 25, 2020 at 2:51 PM Daniel Westermann (DWE)
<daniel.westermann@dbi-services.com> wrote:
>
> On Thu, Sep 24, 2020 at 10:58 AM Michael Paquier <michael@paquier.xyz> wrote:
> >>
> >> On Wed, Sep 23, 2020 at 03:28:45PM +0000, Daniel Westermann (DWE) wrote:
> >> > I was playing a bit with trusted extensions and wondered if there is
> >> > a reason that the "trusted" flag is not exposed in pg_available_extensions.
> >> > I believe that information would be quite useful so one can easily
> >> > identify extensions that can be installed as "normal" user.
> >>
> >> Adding the trusted flag makes sense for visibility. There is a bit
> >> more that we could consider though? For example, what about
> >> "relocatable" and "requires"?
>
> >+1, and also the schema (for non relocatable extensions).
So, apparently pg_available_extension_versions already had those
fields so all the required infrastructure was already there. I just
added the exact same fields to pg_available_extensions, see attached
patch.
Attachments:
v1-pg_available_extensions_fields.diff (application/octet-stream, 3.9K) download
diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql
index ed4f3f142d..82e81c1bb9 100644
--- a/src/backend/catalog/system_views.sql
+++ b/src/backend/catalog/system_views.sql
@@ -311,7 +311,8 @@ CREATE VIEW pg_cursors AS
CREATE VIEW pg_available_extensions AS
SELECT E.name, E.default_version, X.extversion AS installed_version,
- E.comment
+ E.superuser, E.trusted, E.relocatable,
+ E.schema, E.requires, E.comment
FROM pg_available_extensions() AS E
LEFT JOIN pg_extension AS X ON E.name = X.extname;
diff --git a/src/backend/commands/extension.c b/src/backend/commands/extension.c
index b5630b4c8d..3b3a4bc330 100644
--- a/src/backend/commands/extension.c
+++ b/src/backend/commands/extension.c
@@ -1979,8 +1979,8 @@ pg_available_extensions(PG_FUNCTION_ARGS)
{
ExtensionControlFile *control;
char *extname;
- Datum values[3];
- bool nulls[3];
+ Datum values[8];
+ bool nulls[8];
if (!is_extension_control_filename(de->d_name))
continue;
@@ -2006,11 +2006,28 @@ pg_available_extensions(PG_FUNCTION_ARGS)
nulls[1] = true;
else
values[1] = CStringGetTextDatum(control->default_version);
+ /* superuser */
+ values[2] = BoolGetDatum(control->superuser);
+ /* trusted */
+ values[3] = BoolGetDatum(control->trusted);
+ /* relocatable */
+ values[4] = BoolGetDatum(control->relocatable);
+ /* schema */
+ if (control->schema == NULL)
+ nulls[5] = true;
+ else
+ values[5] = DirectFunctionCall1(namein,
+ CStringGetDatum(control->schema));
+ /* requires */
+ if (control->requires == NIL)
+ nulls[6] = true;
+ else
+ values[6] = convert_requires_to_datum(control->requires);
/* comment */
if (control->comment == NULL)
- nulls[2] = true;
+ nulls[7] = true;
else
- values[2] = CStringGetTextDatum(control->comment);
+ values[7] = CStringGetTextDatum(control->comment);
tuplestore_putvalues(tupstore, tupdesc, values, nulls);
}
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index f48f5fb4d9..94c44acb4b 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -9678,10 +9678,12 @@
# Extensions
{ oid => '3082', descr => 'list available extensions',
- proname => 'pg_available_extensions', procost => '10', prorows => '100',
- proretset => 't', provolatile => 's', prorettype => 'record',
- proargtypes => '', proallargtypes => '{name,text,text}',
- proargmodes => '{o,o,o}', proargnames => '{name,default_version,comment}',
+ proname => 'pg_available_extensions', procost => '10',
+ prorows => '100', proretset => 't', provolatile => 's',
+ prorettype => 'record', proargtypes => '',
+ proallargtypes => '{name,text,bool,bool,bool,name,_name,text}',
+ proargmodes => '{o,o,o,o,o,o,o,o}',
+ proargnames => '{name,default_version,superuser,trusted,relocatable,schema,requires,comment}',
prosrc => 'pg_available_extensions' },
{ oid => '3083', descr => 'list available extension versions',
proname => 'pg_available_extension_versions', procost => '10',
diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out
index 2a18dc423e..30414a308b 100644
--- a/src/test/regress/expected/rules.out
+++ b/src/test/regress/expected/rules.out
@@ -1321,8 +1321,13 @@ pg_available_extension_versions| SELECT e.name,
pg_available_extensions| SELECT e.name,
e.default_version,
x.extversion AS installed_version,
+ e.superuser,
+ e.trusted,
+ e.relocatable,
+ e.schema,
+ e.requires,
e.comment
- FROM (pg_available_extensions() e(name, default_version, comment)
+ FROM (pg_available_extensions() e(name, default_version, superuser, trusted, relocatable, schema, requires, comment)
LEFT JOIN pg_extension x ON ((e.name = x.extname)));
pg_backend_memory_contexts| SELECT pg_get_backend_memory_contexts.name,
pg_get_backend_memory_contexts.ident,
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: PG 13 trusted extensions and pg_available_extensions
2020-09-23 15:28 PG 13 trusted extensions and pg_available_extensions Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>
2020-09-24 02:58 ` Re: PG 13 trusted extensions and pg_available_extensions Michael Paquier <michael@paquier.xyz>
2020-09-24 03:15 ` Re: PG 13 trusted extensions and pg_available_extensions Julien Rouhaud <rjuju123@gmail.com>
2020-09-25 06:51 ` Re: PG 13 trusted extensions and pg_available_extensions Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>
2020-09-26 10:06 ` Re: PG 13 trusted extensions and pg_available_extensions Julien Rouhaud <rjuju123@gmail.com>
@ 2020-09-26 14:11 ` Tom Lane <tgl@sss.pgh.pa.us>
2020-09-26 14:25 ` Re: PG 13 trusted extensions and pg_available_extensions Julien Rouhaud <rjuju123@gmail.com>
0 siblings, 1 reply; 7+ messages in thread
From: Tom Lane @ 2020-09-26 14:11 UTC (permalink / raw)
To: Julien Rouhaud <rjuju123@gmail.com>; +Cc: Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>; Michael Paquier <michael@paquier.xyz>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Julien Rouhaud <rjuju123@gmail.com> writes:
> So, apparently pg_available_extension_versions already had those
> fields so all the required infrastructure was already there. I just
> added the exact same fields to pg_available_extensions, see attached
> patch.
The reason that pg_available_extensions has only the fields it has
is that these other values are potentially extension-version-dependent.
I do not think we can accept this patch.
(Strictly speaking, the "comment" might be version-specific too, but
there's less chance of printing a critically misleading value there.)
regards, tom lane
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: PG 13 trusted extensions and pg_available_extensions
2020-09-23 15:28 PG 13 trusted extensions and pg_available_extensions Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>
2020-09-24 02:58 ` Re: PG 13 trusted extensions and pg_available_extensions Michael Paquier <michael@paquier.xyz>
2020-09-24 03:15 ` Re: PG 13 trusted extensions and pg_available_extensions Julien Rouhaud <rjuju123@gmail.com>
2020-09-25 06:51 ` Re: PG 13 trusted extensions and pg_available_extensions Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>
2020-09-26 10:06 ` Re: PG 13 trusted extensions and pg_available_extensions Julien Rouhaud <rjuju123@gmail.com>
2020-09-26 14:11 ` Re: PG 13 trusted extensions and pg_available_extensions Tom Lane <tgl@sss.pgh.pa.us>
@ 2020-09-26 14:25 ` Julien Rouhaud <rjuju123@gmail.com>
0 siblings, 0 replies; 7+ messages in thread
From: Julien Rouhaud @ 2020-09-26 14:25 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>; Michael Paquier <michael@paquier.xyz>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
On Sat, Sep 26, 2020 at 10:11 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> Julien Rouhaud <rjuju123@gmail.com> writes:
> > So, apparently pg_available_extension_versions already had those
> > fields so all the required infrastructure was already there. I just
> > added the exact same fields to pg_available_extensions, see attached
> > patch.
>
> The reason that pg_available_extensions has only the fields it has
> is that these other values are potentially extension-version-dependent.
> I do not think we can accept this patch.
Oh, I didn't know there could be multiple control files per extension,
and I missed the "aux" reference. So indeed this patch is
unacceptable.
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2020-09-26 14:25 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-09-23 15:28 PG 13 trusted extensions and pg_available_extensions Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>
2020-09-24 02:58 ` Michael Paquier <michael@paquier.xyz>
2020-09-24 03:15 ` Julien Rouhaud <rjuju123@gmail.com>
2020-09-25 06:51 ` Daniel Westermann (DWE) <daniel.westermann@dbi-services.com>
2020-09-26 10:06 ` Julien Rouhaud <rjuju123@gmail.com>
2020-09-26 14:11 ` Tom Lane <tgl@sss.pgh.pa.us>
2020-09-26 14:25 ` Julien Rouhaud <rjuju123@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox