shoud be get_extension_schema visible?

Started by Pavel Stehulealmost 3 years ago7 messages
#1Pavel Stehule
pavel.stehule@gmail.com

Hi

more times I needed to get the extension's assigned namespace. There is
already a cooked function get_extension_schema, but it is static.

I need to find a function with a known name, but possibly an unknown schema
from a known extension.

Regards

Pavel

#2Pavel Stehule
pavel.stehule@gmail.com
In reply to: Pavel Stehule (#1)
1 attachment(s)
Re: shoud be get_extension_schema visible?

Hi

pá 17. 2. 2023 v 6:45 odesílatel Pavel Stehule <pavel.stehule@gmail.com>
napsal:

Hi

more times I needed to get the extension's assigned namespace. There is
already a cooked function get_extension_schema, but it is static.

I need to find a function with a known name, but possibly an unknown
schema from a known extension.

Here is an patch

Regards

Pavel

Show quoted text

Regards

Pavel

Attachments:

public_get_extension_schema.patchtext/x-patch; charset=US-ASCII; name=public_get_extension_schema.patchDownload
commit a0bcf2b8261c330e228268939c0381cd2d14eec2
Author: okbob@github.com <pavel.stehule@gmail.com>
Date:   Sun Feb 19 06:38:51 2023 +0100

    initial

diff --git a/src/backend/commands/extension.c b/src/backend/commands/extension.c
index b1509cc505..02ff4a9a7f 100644
--- a/src/backend/commands/extension.c
+++ b/src/backend/commands/extension.c
@@ -222,7 +222,7 @@ get_extension_name(Oid ext_oid)
  *
  * Returns InvalidOid if no such extension.
  */
-static Oid
+Oid
 get_extension_schema(Oid ext_oid)
 {
 	Oid			result;
diff --git a/src/include/commands/extension.h b/src/include/commands/extension.h
index 9f47504491..7e98e37b50 100644
--- a/src/include/commands/extension.h
+++ b/src/include/commands/extension.h
@@ -47,6 +47,7 @@ extern ObjectAddress ExecAlterExtensionContentsStmt(AlterExtensionContentsStmt *
 
 extern Oid	get_extension_oid(const char *extname, bool missing_ok);
 extern char *get_extension_name(Oid ext_oid);
+extern Oid get_extension_schema(Oid ext_oid);
 extern bool extension_file_exists(const char *extensionName);
 
 extern ObjectAddress AlterExtensionNamespace(const char *extensionName, const char *newschema,
#3Julien Rouhaud
rjuju123@gmail.com
In reply to: Pavel Stehule (#2)
Re: shoud be get_extension_schema visible?

Hi,

On Sun, Feb 19, 2023 at 06:40:39AM +0100, Pavel Stehule wrote:

p� 17. 2. 2023 v 6:45 odes�latel Pavel Stehule <pavel.stehule@gmail.com>
napsal:

more times I needed to get the extension's assigned namespace. There is
already a cooked function get_extension_schema, but it is static.

I need to find a function with a known name, but possibly an unknown
schema from a known extension.

Here is an patch

The patch is trivial so I don't have much to say about it, and it also seems
quite reasonable generally.

Note for other reviewers / committers: this is a something actually already
wanted for 3rd party code. As an example, here's Pavel's code in plpgsql_check
extension that internally has to duplicate this function (and deal with
compatibility):
https://github.com/okbob/plpgsql_check/blob/master/src/catalog.c#L205

I'm marking this entry as Ready For Committer.

#4Pavel Stehule
pavel.stehule@gmail.com
In reply to: Julien Rouhaud (#3)
Re: shoud be get_extension_schema visible?

po 6. 3. 2023 v 8:33 odesílatel Julien Rouhaud <rjuju123@gmail.com> napsal:

Hi,

On Sun, Feb 19, 2023 at 06:40:39AM +0100, Pavel Stehule wrote:

pá 17. 2. 2023 v 6:45 odesílatel Pavel Stehule <pavel.stehule@gmail.com>
napsal:

more times I needed to get the extension's assigned namespace. There is
already a cooked function get_extension_schema, but it is static.

I need to find a function with a known name, but possibly an unknown
schema from a known extension.

Here is an patch

The patch is trivial so I don't have much to say about it, and it also
seems
quite reasonable generally.

Note for other reviewers / committers: this is a something actually already
wanted for 3rd party code. As an example, here's Pavel's code in
plpgsql_check
extension that internally has to duplicate this function (and deal with
compatibility):
https://github.com/okbob/plpgsql_check/blob/master/src/catalog.c#L205

I'm marking this entry as Ready For Committer.

Thank you very much

Pavel

#5Michael Paquier
michael@paquier.xyz
In reply to: Pavel Stehule (#4)
Re: shoud be get_extension_schema visible?

On Mon, Mar 06, 2023 at 08:34:49AM +0100, Pavel Stehule wrote:

Note for other reviewers / committers: this is a something actually already
wanted for 3rd party code. As an example, here's Pavel's code in
plpgsql_check
extension that internally has to duplicate this function (and deal with
compatibility):
https://github.com/okbob/plpgsql_check/blob/master/src/catalog.c#L205

I can see why you'd want that, so OK from here to provide this routine
for external consumption. Let's first wait a bit and see if others
have any kind of objections or comments.
--
Michael

#6Michael Paquier
michael@paquier.xyz
In reply to: Michael Paquier (#5)
Re: shoud be get_extension_schema visible?

On Mon, Mar 06, 2023 at 04:44:59PM +0900, Michael Paquier wrote:

I can see why you'd want that, so OK from here to provide this routine
for external consumption. Let's first wait a bit and see if others
have any kind of objections or comments.

Done this one as of e20b1ea.
--
Michael

#7Pavel Stehule
pavel.stehule@gmail.com
In reply to: Michael Paquier (#6)
Re: shoud be get_extension_schema visible?

st 8. 3. 2023 v 2:04 odesílatel Michael Paquier <michael@paquier.xyz>
napsal:

On Mon, Mar 06, 2023 at 04:44:59PM +0900, Michael Paquier wrote:

I can see why you'd want that, so OK from here to provide this routine
for external consumption. Let's first wait a bit and see if others
have any kind of objections or comments.

Done this one as of e20b1ea.

Thank you very much

Pavel

Show quoted text

--
Michael