Re: schema agnostic functions in language sql - Mailing list pgsql-general

From Tom Lane
Subject Re: schema agnostic functions in language sql
Date
Msg-id 17840.1589586084@sss.pgh.pa.us
Whole thread Raw
In response to Re: schema agnostic functions in language sql  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Re: schema agnostic functions in language sql  (Rob Sargent <robjsargent@gmail.com>)
List pgsql-general
"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



pgsql-general by date:

Previous
From: Rob Sargent
Date:
Subject: Re: schema agnostic functions in language sql
Next
From: Rob Sargent
Date:
Subject: Re: schema agnostic functions in language sql