From: Rob Sargent <robjsargent@gmail.com>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: schema agnostic functions in language sql
Date: Fri, 15 May 2020 17:21:51 -0600
Message-ID: <46867210-4a1e-d066-2e63-1d3fe580a733@gmail.com> (raw)
In-Reply-To: <CAKFQuwYy5p3V6DmSn5-y91QUiWXQ75BPi9MChx+HQhK2=vveiQ@mail.gmail.com>
References: <db508d6f-7e78-e57d-85f1-515353c66e43@gmail.com>
<a15a707a-1c33-8d23-6133-ff1466234700@aklaver.com>
<92aa43c7-6b96-ab7f-ddde-61346f957801@gmail.com>
<fc17f5bc-51d0-6e38-9642-752618ae507e@aklaver.com>
<cbea3b73-54e8-acd7-3f32-30c29ac30b26@gmail.com>
<CAKFQuwYy5p3V6DmSn5-y91QUiWXQ75BPi9MChx+HQhK2=vveiQ@mail.gmail.com>
On 5/15/20 5:16 PM, David G. Johnston wrote:
> On Fri, May 15, 2020 at 4:07 PM Rob Sargent <robjsargent@gmail.com
> <mailto:robjsargent@gmail.com>> wrote:
>
> I'm terribly sorry: I needed to add that plpgsql works without any
> knowledge of the schema, where as defining a plain sql functions does
> not work without schema qualification.
>
>
> You need to distinguish between "works" as in "compiles" and "works"
> as in "executes".
>
> Yes, SQL and pl/pgsql have very different behaviors when it comes to
> compilation and execution. In particular SQL performs parsing earlier
> (during creation - just like it does for views) and links the textual
> query to its parse result earlier. For pl/pgsql none of that happens
> until the function is called. Because of this pl/pgsql allows for
> ambiguous sql text to exist and be concretely resolved during
> execution while SQL does not.
>
Thank you for the confirmation. I'll decide whether I move to plpgsql
or dither with role/search_path in the db creation scripts.
(Both forms, plpgsql and sql, "work" once given the correct context.)
> David J.
>
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, david.g.johnston@gmail.com, adrian.klaver@aklaver.com
Subject: Re: schema agnostic functions in language sql
In-Reply-To: <46867210-4a1e-d066-2e63-1d3fe580a733@gmail.com>
References: <db508d6f-7e78-e57d-85f1-515353c66e43@gmail.com> <a15a707a-1c33-8d23-6133-ff1466234700@aklaver.com> <92aa43c7-6b96-ab7f-ddde-61346f957801@gmail.com> <fc17f5bc-51d0-6e38-9642-752618ae507e@aklaver.com> <cbea3b73-54e8-acd7-3f32-30c29ac30b26@gmail.com> <CAKFQuwYy5p3V6DmSn5-y91QUiWXQ75BPi9MChx+HQhK2=vveiQ@mail.gmail.com> <46867210-4a1e-d066-2e63-1d3fe580a733@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