aboutsummaryrefslogtreecommitdiff
path: root/src/include/fe_utils/string_utils.h
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2022-04-20 11:02:35 -0400
committerRobert Haas <rhaas@postgresql.org>2022-04-20 11:37:29 -0400
commitd2d35479796c3510e249d6fc72adbd5df918efbf (patch)
treed072bdea0ad0b0a1d598eb75daf06be1dfec7ad9 /src/include/fe_utils/string_utils.h
parent836af9756b742f5a8ae77b4bef9d27311772a13c (diff)
downloadpostgresql-d2d35479796c3510e249d6fc72adbd5df918efbf.tar.gz
postgresql-d2d35479796c3510e249d6fc72adbd5df918efbf.zip
Allow db.schema.table patterns, but complain about random garbage.
psql, pg_dump, and pg_amcheck share code to process object name patterns like 'foo*.bar*' to match all tables with names starting in 'bar' that are in schemas starting with 'foo'. Before v14, any number of extra name parts were silently ignored, so a command line '\d foo.bar.baz.bletch.quux' was interpreted as '\d bletch.quux'. In v14, as a result of commit 2c8726c4b0a496608919d1f78a5abc8c9b6e0868, we instead treated this as a request for table quux in a schema named 'foo.bar.baz.bletch'. That caused problems for people like Justin Pryzby who were accustomed to copying strings of the form db.schema.table from messages generated by PostgreSQL itself and using them as arguments to \d. Accordingly, revise things so that if an object name pattern contains more parts than we're expecting, we throw an error, unless there's exactly one extra part and it matches the current database name. That way, thisdb.myschema.mytable is accepted as meaning just myschema.mytable, but otherdb.myschema.mytable is an error, and so is some.random.garbage.myschema.mytable. Mark Dilger, per report from Justin Pryzby and discussion among various people. Discussion: https://www.postgresql.org/message-id/20211013165426.GD27491%40telsasoft.com
Diffstat (limited to 'src/include/fe_utils/string_utils.h')
-rw-r--r--src/include/fe_utils/string_utils.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/include/fe_utils/string_utils.h b/src/include/fe_utils/string_utils.h
index b9b8708dab7..fa4deb24978 100644
--- a/src/include/fe_utils/string_utils.h
+++ b/src/include/fe_utils/string_utils.h
@@ -55,10 +55,12 @@ extern bool processSQLNamePattern(PGconn *conn, PQExpBuffer buf,
const char *pattern,
bool have_where, bool force_escape,
const char *schemavar, const char *namevar,
- const char *altnamevar, const char *visibilityrule);
+ const char *altnamevar, const char *visibilityrule,
+ PQExpBuffer dbnamebuf, int *dotcnt);
extern void patternToSQLRegex(int encoding, PQExpBuffer dbnamebuf,
PQExpBuffer schemabuf, PQExpBuffer namebuf,
- const char *pattern, bool force_escape);
+ const char *pattern, bool force_escape,
+ bool want_literal_dbname, int *dotcnt);
#endif /* STRING_UTILS_H */