2000-07-21 13:40:08 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* pg_restore.c
|
|
|
|
* pg_restore is an utility extracting postgres database definitions
|
2001-03-22 05:01:46 +01:00
|
|
|
* from a backup archive created by pg_dump using the archiver
|
2000-07-21 13:40:08 +02:00
|
|
|
* interface.
|
|
|
|
*
|
|
|
|
* pg_restore will read the backup archive and
|
|
|
|
* dump out a script that reproduces
|
|
|
|
* the schema of the database in terms of
|
|
|
|
* user-defined types
|
|
|
|
* user-defined functions
|
|
|
|
* tables
|
2001-06-27 23:21:37 +02:00
|
|
|
* indexes
|
2000-07-21 13:40:08 +02:00
|
|
|
* aggregates
|
|
|
|
* operators
|
|
|
|
* ACL - grant/revoke
|
|
|
|
*
|
|
|
|
* the output script is SQL that is understood by PostgreSQL
|
|
|
|
*
|
|
|
|
* Basic process in a restore operation is:
|
2001-03-22 05:01:46 +01:00
|
|
|
*
|
|
|
|
* Open the Archive and read the TOC.
|
|
|
|
* Set flags in TOC entries, and *maybe* reorder them.
|
|
|
|
* Generate script to stdout
|
|
|
|
* Exit
|
2000-07-21 13:40:08 +02:00
|
|
|
*
|
|
|
|
* Copyright (c) 2000, Philip Warner
|
2001-03-22 05:01:46 +01:00
|
|
|
* Rights are granted to use this software in any way so long
|
|
|
|
* as this notice is not removed.
|
2000-07-21 13:40:08 +02:00
|
|
|
*
|
|
|
|
* The author is not responsible for loss or damages that may
|
2002-08-10 18:57:32 +02:00
|
|
|
* result from its use.
|
2000-07-21 13:40:08 +02:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
2010-09-20 22:08:53 +02:00
|
|
|
* src/bin/pg_dump/pg_restore.c
|
2001-03-06 05:08:04 +01:00
|
|
|
*
|
2000-07-21 13:40:08 +02:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2014-10-14 20:00:55 +02:00
|
|
|
#include "postgres_fe.h"
|
|
|
|
|
2000-07-21 13:40:08 +02:00
|
|
|
#include <ctype.h>
|
|
|
|
#ifdef HAVE_TERMIOS_H
|
|
|
|
#include <termios.h>
|
|
|
|
#endif
|
|
|
|
|
2017-02-25 22:12:24 +01:00
|
|
|
#include "dumputils.h"
|
2019-10-23 06:08:53 +02:00
|
|
|
#include "getopt_long.h"
|
2017-02-25 22:12:24 +01:00
|
|
|
#include "parallel.h"
|
|
|
|
#include "pg_backup_utils.h"
|
2001-06-27 23:21:37 +02:00
|
|
|
|
2000-07-21 13:40:08 +02:00
|
|
|
static void usage(const char *progname);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
2000-07-21 13:40:08 +02:00
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
RestoreOptions *opts;
|
|
|
|
int c;
|
2004-04-22 04:39:10 +02:00
|
|
|
int exit_code;
|
2013-03-24 16:27:20 +01:00
|
|
|
int numWorkers = 1;
|
2001-03-22 05:01:46 +01:00
|
|
|
Archive *AH;
|
2003-10-20 23:05:12 +02:00
|
|
|
char *inputFileSpec;
|
2002-05-11 00:36:27 +02:00
|
|
|
static int disable_triggers = 0;
|
Row-Level Security Policies (RLS)
Building on the updatable security-barrier views work, add the
ability to define policies on tables to limit the set of rows
which are returned from a query and which are allowed to be added
to a table. Expressions defined by the policy for filtering are
added to the security barrier quals of the query, while expressions
defined to check records being added to a table are added to the
with-check options of the query.
New top-level commands are CREATE/ALTER/DROP POLICY and are
controlled by the table owner. Row Security is able to be enabled
and disabled by the owner on a per-table basis using
ALTER TABLE .. ENABLE/DISABLE ROW SECURITY.
Per discussion, ROW SECURITY is disabled on tables by default and
must be enabled for policies on the table to be used. If no
policies exist on a table with ROW SECURITY enabled, a default-deny
policy is used and no records will be visible.
By default, row security is applied at all times except for the
table owner and the superuser. A new GUC, row_security, is added
which can be set to ON, OFF, or FORCE. When set to FORCE, row
security will be applied even for the table owner and superusers.
When set to OFF, row security will be disabled when allowed and an
error will be thrown if the user does not have rights to bypass row
security.
Per discussion, pg_dump sets row_security = OFF by default to ensure
that exports and backups will have all data in the table or will
error if there are insufficient privileges to bypass row security.
A new option has been added to pg_dump, --enable-row-security, to
ask pg_dump to export with row security enabled.
A new role capability, BYPASSRLS, which can only be set by the
superuser, is added to allow other users to be able to bypass row
security using row_security = OFF.
Many thanks to the various individuals who have helped with the
design, particularly Robert Haas for his feedback.
Authors include Craig Ringer, KaiGai Kohei, Adam Brightwell, Dean
Rasheed, with additional changes and rework by me.
Reviewers have included all of the above, Greg Smith,
Jeff McCormick, and Robert Haas.
2014-09-19 17:18:35 +02:00
|
|
|
static int enable_row_security = 0;
|
2014-03-03 19:02:18 +01:00
|
|
|
static int if_exists = 0;
|
2006-10-07 22:59:05 +02:00
|
|
|
static int no_data_for_failed_tables = 0;
|
2009-06-11 16:49:15 +02:00
|
|
|
static int outputNoTablespaces = 0;
|
2008-03-20 18:36:58 +01:00
|
|
|
static int use_setsessauth = 0;
|
Support --no-comments in pg_dump, pg_dumpall, pg_restore.
We have switches already to suppress other subsidiary object properties,
such as ACLs, security labels, ownership, and tablespaces, so just on
the grounds of symmetry we should allow suppressing comments as well.
Also, commit 0d4e6ed30 added a positive reason to have this feature,
i.e. to allow obtaining the old behavior of selective pg_restore should
anyone desire that.
Recent commits have removed the cases where pg_dump emitted comments on
built-in objects that the restoring user might not have privileges to
comment on, so the original primary motivation for this feature is gone,
but it still seems at least somewhat useful in its own right.
Robins Tharakan, reviewed by Fabrízio Mello
Discussion: https://postgr.es/m/CAEP4nAx22Z4ch74oJGzr5RyyjcyUSbpiFLyeYXX8pehfou92ug@mail.gmail.com
2018-01-25 21:27:24 +01:00
|
|
|
static int no_comments = 0;
|
2017-05-12 15:15:40 +02:00
|
|
|
static int no_publications = 0;
|
2011-05-19 22:20:11 +02:00
|
|
|
static int no_security_labels = 0;
|
2017-05-09 16:58:06 +02:00
|
|
|
static int no_subscriptions = 0;
|
2015-09-14 15:19:49 +02:00
|
|
|
static int strict_names = 0;
|
2001-08-22 22:23:24 +02:00
|
|
|
|
|
|
|
struct option cmdopts[] = {
|
|
|
|
{"clean", 0, NULL, 'c'},
|
|
|
|
{"create", 0, NULL, 'C'},
|
|
|
|
{"data-only", 0, NULL, 'a'},
|
|
|
|
{"dbname", 1, NULL, 'd'},
|
2004-08-20 06:20:23 +02:00
|
|
|
{"exit-on-error", 0, NULL, 'e'},
|
2016-09-20 18:00:00 +02:00
|
|
|
{"exclude-schema", 1, NULL, 'N'},
|
2001-08-22 22:23:24 +02:00
|
|
|
{"file", 1, NULL, 'f'},
|
|
|
|
{"format", 1, NULL, 'F'},
|
|
|
|
{"function", 1, NULL, 'P'},
|
|
|
|
{"host", 1, NULL, 'h'},
|
|
|
|
{"index", 1, NULL, 'I'},
|
2009-03-20 10:21:09 +01:00
|
|
|
{"jobs", 1, NULL, 'j'},
|
2001-08-22 22:23:24 +02:00
|
|
|
{"list", 0, NULL, 'l'},
|
|
|
|
{"no-privileges", 0, NULL, 'x'},
|
|
|
|
{"no-acl", 0, NULL, 'x'},
|
|
|
|
{"no-owner", 0, NULL, 'O'},
|
|
|
|
{"no-reconnect", 0, NULL, 'R'},
|
|
|
|
{"port", 1, NULL, 'p'},
|
2009-02-26 17:02:39 +01:00
|
|
|
{"no-password", 0, NULL, 'w'},
|
2001-08-22 22:23:24 +02:00
|
|
|
{"password", 0, NULL, 'W'},
|
2005-06-09 19:56:51 +02:00
|
|
|
{"schema", 1, NULL, 'n'},
|
2001-08-22 22:23:24 +02:00
|
|
|
{"schema-only", 0, NULL, 's'},
|
|
|
|
{"superuser", 1, NULL, 'S'},
|
|
|
|
{"table", 1, NULL, 't'},
|
|
|
|
{"trigger", 1, NULL, 'T'},
|
|
|
|
{"use-list", 1, NULL, 'L'},
|
|
|
|
{"username", 1, NULL, 'U'},
|
|
|
|
{"verbose", 0, NULL, 'v'},
|
2006-02-12 05:04:32 +01:00
|
|
|
{"single-transaction", 0, NULL, '1'},
|
2001-08-22 22:23:24 +02:00
|
|
|
|
2001-10-25 07:50:21 +02:00
|
|
|
/*
|
2006-10-07 22:59:05 +02:00
|
|
|
* the following options don't have an equivalent short option letter
|
2001-10-25 07:50:21 +02:00
|
|
|
*/
|
2002-05-11 00:36:27 +02:00
|
|
|
{"disable-triggers", no_argument, &disable_triggers, 1},
|
Row-Level Security Policies (RLS)
Building on the updatable security-barrier views work, add the
ability to define policies on tables to limit the set of rows
which are returned from a query and which are allowed to be added
to a table. Expressions defined by the policy for filtering are
added to the security barrier quals of the query, while expressions
defined to check records being added to a table are added to the
with-check options of the query.
New top-level commands are CREATE/ALTER/DROP POLICY and are
controlled by the table owner. Row Security is able to be enabled
and disabled by the owner on a per-table basis using
ALTER TABLE .. ENABLE/DISABLE ROW SECURITY.
Per discussion, ROW SECURITY is disabled on tables by default and
must be enabled for policies on the table to be used. If no
policies exist on a table with ROW SECURITY enabled, a default-deny
policy is used and no records will be visible.
By default, row security is applied at all times except for the
table owner and the superuser. A new GUC, row_security, is added
which can be set to ON, OFF, or FORCE. When set to FORCE, row
security will be applied even for the table owner and superusers.
When set to OFF, row security will be disabled when allowed and an
error will be thrown if the user does not have rights to bypass row
security.
Per discussion, pg_dump sets row_security = OFF by default to ensure
that exports and backups will have all data in the table or will
error if there are insufficient privileges to bypass row security.
A new option has been added to pg_dump, --enable-row-security, to
ask pg_dump to export with row security enabled.
A new role capability, BYPASSRLS, which can only be set by the
superuser, is added to allow other users to be able to bypass row
security using row_security = OFF.
Many thanks to the various individuals who have helped with the
design, particularly Robert Haas for his feedback.
Authors include Craig Ringer, KaiGai Kohei, Adam Brightwell, Dean
Rasheed, with additional changes and rework by me.
Reviewers have included all of the above, Greg Smith,
Jeff McCormick, and Robert Haas.
2014-09-19 17:18:35 +02:00
|
|
|
{"enable-row-security", no_argument, &enable_row_security, 1},
|
2014-03-03 19:02:18 +01:00
|
|
|
{"if-exists", no_argument, &if_exists, 1},
|
2006-10-07 22:59:05 +02:00
|
|
|
{"no-data-for-failed-tables", no_argument, &no_data_for_failed_tables, 1},
|
2008-03-20 18:36:58 +01:00
|
|
|
{"no-tablespaces", no_argument, &outputNoTablespaces, 1},
|
2009-01-05 17:54:37 +01:00
|
|
|
{"role", required_argument, NULL, 2},
|
2011-12-17 01:09:38 +01:00
|
|
|
{"section", required_argument, NULL, 3},
|
2015-09-14 15:19:49 +02:00
|
|
|
{"strict-names", no_argument, &strict_names, 1},
|
2008-03-20 18:36:58 +01:00
|
|
|
{"use-set-session-authorization", no_argument, &use_setsessauth, 1},
|
Support --no-comments in pg_dump, pg_dumpall, pg_restore.
We have switches already to suppress other subsidiary object properties,
such as ACLs, security labels, ownership, and tablespaces, so just on
the grounds of symmetry we should allow suppressing comments as well.
Also, commit 0d4e6ed30 added a positive reason to have this feature,
i.e. to allow obtaining the old behavior of selective pg_restore should
anyone desire that.
Recent commits have removed the cases where pg_dump emitted comments on
built-in objects that the restoring user might not have privileges to
comment on, so the original primary motivation for this feature is gone,
but it still seems at least somewhat useful in its own right.
Robins Tharakan, reviewed by Fabrízio Mello
Discussion: https://postgr.es/m/CAEP4nAx22Z4ch74oJGzr5RyyjcyUSbpiFLyeYXX8pehfou92ug@mail.gmail.com
2018-01-25 21:27:24 +01:00
|
|
|
{"no-comments", no_argument, &no_comments, 1},
|
2017-05-12 15:15:40 +02:00
|
|
|
{"no-publications", no_argument, &no_publications, 1},
|
2011-05-19 22:20:11 +02:00
|
|
|
{"no-security-labels", no_argument, &no_security_labels, 1},
|
2017-05-09 16:58:06 +02:00
|
|
|
{"no-subscriptions", no_argument, &no_subscriptions, 1},
|
2002-05-11 00:36:27 +02:00
|
|
|
|
2001-08-22 22:23:24 +02:00
|
|
|
{NULL, 0, NULL, 0}
|
|
|
|
};
|
2000-07-21 13:40:08 +02:00
|
|
|
|
Unified logging system for command-line programs
This unifies the various ad hoc logging (message printing, error
printing) systems used throughout the command-line programs.
Features:
- Program name is automatically prefixed.
- Message string does not end with newline. This removes a common
source of inconsistencies and omissions.
- Additionally, a final newline is automatically stripped, simplifying
use of PQerrorMessage() etc., another common source of mistakes.
- I converted error message strings to use %m where possible.
- As a result of the above several points, more translatable message
strings can be shared between different components and between
frontends and backend, without gratuitous punctuation or whitespace
differences.
- There is support for setting a "log level". This is not meant to be
user-facing, but can be used internally to implement debug or
verbose modes.
- Lazy argument evaluation, so no significant overhead if logging at
some level is disabled.
- Some color in the messages, similar to gcc and clang. Set
PG_COLOR=auto to try it out. Some colors are predefined, but can be
customized by setting PG_COLORS.
- Common files (common/, fe_utils/, etc.) can handle logging much more
simply by just using one API without worrying too much about the
context of the calling program, requiring callbacks, or having to
pass "progname" around everywhere.
- Some programs called setvbuf() to make sure that stderr is
unbuffered, even on Windows. But not all programs did that. This
is now done centrally.
Soft goals:
- Reduces vertical space use and visual complexity of error reporting
in the source code.
- Encourages more deliberate classification of messages. For example,
in some cases it wasn't clear without analyzing the surrounding code
whether a message was meant as an error or just an info.
- Concepts and terms are vaguely aligned with popular logging
frameworks such as log4j and Python logging.
This is all just about printing stuff out. Nothing affects program
flow (e.g., fatal exits). The uses are just too varied to do that.
Some existing code had wrappers that do some kind of print-and-exit,
and I adapted those.
I tried to keep the output mostly the same, but there is a lot of
historical baggage to unwind and special cases to consider, and I
might not always have succeeded. One significant change is that
pg_rewind used to write all error messages to stdout. That is now
changed to stderr.
Reviewed-by: Donald Dong <xdong@csumb.edu>
Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru>
Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
|
|
|
pg_logging_init(argv[0]);
|
2019-04-10 11:45:00 +02:00
|
|
|
pg_logging_set_level(PG_LOG_WARNING);
|
2008-12-11 08:34:09 +01:00
|
|
|
set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_dump"));
|
2001-06-27 23:21:37 +02:00
|
|
|
|
2009-03-11 04:33:29 +01:00
|
|
|
init_parallel_dump_utils();
|
|
|
|
|
2000-07-21 13:40:08 +02:00
|
|
|
opts = NewRestoreOptions();
|
|
|
|
|
2003-04-04 22:42:13 +02:00
|
|
|
progname = get_progname(argv[0]);
|
2001-01-06 21:57:26 +01:00
|
|
|
|
|
|
|
if (argc > 1)
|
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)
|
2001-01-06 21:57:26 +01:00
|
|
|
{
|
|
|
|
usage(progname);
|
2012-02-16 17:49:20 +01:00
|
|
|
exit_nicely(0);
|
2001-01-06 21:57:26 +01:00
|
|
|
}
|
2001-03-22 05:01:46 +01:00
|
|
|
if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0)
|
2001-01-06 21:57:26 +01:00
|
|
|
{
|
|
|
|
puts("pg_restore (PostgreSQL) " PG_VERSION);
|
2012-02-16 17:49:20 +01:00
|
|
|
exit_nicely(0);
|
2001-01-06 21:57:26 +01:00
|
|
|
}
|
|
|
|
}
|
2000-07-21 13:40:08 +02:00
|
|
|
|
2016-09-20 18:00:00 +02:00
|
|
|
while ((c = getopt_long(argc, argv, "acCd:ef:F:h:I:j:lL:n:N:Op:P:RsS:t:T:U:vwWx1",
|
2003-01-06 19:53:25 +01:00
|
|
|
cmdopts, NULL)) != -1)
|
2000-07-21 13:40:08 +02:00
|
|
|
{
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
case 'a': /* Dump data only */
|
|
|
|
opts->dataOnly = 1;
|
|
|
|
break;
|
2005-10-15 04:49:52 +02:00
|
|
|
case 'c': /* clean (i.e., drop) schema prior to create */
|
2000-07-21 13:40:08 +02:00
|
|
|
opts->dropSchema = 1;
|
|
|
|
break;
|
2000-08-01 17:51:45 +02:00
|
|
|
case 'C':
|
2010-05-15 23:41:16 +02:00
|
|
|
opts->createDB = 1;
|
2000-08-01 17:51:45 +02:00
|
|
|
break;
|
2000-07-21 13:40:08 +02:00
|
|
|
case 'd':
|
2011-11-25 21:40:51 +01:00
|
|
|
opts->dbname = pg_strdup(optarg);
|
2000-07-21 13:40:08 +02:00
|
|
|
break;
|
2004-08-20 06:20:23 +02:00
|
|
|
case 'e':
|
|
|
|
opts->exit_on_error = true;
|
|
|
|
break;
|
2000-07-21 13:40:08 +02:00
|
|
|
case 'f': /* output file name */
|
2011-11-25 21:40:51 +01:00
|
|
|
opts->filename = pg_strdup(optarg);
|
2000-07-21 13:40:08 +02:00
|
|
|
break;
|
|
|
|
case 'F':
|
2001-03-22 05:01:46 +01:00
|
|
|
if (strlen(optarg) != 0)
|
2011-11-25 21:40:51 +01:00
|
|
|
opts->formatName = pg_strdup(optarg);
|
2000-07-21 13:40:08 +02:00
|
|
|
break;
|
|
|
|
case 'h':
|
|
|
|
if (strlen(optarg) != 0)
|
2011-11-25 21:40:51 +01:00
|
|
|
opts->pghost = pg_strdup(optarg);
|
2000-07-21 13:40:08 +02:00
|
|
|
break;
|
2001-03-06 05:08:04 +01:00
|
|
|
|
2009-03-20 10:21:09 +01:00
|
|
|
case 'j': /* number of restore jobs */
|
2013-03-24 16:27:20 +01:00
|
|
|
numWorkers = atoi(optarg);
|
2009-03-20 10:21:09 +01:00
|
|
|
break;
|
|
|
|
|
2001-03-06 05:08:04 +01:00
|
|
|
case 'l': /* Dump the TOC summary */
|
|
|
|
opts->tocSummary = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'L': /* input TOC summary file name */
|
2011-11-25 21:40:51 +01:00
|
|
|
opts->tocFile = pg_strdup(optarg);
|
2001-03-06 05:08:04 +01:00
|
|
|
break;
|
|
|
|
|
2006-02-12 05:04:32 +01:00
|
|
|
case 'n': /* Dump data for this schema only */
|
2013-08-28 08:43:34 +02:00
|
|
|
simple_string_list_append(&opts->schemaNames, optarg);
|
2006-02-12 05:04:32 +01:00
|
|
|
break;
|
|
|
|
|
2016-09-20 18:00:00 +02:00
|
|
|
case 'N': /* Do not dump data for this schema */
|
|
|
|
simple_string_list_append(&opts->schemaExcludeNames, optarg);
|
|
|
|
break;
|
|
|
|
|
2000-07-21 13:40:08 +02:00
|
|
|
case 'O':
|
2000-08-01 17:51:45 +02:00
|
|
|
opts->noOwner = 1;
|
2000-07-21 13:40:08 +02:00
|
|
|
break;
|
2006-02-12 05:04:32 +01:00
|
|
|
|
2000-07-21 13:40:08 +02:00
|
|
|
case 'p':
|
|
|
|
if (strlen(optarg) != 0)
|
2011-11-25 21:40:51 +01:00
|
|
|
opts->pgport = pg_strdup(optarg);
|
2000-07-21 13:40:08 +02:00
|
|
|
break;
|
2000-08-01 17:51:45 +02:00
|
|
|
case 'R':
|
2003-09-24 00:48:53 +02:00
|
|
|
/* no-op, still accepted for backwards compatibility */
|
2000-08-01 17:51:45 +02:00
|
|
|
break;
|
2001-03-22 05:01:46 +01:00
|
|
|
case 'P': /* Function */
|
2000-07-21 13:40:08 +02:00
|
|
|
opts->selTypes = 1;
|
|
|
|
opts->selFunction = 1;
|
2013-08-28 08:43:34 +02:00
|
|
|
simple_string_list_append(&opts->functionNames, optarg);
|
2000-07-21 13:40:08 +02:00
|
|
|
break;
|
2001-03-22 05:01:46 +01:00
|
|
|
case 'I': /* Index */
|
2000-07-21 13:40:08 +02:00
|
|
|
opts->selTypes = 1;
|
|
|
|
opts->selIndex = 1;
|
2013-08-28 08:43:34 +02:00
|
|
|
simple_string_list_append(&opts->indexNames, optarg);
|
2000-07-21 13:40:08 +02:00
|
|
|
break;
|
2001-03-22 05:01:46 +01:00
|
|
|
case 'T': /* Trigger */
|
2000-07-21 13:40:08 +02:00
|
|
|
opts->selTypes = 1;
|
|
|
|
opts->selTrigger = 1;
|
2013-08-28 08:43:34 +02:00
|
|
|
simple_string_list_append(&opts->triggerNames, optarg);
|
2000-07-21 13:40:08 +02:00
|
|
|
break;
|
|
|
|
case 's': /* dump schema only */
|
|
|
|
opts->schemaOnly = 1;
|
|
|
|
break;
|
2000-08-01 17:51:45 +02:00
|
|
|
case 'S': /* Superuser username */
|
|
|
|
if (strlen(optarg) != 0)
|
2011-11-25 21:40:51 +01:00
|
|
|
opts->superuser = pg_strdup(optarg);
|
2000-08-01 17:51:45 +02:00
|
|
|
break;
|
2015-07-03 00:13:34 +02:00
|
|
|
case 't': /* Dump specified table(s) only */
|
2000-07-21 13:40:08 +02:00
|
|
|
opts->selTypes = 1;
|
|
|
|
opts->selTable = 1;
|
2013-01-17 11:24:47 +01:00
|
|
|
simple_string_list_append(&opts->tableNames, optarg);
|
2000-07-21 13:40:08 +02:00
|
|
|
break;
|
|
|
|
|
2001-05-17 23:12:49 +02:00
|
|
|
case 'U':
|
2012-10-12 19:35:40 +02:00
|
|
|
opts->username = pg_strdup(optarg);
|
2000-07-21 13:40:08 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'v': /* verbose */
|
|
|
|
opts->verbose = 1;
|
2019-04-10 11:45:00 +02:00
|
|
|
pg_logging_set_level(PG_LOG_INFO);
|
2000-07-21 13:40:08 +02:00
|
|
|
break;
|
2001-05-17 23:12:49 +02:00
|
|
|
|
2009-02-26 17:02:39 +01:00
|
|
|
case 'w':
|
|
|
|
opts->promptPassword = TRI_NO;
|
|
|
|
break;
|
|
|
|
|
2001-05-17 23:12:49 +02:00
|
|
|
case 'W':
|
2009-02-26 17:02:39 +01:00
|
|
|
opts->promptPassword = TRI_YES;
|
2001-05-17 23:12:49 +02:00
|
|
|
break;
|
|
|
|
|
2000-07-21 13:40:08 +02:00
|
|
|
case 'x': /* skip ACL dump */
|
|
|
|
opts->aclsSkip = 1;
|
|
|
|
break;
|
2001-08-22 22:23:24 +02:00
|
|
|
|
2009-01-05 17:54:37 +01:00
|
|
|
case '1': /* Restore data in a single transaction */
|
|
|
|
opts->single_txn = true;
|
|
|
|
opts->exit_on_error = true;
|
|
|
|
break;
|
|
|
|
|
2001-08-22 22:23:24 +02:00
|
|
|
case 0:
|
2009-06-11 16:49:15 +02:00
|
|
|
|
|
|
|
/*
|
2011-03-18 14:44:44 +01:00
|
|
|
* This covers the long options without a short equivalent.
|
2009-02-02 21:07:37 +01:00
|
|
|
*/
|
2001-08-22 22:23:24 +02:00
|
|
|
break;
|
|
|
|
|
2009-01-05 17:54:37 +01:00
|
|
|
case 2: /* SET ROLE */
|
2012-10-12 19:35:40 +02:00
|
|
|
opts->use_role = pg_strdup(optarg);
|
2006-02-12 05:04:32 +01:00
|
|
|
break;
|
|
|
|
|
2011-12-17 01:09:38 +01:00
|
|
|
case 3: /* section */
|
Rewrite --section option to decouple it from --schema-only/--data-only.
The initial implementation of pg_dump's --section option supposed that the
existing --schema-only and --data-only options could be made equivalent to
--section settings. This is wrong, though, due to dubious but long since
set-in-stone decisions about where to dump SEQUENCE SET items, as seen in
bug report from Martin Pitt. (And I'm not totally convinced there weren't
other bugs, either.) Undo that coupling and instead drive --section
filtering off current-section state tracked as we scan through the TOC
list to call _tocEntryRequired().
To make sure those decisions don't shift around and hopefully save a few
cycles, run _tocEntryRequired() only once per TOC entry and save the result
in a new TOC field. This required minor rejiggering of ACL handling but
also allows a far cleaner implementation of inhibit_data_for_failed_table.
Also, to ensure that pg_dump and pg_restore have the same behavior with
respect to the --section switches, add _tocEntryRequired() filtering to
WriteToc() and WriteDataChunks(), rather than trying to implement section
filtering in an entirely orthogonal way in dumpDumpableObject(). This
required adjusting the handling of the special ENCODING and STDSTRINGS
items, but they were pretty weird before anyway.
Minor other code review for the patch, too.
2012-05-30 05:22:14 +02:00
|
|
|
set_dump_section(optarg, &(opts->dumpSections));
|
2011-12-17 01:09:38 +01:00
|
|
|
break;
|
|
|
|
|
2000-07-21 13:40:08 +02:00
|
|
|
default:
|
2003-07-23 10:47:41 +02:00
|
|
|
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
|
2012-02-16 17:49:20 +01:00
|
|
|
exit_nicely(1);
|
2000-07-21 13:40:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-13 16:38:04 +02:00
|
|
|
/* Get file name from command line */
|
2001-03-22 05:01:46 +01:00
|
|
|
if (optind < argc)
|
2010-08-13 16:38:04 +02:00
|
|
|
inputFileSpec = argv[optind++];
|
2001-03-22 05:01:46 +01:00
|
|
|
else
|
2003-10-20 23:05:12 +02:00
|
|
|
inputFileSpec = NULL;
|
|
|
|
|
2010-08-13 16:38:04 +02:00
|
|
|
/* Complain if any arguments remain */
|
|
|
|
if (optind < argc)
|
|
|
|
{
|
Unified logging system for command-line programs
This unifies the various ad hoc logging (message printing, error
printing) systems used throughout the command-line programs.
Features:
- Program name is automatically prefixed.
- Message string does not end with newline. This removes a common
source of inconsistencies and omissions.
- Additionally, a final newline is automatically stripped, simplifying
use of PQerrorMessage() etc., another common source of mistakes.
- I converted error message strings to use %m where possible.
- As a result of the above several points, more translatable message
strings can be shared between different components and between
frontends and backend, without gratuitous punctuation or whitespace
differences.
- There is support for setting a "log level". This is not meant to be
user-facing, but can be used internally to implement debug or
verbose modes.
- Lazy argument evaluation, so no significant overhead if logging at
some level is disabled.
- Some color in the messages, similar to gcc and clang. Set
PG_COLOR=auto to try it out. Some colors are predefined, but can be
customized by setting PG_COLORS.
- Common files (common/, fe_utils/, etc.) can handle logging much more
simply by just using one API without worrying too much about the
context of the calling program, requiring callbacks, or having to
pass "progname" around everywhere.
- Some programs called setvbuf() to make sure that stderr is
unbuffered, even on Windows. But not all programs did that. This
is now done centrally.
Soft goals:
- Reduces vertical space use and visual complexity of error reporting
in the source code.
- Encourages more deliberate classification of messages. For example,
in some cases it wasn't clear without analyzing the surrounding code
whether a message was meant as an error or just an info.
- Concepts and terms are vaguely aligned with popular logging
frameworks such as log4j and Python logging.
This is all just about printing stuff out. Nothing affects program
flow (e.g., fatal exits). The uses are just too varied to do that.
Some existing code had wrappers that do some kind of print-and-exit,
and I adapted those.
I tried to keep the output mostly the same, but there is a lot of
historical baggage to unwind and special cases to consider, and I
might not always have succeeded. One significant change is that
pg_rewind used to write all error messages to stdout. That is now
changed to stderr.
Reviewed-by: Donald Dong <xdong@csumb.edu>
Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru>
Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
|
|
|
pg_log_error("too many command-line arguments (first is \"%s\")",
|
|
|
|
argv[optind]);
|
2010-08-13 16:38:04 +02:00
|
|
|
fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
|
|
|
|
progname);
|
2012-02-16 17:49:20 +01:00
|
|
|
exit_nicely(1);
|
2010-08-13 16:38:04 +02:00
|
|
|
}
|
|
|
|
|
2019-04-04 21:34:58 +02:00
|
|
|
/* Complain if neither -f nor -d was specified (except if dumping TOC) */
|
|
|
|
if (!opts->dbname && !opts->filename && !opts->tocSummary)
|
|
|
|
{
|
|
|
|
pg_log_error("one of -d/--dbname and -f/--file must be specified");
|
|
|
|
exit_nicely(1);
|
|
|
|
}
|
|
|
|
|
2003-10-20 23:05:12 +02:00
|
|
|
/* Should get at most one of -d and -f, else user is confused */
|
|
|
|
if (opts->dbname)
|
|
|
|
{
|
|
|
|
if (opts->filename)
|
|
|
|
{
|
Unified logging system for command-line programs
This unifies the various ad hoc logging (message printing, error
printing) systems used throughout the command-line programs.
Features:
- Program name is automatically prefixed.
- Message string does not end with newline. This removes a common
source of inconsistencies and omissions.
- Additionally, a final newline is automatically stripped, simplifying
use of PQerrorMessage() etc., another common source of mistakes.
- I converted error message strings to use %m where possible.
- As a result of the above several points, more translatable message
strings can be shared between different components and between
frontends and backend, without gratuitous punctuation or whitespace
differences.
- There is support for setting a "log level". This is not meant to be
user-facing, but can be used internally to implement debug or
verbose modes.
- Lazy argument evaluation, so no significant overhead if logging at
some level is disabled.
- Some color in the messages, similar to gcc and clang. Set
PG_COLOR=auto to try it out. Some colors are predefined, but can be
customized by setting PG_COLORS.
- Common files (common/, fe_utils/, etc.) can handle logging much more
simply by just using one API without worrying too much about the
context of the calling program, requiring callbacks, or having to
pass "progname" around everywhere.
- Some programs called setvbuf() to make sure that stderr is
unbuffered, even on Windows. But not all programs did that. This
is now done centrally.
Soft goals:
- Reduces vertical space use and visual complexity of error reporting
in the source code.
- Encourages more deliberate classification of messages. For example,
in some cases it wasn't clear without analyzing the surrounding code
whether a message was meant as an error or just an info.
- Concepts and terms are vaguely aligned with popular logging
frameworks such as log4j and Python logging.
This is all just about printing stuff out. Nothing affects program
flow (e.g., fatal exits). The uses are just too varied to do that.
Some existing code had wrappers that do some kind of print-and-exit,
and I adapted those.
I tried to keep the output mostly the same, but there is a lot of
historical baggage to unwind and special cases to consider, and I
might not always have succeeded. One significant change is that
pg_rewind used to write all error messages to stdout. That is now
changed to stderr.
Reviewed-by: Donald Dong <xdong@csumb.edu>
Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru>
Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
|
|
|
pg_log_error("options -d/--dbname and -f/--file cannot be used together");
|
2003-10-20 23:05:12 +02:00
|
|
|
fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
|
|
|
|
progname);
|
2012-02-16 17:49:20 +01:00
|
|
|
exit_nicely(1);
|
2003-10-20 23:05:12 +02:00
|
|
|
}
|
|
|
|
opts->useDB = 1;
|
|
|
|
}
|
2000-07-21 13:40:08 +02:00
|
|
|
|
2013-07-03 02:07:35 +02:00
|
|
|
if (opts->dataOnly && opts->schemaOnly)
|
|
|
|
{
|
Unified logging system for command-line programs
This unifies the various ad hoc logging (message printing, error
printing) systems used throughout the command-line programs.
Features:
- Program name is automatically prefixed.
- Message string does not end with newline. This removes a common
source of inconsistencies and omissions.
- Additionally, a final newline is automatically stripped, simplifying
use of PQerrorMessage() etc., another common source of mistakes.
- I converted error message strings to use %m where possible.
- As a result of the above several points, more translatable message
strings can be shared between different components and between
frontends and backend, without gratuitous punctuation or whitespace
differences.
- There is support for setting a "log level". This is not meant to be
user-facing, but can be used internally to implement debug or
verbose modes.
- Lazy argument evaluation, so no significant overhead if logging at
some level is disabled.
- Some color in the messages, similar to gcc and clang. Set
PG_COLOR=auto to try it out. Some colors are predefined, but can be
customized by setting PG_COLORS.
- Common files (common/, fe_utils/, etc.) can handle logging much more
simply by just using one API without worrying too much about the
context of the calling program, requiring callbacks, or having to
pass "progname" around everywhere.
- Some programs called setvbuf() to make sure that stderr is
unbuffered, even on Windows. But not all programs did that. This
is now done centrally.
Soft goals:
- Reduces vertical space use and visual complexity of error reporting
in the source code.
- Encourages more deliberate classification of messages. For example,
in some cases it wasn't clear without analyzing the surrounding code
whether a message was meant as an error or just an info.
- Concepts and terms are vaguely aligned with popular logging
frameworks such as log4j and Python logging.
This is all just about printing stuff out. Nothing affects program
flow (e.g., fatal exits). The uses are just too varied to do that.
Some existing code had wrappers that do some kind of print-and-exit,
and I adapted those.
I tried to keep the output mostly the same, but there is a lot of
historical baggage to unwind and special cases to consider, and I
might not always have succeeded. One significant change is that
pg_rewind used to write all error messages to stdout. That is now
changed to stderr.
Reviewed-by: Donald Dong <xdong@csumb.edu>
Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru>
Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
|
|
|
pg_log_error("options -s/--schema-only and -a/--data-only cannot be used together");
|
2013-07-03 02:07:35 +02:00
|
|
|
exit_nicely(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (opts->dataOnly && opts->dropSchema)
|
|
|
|
{
|
Unified logging system for command-line programs
This unifies the various ad hoc logging (message printing, error
printing) systems used throughout the command-line programs.
Features:
- Program name is automatically prefixed.
- Message string does not end with newline. This removes a common
source of inconsistencies and omissions.
- Additionally, a final newline is automatically stripped, simplifying
use of PQerrorMessage() etc., another common source of mistakes.
- I converted error message strings to use %m where possible.
- As a result of the above several points, more translatable message
strings can be shared between different components and between
frontends and backend, without gratuitous punctuation or whitespace
differences.
- There is support for setting a "log level". This is not meant to be
user-facing, but can be used internally to implement debug or
verbose modes.
- Lazy argument evaluation, so no significant overhead if logging at
some level is disabled.
- Some color in the messages, similar to gcc and clang. Set
PG_COLOR=auto to try it out. Some colors are predefined, but can be
customized by setting PG_COLORS.
- Common files (common/, fe_utils/, etc.) can handle logging much more
simply by just using one API without worrying too much about the
context of the calling program, requiring callbacks, or having to
pass "progname" around everywhere.
- Some programs called setvbuf() to make sure that stderr is
unbuffered, even on Windows. But not all programs did that. This
is now done centrally.
Soft goals:
- Reduces vertical space use and visual complexity of error reporting
in the source code.
- Encourages more deliberate classification of messages. For example,
in some cases it wasn't clear without analyzing the surrounding code
whether a message was meant as an error or just an info.
- Concepts and terms are vaguely aligned with popular logging
frameworks such as log4j and Python logging.
This is all just about printing stuff out. Nothing affects program
flow (e.g., fatal exits). The uses are just too varied to do that.
Some existing code had wrappers that do some kind of print-and-exit,
and I adapted those.
I tried to keep the output mostly the same, but there is a lot of
historical baggage to unwind and special cases to consider, and I
might not always have succeeded. One significant change is that
pg_rewind used to write all error messages to stdout. That is now
changed to stderr.
Reviewed-by: Donald Dong <xdong@csumb.edu>
Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru>
Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
|
|
|
pg_log_error("options -c/--clean and -a/--data-only cannot be used together");
|
2013-07-03 02:07:35 +02:00
|
|
|
exit_nicely(1);
|
|
|
|
}
|
|
|
|
|
2018-10-30 03:38:35 +01:00
|
|
|
/*
|
|
|
|
* -C is not compatible with -1, because we can't create a database inside
|
|
|
|
* a transaction block.
|
|
|
|
*/
|
|
|
|
if (opts->createDB && opts->single_txn)
|
|
|
|
{
|
Unified logging system for command-line programs
This unifies the various ad hoc logging (message printing, error
printing) systems used throughout the command-line programs.
Features:
- Program name is automatically prefixed.
- Message string does not end with newline. This removes a common
source of inconsistencies and omissions.
- Additionally, a final newline is automatically stripped, simplifying
use of PQerrorMessage() etc., another common source of mistakes.
- I converted error message strings to use %m where possible.
- As a result of the above several points, more translatable message
strings can be shared between different components and between
frontends and backend, without gratuitous punctuation or whitespace
differences.
- There is support for setting a "log level". This is not meant to be
user-facing, but can be used internally to implement debug or
verbose modes.
- Lazy argument evaluation, so no significant overhead if logging at
some level is disabled.
- Some color in the messages, similar to gcc and clang. Set
PG_COLOR=auto to try it out. Some colors are predefined, but can be
customized by setting PG_COLORS.
- Common files (common/, fe_utils/, etc.) can handle logging much more
simply by just using one API without worrying too much about the
context of the calling program, requiring callbacks, or having to
pass "progname" around everywhere.
- Some programs called setvbuf() to make sure that stderr is
unbuffered, even on Windows. But not all programs did that. This
is now done centrally.
Soft goals:
- Reduces vertical space use and visual complexity of error reporting
in the source code.
- Encourages more deliberate classification of messages. For example,
in some cases it wasn't clear without analyzing the surrounding code
whether a message was meant as an error or just an info.
- Concepts and terms are vaguely aligned with popular logging
frameworks such as log4j and Python logging.
This is all just about printing stuff out. Nothing affects program
flow (e.g., fatal exits). The uses are just too varied to do that.
Some existing code had wrappers that do some kind of print-and-exit,
and I adapted those.
I tried to keep the output mostly the same, but there is a lot of
historical baggage to unwind and special cases to consider, and I
might not always have succeeded. One significant change is that
pg_rewind used to write all error messages to stdout. That is now
changed to stderr.
Reviewed-by: Donald Dong <xdong@csumb.edu>
Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru>
Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
|
|
|
pg_log_error("options -C/--create and -1/--single-transaction cannot be used together");
|
2018-10-30 03:38:35 +01:00
|
|
|
exit_nicely(1);
|
|
|
|
}
|
|
|
|
|
2017-01-11 21:45:50 +01:00
|
|
|
if (numWorkers <= 0)
|
|
|
|
{
|
Unified logging system for command-line programs
This unifies the various ad hoc logging (message printing, error
printing) systems used throughout the command-line programs.
Features:
- Program name is automatically prefixed.
- Message string does not end with newline. This removes a common
source of inconsistencies and omissions.
- Additionally, a final newline is automatically stripped, simplifying
use of PQerrorMessage() etc., another common source of mistakes.
- I converted error message strings to use %m where possible.
- As a result of the above several points, more translatable message
strings can be shared between different components and between
frontends and backend, without gratuitous punctuation or whitespace
differences.
- There is support for setting a "log level". This is not meant to be
user-facing, but can be used internally to implement debug or
verbose modes.
- Lazy argument evaluation, so no significant overhead if logging at
some level is disabled.
- Some color in the messages, similar to gcc and clang. Set
PG_COLOR=auto to try it out. Some colors are predefined, but can be
customized by setting PG_COLORS.
- Common files (common/, fe_utils/, etc.) can handle logging much more
simply by just using one API without worrying too much about the
context of the calling program, requiring callbacks, or having to
pass "progname" around everywhere.
- Some programs called setvbuf() to make sure that stderr is
unbuffered, even on Windows. But not all programs did that. This
is now done centrally.
Soft goals:
- Reduces vertical space use and visual complexity of error reporting
in the source code.
- Encourages more deliberate classification of messages. For example,
in some cases it wasn't clear without analyzing the surrounding code
whether a message was meant as an error or just an info.
- Concepts and terms are vaguely aligned with popular logging
frameworks such as log4j and Python logging.
This is all just about printing stuff out. Nothing affects program
flow (e.g., fatal exits). The uses are just too varied to do that.
Some existing code had wrappers that do some kind of print-and-exit,
and I adapted those.
I tried to keep the output mostly the same, but there is a lot of
historical baggage to unwind and special cases to consider, and I
might not always have succeeded. One significant change is that
pg_rewind used to write all error messages to stdout. That is now
changed to stderr.
Reviewed-by: Donald Dong <xdong@csumb.edu>
Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru>
Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
|
|
|
pg_log_error("invalid number of parallel jobs");
|
2017-01-11 21:45:50 +01:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* See comments in pg_dump.c */
|
|
|
|
#ifdef WIN32
|
|
|
|
if (numWorkers > MAXIMUM_WAIT_OBJECTS)
|
|
|
|
{
|
Unified logging system for command-line programs
This unifies the various ad hoc logging (message printing, error
printing) systems used throughout the command-line programs.
Features:
- Program name is automatically prefixed.
- Message string does not end with newline. This removes a common
source of inconsistencies and omissions.
- Additionally, a final newline is automatically stripped, simplifying
use of PQerrorMessage() etc., another common source of mistakes.
- I converted error message strings to use %m where possible.
- As a result of the above several points, more translatable message
strings can be shared between different components and between
frontends and backend, without gratuitous punctuation or whitespace
differences.
- There is support for setting a "log level". This is not meant to be
user-facing, but can be used internally to implement debug or
verbose modes.
- Lazy argument evaluation, so no significant overhead if logging at
some level is disabled.
- Some color in the messages, similar to gcc and clang. Set
PG_COLOR=auto to try it out. Some colors are predefined, but can be
customized by setting PG_COLORS.
- Common files (common/, fe_utils/, etc.) can handle logging much more
simply by just using one API without worrying too much about the
context of the calling program, requiring callbacks, or having to
pass "progname" around everywhere.
- Some programs called setvbuf() to make sure that stderr is
unbuffered, even on Windows. But not all programs did that. This
is now done centrally.
Soft goals:
- Reduces vertical space use and visual complexity of error reporting
in the source code.
- Encourages more deliberate classification of messages. For example,
in some cases it wasn't clear without analyzing the surrounding code
whether a message was meant as an error or just an info.
- Concepts and terms are vaguely aligned with popular logging
frameworks such as log4j and Python logging.
This is all just about printing stuff out. Nothing affects program
flow (e.g., fatal exits). The uses are just too varied to do that.
Some existing code had wrappers that do some kind of print-and-exit,
and I adapted those.
I tried to keep the output mostly the same, but there is a lot of
historical baggage to unwind and special cases to consider, and I
might not always have succeeded. One significant change is that
pg_rewind used to write all error messages to stdout. That is now
changed to stderr.
Reviewed-by: Donald Dong <xdong@csumb.edu>
Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru>
Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
|
|
|
pg_log_error("maximum number of parallel jobs is %d",
|
|
|
|
MAXIMUM_WAIT_OBJECTS);
|
2017-01-11 21:45:50 +01:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-02-02 21:07:37 +01:00
|
|
|
/* Can't do single-txn mode with multiple connections */
|
2013-03-24 16:27:20 +01:00
|
|
|
if (opts->single_txn && numWorkers > 1)
|
2009-02-02 21:07:37 +01:00
|
|
|
{
|
Unified logging system for command-line programs
This unifies the various ad hoc logging (message printing, error
printing) systems used throughout the command-line programs.
Features:
- Program name is automatically prefixed.
- Message string does not end with newline. This removes a common
source of inconsistencies and omissions.
- Additionally, a final newline is automatically stripped, simplifying
use of PQerrorMessage() etc., another common source of mistakes.
- I converted error message strings to use %m where possible.
- As a result of the above several points, more translatable message
strings can be shared between different components and between
frontends and backend, without gratuitous punctuation or whitespace
differences.
- There is support for setting a "log level". This is not meant to be
user-facing, but can be used internally to implement debug or
verbose modes.
- Lazy argument evaluation, so no significant overhead if logging at
some level is disabled.
- Some color in the messages, similar to gcc and clang. Set
PG_COLOR=auto to try it out. Some colors are predefined, but can be
customized by setting PG_COLORS.
- Common files (common/, fe_utils/, etc.) can handle logging much more
simply by just using one API without worrying too much about the
context of the calling program, requiring callbacks, or having to
pass "progname" around everywhere.
- Some programs called setvbuf() to make sure that stderr is
unbuffered, even on Windows. But not all programs did that. This
is now done centrally.
Soft goals:
- Reduces vertical space use and visual complexity of error reporting
in the source code.
- Encourages more deliberate classification of messages. For example,
in some cases it wasn't clear without analyzing the surrounding code
whether a message was meant as an error or just an info.
- Concepts and terms are vaguely aligned with popular logging
frameworks such as log4j and Python logging.
This is all just about printing stuff out. Nothing affects program
flow (e.g., fatal exits). The uses are just too varied to do that.
Some existing code had wrappers that do some kind of print-and-exit,
and I adapted those.
I tried to keep the output mostly the same, but there is a lot of
historical baggage to unwind and special cases to consider, and I
might not always have succeeded. One significant change is that
pg_rewind used to write all error messages to stdout. That is now
changed to stderr.
Reviewed-by: Donald Dong <xdong@csumb.edu>
Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru>
Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
|
|
|
pg_log_error("cannot specify both --single-transaction and multiple jobs");
|
2012-02-16 17:49:20 +01:00
|
|
|
exit_nicely(1);
|
2009-02-02 21:07:37 +01:00
|
|
|
}
|
|
|
|
|
2002-05-11 00:36:27 +02:00
|
|
|
opts->disable_triggers = disable_triggers;
|
Row-Level Security Policies (RLS)
Building on the updatable security-barrier views work, add the
ability to define policies on tables to limit the set of rows
which are returned from a query and which are allowed to be added
to a table. Expressions defined by the policy for filtering are
added to the security barrier quals of the query, while expressions
defined to check records being added to a table are added to the
with-check options of the query.
New top-level commands are CREATE/ALTER/DROP POLICY and are
controlled by the table owner. Row Security is able to be enabled
and disabled by the owner on a per-table basis using
ALTER TABLE .. ENABLE/DISABLE ROW SECURITY.
Per discussion, ROW SECURITY is disabled on tables by default and
must be enabled for policies on the table to be used. If no
policies exist on a table with ROW SECURITY enabled, a default-deny
policy is used and no records will be visible.
By default, row security is applied at all times except for the
table owner and the superuser. A new GUC, row_security, is added
which can be set to ON, OFF, or FORCE. When set to FORCE, row
security will be applied even for the table owner and superusers.
When set to OFF, row security will be disabled when allowed and an
error will be thrown if the user does not have rights to bypass row
security.
Per discussion, pg_dump sets row_security = OFF by default to ensure
that exports and backups will have all data in the table or will
error if there are insufficient privileges to bypass row security.
A new option has been added to pg_dump, --enable-row-security, to
ask pg_dump to export with row security enabled.
A new role capability, BYPASSRLS, which can only be set by the
superuser, is added to allow other users to be able to bypass row
security using row_security = OFF.
Many thanks to the various individuals who have helped with the
design, particularly Robert Haas for his feedback.
Authors include Craig Ringer, KaiGai Kohei, Adam Brightwell, Dean
Rasheed, with additional changes and rework by me.
Reviewers have included all of the above, Greg Smith,
Jeff McCormick, and Robert Haas.
2014-09-19 17:18:35 +02:00
|
|
|
opts->enable_row_security = enable_row_security;
|
2006-10-07 22:59:05 +02:00
|
|
|
opts->noDataForFailedTables = no_data_for_failed_tables;
|
2008-03-20 18:36:58 +01:00
|
|
|
opts->noTablespace = outputNoTablespaces;
|
|
|
|
opts->use_setsessauth = use_setsessauth;
|
Support --no-comments in pg_dump, pg_dumpall, pg_restore.
We have switches already to suppress other subsidiary object properties,
such as ACLs, security labels, ownership, and tablespaces, so just on
the grounds of symmetry we should allow suppressing comments as well.
Also, commit 0d4e6ed30 added a positive reason to have this feature,
i.e. to allow obtaining the old behavior of selective pg_restore should
anyone desire that.
Recent commits have removed the cases where pg_dump emitted comments on
built-in objects that the restoring user might not have privileges to
comment on, so the original primary motivation for this feature is gone,
but it still seems at least somewhat useful in its own right.
Robins Tharakan, reviewed by Fabrízio Mello
Discussion: https://postgr.es/m/CAEP4nAx22Z4ch74oJGzr5RyyjcyUSbpiFLyeYXX8pehfou92ug@mail.gmail.com
2018-01-25 21:27:24 +01:00
|
|
|
opts->no_comments = no_comments;
|
2017-05-12 15:15:40 +02:00
|
|
|
opts->no_publications = no_publications;
|
2011-05-19 22:20:11 +02:00
|
|
|
opts->no_security_labels = no_security_labels;
|
2017-05-09 16:58:06 +02:00
|
|
|
opts->no_subscriptions = no_subscriptions;
|
2001-08-22 22:23:24 +02:00
|
|
|
|
2014-03-03 19:02:18 +01:00
|
|
|
if (if_exists && !opts->dropSchema)
|
|
|
|
{
|
Unified logging system for command-line programs
This unifies the various ad hoc logging (message printing, error
printing) systems used throughout the command-line programs.
Features:
- Program name is automatically prefixed.
- Message string does not end with newline. This removes a common
source of inconsistencies and omissions.
- Additionally, a final newline is automatically stripped, simplifying
use of PQerrorMessage() etc., another common source of mistakes.
- I converted error message strings to use %m where possible.
- As a result of the above several points, more translatable message
strings can be shared between different components and between
frontends and backend, without gratuitous punctuation or whitespace
differences.
- There is support for setting a "log level". This is not meant to be
user-facing, but can be used internally to implement debug or
verbose modes.
- Lazy argument evaluation, so no significant overhead if logging at
some level is disabled.
- Some color in the messages, similar to gcc and clang. Set
PG_COLOR=auto to try it out. Some colors are predefined, but can be
customized by setting PG_COLORS.
- Common files (common/, fe_utils/, etc.) can handle logging much more
simply by just using one API without worrying too much about the
context of the calling program, requiring callbacks, or having to
pass "progname" around everywhere.
- Some programs called setvbuf() to make sure that stderr is
unbuffered, even on Windows. But not all programs did that. This
is now done centrally.
Soft goals:
- Reduces vertical space use and visual complexity of error reporting
in the source code.
- Encourages more deliberate classification of messages. For example,
in some cases it wasn't clear without analyzing the surrounding code
whether a message was meant as an error or just an info.
- Concepts and terms are vaguely aligned with popular logging
frameworks such as log4j and Python logging.
This is all just about printing stuff out. Nothing affects program
flow (e.g., fatal exits). The uses are just too varied to do that.
Some existing code had wrappers that do some kind of print-and-exit,
and I adapted those.
I tried to keep the output mostly the same, but there is a lot of
historical baggage to unwind and special cases to consider, and I
might not always have succeeded. One significant change is that
pg_rewind used to write all error messages to stdout. That is now
changed to stderr.
Reviewed-by: Donald Dong <xdong@csumb.edu>
Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru>
Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
|
|
|
pg_log_error("option --if-exists requires option -c/--clean");
|
2014-03-03 19:02:18 +01:00
|
|
|
exit_nicely(1);
|
|
|
|
}
|
|
|
|
opts->if_exists = if_exists;
|
2015-09-14 15:19:49 +02:00
|
|
|
opts->strict_names = strict_names;
|
2014-03-03 19:02:18 +01:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
if (opts->formatName)
|
|
|
|
{
|
|
|
|
switch (opts->formatName[0])
|
|
|
|
{
|
2001-03-06 05:08:04 +01:00
|
|
|
case 'c':
|
|
|
|
case 'C':
|
|
|
|
opts->format = archCustom;
|
|
|
|
break;
|
2000-07-21 13:40:08 +02:00
|
|
|
|
2011-01-23 22:10:15 +01:00
|
|
|
case 'd':
|
|
|
|
case 'D':
|
|
|
|
opts->format = archDirectory;
|
|
|
|
break;
|
|
|
|
|
2001-03-06 05:08:04 +01:00
|
|
|
case 't':
|
|
|
|
case 'T':
|
|
|
|
opts->format = archTar;
|
|
|
|
break;
|
2000-07-21 13:40:08 +02:00
|
|
|
|
2001-03-06 05:08:04 +01:00
|
|
|
default:
|
Unified logging system for command-line programs
This unifies the various ad hoc logging (message printing, error
printing) systems used throughout the command-line programs.
Features:
- Program name is automatically prefixed.
- Message string does not end with newline. This removes a common
source of inconsistencies and omissions.
- Additionally, a final newline is automatically stripped, simplifying
use of PQerrorMessage() etc., another common source of mistakes.
- I converted error message strings to use %m where possible.
- As a result of the above several points, more translatable message
strings can be shared between different components and between
frontends and backend, without gratuitous punctuation or whitespace
differences.
- There is support for setting a "log level". This is not meant to be
user-facing, but can be used internally to implement debug or
verbose modes.
- Lazy argument evaluation, so no significant overhead if logging at
some level is disabled.
- Some color in the messages, similar to gcc and clang. Set
PG_COLOR=auto to try it out. Some colors are predefined, but can be
customized by setting PG_COLORS.
- Common files (common/, fe_utils/, etc.) can handle logging much more
simply by just using one API without worrying too much about the
context of the calling program, requiring callbacks, or having to
pass "progname" around everywhere.
- Some programs called setvbuf() to make sure that stderr is
unbuffered, even on Windows. But not all programs did that. This
is now done centrally.
Soft goals:
- Reduces vertical space use and visual complexity of error reporting
in the source code.
- Encourages more deliberate classification of messages. For example,
in some cases it wasn't clear without analyzing the surrounding code
whether a message was meant as an error or just an info.
- Concepts and terms are vaguely aligned with popular logging
frameworks such as log4j and Python logging.
This is all just about printing stuff out. Nothing affects program
flow (e.g., fatal exits). The uses are just too varied to do that.
Some existing code had wrappers that do some kind of print-and-exit,
and I adapted those.
I tried to keep the output mostly the same, but there is a lot of
historical baggage to unwind and special cases to consider, and I
might not always have succeeded. One significant change is that
pg_rewind used to write all error messages to stdout. That is now
changed to stderr.
Reviewed-by: Donald Dong <xdong@csumb.edu>
Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru>
Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
|
|
|
pg_log_error("unrecognized archive format \"%s\"; please specify \"c\", \"d\", or \"t\"",
|
2019-05-22 18:55:34 +02:00
|
|
|
opts->formatName);
|
2012-02-16 17:49:20 +01:00
|
|
|
exit_nicely(1);
|
2001-03-06 05:08:04 +01:00
|
|
|
}
|
2001-03-22 05:01:46 +01:00
|
|
|
}
|
2000-07-21 13:40:08 +02:00
|
|
|
|
2003-10-20 23:05:12 +02:00
|
|
|
AH = OpenArchive(inputFileSpec, opts->format);
|
2000-07-21 13:40:08 +02:00
|
|
|
|
2016-01-13 23:48:33 +01:00
|
|
|
SetArchiveOptions(AH, NULL, opts);
|
|
|
|
|
2012-03-20 22:38:11 +01:00
|
|
|
/*
|
|
|
|
* We don't have a connection yet but that doesn't matter. The connection
|
|
|
|
* is initialized to NULL and if we terminate through exit_nicely() while
|
|
|
|
* it's still NULL, the cleanup function will just be a no-op.
|
|
|
|
*/
|
|
|
|
on_exit_close_archive(AH);
|
|
|
|
|
2000-07-21 13:40:08 +02:00
|
|
|
/* Let the archiver know how noisy to be */
|
|
|
|
AH->verbose = opts->verbose;
|
|
|
|
|
2004-08-20 06:20:23 +02:00
|
|
|
/*
|
2005-10-15 04:49:52 +02:00
|
|
|
* Whether to keep submitting sql commands as "pg_restore ... | psql ... "
|
2004-04-22 04:39:10 +02:00
|
|
|
*/
|
2004-08-20 06:20:23 +02:00
|
|
|
AH->exit_on_error = opts->exit_on_error;
|
2004-04-22 04:39:10 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
if (opts->tocFile)
|
2016-01-13 23:48:33 +01:00
|
|
|
SortTocFromFile(AH);
|
2000-07-21 13:40:08 +02:00
|
|
|
|
2013-03-24 16:27:20 +01:00
|
|
|
AH->numWorkers = numWorkers;
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
if (opts->tocSummary)
|
2016-01-13 23:48:33 +01:00
|
|
|
PrintTOCSummary(AH);
|
2001-03-22 05:01:46 +01:00
|
|
|
else
|
Rewrite --section option to decouple it from --schema-only/--data-only.
The initial implementation of pg_dump's --section option supposed that the
existing --schema-only and --data-only options could be made equivalent to
--section settings. This is wrong, though, due to dubious but long since
set-in-stone decisions about where to dump SEQUENCE SET items, as seen in
bug report from Martin Pitt. (And I'm not totally convinced there weren't
other bugs, either.) Undo that coupling and instead drive --section
filtering off current-section state tracked as we scan through the TOC
list to call _tocEntryRequired().
To make sure those decisions don't shift around and hopefully save a few
cycles, run _tocEntryRequired() only once per TOC entry and save the result
in a new TOC field. This required minor rejiggering of ACL handling but
also allows a far cleaner implementation of inhibit_data_for_failed_table.
Also, to ensure that pg_dump and pg_restore have the same behavior with
respect to the --section switches, add _tocEntryRequired() filtering to
WriteToc() and WriteDataChunks(), rather than trying to implement section
filtering in an entirely orthogonal way in dumpDumpableObject(). This
required adjusting the handling of the special ENCODING and STDSTRINGS
items, but they were pretty weird before anyway.
Minor other code review for the patch, too.
2012-05-30 05:22:14 +02:00
|
|
|
{
|
2016-01-13 23:48:33 +01:00
|
|
|
ProcessArchiveRestoreOptions(AH);
|
Rewrite --section option to decouple it from --schema-only/--data-only.
The initial implementation of pg_dump's --section option supposed that the
existing --schema-only and --data-only options could be made equivalent to
--section settings. This is wrong, though, due to dubious but long since
set-in-stone decisions about where to dump SEQUENCE SET items, as seen in
bug report from Martin Pitt. (And I'm not totally convinced there weren't
other bugs, either.) Undo that coupling and instead drive --section
filtering off current-section state tracked as we scan through the TOC
list to call _tocEntryRequired().
To make sure those decisions don't shift around and hopefully save a few
cycles, run _tocEntryRequired() only once per TOC entry and save the result
in a new TOC field. This required minor rejiggering of ACL handling but
also allows a far cleaner implementation of inhibit_data_for_failed_table.
Also, to ensure that pg_dump and pg_restore have the same behavior with
respect to the --section switches, add _tocEntryRequired() filtering to
WriteToc() and WriteDataChunks(), rather than trying to implement section
filtering in an entirely orthogonal way in dumpDumpableObject(). This
required adjusting the handling of the special ENCODING and STDSTRINGS
items, but they were pretty weird before anyway.
Minor other code review for the patch, too.
2012-05-30 05:22:14 +02:00
|
|
|
RestoreArchive(AH);
|
|
|
|
}
|
2000-07-21 13:40:08 +02:00
|
|
|
|
2004-04-22 04:39:10 +02:00
|
|
|
/* done, print a summary of ignored errors */
|
|
|
|
if (AH->n_errors)
|
Unified logging system for command-line programs
This unifies the various ad hoc logging (message printing, error
printing) systems used throughout the command-line programs.
Features:
- Program name is automatically prefixed.
- Message string does not end with newline. This removes a common
source of inconsistencies and omissions.
- Additionally, a final newline is automatically stripped, simplifying
use of PQerrorMessage() etc., another common source of mistakes.
- I converted error message strings to use %m where possible.
- As a result of the above several points, more translatable message
strings can be shared between different components and between
frontends and backend, without gratuitous punctuation or whitespace
differences.
- There is support for setting a "log level". This is not meant to be
user-facing, but can be used internally to implement debug or
verbose modes.
- Lazy argument evaluation, so no significant overhead if logging at
some level is disabled.
- Some color in the messages, similar to gcc and clang. Set
PG_COLOR=auto to try it out. Some colors are predefined, but can be
customized by setting PG_COLORS.
- Common files (common/, fe_utils/, etc.) can handle logging much more
simply by just using one API without worrying too much about the
context of the calling program, requiring callbacks, or having to
pass "progname" around everywhere.
- Some programs called setvbuf() to make sure that stderr is
unbuffered, even on Windows. But not all programs did that. This
is now done centrally.
Soft goals:
- Reduces vertical space use and visual complexity of error reporting
in the source code.
- Encourages more deliberate classification of messages. For example,
in some cases it wasn't clear without analyzing the surrounding code
whether a message was meant as an error or just an info.
- Concepts and terms are vaguely aligned with popular logging
frameworks such as log4j and Python logging.
This is all just about printing stuff out. Nothing affects program
flow (e.g., fatal exits). The uses are just too varied to do that.
Some existing code had wrappers that do some kind of print-and-exit,
and I adapted those.
I tried to keep the output mostly the same, but there is a lot of
historical baggage to unwind and special cases to consider, and I
might not always have succeeded. One significant change is that
pg_rewind used to write all error messages to stdout. That is now
changed to stderr.
Reviewed-by: Donald Dong <xdong@csumb.edu>
Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru>
Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
|
|
|
pg_log_warning("errors ignored on restore: %d", AH->n_errors);
|
2004-04-22 04:39:10 +02:00
|
|
|
|
|
|
|
/* AH may be freed in CloseArchive? */
|
2004-08-29 07:07:03 +02:00
|
|
|
exit_code = AH->n_errors ? 1 : 0;
|
2004-04-22 04:39:10 +02:00
|
|
|
|
2016-01-13 23:48:33 +01:00
|
|
|
CloseArchive(AH);
|
2000-07-21 13:40:08 +02:00
|
|
|
|
2004-04-22 04:39:10 +02:00
|
|
|
return exit_code;
|
2000-07-21 13:40:08 +02:00
|
|
|
}
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
static void
|
|
|
|
usage(const char *progname)
|
2000-07-21 13:40:08 +02:00
|
|
|
{
|
2002-08-28 22:57:22 +02:00
|
|
|
printf(_("%s restores a PostgreSQL database from an archive created by pg_dump.\n\n"), progname);
|
|
|
|
printf(_("Usage:\n"));
|
2002-10-19 00:05:36 +02:00
|
|
|
printf(_(" %s [OPTION]... [FILE]\n"), progname);
|
2002-08-28 22:57:22 +02:00
|
|
|
|
2002-10-19 00:05:36 +02:00
|
|
|
printf(_("\nGeneral options:\n"));
|
2004-11-11 18:06:46 +01:00
|
|
|
printf(_(" -d, --dbname=NAME connect to database name\n"));
|
2019-04-04 21:34:58 +02:00
|
|
|
printf(_(" -f, --file=FILENAME output file name (- for stdout)\n"));
|
2011-01-23 22:10:15 +01:00
|
|
|
printf(_(" -F, --format=c|d|t backup file format (should be automatic)\n"));
|
2002-09-04 22:31:48 +02:00
|
|
|
printf(_(" -l, --list print summarized TOC of the archive\n"));
|
2002-10-19 00:05:36 +02:00
|
|
|
printf(_(" -v, --verbose verbose mode\n"));
|
2012-06-18 01:44:00 +02:00
|
|
|
printf(_(" -V, --version output version information, then exit\n"));
|
|
|
|
printf(_(" -?, --help show this help, then exit\n"));
|
2002-10-19 00:05:36 +02:00
|
|
|
|
2004-10-13 02:42:53 +02:00
|
|
|
printf(_("\nOptions controlling the restore:\n"));
|
2012-05-18 19:34:14 +02:00
|
|
|
printf(_(" -a, --data-only restore only the data, no schema\n"));
|
|
|
|
printf(_(" -c, --clean clean (drop) database objects before recreating\n"));
|
|
|
|
printf(_(" -C, --create create the target database\n"));
|
|
|
|
printf(_(" -e, --exit-on-error exit on error, default is to continue\n"));
|
2014-08-23 06:23:34 +02:00
|
|
|
printf(_(" -I, --index=NAME restore named index\n"));
|
2012-05-18 19:34:14 +02:00
|
|
|
printf(_(" -j, --jobs=NUM use this many parallel jobs to restore\n"));
|
|
|
|
printf(_(" -L, --use-list=FILENAME use table of contents from this file for\n"
|
|
|
|
" selecting/ordering output\n"));
|
2014-08-23 06:23:34 +02:00
|
|
|
printf(_(" -n, --schema=NAME restore only objects in this schema\n"));
|
2016-09-20 18:00:00 +02:00
|
|
|
printf(_(" -N, --exclude-schema=NAME do not restore objects in this schema\n"));
|
2012-05-18 19:34:14 +02:00
|
|
|
printf(_(" -O, --no-owner skip restoration of object ownership\n"));
|
2014-08-23 06:23:34 +02:00
|
|
|
printf(_(" -P, --function=NAME(args) restore named function\n"));
|
2012-05-18 19:34:14 +02:00
|
|
|
printf(_(" -s, --schema-only restore only the schema, no data\n"));
|
|
|
|
printf(_(" -S, --superuser=NAME superuser user name to use for disabling triggers\n"));
|
2016-04-25 23:16:59 +02:00
|
|
|
printf(_(" -t, --table=NAME restore named relation (table, view, etc.)\n"));
|
2014-08-23 06:23:34 +02:00
|
|
|
printf(_(" -T, --trigger=NAME restore named trigger\n"));
|
2012-05-18 19:34:14 +02:00
|
|
|
printf(_(" -x, --no-privileges skip restoration of access privileges (grant/revoke)\n"));
|
|
|
|
printf(_(" -1, --single-transaction restore as a single transaction\n"));
|
|
|
|
printf(_(" --disable-triggers disable triggers during data-only restore\n"));
|
2015-09-16 06:37:39 +02:00
|
|
|
printf(_(" --enable-row-security enable row security\n"));
|
2014-03-03 19:02:18 +01:00
|
|
|
printf(_(" --if-exists use IF EXISTS when dropping objects\n"));
|
2018-06-26 07:57:53 +02:00
|
|
|
printf(_(" --no-comments do not restore comments\n"));
|
2012-05-18 19:34:14 +02:00
|
|
|
printf(_(" --no-data-for-failed-tables do not restore data of tables that could not be\n"
|
|
|
|
" created\n"));
|
2017-05-12 15:15:40 +02:00
|
|
|
printf(_(" --no-publications do not restore publications\n"));
|
2012-05-18 19:34:14 +02:00
|
|
|
printf(_(" --no-security-labels do not restore security labels\n"));
|
2017-05-09 16:58:06 +02:00
|
|
|
printf(_(" --no-subscriptions do not restore subscriptions\n"));
|
2012-05-18 19:34:14 +02:00
|
|
|
printf(_(" --no-tablespaces do not restore tablespace assignments\n"));
|
2014-08-23 06:23:34 +02:00
|
|
|
printf(_(" --section=SECTION restore named section (pre-data, data, or post-data)\n"));
|
2015-09-14 15:19:49 +02:00
|
|
|
printf(_(" --strict-names require table and/or schema include patterns to\n"
|
Phase 3 of pgindent updates.
Don't move parenthesized lines to the left, even if that means they
flow past the right margin.
By default, BSD indent lines up statement continuation lines that are
within parentheses so that they start just to the right of the preceding
left parenthesis. However, traditionally, if that resulted in the
continuation line extending to the right of the desired right margin,
then indent would push it left just far enough to not overrun the margin,
if it could do so without making the continuation line start to the left of
the current statement indent. That makes for a weird mix of indentations
unless one has been completely rigid about never violating the 80-column
limit.
This behavior has been pretty universally panned by Postgres developers.
Hence, disable it with indent's new -lpl switch, so that parenthesized
lines are always lined up with the preceding left paren.
This patch is much less interesting than the first round of indent
changes, but also bulkier, so I thought it best to separate the effects.
Discussion: https://postgr.es/m/E1dAmxK-0006EE-1r@gemulon.postgresql.org
Discussion: https://postgr.es/m/30527.1495162840@sss.pgh.pa.us
2017-06-21 21:35:54 +02:00
|
|
|
" match at least one entity each\n"));
|
2008-03-20 18:36:58 +01:00
|
|
|
printf(_(" --use-set-session-authorization\n"
|
2012-05-18 19:34:14 +02:00
|
|
|
" use SET SESSION AUTHORIZATION commands instead of\n"
|
|
|
|
" ALTER OWNER commands to set ownership\n"));
|
2002-10-19 00:05:36 +02:00
|
|
|
|
|
|
|
printf(_("\nConnection options:\n"));
|
2003-06-11 07:13:12 +02:00
|
|
|
printf(_(" -h, --host=HOSTNAME database server host or socket directory\n"));
|
2002-10-19 00:05:36 +02:00
|
|
|
printf(_(" -p, --port=PORT database server port number\n"));
|
|
|
|
printf(_(" -U, --username=NAME connect as specified database user\n"));
|
2009-02-26 17:02:39 +01:00
|
|
|
printf(_(" -w, --no-password never prompt for password\n"));
|
2002-10-19 00:05:36 +02:00
|
|
|
printf(_(" -W, --password force password prompt (should happen automatically)\n"));
|
2011-05-25 20:53:26 +02:00
|
|
|
printf(_(" --role=ROLENAME do SET ROLE before restore\n"));
|
2002-08-28 22:57:22 +02:00
|
|
|
|
2014-08-23 06:23:34 +02:00
|
|
|
printf(_("\n"
|
2018-10-29 11:31:43 +01:00
|
|
|
"The options -I, -n, -N, -P, -t, -T, and --section can be combined and specified\n"
|
2014-08-23 06:23:34 +02:00
|
|
|
"multiple times to select multiple objects.\n"));
|
2002-08-28 22:57:22 +02:00
|
|
|
printf(_("\nIf no input file name is supplied, then standard input is used.\n\n"));
|
2020-02-28 08:54:49 +01:00
|
|
|
printf(_("Report bugs to <%s>.\n"), PACKAGE_BUGREPORT);
|
2020-02-28 08:54:49 +01:00
|
|
|
printf(_("%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL);
|
2000-07-21 13:40:08 +02:00
|
|
|
}
|