pgsql: Factor pattern-construction logic out of processSQLNamePattern. - Mailing list pgsql-committers

From Robert Haas
Subject pgsql: Factor pattern-construction logic out of processSQLNamePattern.
Date
Msg-id E1l7N9a-00009z-OE@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Factor pattern-construction logic out of processSQLNamePattern.

The logic for converting the shell-glob-like syntax supported by
utilities like psql and pg_dump to regular expression is
extracted into a new function patternToSQLRegex. The existing
function processSQLNamePattern now uses this function as a
subroutine.

patternToSQLRegex is a little more general than what is required
by processSQLNamePattern. That function is only interested in
patterns that can have up to 2 parts, a schema and a relation;
but patternToSQLRegex can limit the maximum number of parts to
between 1 and 3, so that patterns can look like either
"database.schema.relation", "schema.relation", or "relation"
depending on how it's invoked and what the user specifies.

processSQLNamePattern only passes two buffers, so works exactly
the same as before, always interpreting the pattern as either
a "schema.relation" pattern or a "relation" pattern. But,
future callers can use this function in other ways.

Mark Dilger, reviewed by me. The larger patch series of which this is
a part has also had review from Peter Geoghegan, Andres Freund, Álvaro
Herrera, Michael Paquier, and Amul Sul, but I don't know whether
any of them have reviewed this bit specifically.

Discussion: http://postgr.es/m/12ED3DA8-25F0-4B68-937D-D907CFBF08E7@enterprisedb.com
Discussion: http://postgr.es/m/5F743835-3399-419C-8324-2D424237E999@enterprisedb.com
Discussion: http://postgr.es/m/70655DF3-33CE-4527-9A4D-DDEB582B6BA0@enterprisedb.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/2c8726c4b0a496608919d1f78a5abc8c9b6e0868

Modified Files
--------------
src/fe_utils/string_utils.c         | 260 ++++++++++++++++++++++--------------
src/include/fe_utils/string_utils.h |   4 +
2 files changed, 167 insertions(+), 97 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Remove special BKI_LOOKUP magic for namespace and role OIDs.
Next
From: Tom Lane
Date:
Subject: pgsql: Avoid crash when rolling back within a prepared statement.