pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Switch SQLValueFunction on "name" to use COERCE_SQL_SYNTAX
Date: Sun, 20 Nov 2022 02:01:35 +0000
Message-ID: <E1owZeI-0001Aw-CI@gemulon.postgresql.org> (raw)

Switch SQLValueFunction on "name" to use COERCE_SQL_SYNTAX

This commit changes six SQL keywords to use COERCE_SQL_SYNTAX rather
than relying on SQLValueFunction:
- CURRENT_ROLE
- CURRENT_USER
- USER
- SESSION_USER
- CURRENT_CATALOG
- CURRENT_SCHEMA

Among the six, "user", "current_role" and "current_catalog" require
specific SQL functions to allow ruleutils.c to map them to the SQL
keywords these require when using COERCE_SQL_SYNTAX.  Having
pg_proc.proname match with the keyword ensures that the compatibility
remains the same when projecting any of these keywords in a FROM clause
to an attribute name when an alias is not specified.  This is covered by
the tests added in 2e0d80c, making sure that a correct mapping happens
with each SQL keyword.  The three others (current_schema, session_user
and current_user) already have pg_proc entries for this job, so this
brings more consistency between the way such keywords are treated in the
parser, the executor and ruleutils.c.

SQLValueFunction is reduced to half its contents after this change,
simplifying its logic a bit as there is no need to enforce a C collation
anymore for the entries returning a name as a result.  I have made a few
performance tests, with a million-ish calls to these keywords without
seeing a difference in run-time or in perf profiles
(ExecEvalSQLValueFunction() is removed from the profiles).  The
remaining SQLValueFunctions are now related to timestamps and dates.

Bump catalog version.

Reviewed-by: Corey Huinker
Discussion: https://postgr.es/m/YzaG3MoryCguUOym@paquier.xyz

Branch
------
master

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

Modified Files
--------------
src/backend/executor/execExprInterp.c | 27 --------------------------
src/backend/nodes/nodeFuncs.c         | 11 +++--------
src/backend/parser/gram.y             | 30 +++++++++++++++++++++++------
src/backend/parser/parse_expr.c       |  8 --------
src/backend/parser/parse_target.c     | 18 ------------------
src/backend/utils/adt/ruleutils.c     | 36 +++++++++++++++++------------------
src/include/catalog/catversion.h      |  2 +-
src/include/catalog/pg_proc.dat       |  9 +++++++++
src/include/nodes/primnodes.h         |  8 +-------
9 files changed, 56 insertions(+), 93 deletions(-)



Message-ID: <E1owZeI-0001Aw-CI@gemulon.postgresql.org>
Permalink:  ../E1owZeI-0001Aw-CI@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1owZeI-0001Aw-CI@gemulon.postgresql.org

 · 

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-committers@postgresql.org
  Cc: michael@paquier.xyz
  Subject: Re: pgsql: Switch SQLValueFunction on "name" to use COERCE_SQL_SYNTAX
  In-Reply-To: <E1owZeI-0001Aw-CI@gemulon.postgresql.org>
  References: <E1owZeI-0001Aw-CI@gemulon.postgresql.org>

* 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