-
-
-
- Do not output commands to select tablespaces.
- With this option, all objects will be created in whichever
- tablespace is the default during restore.
-
-
- This option is only meaningful for the plain-text format. For
- the archive formats, you can specify the option when you
- call pg_restore.
-
-
-
-
+
+
+
+
+ Specify the compression level to use in archive formats that
+ support compression. (Currently only the custom archive
+ format supports compression.)
+
+
+
+
This option disables the use of dollar quoting for function bodies,
and forces them to be quoted using SQL standard string syntax.
-
-
+
+
+
+
+
+ Do not wait forever to acquire shared table locks at the beginning of
+ the dump. Instead fail if unable to lock a table within the specified
+ timeout>. The timeout may be
+ specified in any of the formats accepted by SET
+ statement_timeout>. (Allowed values vary depending on the server
+ version you are dumping from, but an integer number of milliseconds
+ is accepted by all versions since 7.3. This option is ignored when
+ dumping from a pre-7.3 server.)
+
+
+
+
+
+
+
+ Do not output commands to select tablespaces.
+ With this option, all objects will be created in whichever
+ tablespace is the default during restore.
+
+
+ This option is only meaningful for the plain-text format. For
+ the archive formats, you can specify the option when you
+ call pg_restore.
+
+
+
+
-
-
-
-
-
- Specify the compression level to use in archive formats that
- support compression. (Currently only the custom archive
- format supports compression.)
-
-
-
Force
pg_dump to prompt for a
- password before connecting to a database.
+ password before connecting to a database.
* by PostgreSQL
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.496 2008/07/18 03:32:52 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.497 2008/07/20 18:43:30 tgl Exp $
*
*-------------------------------------------------------------------------
*/
bool schemaOnly;
bool dataOnly;
bool aclsSkip;
+const char *lockWaitTimeout;
/* subquery used to convert user ID (eg, datdba) to user name */
static const char *username_subquery;
*/
{"disable-dollar-quoting", no_argument, &disable_dollar_quoting, 1},
{"disable-triggers", no_argument, &disable_triggers, 1},
+ {"lock-wait-timeout", required_argument, NULL, 2},
{"no-tablespaces", no_argument, &outputNoTablespaces, 1},
{"use-set-session-authorization", no_argument, &use_setsessauth, 1},
strcpy(g_opaque_type, "opaque");
dataOnly = schemaOnly = dumpInserts = attrNames = false;
+ lockWaitTimeout = NULL;
progname = get_progname(argv[0]);
/* This covers the long options equivalent to -X xxx. */
break;
+ case 2:
+ /* lock-wait-timeout */
+ lockWaitTimeout = optarg;
+ break;
+
default:
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
exit(1);
printf(_(" %s [OPTION]... [DBNAME]\n"), progname);
printf(_("\nGeneral options:\n"));
- printf(_(" -f, --file=FILENAME output file name\n"));
- printf(_(" -F, --format=c|t|p output file format (custom, tar, plain text)\n"));
- printf(_(" -v, --verbose verbose mode\n"));
- printf(_(" -Z, --compress=0-9 compression level for compressed formats\n"));
- printf(_(" --help show this help, then exit\n"));
- printf(_(" --version output version information, then exit\n"));
+ printf(_(" -f, --file=FILENAME output file name\n"));
+ printf(_(" -F, --format=c|t|p output file format (custom, tar, plain text)\n"));
+ printf(_(" -v, --verbose verbose mode\n"));
+ printf(_(" -Z, --compress=0-9 compression level for compressed formats\n"));
+ printf(_(" --lock-wait-timeout=TIMEOUT fail after waiting TIMEOUT for a table lock\n"));
+ printf(_(" --help show this help, then exit\n"));
+ printf(_(" --version output version information, then exit\n"));
printf(_("\nOptions controlling the output content:\n"));
printf(_(" -a, --data-only dump only the data, not the schema\n"));
int ntups;
int i;
PQExpBuffer query = createPQExpBuffer();
- PQExpBuffer delqry = createPQExpBuffer();
- PQExpBuffer lockquery = createPQExpBuffer();
TableInfo *tblinfo;
int i_reltableoid;
int i_reloid;
i_reltablespace = PQfnumber(res, "reltablespace");
i_reloptions = PQfnumber(res, "reloptions");
+ if (lockWaitTimeout && g_fout->remoteVersion >= 70300)
+ {
+ /*
+ * Arrange to fail instead of waiting forever for a table lock.
+ *
+ * NB: this coding assumes that the only queries issued within
+ * the following loop are LOCK TABLEs; else the timeout may be
+ * undesirably applied to other things too.
+ */
+ resetPQExpBuffer(query);
+ appendPQExpBuffer(query, "SET statement_timeout = ");
+ appendStringLiteralConn(query, lockWaitTimeout, g_conn);
+ do_sql_command(g_conn, query->data);
+ }
+
for (i = 0; i < ntups; i++)
{
tblinfo[i].dobj.objType = DO_TABLE;
*/
if (tblinfo[i].dobj.dump && tblinfo[i].relkind == RELKIND_RELATION)
{
- resetPQExpBuffer(lockquery);
- appendPQExpBuffer(lockquery,
+ resetPQExpBuffer(query);
+ appendPQExpBuffer(query,
"LOCK TABLE %s IN ACCESS SHARE MODE",
fmtQualifiedId(tblinfo[i].dobj.namespace->dobj.name,
tblinfo[i].dobj.name));
- do_sql_command(g_conn, lockquery->data);
+ do_sql_command(g_conn, query->data);
}
/* Emit notice if join for owner failed */
tblinfo[i].dobj.name);
}
+ if (lockWaitTimeout && g_fout->remoteVersion >= 70300)
+ {
+ do_sql_command(g_conn, "SET statement_timeout = 0");
+ }
+
PQclear(res);
/*
}
destroyPQExpBuffer(query);
- destroyPQExpBuffer(delqry);
- destroyPQExpBuffer(lockquery);
return tblinfo;
}