mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
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 2c8726c4b0
, 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
This commit is contained in:
@ -3641,14 +3641,27 @@ select 1\; select 2\; select 3;
|
||||
</para>
|
||||
|
||||
<para>
|
||||
A pattern that contains a dot (<literal>.</literal>) is interpreted as a schema
|
||||
A relation pattern that contains a dot (<literal>.</literal>) is interpreted as a schema
|
||||
name pattern followed by an object name pattern. For example,
|
||||
<literal>\dt foo*.*bar*</literal> displays all tables whose table name
|
||||
includes <literal>bar</literal> that are in schemas whose schema name
|
||||
starts with <literal>foo</literal>. When no dot appears, then the pattern
|
||||
matches only objects that are visible in the current schema search path.
|
||||
Again, a dot within double quotes loses its special meaning and is matched
|
||||
literally.
|
||||
literally. A relation pattern that contains two dots (<literal>.</literal>)
|
||||
is interpreted as a database name followed by a schema name pattern followed
|
||||
by an object name pattern. The database name portion will not be treated as
|
||||
a pattern and must match the name of the currently connected database, else
|
||||
an error will be raised.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
A schema pattern that contains a dot (<literal>.</literal>) is interpreted
|
||||
as a database name followed by a schema name pattern. For example,
|
||||
<literal>\dn mydb.*foo*</literal> displays all schemas whose schema name
|
||||
includes <literal>foo</literal>. The database name portion will not be
|
||||
treated as a pattern and must match the name of the currently connected
|
||||
database, else an error will be raised.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
|
Reference in New Issue
Block a user