Re: How to add function schema in search_path in option definitio - Mailing list pgsql-general

From David G. Johnston
Subject Re: How to add function schema in search_path in option definitio
Date
Msg-id CAKFQuwZo8B9PMdBL2o7Tzr9HuDfobBk5XpPWrsuf4Lv44uP3Vw@mail.gmail.com
Whole thread Raw
In response to Re: How to add function schema in search_path in option definitio  (Lorusso Domenico <domenico.l76@gmail.com>)
Responses RE: How to add function schema in search_path in option definitio
Re: How to add function schema in search_path in option definitio
List pgsql-general
On Sat, Jul 8, 2023 at 10:00 AM Lorusso Domenico <domenico.l76@gmail.com> wrote:
Hello Adrian,
I've created a schema to handle some specific features.
In the schema there are a couple of tables used by many functions (more than 20).
In other words, I've created a schema as a package (as suggested in many points).

I wish, in a function of this schema, to be able to call each other functions of this schema without adding the schema name in the call instruction.

PostgreSQL isn't really designed for that - especially if you aren't formally creating an extension but simply putting stuff into a schema.

The script code you use to install your makeshift package should handle dynamic schema naming.  It's a pain, do you really need to allow the name of the schema to be unknown at installation time?

You should read up on how extensions are implemented - you are basically writing your own CREATE EXTENSION implementation.


In any case, there really aren't any smarts here: explicitly schema qualify your function calls and forget that search_path even exists.  Unless you are writing custom operators, and even then, consider search_path to be evil.

David J.

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: How to add function schema in search_path in option definitio
Next
From: Johnathan Tiamoh
Date:
Subject: Re: Need Help On Upgrade