aboutsummaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/parallel.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2016-06-01 16:14:21 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2016-06-01 16:14:21 -0400
commit763eec6b6d64767f5b2dd1a1fe314923bbc17968 (patch)
tree36f0897ded00ecc08cc981434329bc1ba7f342f0 /src/bin/pg_dump/parallel.c
parent9ee56dfeee0389d61020db3c6a47bd2690bd040e (diff)
downloadpostgresql-763eec6b6d64767f5b2dd1a1fe314923bbc17968.tar.gz
postgresql-763eec6b6d64767f5b2dd1a1fe314923bbc17968.zip
Clean up some minor inefficiencies in parallel dump/restore.
Parallel dump did a totally pointless query to find out the name of each table to be dumped, which it already knows. Parallel restore runs issued lots of redundant SET commands because _doSetFixedOutputState() was invoked once per TOC item rather than just once at connection start. While the extra queries are insignificant if you're dumping or restoring large tables, it still seems worth getting rid of them. Also, give the responsibility for selecting the right client_encoding for a parallel dump worker to setup_connection() where it naturally belongs, instead of having ad-hoc code for that in CloneArchive(). And fix some minor bugs like use of strdup() where pg_strdup() would be safer. Back-patch to 9.3, mostly to keep the branches in sync in an area that we're still finding bugs in. Discussion: <5086.1464793073@sss.pgh.pa.us>
Diffstat (limited to 'src/bin/pg_dump/parallel.c')
-rw-r--r--src/bin/pg_dump/parallel.c26
1 files changed, 1 insertions, 25 deletions
diff --git a/src/bin/pg_dump/parallel.c b/src/bin/pg_dump/parallel.c
index e9e86988d28..6a808dcbf25 100644
--- a/src/bin/pg_dump/parallel.c
+++ b/src/bin/pg_dump/parallel.c
@@ -802,7 +802,6 @@ IsEveryWorkerIdle(ParallelState *pstate)
static void
lockTableForWorker(ArchiveHandle *AH, TocEntry *te)
{
- Archive *AHX = (Archive *) AH;
const char *qualId;
PQExpBuffer query;
PGresult *res;
@@ -813,33 +812,10 @@ lockTableForWorker(ArchiveHandle *AH, TocEntry *te)
query = createPQExpBuffer();
- /*
- * XXX this is an unbelievably expensive substitute for knowing how to dig
- * a table name out of a TocEntry.
- */
- appendPQExpBuffer(query,
- "SELECT pg_namespace.nspname,"
- " pg_class.relname "
- " FROM pg_class "
- " JOIN pg_namespace on pg_namespace.oid = relnamespace "
- " WHERE pg_class.oid = %u", te->catalogId.oid);
-
- res = PQexec(AH->connection, query->data);
-
- if (!res || PQresultStatus(res) != PGRES_TUPLES_OK)
- exit_horribly(modulename,
- "could not get relation name for OID %u: %s\n",
- te->catalogId.oid, PQerrorMessage(AH->connection));
-
- resetPQExpBuffer(query);
-
- qualId = fmtQualifiedId(AHX->remoteVersion,
- PQgetvalue(res, 0, 0),
- PQgetvalue(res, 0, 1));
+ qualId = fmtQualifiedId(AH->public.remoteVersion, te->namespace, te->tag);
appendPQExpBuffer(query, "LOCK TABLE %s IN ACCESS SHARE MODE NOWAIT",
qualId);
- PQclear(res);
res = PQexec(AH->connection, query->data);