pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Rob Sargent <robjsargent@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 19:41:24 -0400
Message-ID: <17840.1589586084@sss.pgh.pa.us> (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>

"David G. Johnston" <david.g.johnston@gmail.com> writes:
> 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.

I don't think that's accurate.  SQL functions are stored as plain text,
just like any other non-C-coded function, and they are not parsed until
execution.

There are big differences from plpgsql of course.  For one, it's
possible for a SQL function to be "inlined" into the calling query,
in which case parsing happens during planning of the calling query.
But other than that, I'd expect the execution-time search path
to determine how a SQL function behaves.

Since Rob didn't provide any details, it's far from clear what's
going wrong for him.

			regards, tom lane





view thread (15+ messages)  latest in thread

Message-ID: <17840.1589586084@sss.pgh.pa.us>
Permalink:  ../17840.1589586084@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/17840.1589586084@sss.pgh.pa.us

 · 

reply

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: tgl@sss.pgh.pa.us, david.g.johnston@gmail.com, robjsargent@gmail.com, adrian.klaver@aklaver.com
  Subject: Re: schema agnostic functions in language sql
  In-Reply-To: <17840.1589586084@sss.pgh.pa.us>
  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> <17840.1589586084@sss.pgh.pa.us>

* 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