pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedQuery regarding function cleanup in extension upgrade path
5+ messages / 3 participants
[nested] [flat]
* Query regarding function cleanup in extension upgrade path
@ 2024-02-14 16:28 Ayush Vatsa <ayushvatsa1810@gmail.com>
2024-02-14 16:37 ` Re: Query regarding function cleanup in extension upgrade path Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 5+ messages in thread
From: Ayush Vatsa @ 2024-02-14 16:28 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Hi PostgreSQL Community,
I have been working on a few extensions but got confused in the upgrade
scenario.
To ask the question let me give a hypothetical example:-
Suppose we have an extension named xyz with version 1.0. It has
xyz--1.0.sql and xyz.c file. I have declared a function named fun() in the
xyz--1.0.sql file and its definition in the xyz.c file.
Now I want to drop this function in the next upgrade i.e. xyz--1.0--1.1 so
I will use DROP FUNCTION fun(); in it and remove the definition from the
xyz.c file.
Here my doubt is wouldn't xyz--1.0 complain about the missing definition of
fun() and if yes how can I clean up my function definition in the xyz.c
file?
I had earlier asked the same question in DBS StackExchange
<https://dba.stackexchange.com/questions/335645/how-to-drop-a-function-in-postgres-extension-upgrade-...;
but didn't get any reply hence trying my luck here.
Regards
Ayush Vatsa
Amazon Web Services (AWS)
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Query regarding function cleanup in extension upgrade path
2024-02-14 16:28 Query regarding function cleanup in extension upgrade path Ayush Vatsa <ayushvatsa1810@gmail.com>
@ 2024-02-14 16:37 ` Tom Lane <tgl@sss.pgh.pa.us>
2024-02-14 17:00 ` Re: Query regarding function cleanup in extension upgrade path Ayush Vatsa <ayushvatsa1810@gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: Tom Lane @ 2024-02-14 16:37 UTC (permalink / raw)
To: Ayush Vatsa <ayushvatsa1810@gmail.com>; +Cc: pgsql-general@lists.postgresql.org
Ayush Vatsa <ayushvatsa1810@gmail.com> writes:
> To ask the question let me give a hypothetical example:-
> Suppose we have an extension named xyz with version 1.0. It has
> xyz--1.0.sql and xyz.c file. I have declared a function named fun() in the
> xyz--1.0.sql file and its definition in the xyz.c file.
> Now I want to drop this function in the next upgrade i.e. xyz--1.0--1.1 so
> I will use DROP FUNCTION fun(); in it and remove the definition from the
> xyz.c file.
> Here my doubt is wouldn't xyz--1.0 complain about the missing definition of
> fun() and if yes how can I clean up my function definition in the xyz.c
> file?
Yeah, you can't really remove the C extern symbol ever. You can
reduce the C function to a stub that just throws a not-supported
error, perhaps, but your users won't necessarily appreciate that.
It's usually better to make the shlib capable of supporting both
the 1.0 and 1.1 APIs, so that users aren't forced into updating
the extension's SQL declarations immediately.
If you look at the standard contrib modules, you'll find a number
of cases where there are backwards-compatibility functions that
just exist to support people who're still using an older version
of the extension's SQL declarations. Those are likely to remain
there indefinitely.
regards, tom lane
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Query regarding function cleanup in extension upgrade path
2024-02-14 16:28 Query regarding function cleanup in extension upgrade path Ayush Vatsa <ayushvatsa1810@gmail.com>
2024-02-14 16:37 ` Re: Query regarding function cleanup in extension upgrade path Tom Lane <tgl@sss.pgh.pa.us>
@ 2024-02-14 17:00 ` Ayush Vatsa <ayushvatsa1810@gmail.com>
2024-02-14 20:56 ` Re: Query regarding function cleanup in extension upgrade path Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 5+ messages in thread
From: Ayush Vatsa @ 2024-02-14 17:00 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-general@lists.postgresql.org
Hi Tom thanks for the answer,
Just two follow up queries regarding this -
1. Suppose I created a new version 1.1 in which I reduce the C function to
throw an error then ship it, will users get the .c latest file immediately
and their old function will throw error but they have to use ALTER
EXTENSION xyz UPGRADE TO 1.1 to use the latest objects defined in 1.1.sql.
Is this the correct understanding?
2. While going through the contrib folder I find that in the regress test
there are two .out files with respect to a single .sql file, example
citext.out and citext_1.out wrt citext.sql. Why is it so? Even in git blame
, I couldn't find much!
Regards
Ayush Vatsa
Amazon Web Services (AWS)
On Wed, 14 Feb 2024 at 22:07, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Ayush Vatsa <ayushvatsa1810@gmail.com> writes:
> > To ask the question let me give a hypothetical example:-
> > Suppose we have an extension named xyz with version 1.0. It has
> > xyz--1.0.sql and xyz.c file. I have declared a function named fun() in
> the
> > xyz--1.0.sql file and its definition in the xyz.c file.
> > Now I want to drop this function in the next upgrade i.e. xyz--1.0--1.1
> so
> > I will use DROP FUNCTION fun(); in it and remove the definition from the
> > xyz.c file.
> > Here my doubt is wouldn't xyz--1.0 complain about the missing definition
> of
> > fun() and if yes how can I clean up my function definition in the xyz.c
> > file?
>
> Yeah, you can't really remove the C extern symbol ever. You can
> reduce the C function to a stub that just throws a not-supported
> error, perhaps, but your users won't necessarily appreciate that.
> It's usually better to make the shlib capable of supporting both
> the 1.0 and 1.1 APIs, so that users aren't forced into updating
> the extension's SQL declarations immediately.
>
> If you look at the standard contrib modules, you'll find a number
> of cases where there are backwards-compatibility functions that
> just exist to support people who're still using an older version
> of the extension's SQL declarations. Those are likely to remain
> there indefinitely.
>
> regards, tom lane
>
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Query regarding function cleanup in extension upgrade path
2024-02-14 16:28 Query regarding function cleanup in extension upgrade path Ayush Vatsa <ayushvatsa1810@gmail.com>
2024-02-14 16:37 ` Re: Query regarding function cleanup in extension upgrade path Tom Lane <tgl@sss.pgh.pa.us>
2024-02-14 17:00 ` Re: Query regarding function cleanup in extension upgrade path Ayush Vatsa <ayushvatsa1810@gmail.com>
@ 2024-02-14 20:56 ` Tom Lane <tgl@sss.pgh.pa.us>
2024-02-15 08:31 ` Re: Query regarding function cleanup in extension upgrade path Daniel Gustafsson <daniel@yesql.se>
0 siblings, 1 reply; 5+ messages in thread
From: Tom Lane @ 2024-02-14 20:56 UTC (permalink / raw)
To: Ayush Vatsa <ayushvatsa1810@gmail.com>; +Cc: pgsql-general@lists.postgresql.org
Ayush Vatsa <ayushvatsa1810@gmail.com> writes:
> Just two follow up queries regarding this -
> 1. Suppose I created a new version 1.1 in which I reduce the C function to
> throw an error then ship it, will users get the .c latest file immediately
> and their old function will throw error but they have to use ALTER
> EXTENSION xyz UPGRADE TO 1.1 to use the latest objects defined in 1.1.sql.
> Is this the correct understanding?
Yes, if you do it like that then once they install the new shlib their
function will be broken until they do ALTER EXTENSION UPGRADE.
> 2. While going through the contrib folder I find that in the regress test
> there are two .out files with respect to a single .sql file, example
> citext.out and citext_1.out wrt citext.sql. Why is it so? Even in git blame
> , I couldn't find much!
We use that when the expected test output is environment-dependent.
If the diff between the .out files isn't pretty self-explanatory,
you can try checking the git log for the "_1.out" file to see why it
was created.
regards, tom lane
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Query regarding function cleanup in extension upgrade path
2024-02-14 16:28 Query regarding function cleanup in extension upgrade path Ayush Vatsa <ayushvatsa1810@gmail.com>
2024-02-14 16:37 ` Re: Query regarding function cleanup in extension upgrade path Tom Lane <tgl@sss.pgh.pa.us>
2024-02-14 17:00 ` Re: Query regarding function cleanup in extension upgrade path Ayush Vatsa <ayushvatsa1810@gmail.com>
2024-02-14 20:56 ` Re: Query regarding function cleanup in extension upgrade path Tom Lane <tgl@sss.pgh.pa.us>
@ 2024-02-15 08:31 ` Daniel Gustafsson <daniel@yesql.se>
0 siblings, 0 replies; 5+ messages in thread
From: Daniel Gustafsson @ 2024-02-15 08:31 UTC (permalink / raw)
To: Ayush Vatsa <ayushvatsa1810@gmail.com>; +Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>; Tom Lane <tgl@sss.pgh.pa.us>
> On 14 Feb 2024, at 21:56, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Ayush Vatsa <ayushvatsa1810@gmail.com> writes:
>> 2. While going through the contrib folder I find that in the regress test
>> there are two .out files with respect to a single .sql file, example
>> citext.out and citext_1.out wrt citext.sql. Why is it so? Even in git blame
>> , I couldn't find much!
>
> We use that when the expected test output is environment-dependent.
> If the diff between the .out files isn't pretty self-explanatory,
> you can try checking the git log for the "_1.out" file to see why it
> was created.
Some further details on this may be gleaned from the pg_regress source code
where it checks for an alternate file (_1 through _9) in case the main expected
output file created a diff:
https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/test/regress/pg_regress.c;h=c894005...
--
Daniel Gustafsson
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2024-02-15 08:31 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-02-14 16:28 Query regarding function cleanup in extension upgrade path Ayush Vatsa <ayushvatsa1810@gmail.com>
2024-02-14 16:37 ` Tom Lane <tgl@sss.pgh.pa.us>
2024-02-14 17:00 ` Ayush Vatsa <ayushvatsa1810@gmail.com>
2024-02-14 20:56 ` Tom Lane <tgl@sss.pgh.pa.us>
2024-02-15 08:31 ` Daniel Gustafsson <daniel@yesql.se>
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