Re: Add a function to get the version of installed extension

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Add a function to get the version of installed extension
Date: 2025-02-02 05:15:25
Message-ID: 285641.1738473325@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp> writes:
> This might be avoidable if the binary is made carefully to check the existing
> of objects, but I think it is useful if an extension module function can check
> the current extension version. So, I would like to propose a new function to
> return the current extension version, get_extension_version. I've attached a
> patch.

While I don't say this is a bad idea, I do say you've not made a very
good case for it. How would an extension know its own OID in order
to call the function? If it did manage to call the function, what
exactly would it do with the result, and how would that be easier than
maintaining backwards compatibility with its old SQL definitions?
We've not found the backwards-compatibility requirement to be hugely
onerous in our contrib extensions.

A concrete example use-case would make this a lot more convincing.

> Also, as an application of this function, how about allowing to include versions
> in the "requires" list in the control file?

That could be a good feature, but it doesn't follow that an
implementation of it would have any use for this exact function.
It might well be, for example, that the code would need to fetch
the pg_extension catalog entry for other purposes and so could
read the extversion field "for free" then.

BTW, the cfbot claims that this patch doesn't compile. The
error is a little confusing, but I'm suspicious that it somehow
traces to the fact that you applied NameStr to a field that is
not of type "name". See ExecAlterExtensionStmt for known-to-work
code for fetching extversion.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message jian he 2025-02-02 09:41:15 Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)
Previous Message Tom Lane 2025-02-02 01:44:12 Cross-type index comparison support in contrib/btree_gin