pgsql: Switch SQLValueFunction on "name" to use COERCE_SQL_SYNTAX - Mailing list pgsql-committers

From Michael Paquier
Subject pgsql: Switch SQLValueFunction on "name" to use COERCE_SQL_SYNTAX
Date
Msg-id E1owZeI-0001Aw-CI@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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(-)


pgsql-committers by date:

Previous
From: Joe Conway
Date:
Subject: pgsql: Fix catversion
Next
From: Andrew Dunstan
Date:
Subject: pgsql: Prevent port collisions between concurrent TAP tests