From: Tom Lane <tgl@sss.pgh.pa.us>
To: Ayush Vatsa <ayushvatsa1810@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Query regarding function cleanup in extension upgrade path
Date: Wed, 14 Feb 2024 11:37:37 -0500
Message-ID: <2899690.1707928657@sss.pgh.pa.us> (raw)
In-Reply-To: <CACX+KaMFA=k1_c7C8ywm7eG2Y05sYyzYoseVr8epWhqO-T7McQ@mail.gmail.com>
References: <CACX+KaMFA=k1_c7C8ywm7eG2Y05sYyzYoseVr8epWhqO-T7McQ@mail.gmail.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, ayushvatsa1810@gmail.com
Subject: Re: Query regarding function cleanup in extension upgrade path
In-Reply-To: <2899690.1707928657@sss.pgh.pa.us>
References: <CACX+KaMFA=k1_c7C8ywm7eG2Y05sYyzYoseVr8epWhqO-T7McQ@mail.gmail.com> <2899690.1707928657@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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