Re: [patch] [doc] Minor variable related cleanup and rewording of plpgsql docs

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: "David G. Johnston" <david.g.johnston@gmail.com>
Cc: Pavel Stehule <pavel.stehule@gmail.com>, David Steele <david@pgmasters.net>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2021-03-12T21:40:25Z
Lists: pgsql-hackers

Attachments

"David G. Johnston" <david.g.johnston@gmail.com> writes:
> I do agree that the delineation of "returns records or not" is not ideal
> here.  SELECT, then INSERT/UPDATE/DELETE (due to their shared RETURNING
> dynamic), then "DML commands", then "DMS exceptions" (these last two
> ideally leveraging the conceptual work noted above).  That said, I do not
> think this is such a big issue as to warrant that much of a rewrite.

I took a stab at doing that, just to see what it might look like.
I thought it comes out pretty well, really -- see what you think.

(This still uses the terminology "optimizable statement", but I'm open
to replacing that with something else.)

> In the following I'm confused as to why "column reference" is specified
> since those are not substituted:
> "Parameters will only be substituted in places where a parameter or
> column reference is syntactically allowed."

The meaning of "column reference" there is, I think, a reference to
a column of a table being read by a query.  In the counterexample
of "INSERT INTO mytable (col) ...", "col" cannot be replaced by a
data value.  But in "INSERT INTO mytable (col) SELECT foo FROM bar",
"foo" is a candidate for replacement, even though it's likely meant
as a reference to bar.foo.

> I'm not married to my explicit calling out of identifiers not being
> substitutable but that does tend to be what people try to do.

The problem I had with it was that it didn't help clarify this
distinction.  I'm certainly open to changes that do clarify that.

			regards, tom lane

Commits

  1. Doc: improve discussion of variable substitution in PL/pgSQL.