]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
In client support of v10 features, use standard schema handling.
authorNoah Misch <noah@leadboat.com>
Thu, 2 Nov 2017 02:16:14 +0000 (19:16 -0700)
committerNoah Misch <noah@leadboat.com>
Thu, 2 Nov 2017 02:16:17 +0000 (19:16 -0700)
Back-patch to v10.  This continues the work of commit
080351466c5a669bf35a323bdec9e296330a5dbb.

Discussion: https://postgr.es/m/CAKOSWN=ds66zLw2SqkLTM8wbXFgDbc_OdkmT3dJfPT2mE5kipA@mail.gmail.com

src/bin/pg_dump/pg_dump.c
src/bin/psql/describe.c

index 07050cd08f08b5c18d0b246d7410a0a7d0032ca9..ecda9bb87c448e798bcfd14709a6ff162d17338a 100644 (file)
@@ -3400,12 +3400,15 @@ getPublications(Archive *fout)
 
        resetPQExpBuffer(query);
 
+       /* Make sure we are in proper schema */
+       selectSourceSchema(fout, "pg_catalog");
+
        /* Get the publications. */
        appendPQExpBuffer(query,
                                          "SELECT p.tableoid, p.oid, p.pubname, "
                                          "(%s p.pubowner) AS rolname, "
                                          "p.puballtables, p.pubinsert, p.pubupdate, p.pubdelete "
-                                         "FROM pg_catalog.pg_publication p",
+                                         "FROM pg_publication p",
                                          username_subquery);
 
        res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -3556,6 +3559,9 @@ getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables)
 
        query = createPQExpBuffer();
 
+       /* Make sure we are in proper schema */
+       selectSourceSchema(fout, "pg_catalog");
+
        for (i = 0; i < numTables; i++)
        {
                TableInfo  *tbinfo = &tblinfo[i];
@@ -3581,8 +3587,7 @@ getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables)
                /* Get the publication membership for the table. */
                appendPQExpBuffer(query,
                                                  "SELECT pr.tableoid, pr.oid, p.pubname "
-                                                 "FROM pg_catalog.pg_publication_rel pr,"
-                                                 "     pg_catalog.pg_publication p "
+                                                 "FROM pg_publication_rel pr, pg_publication p "
                                                  "WHERE pr.prrelid = '%u'"
                                                  "  AND p.oid = pr.prpubid",
                                                  tbinfo->dobj.catId.oid);
@@ -3708,13 +3713,16 @@ getSubscriptions(Archive *fout)
        if (dopt->no_subscriptions || fout->remoteVersion < 100000)
                return;
 
+       /* Make sure we are in proper schema */
+       selectSourceSchema(fout, "pg_catalog");
+
        if (!is_superuser(fout))
        {
                int                     n;
 
                res = ExecuteSqlQuery(fout,
                                                          "SELECT count(*) FROM pg_subscription "
-                                                         "WHERE subdbid = (SELECT oid FROM pg_catalog.pg_database"
+                                                         "WHERE subdbid = (SELECT oid FROM pg_database"
                                                          "                 WHERE datname = current_database())",
                                                          PGRES_TUPLES_OK);
                n = atoi(PQgetvalue(res, 0, 0));
@@ -3734,8 +3742,8 @@ getSubscriptions(Archive *fout)
                                          "(%s s.subowner) AS rolname, "
                                          " s.subconninfo, s.subslotname, s.subsynccommit, "
                                          " s.subpublications "
-                                         "FROM pg_catalog.pg_subscription s "
-                                         "WHERE s.subdbid = (SELECT oid FROM pg_catalog.pg_database"
+                                         "FROM pg_subscription s "
+                                         "WHERE s.subdbid = (SELECT oid FROM pg_database"
                                          "                   WHERE datname = current_database())",
                                          username_subquery);
        res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
@@ -6724,7 +6732,7 @@ getExtendedStatistics(Archive *fout, TableInfo tblinfo[], int numTables)
                                                  "oid, "
                                                  "stxname, "
                                                  "pg_catalog.pg_get_statisticsobjdef(oid) AS stxdef "
-                                                 "FROM pg_statistic_ext "
+                                                 "FROM pg_catalog.pg_statistic_ext "
                                                  "WHERE stxrelid = '%u' "
                                                  "ORDER BY stxname", tbinfo->dobj.catId.oid);
 
index 5b775d37c211fa6d51f74257d3773b358abc3858..67707ffca129836549f2512254f308635e9e67ff 100644 (file)
@@ -5357,7 +5357,7 @@ describeSubscriptions(const char *pattern, bool verbose)
                                                 "FROM pg_catalog.pg_subscription\n"
                                                 "WHERE subdbid = (SELECT oid\n"
                                                 "                 FROM pg_catalog.pg_database\n"
-                                                "                 WHERE datname = current_database())");
+                                                "                 WHERE datname = pg_catalog.current_database())");
 
        processSQLNamePattern(pset.db, &buf, pattern, true, false,
                                                  NULL, "subname", NULL,