pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix plpgsql to allow new-style SQL CREATE FUNCTION as a SQL comm
4+ messages / 1 participants
[nested] [flat]

* pgsql: Fix plpgsql to allow new-style SQL CREATE FUNCTION as a SQL comm
@ 2024-01-18 21:11  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2024-01-18 21:11 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix plpgsql to allow new-style SQL CREATE FUNCTION as a SQL command.

plpgsql fails on new-style CREATE FUNCTION/PROCEDURE commands within
a routine or DO block, because make_execsql_stmt believes that a
semicolon token always terminates a SQL command.  Now, that's actually
been wrong since the day it was written, because CREATE RULE has long
allowed multiple rule actions separated by semicolons.  But there are
few enough people using multi-action rules that there was never an
attempt to fix it.  New-style SQL functions, though, are popular.

psql has this same problem of "does this semicolon really terminate
the command?".  It deals with CREATE RULE by counting parenthesis
nesting depth: a semicolon within parens doesn't end a command.
Commits e717a9a18 and 029c5ac03 created a similar heuristic to count
matching BEGIN/END pairs (but only within CREATEs, so as not to be
fooled by plain BEGIN).  That's survived several releases now without
trouble reports, so let's just absorb those heuristics into plpgsql.

Per report from Samuel Dussault.  Back-patch to v14 where new-style
SQL function syntax came in.

Discussion: https://postgr.es/m/YT2PR01MB88552C3E9AD40A6C038774A781722@YT2PR01MB8855.CANPRD01.PROD.OUTLOOK.COM

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/00f941356e56bd80427765a6a8261eb71e4eb3cc

Modified Files
--------------
src/pl/plpgsql/src/Makefile                  |  5 +-
src/pl/plpgsql/src/expected/plpgsql_misc.out | 31 ++++++++++++
src/pl/plpgsql/src/meson.build               |  3 +-
src/pl/plpgsql/src/pl_gram.y                 | 72 ++++++++++++++++++++++++----
src/pl/plpgsql/src/sql/plpgsql_misc.sql      | 22 +++++++++
5 files changed, 122 insertions(+), 11 deletions(-)



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* pgsql: Fix plpgsql to allow new-style SQL CREATE FUNCTION as a SQL comm
@ 2024-01-18 21:11  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2024-01-18 21:11 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix plpgsql to allow new-style SQL CREATE FUNCTION as a SQL command.

plpgsql fails on new-style CREATE FUNCTION/PROCEDURE commands within
a routine or DO block, because make_execsql_stmt believes that a
semicolon token always terminates a SQL command.  Now, that's actually
been wrong since the day it was written, because CREATE RULE has long
allowed multiple rule actions separated by semicolons.  But there are
few enough people using multi-action rules that there was never an
attempt to fix it.  New-style SQL functions, though, are popular.

psql has this same problem of "does this semicolon really terminate
the command?".  It deals with CREATE RULE by counting parenthesis
nesting depth: a semicolon within parens doesn't end a command.
Commits e717a9a18 and 029c5ac03 created a similar heuristic to count
matching BEGIN/END pairs (but only within CREATEs, so as not to be
fooled by plain BEGIN).  That's survived several releases now without
trouble reports, so let's just absorb those heuristics into plpgsql.

Per report from Samuel Dussault.  Back-patch to v14 where new-style
SQL function syntax came in.

Discussion: https://postgr.es/m/YT2PR01MB88552C3E9AD40A6C038774A781722@YT2PR01MB8855.CANPRD01.PROD.OUTLOOK.COM

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/57b440ec115f57ff6e6a3f0df26063822e3123d2

Modified Files
--------------
src/pl/plpgsql/src/Makefile                  |  5 +-
src/pl/plpgsql/src/expected/plpgsql_misc.out | 31 ++++++++++++
src/pl/plpgsql/src/meson.build               |  3 +-
src/pl/plpgsql/src/pl_gram.y                 | 72 ++++++++++++++++++++++++----
src/pl/plpgsql/src/sql/plpgsql_misc.sql      | 22 +++++++++
5 files changed, 122 insertions(+), 11 deletions(-)



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* pgsql: Fix plpgsql to allow new-style SQL CREATE FUNCTION as a SQL comm
@ 2024-01-18 21:11  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2024-01-18 21:11 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix plpgsql to allow new-style SQL CREATE FUNCTION as a SQL command.

plpgsql fails on new-style CREATE FUNCTION/PROCEDURE commands within
a routine or DO block, because make_execsql_stmt believes that a
semicolon token always terminates a SQL command.  Now, that's actually
been wrong since the day it was written, because CREATE RULE has long
allowed multiple rule actions separated by semicolons.  But there are
few enough people using multi-action rules that there was never an
attempt to fix it.  New-style SQL functions, though, are popular.

psql has this same problem of "does this semicolon really terminate
the command?".  It deals with CREATE RULE by counting parenthesis
nesting depth: a semicolon within parens doesn't end a command.
Commits e717a9a18 and 029c5ac03 created a similar heuristic to count
matching BEGIN/END pairs (but only within CREATEs, so as not to be
fooled by plain BEGIN).  That's survived several releases now without
trouble reports, so let's just absorb those heuristics into plpgsql.

Per report from Samuel Dussault.  Back-patch to v14 where new-style
SQL function syntax came in.

Discussion: https://postgr.es/m/YT2PR01MB88552C3E9AD40A6C038774A781722@YT2PR01MB8855.CANPRD01.PROD.OUTLOOK.COM

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/b7e8f27d1478f75a443a4df226f696b8c29e5107

Modified Files
--------------
src/pl/plpgsql/src/Makefile                  |  5 +-
src/pl/plpgsql/src/expected/plpgsql_misc.out | 31 ++++++++++++
src/pl/plpgsql/src/pl_gram.y                 | 70 +++++++++++++++++++++++++---
src/pl/plpgsql/src/sql/plpgsql_misc.sql      | 22 +++++++++
4 files changed, 119 insertions(+), 9 deletions(-)



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* pgsql: Fix plpgsql to allow new-style SQL CREATE FUNCTION as a SQL comm
@ 2024-01-18 21:11  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2024-01-18 21:11 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix plpgsql to allow new-style SQL CREATE FUNCTION as a SQL command.

plpgsql fails on new-style CREATE FUNCTION/PROCEDURE commands within
a routine or DO block, because make_execsql_stmt believes that a
semicolon token always terminates a SQL command.  Now, that's actually
been wrong since the day it was written, because CREATE RULE has long
allowed multiple rule actions separated by semicolons.  But there are
few enough people using multi-action rules that there was never an
attempt to fix it.  New-style SQL functions, though, are popular.

psql has this same problem of "does this semicolon really terminate
the command?".  It deals with CREATE RULE by counting parenthesis
nesting depth: a semicolon within parens doesn't end a command.
Commits e717a9a18 and 029c5ac03 created a similar heuristic to count
matching BEGIN/END pairs (but only within CREATEs, so as not to be
fooled by plain BEGIN).  That's survived several releases now without
trouble reports, so let's just absorb those heuristics into plpgsql.

Per report from Samuel Dussault.  Back-patch to v14 where new-style
SQL function syntax came in.

Discussion: https://postgr.es/m/YT2PR01MB88552C3E9AD40A6C038774A781722@YT2PR01MB8855.CANPRD01.PROD.OUTLOOK.COM

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/de2d393a8a870750f4d03ad771541f4600b9f23b

Modified Files
--------------
src/pl/plpgsql/src/Makefile                  |  5 +-
src/pl/plpgsql/src/expected/plpgsql_misc.out | 31 ++++++++++++
src/pl/plpgsql/src/pl_gram.y                 | 72 ++++++++++++++++++++++++----
src/pl/plpgsql/src/sql/plpgsql_misc.sql      | 22 +++++++++
4 files changed, 120 insertions(+), 10 deletions(-)



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2024-01-18 21:11 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-01-18 21:11 pgsql: Fix plpgsql to allow new-style SQL CREATE FUNCTION as a SQL comm Tom Lane <tgl@sss.pgh.pa.us>
2024-01-18 21:11 pgsql: Fix plpgsql to allow new-style SQL CREATE FUNCTION as a SQL comm Tom Lane <tgl@sss.pgh.pa.us>
2024-01-18 21:11 pgsql: Fix plpgsql to allow new-style SQL CREATE FUNCTION as a SQL comm Tom Lane <tgl@sss.pgh.pa.us>
2024-01-18 21:11 pgsql: Fix plpgsql to allow new-style SQL CREATE FUNCTION as a SQL comm Tom Lane <tgl@sss.pgh.pa.us>

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