Skip to content

Commit 2560d24

Browse files
committed
Fix quoting and a compiler warning in dumping partitions.
Partition name needs to be quoted in the ATTACH PARTITION command constructed in binary-upgrade mode. Silence compiler warning about set but unused variable, without --enable-cassert.
1 parent fe7bdf0 commit 2560d24

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/bin/pg_dump/pg_dump.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7022,8 +7022,7 @@ void
70227022
getTablePartitionKeyInfo(Archive *fout, TableInfo *tblinfo, int numTables)
70237023
{
70247024
PQExpBuffer q = createPQExpBuffer();
7025-
int i,
7026-
ntups;
7025+
int i;
70277026
PGresult *res;
70287027

70297028
/* No partitioned tables before 10 */
@@ -7046,8 +7045,7 @@ getTablePartitionKeyInfo(Archive *fout, TableInfo *tblinfo, int numTables)
70467045
appendPQExpBuffer(q, "SELECT pg_catalog.pg_get_partkeydef('%u'::pg_catalog.oid)",
70477046
tbinfo->dobj.catId.oid);
70487047
res = ExecuteSqlQuery(fout, q->data, PGRES_TUPLES_OK);
7049-
ntups = PQntuples(res);
7050-
Assert(ntups == 1);
7048+
Assert(PQntuples(res) == 1);
70517049
tbinfo->partkeydef = pg_strdup(PQgetvalue(res, 0, 0));
70527050
}
70537051
}
@@ -14639,9 +14637,10 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
1463914637
if (tbinfo->partitionOf)
1464014638
{
1464114639
appendPQExpBufferStr(q, "\n-- For binary upgrade, set up partitions this way.\n");
14642-
appendPQExpBuffer(q, "ALTER TABLE ONLY %s ATTACH PARTITION %s %s;\n",
14643-
fmtId(tbinfo->partitionOf->dobj.name),
14644-
tbinfo->dobj.name,
14640+
appendPQExpBuffer(q, "ALTER TABLE ONLY %s ",
14641+
fmtId(tbinfo->partitionOf->dobj.name));
14642+
appendPQExpBuffer(q, "ATTACH PARTITION %s %s;\n",
14643+
fmtId(tbinfo->dobj.name),
1464514644
tbinfo->partitiondef);
1464614645
}
1464714646

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy