RE: Ability to reference other extensions by schema in extension scripts

From: "Regina Obe" <lr(at)pcorp(dot)us>
To: "'Tom Lane'" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "'Gregory Stark \(as CFM\)'" <stark(dot)cfm(at)gmail(dot)com>, "'Sandro Santilli'" <strk(at)kbt(dot)io>, <pgsql-hackers(at)lists(dot)postgresql(dot)org>, "'Regina Obe'" <r(at)pcorp(dot)us>
Subject: RE: Ability to reference other extensions by schema in extension scripts
Date: 2023-03-11 08:18:18
Message-ID: 001d01d953f2$099b6430$1cd22c90$@pcorp.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> Subject: Re: Ability to reference other extensions by schema in extension
> scripts
>
> "Regina Obe" <lr(at)pcorp(dot)us> writes:
> >> requires = 'extfoo, extbar'
> >> no_relocate = 'extfoo'
>
> > So when no_relocate is specified, where would that live?
>
> In the control file.
>
> > Would I mark the extfoo as not relocatable on CREATE / ALTER of said
> > extension?
> > Or add an extra field to pg_extension
>
> We don't record dependent extensions in pg_extension now, so that doesn't
> seem like it would fit well. I was envisioning that ALTER EXTENSION SET
> SCHEMA would do something along the lines of
>
> (1) scrape the list of dependent extensions out of pg_depend
> (2) open and parse each of their control files
> (3) fail if any of their control files mentions the target one in
> no_relocate.
>
> Admittedly, this'd be a bit slow, but I doubt that ALTER EXTENSION SET
> SCHEMA is a performance bottleneck for anybody.
>
> > I had tried to do that originally, e.g. instead of even bothering with
> > such an extra arg, just mark it as not relocatable if the extension's
> > script contains references to the required extension's schema.
>
> I don't think that's a great approach, because those references might
appear
> in places that can track a rename (ie, in an object name that's resolved
to a
> stored OID). Short of fully parsing the script file you aren't going to
get a
> reliable answer. I'm content to lay that problem off on the extension
authors.
>
> > But then what if extfoo is upgraded?
>
> We already have mechanisms for version-dependent control files, so I don't
> see where there's a problem.
>
> regards, tom lane

Attached is a revised patch with these changes in place.

Attachment Content-Type Size
0006-Allow-use-of-extschema-reqextname-to-reference.patch application/octet-stream 20.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ankit Kumar Pandey 2023-03-11 09:41:18 Re: optimize several list functions with SIMD intrinsics
Previous Message Amit Kapila 2023-03-11 07:05:13 Re: [PATCH] Use indexes on the subscriber when REPLICA IDENTITY is full on the publisher