Skip to content

Commit 51f4d3e

Browse files
committed
In client support of v10 features, use standard schema handling.
Back-patch to v10. This continues the work of commit 0803514. Discussion: https://postgr.es/m/CAKOSWN=ds66zLw2SqkLTM8wbXFgDbc_OdkmT3dJfPT2mE5kipA@mail.gmail.com
1 parent c0e2062 commit 51f4d3e

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

src/bin/pg_dump/pg_dump.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3475,12 +3475,15 @@ getPublications(Archive *fout)
34753475

34763476
resetPQExpBuffer(query);
34773477

3478+
/* Make sure we are in proper schema */
3479+
selectSourceSchema(fout, "pg_catalog");
3480+
34783481
/* Get the publications. */
34793482
appendPQExpBuffer(query,
34803483
"SELECT p.tableoid, p.oid, p.pubname, "
34813484
"(%s p.pubowner) AS rolname, "
34823485
"p.puballtables, p.pubinsert, p.pubupdate, p.pubdelete "
3483-
"FROM pg_catalog.pg_publication p",
3486+
"FROM pg_publication p",
34843487
username_subquery);
34853488

34863489
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -3631,6 +3634,9 @@ getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables)
36313634

36323635
query = createPQExpBuffer();
36333636

3637+
/* Make sure we are in proper schema */
3638+
selectSourceSchema(fout, "pg_catalog");
3639+
36343640
for (i = 0; i < numTables; i++)
36353641
{
36363642
TableInfo *tbinfo = &tblinfo[i];
@@ -3656,8 +3662,7 @@ getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables)
36563662
/* Get the publication membership for the table. */
36573663
appendPQExpBuffer(query,
36583664
"SELECT pr.tableoid, pr.oid, p.pubname "
3659-
"FROM pg_catalog.pg_publication_rel pr,"
3660-
" pg_catalog.pg_publication p "
3665+
"FROM pg_publication_rel pr, pg_publication p "
36613666
"WHERE pr.prrelid = '%u'"
36623667
" AND p.oid = pr.prpubid",
36633668
tbinfo->dobj.catId.oid);
@@ -3783,13 +3788,16 @@ getSubscriptions(Archive *fout)
37833788
if (dopt->no_subscriptions || fout->remoteVersion < 100000)
37843789
return;
37853790

3791+
/* Make sure we are in proper schema */
3792+
selectSourceSchema(fout, "pg_catalog");
3793+
37863794
if (!is_superuser(fout))
37873795
{
37883796
int n;
37893797

37903798
res = ExecuteSqlQuery(fout,
37913799
"SELECT count(*) FROM pg_subscription "
3792-
"WHERE subdbid = (SELECT oid FROM pg_catalog.pg_database"
3800+
"WHERE subdbid = (SELECT oid FROM pg_database"
37933801
" WHERE datname = current_database())",
37943802
PGRES_TUPLES_OK);
37953803
n = atoi(PQgetvalue(res, 0, 0));
@@ -3809,8 +3817,8 @@ getSubscriptions(Archive *fout)
38093817
"(%s s.subowner) AS rolname, "
38103818
" s.subconninfo, s.subslotname, s.subsynccommit, "
38113819
" s.subpublications "
3812-
"FROM pg_catalog.pg_subscription s "
3813-
"WHERE s.subdbid = (SELECT oid FROM pg_catalog.pg_database"
3820+
"FROM pg_subscription s "
3821+
"WHERE s.subdbid = (SELECT oid FROM pg_database"
38143822
" WHERE datname = current_database())",
38153823
username_subquery);
38163824
res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -6830,7 +6838,7 @@ getExtendedStatistics(Archive *fout, TableInfo tblinfo[], int numTables)
68306838
"oid, "
68316839
"stxname, "
68326840
"pg_catalog.pg_get_statisticsobjdef(oid) AS stxdef "
6833-
"FROM pg_statistic_ext "
6841+
"FROM pg_catalog.pg_statistic_ext "
68346842
"WHERE stxrelid = '%u' "
68356843
"ORDER BY stxname", tbinfo->dobj.catId.oid);
68366844

src/bin/psql/describe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5363,7 +5363,7 @@ describeSubscriptions(const char *pattern, bool verbose)
53635363
"FROM pg_catalog.pg_subscription\n"
53645364
"WHERE subdbid = (SELECT oid\n"
53655365
" FROM pg_catalog.pg_database\n"
5366-
" WHERE datname = current_database())");
5366+
" WHERE datname = pg_catalog.current_database())");
53675367

53685368
processSQLNamePattern(pset.db, &buf, pattern, true, false,
53695369
NULL, "subname", NULL,

0 commit comments

Comments
 (0)