Commit 2560d244 authored by Heikki Linnakangas's avatar Heikki Linnakangas

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.
parent fe7bdf0b
...@@ -7022,8 +7022,7 @@ void ...@@ -7022,8 +7022,7 @@ void
getTablePartitionKeyInfo(Archive *fout, TableInfo *tblinfo, int numTables) getTablePartitionKeyInfo(Archive *fout, TableInfo *tblinfo, int numTables)
{ {
PQExpBuffer q = createPQExpBuffer(); PQExpBuffer q = createPQExpBuffer();
int i, int i;
ntups;
PGresult *res; PGresult *res;
/* No partitioned tables before 10 */ /* No partitioned tables before 10 */
...@@ -7046,8 +7045,7 @@ getTablePartitionKeyInfo(Archive *fout, TableInfo *tblinfo, int numTables) ...@@ -7046,8 +7045,7 @@ getTablePartitionKeyInfo(Archive *fout, TableInfo *tblinfo, int numTables)
appendPQExpBuffer(q, "SELECT pg_catalog.pg_get_partkeydef('%u'::pg_catalog.oid)", appendPQExpBuffer(q, "SELECT pg_catalog.pg_get_partkeydef('%u'::pg_catalog.oid)",
tbinfo->dobj.catId.oid); tbinfo->dobj.catId.oid);
res = ExecuteSqlQuery(fout, q->data, PGRES_TUPLES_OK); res = ExecuteSqlQuery(fout, q->data, PGRES_TUPLES_OK);
ntups = PQntuples(res); Assert(PQntuples(res) == 1);
Assert(ntups == 1);
tbinfo->partkeydef = pg_strdup(PQgetvalue(res, 0, 0)); tbinfo->partkeydef = pg_strdup(PQgetvalue(res, 0, 0));
} }
} }
...@@ -14639,9 +14637,10 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) ...@@ -14639,9 +14637,10 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
if (tbinfo->partitionOf) if (tbinfo->partitionOf)
{ {
appendPQExpBufferStr(q, "\n-- For binary upgrade, set up partitions this way.\n"); appendPQExpBufferStr(q, "\n-- For binary upgrade, set up partitions this way.\n");
appendPQExpBuffer(q, "ALTER TABLE ONLY %s ATTACH PARTITION %s %s;\n", appendPQExpBuffer(q, "ALTER TABLE ONLY %s ",
fmtId(tbinfo->partitionOf->dobj.name), fmtId(tbinfo->partitionOf->dobj.name));
tbinfo->dobj.name, appendPQExpBuffer(q, "ATTACH PARTITION %s %s;\n",
fmtId(tbinfo->dobj.name),
tbinfo->partitiondef); tbinfo->partitiondef);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment