aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2011-06-17 18:19:31 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2011-06-17 18:19:31 -0400
commit6c320b8ab84584e8f21cf8341121a47b51e4d297 (patch)
treec77add90f3057430392c202a0f60bce841ad7b5e /src
parent199d449c076a8564a9e8b113818f71c43f59d4cd (diff)
downloadpostgresql-6c320b8ab84584e8f21cf8341121a47b51e4d297.tar.gz
postgresql-6c320b8ab84584e8f21cf8341121a47b51e4d297.zip
Obtain table locks as soon as practical during pg_dump.
For some reason, when we (I) added table lock acquisition to pg_dump, we didn't think about making it happen as soon as possible after the start of the transaction. What with subsequent additions, there was actually quite a lot going on before we got around to that; which sort of defeats the purpose. Rearrange the order of calls in dumpSchema() to close the risk window as much as we easily can. Back-patch to all supported branches.
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_dump/common.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c
index 070036ec054..7ea98b396fa 100644
--- a/src/bin/pg_dump/common.c
+++ b/src/bin/pg_dump/common.c
@@ -91,6 +91,16 @@ getSchemaData(int *numTablesPtr)
write_msg(NULL, "reading schemas\n");
nsinfo = getNamespaces(&numNamespaces);
+ /*
+ * getTables should be done as soon as possible, so as to minimize the
+ * window between starting our transaction and acquiring per-table locks.
+ * However, we have to do getNamespaces first because the tables get
+ * linked to their containing namespaces during getTables.
+ */
+ if (g_verbose)
+ write_msg(NULL, "reading user-defined tables\n");
+ tblinfo = getTables(&numTables);
+
if (g_verbose)
write_msg(NULL, "reading user-defined functions\n");
funinfo = getFuncs(&numFuncs);
@@ -122,10 +132,6 @@ getSchemaData(int *numTablesPtr)
convinfo = getConversions(&numConversions);
if (g_verbose)
- write_msg(NULL, "reading user-defined tables\n");
- tblinfo = getTables(&numTables);
-
- if (g_verbose)
write_msg(NULL, "reading table inheritance information\n");
inhinfo = getInherits(&numInherits);