From: Rob Sargent <robjsargent@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: schema agnostic functions in language sql
Date: Fri, 15 May 2020 16:26:58 -0600
Message-ID: <db508d6f-7e78-e57d-85f1-515353c66e43@gmail.com> (raw)
I'm using postgres 12.2, with multiple identical schema per database
(each with a matching role). I can write public plpgsql functions
without using a schema identifier and let the runtime search_path find
the correct schema-dependent table. The same does not appear to be true
for plain sql functions. The 'parser'? does not recognize the tables
(sans schema qualifier):
ERROR: relation "<tablename>" does not exist.
I would rather not have to duplicate these across multiple schema - I'll
use plpgsql instead unless I've overlooked some other avenue.
I've found that I can create the function, in public, if I set the
search_path containing one schema (of course) and then successfully
access the function after resetting the search path to use a second
schema. My "build the world" scripting has so far avoided needing to
know/use any specific role. Another pipe dream vaporized?
Thanks,
rjs
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: robjsargent@gmail.com
Subject: Re: schema agnostic functions in language sql
In-Reply-To: <db508d6f-7e78-e57d-85f1-515353c66e43@gmail.com>
References: <db508d6f-7e78-e57d-85f1-515353c66e43@gmail.com>
* 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