Skip to content

Commit 7e22470

Browse files
committed
Fix incorrect pattern-match processing in psql's \det command.
listForeignTables' invocation of processSQLNamePattern did not match up with the other ones that handle potentially-schema-qualified names; it failed to make use of pg_table_is_visible() and also passed the name arguments in the wrong order. Bug seems to have been aboriginal in commit 0d692a0. It accidentally sort of worked as long as you didn't inquire too closely into the behavior, although the silliness was later exposed by inconsistencies in the test queries added by 59efda3 (which I probably should have questioned at the time, but didn't). Per bug #13899 from Reece Hart. Patch by Reece Hart and Tom Lane. Back-patch to all affected branches.
1 parent c35c4ec commit 7e22470

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

contrib/postgres_fdw/expected/postgres_fdw.out

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3734,7 +3734,7 @@ CREATE TABLE import_source."x 5" (c1 float8);
37343734
ALTER TABLE import_source."x 5" DROP COLUMN c1;
37353735
CREATE SCHEMA import_dest1;
37363736
IMPORT FOREIGN SCHEMA import_source FROM SERVER loopback INTO import_dest1;
3737-
\det+ import_dest1
3737+
\det+ import_dest1.*
37383738
List of foreign tables
37393739
Schema | Table | Server | FDW Options | Description
37403740
--------------+-------+----------+-------------------------------------------------+-------------
@@ -3790,7 +3790,7 @@ FDW Options: (schema_name 'import_source', table_name 'x 5')
37903790
CREATE SCHEMA import_dest2;
37913791
IMPORT FOREIGN SCHEMA import_source FROM SERVER loopback INTO import_dest2
37923792
OPTIONS (import_default 'true');
3793-
\det+ import_dest2
3793+
\det+ import_dest2.*
37943794
List of foreign tables
37953795
Schema | Table | Server | FDW Options | Description
37963796
--------------+-------+----------+-------------------------------------------------+-------------
@@ -3845,7 +3845,7 @@ FDW Options: (schema_name 'import_source', table_name 'x 5')
38453845
CREATE SCHEMA import_dest3;
38463846
IMPORT FOREIGN SCHEMA import_source FROM SERVER loopback INTO import_dest3
38473847
OPTIONS (import_collate 'false', import_not_null 'false');
3848-
\det+ import_dest3
3848+
\det+ import_dest3.*
38493849
List of foreign tables
38503850
Schema | Table | Server | FDW Options | Description
38513851
--------------+-------+----------+-------------------------------------------------+-------------
@@ -3901,7 +3901,7 @@ FDW Options: (schema_name 'import_source', table_name 'x 5')
39013901
CREATE SCHEMA import_dest4;
39023902
IMPORT FOREIGN SCHEMA import_source LIMIT TO (t1, nonesuch)
39033903
FROM SERVER loopback INTO import_dest4;
3904-
\det+ import_dest4
3904+
\det+ import_dest4.*
39053905
List of foreign tables
39063906
Schema | Table | Server | FDW Options | Description
39073907
--------------+-------+----------+------------------------------------------------+-------------
@@ -3910,7 +3910,7 @@ IMPORT FOREIGN SCHEMA import_source LIMIT TO (t1, nonesuch)
39103910

39113911
IMPORT FOREIGN SCHEMA import_source EXCEPT (t1, "x 4", nonesuch)
39123912
FROM SERVER loopback INTO import_dest4;
3913-
\det+ import_dest4
3913+
\det+ import_dest4.*
39143914
List of foreign tables
39153915
Schema | Table | Server | FDW Options | Description
39163916
--------------+-------+----------+-------------------------------------------------+-------------

contrib/postgres_fdw/sql/postgres_fdw.sql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -879,29 +879,29 @@ ALTER TABLE import_source."x 5" DROP COLUMN c1;
879879

880880
CREATE SCHEMA import_dest1;
881881
IMPORT FOREIGN SCHEMA import_source FROM SERVER loopback INTO import_dest1;
882-
\det+ import_dest1
882+
\det+ import_dest1.*
883883
\d import_dest1.*
884884

885885
-- Options
886886
CREATE SCHEMA import_dest2;
887887
IMPORT FOREIGN SCHEMA import_source FROM SERVER loopback INTO import_dest2
888888
OPTIONS (import_default 'true');
889-
\det+ import_dest2
889+
\det+ import_dest2.*
890890
\d import_dest2.*
891891
CREATE SCHEMA import_dest3;
892892
IMPORT FOREIGN SCHEMA import_source FROM SERVER loopback INTO import_dest3
893893
OPTIONS (import_collate 'false', import_not_null 'false');
894-
\det+ import_dest3
894+
\det+ import_dest3.*
895895
\d import_dest3.*
896896

897897
-- Check LIMIT TO and EXCEPT
898898
CREATE SCHEMA import_dest4;
899899
IMPORT FOREIGN SCHEMA import_source LIMIT TO (t1, nonesuch)
900900
FROM SERVER loopback INTO import_dest4;
901-
\det+ import_dest4
901+
\det+ import_dest4.*
902902
IMPORT FOREIGN SCHEMA import_source EXCEPT (t1, "x 4", nonesuch)
903903
FROM SERVER loopback INTO import_dest4;
904-
\det+ import_dest4
904+
\det+ import_dest4.*
905905

906906
-- Assorted error cases
907907
IMPORT FOREIGN SCHEMA import_source FROM SERVER loopback INTO import_dest4;

src/bin/psql/describe.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4412,7 +4412,8 @@ listForeignTables(const char *pattern, bool verbose)
44124412
"d.objoid = c.oid AND d.objsubid = 0\n");
44134413

44144414
processSQLNamePattern(pset.db, &buf, pattern, false, false,
4415-
NULL, "n.nspname", "c.relname", NULL);
4415+
"n.nspname", "c.relname", NULL,
4416+
"pg_catalog.pg_table_is_visible(c.oid)");
44164417

44174418
appendPQExpBufferStr(&buf, "ORDER BY 1, 2;");
44184419

0 commit comments

Comments
 (0)