Line data Source code
1 : /*-------------------------------------------------------------------------
2 : *
3 : * pg_restore.c
4 : * pg_restore is an utility extracting postgres database definitions
5 : * from a backup archive created by pg_dump using the archiver
6 : * interface.
7 : *
8 : * pg_restore will read the backup archive and
9 : * dump out a script that reproduces
10 : * the schema of the database in terms of
11 : * user-defined types
12 : * user-defined functions
13 : * tables
14 : * indexes
15 : * aggregates
16 : * operators
17 : * ACL - grant/revoke
18 : *
19 : * the output script is SQL that is understood by PostgreSQL
20 : *
21 : * Basic process in a restore operation is:
22 : *
23 : * Open the Archive and read the TOC.
24 : * Set flags in TOC entries, and *maybe* reorder them.
25 : * Generate script to stdout
26 : * Exit
27 : *
28 : * Copyright (c) 2000, Philip Warner
29 : * Rights are granted to use this software in any way so long
30 : * as this notice is not removed.
31 : *
32 : * The author is not responsible for loss or damages that may
33 : * result from its use.
34 : *
35 : *
36 : * IDENTIFICATION
37 : * src/bin/pg_dump/pg_restore.c
38 : *
39 : *-------------------------------------------------------------------------
40 : */
41 : #include "postgres_fe.h"
42 :
43 : #include <ctype.h>
44 : #ifdef HAVE_TERMIOS_H
45 : #include <termios.h>
46 : #endif
47 :
48 : #include "fe_utils/option_utils.h"
49 : #include "filter.h"
50 : #include "getopt_long.h"
51 : #include "parallel.h"
52 : #include "pg_backup_utils.h"
53 :
54 : static void usage(const char *progname);
55 : static void read_restore_filters(const char *filename, RestoreOptions *opts);
56 :
57 : int
58 128 : main(int argc, char **argv)
59 : {
60 : RestoreOptions *opts;
61 : int c;
62 : int exit_code;
63 128 : int numWorkers = 1;
64 : Archive *AH;
65 : char *inputFileSpec;
66 : static int disable_triggers = 0;
67 : static int enable_row_security = 0;
68 : static int if_exists = 0;
69 : static int no_data_for_failed_tables = 0;
70 : static int outputNoTableAm = 0;
71 : static int outputNoTablespaces = 0;
72 : static int use_setsessauth = 0;
73 : static int no_comments = 0;
74 : static int no_publications = 0;
75 : static int no_security_labels = 0;
76 : static int no_subscriptions = 0;
77 : static int strict_names = 0;
78 :
79 128 : struct option cmdopts[] = {
80 : {"clean", 0, NULL, 'c'},
81 : {"create", 0, NULL, 'C'},
82 : {"data-only", 0, NULL, 'a'},
83 : {"dbname", 1, NULL, 'd'},
84 : {"exit-on-error", 0, NULL, 'e'},
85 : {"exclude-schema", 1, NULL, 'N'},
86 : {"file", 1, NULL, 'f'},
87 : {"format", 1, NULL, 'F'},
88 : {"function", 1, NULL, 'P'},
89 : {"host", 1, NULL, 'h'},
90 : {"index", 1, NULL, 'I'},
91 : {"jobs", 1, NULL, 'j'},
92 : {"list", 0, NULL, 'l'},
93 : {"no-privileges", 0, NULL, 'x'},
94 : {"no-acl", 0, NULL, 'x'},
95 : {"no-owner", 0, NULL, 'O'},
96 : {"no-reconnect", 0, NULL, 'R'},
97 : {"port", 1, NULL, 'p'},
98 : {"no-password", 0, NULL, 'w'},
99 : {"password", 0, NULL, 'W'},
100 : {"schema", 1, NULL, 'n'},
101 : {"schema-only", 0, NULL, 's'},
102 : {"superuser", 1, NULL, 'S'},
103 : {"table", 1, NULL, 't'},
104 : {"trigger", 1, NULL, 'T'},
105 : {"use-list", 1, NULL, 'L'},
106 : {"username", 1, NULL, 'U'},
107 : {"verbose", 0, NULL, 'v'},
108 : {"single-transaction", 0, NULL, '1'},
109 :
110 : /*
111 : * the following options don't have an equivalent short option letter
112 : */
113 : {"disable-triggers", no_argument, &disable_triggers, 1},
114 : {"enable-row-security", no_argument, &enable_row_security, 1},
115 : {"if-exists", no_argument, &if_exists, 1},
116 : {"no-data-for-failed-tables", no_argument, &no_data_for_failed_tables, 1},
117 : {"no-table-access-method", no_argument, &outputNoTableAm, 1},
118 : {"no-tablespaces", no_argument, &outputNoTablespaces, 1},
119 : {"role", required_argument, NULL, 2},
120 : {"section", required_argument, NULL, 3},
121 : {"strict-names", no_argument, &strict_names, 1},
122 : {"transaction-size", required_argument, NULL, 5},
123 : {"use-set-session-authorization", no_argument, &use_setsessauth, 1},
124 : {"no-comments", no_argument, &no_comments, 1},
125 : {"no-publications", no_argument, &no_publications, 1},
126 : {"no-security-labels", no_argument, &no_security_labels, 1},
127 : {"no-subscriptions", no_argument, &no_subscriptions, 1},
128 : {"filter", required_argument, NULL, 4},
129 :
130 : {NULL, 0, NULL, 0}
131 : };
132 :
133 128 : pg_logging_init(argv[0]);
134 128 : pg_logging_set_level(PG_LOG_WARNING);
135 128 : set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_dump"));
136 :
137 128 : init_parallel_dump_utils();
138 :
139 128 : opts = NewRestoreOptions();
140 :
141 128 : progname = get_progname(argv[0]);
142 :
143 128 : if (argc > 1)
144 : {
145 126 : if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)
146 : {
147 2 : usage(progname);
148 2 : exit_nicely(0);
149 : }
150 124 : if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0)
151 : {
152 20 : puts("pg_restore (PostgreSQL) " PG_VERSION);
153 20 : exit_nicely(0);
154 : }
155 : }
156 :
157 458 : while ((c = getopt_long(argc, argv, "acCd:ef:F:h:I:j:lL:n:N:Op:P:RsS:t:T:U:vwWx1",
158 : cmdopts, NULL)) != -1)
159 : {
160 364 : switch (c)
161 : {
162 4 : case 'a': /* Dump data only */
163 4 : opts->dataOnly = 1;
164 4 : break;
165 14 : case 'c': /* clean (i.e., drop) schema prior to create */
166 14 : opts->dropSchema = 1;
167 14 : break;
168 24 : case 'C':
169 24 : opts->createDB = 1;
170 24 : break;
171 30 : case 'd':
172 30 : opts->cparams.dbname = pg_strdup(optarg);
173 30 : break;
174 20 : case 'e':
175 20 : opts->exit_on_error = true;
176 20 : break;
177 62 : case 'f': /* output file name */
178 62 : opts->filename = pg_strdup(optarg);
179 62 : break;
180 22 : case 'F':
181 22 : if (strlen(optarg) != 0)
182 22 : opts->formatName = pg_strdup(optarg);
183 22 : break;
184 20 : case 'h':
185 20 : if (strlen(optarg) != 0)
186 20 : opts->cparams.pghost = pg_strdup(optarg);
187 20 : break;
188 :
189 16 : case 'j': /* number of restore jobs */
190 16 : if (!option_parse_int(optarg, "-j/--jobs", 1,
191 : PG_MAX_JOBS,
192 : &numWorkers))
193 2 : exit(1);
194 14 : break;
195 :
196 8 : case 'l': /* Dump the TOC summary */
197 8 : opts->tocSummary = 1;
198 8 : break;
199 :
200 0 : case 'L': /* input TOC summary file name */
201 0 : opts->tocFile = pg_strdup(optarg);
202 0 : break;
203 :
204 0 : case 'n': /* Dump data for this schema only */
205 0 : simple_string_list_append(&opts->schemaNames, optarg);
206 0 : break;
207 :
208 0 : case 'N': /* Do not dump data for this schema */
209 0 : simple_string_list_append(&opts->schemaExcludeNames, optarg);
210 0 : break;
211 :
212 0 : case 'O':
213 0 : opts->noOwner = 1;
214 0 : break;
215 :
216 40 : case 'p':
217 40 : if (strlen(optarg) != 0)
218 40 : opts->cparams.pgport = pg_strdup(optarg);
219 40 : break;
220 0 : case 'R':
221 : /* no-op, still accepted for backwards compatibility */
222 0 : break;
223 0 : case 'P': /* Function */
224 0 : opts->selTypes = 1;
225 0 : opts->selFunction = 1;
226 0 : simple_string_list_append(&opts->functionNames, optarg);
227 0 : break;
228 0 : case 'I': /* Index */
229 0 : opts->selTypes = 1;
230 0 : opts->selIndex = 1;
231 0 : simple_string_list_append(&opts->indexNames, optarg);
232 0 : break;
233 0 : case 'T': /* Trigger */
234 0 : opts->selTypes = 1;
235 0 : opts->selTrigger = 1;
236 0 : simple_string_list_append(&opts->triggerNames, optarg);
237 0 : break;
238 2 : case 's': /* dump schema only */
239 2 : opts->schemaOnly = 1;
240 2 : break;
241 0 : case 'S': /* Superuser username */
242 0 : if (strlen(optarg) != 0)
243 0 : opts->superuser = pg_strdup(optarg);
244 0 : break;
245 0 : case 't': /* Dump specified table(s) only */
246 0 : opts->selTypes = 1;
247 0 : opts->selTable = 1;
248 0 : simple_string_list_append(&opts->tableNames, optarg);
249 0 : break;
250 :
251 24 : case 'U':
252 24 : opts->cparams.username = pg_strdup(optarg);
253 24 : break;
254 :
255 30 : case 'v': /* verbose */
256 30 : opts->verbose = 1;
257 30 : pg_logging_increase_verbosity();
258 30 : break;
259 :
260 0 : case 'w':
261 0 : opts->cparams.promptPassword = TRI_NO;
262 0 : break;
263 :
264 0 : case 'W':
265 0 : opts->cparams.promptPassword = TRI_YES;
266 0 : break;
267 :
268 0 : case 'x': /* skip ACL dump */
269 0 : opts->aclsSkip = 1;
270 0 : break;
271 :
272 4 : case '1': /* Restore data in a single transaction */
273 4 : opts->single_txn = true;
274 4 : opts->exit_on_error = true;
275 4 : break;
276 :
277 2 : case 0:
278 :
279 : /*
280 : * This covers the long options without a short equivalent.
281 : */
282 2 : break;
283 :
284 0 : case 2: /* SET ROLE */
285 0 : opts->use_role = pg_strdup(optarg);
286 0 : break;
287 :
288 0 : case 3: /* section */
289 0 : set_dump_section(optarg, &(opts->dumpSections));
290 0 : break;
291 :
292 20 : case 4: /* filter */
293 20 : read_restore_filters(optarg, opts);
294 12 : break;
295 :
296 20 : case 5: /* transaction-size */
297 20 : if (!option_parse_int(optarg, "--transaction-size",
298 : 1, INT_MAX,
299 : &opts->txn_size))
300 0 : exit(1);
301 20 : opts->exit_on_error = true;
302 20 : break;
303 :
304 2 : default:
305 : /* getopt_long already emitted a complaint */
306 2 : pg_log_error_hint("Try \"%s --help\" for more information.", progname);
307 2 : exit_nicely(1);
308 : }
309 : }
310 :
311 : /* Get file name from command line */
312 94 : if (optind < argc)
313 78 : inputFileSpec = argv[optind++];
314 : else
315 16 : inputFileSpec = NULL;
316 :
317 : /* Complain if any arguments remain */
318 94 : if (optind < argc)
319 : {
320 2 : pg_log_error("too many command-line arguments (first is \"%s\")",
321 : argv[optind]);
322 2 : pg_log_error_hint("Try \"%s --help\" for more information.", progname);
323 2 : exit_nicely(1);
324 : }
325 :
326 : /* Complain if neither -f nor -d was specified (except if dumping TOC) */
327 92 : if (!opts->cparams.dbname && !opts->filename && !opts->tocSummary)
328 2 : pg_fatal("one of -d/--dbname and -f/--file must be specified");
329 :
330 : /* Should get at most one of -d and -f, else user is confused */
331 90 : if (opts->cparams.dbname)
332 : {
333 30 : if (opts->filename)
334 : {
335 2 : pg_log_error("options -d/--dbname and -f/--file cannot be used together");
336 2 : pg_log_error_hint("Try \"%s --help\" for more information.", progname);
337 2 : exit_nicely(1);
338 : }
339 28 : opts->useDB = 1;
340 : }
341 :
342 88 : if (opts->dataOnly && opts->schemaOnly)
343 2 : pg_fatal("options -s/--schema-only and -a/--data-only cannot be used together");
344 :
345 86 : if (opts->dataOnly && opts->dropSchema)
346 2 : pg_fatal("options -c/--clean and -a/--data-only cannot be used together");
347 :
348 84 : if (opts->single_txn && opts->txn_size > 0)
349 0 : pg_fatal("options -1/--single-transaction and --transaction-size cannot be used together");
350 :
351 : /*
352 : * -C is not compatible with -1, because we can't create a database inside
353 : * a transaction block.
354 : */
355 84 : if (opts->createDB && opts->single_txn)
356 2 : pg_fatal("options -C/--create and -1/--single-transaction cannot be used together");
357 :
358 : /* Can't do single-txn mode with multiple connections */
359 82 : if (opts->single_txn && numWorkers > 1)
360 2 : pg_fatal("cannot specify both --single-transaction and multiple jobs");
361 :
362 80 : opts->disable_triggers = disable_triggers;
363 80 : opts->enable_row_security = enable_row_security;
364 80 : opts->noDataForFailedTables = no_data_for_failed_tables;
365 80 : opts->noTableAm = outputNoTableAm;
366 80 : opts->noTablespace = outputNoTablespaces;
367 80 : opts->use_setsessauth = use_setsessauth;
368 80 : opts->no_comments = no_comments;
369 80 : opts->no_publications = no_publications;
370 80 : opts->no_security_labels = no_security_labels;
371 80 : opts->no_subscriptions = no_subscriptions;
372 :
373 80 : if (if_exists && !opts->dropSchema)
374 2 : pg_fatal("option --if-exists requires option -c/--clean");
375 78 : opts->if_exists = if_exists;
376 78 : opts->strict_names = strict_names;
377 :
378 78 : if (opts->formatName)
379 : {
380 22 : switch (opts->formatName[0])
381 : {
382 16 : case 'c':
383 : case 'C':
384 16 : opts->format = archCustom;
385 16 : break;
386 :
387 2 : case 'd':
388 : case 'D':
389 2 : opts->format = archDirectory;
390 2 : break;
391 :
392 2 : case 't':
393 : case 'T':
394 2 : opts->format = archTar;
395 2 : break;
396 :
397 2 : default:
398 2 : pg_fatal("unrecognized archive format \"%s\"; please specify \"c\", \"d\", or \"t\"",
399 : opts->formatName);
400 : }
401 56 : }
402 :
403 76 : AH = OpenArchive(inputFileSpec, opts->format);
404 :
405 76 : SetArchiveOptions(AH, NULL, opts);
406 :
407 : /*
408 : * We don't have a connection yet but that doesn't matter. The connection
409 : * is initialized to NULL and if we terminate through exit_nicely() while
410 : * it's still NULL, the cleanup function will just be a no-op.
411 : */
412 76 : on_exit_close_archive(AH);
413 :
414 : /* Let the archiver know how noisy to be */
415 76 : AH->verbose = opts->verbose;
416 :
417 : /*
418 : * Whether to keep submitting sql commands as "pg_restore ... | psql ... "
419 : */
420 76 : AH->exit_on_error = opts->exit_on_error;
421 :
422 76 : if (opts->tocFile)
423 0 : SortTocFromFile(AH);
424 :
425 76 : AH->numWorkers = numWorkers;
426 :
427 76 : if (opts->tocSummary)
428 8 : PrintTOCSummary(AH);
429 : else
430 : {
431 68 : ProcessArchiveRestoreOptions(AH);
432 68 : RestoreArchive(AH);
433 : }
434 :
435 : /* done, print a summary of ignored errors */
436 76 : if (AH->n_errors)
437 0 : pg_log_warning("errors ignored on restore: %d", AH->n_errors);
438 :
439 : /* AH may be freed in CloseArchive? */
440 76 : exit_code = AH->n_errors ? 1 : 0;
441 :
442 76 : CloseArchive(AH);
443 :
444 76 : return exit_code;
445 : }
446 :
447 : static void
448 2 : usage(const char *progname)
449 : {
450 2 : printf(_("%s restores a PostgreSQL database from an archive created by pg_dump.\n\n"), progname);
451 2 : printf(_("Usage:\n"));
452 2 : printf(_(" %s [OPTION]... [FILE]\n"), progname);
453 :
454 2 : printf(_("\nGeneral options:\n"));
455 2 : printf(_(" -d, --dbname=NAME connect to database name\n"));
456 2 : printf(_(" -f, --file=FILENAME output file name (- for stdout)\n"));
457 2 : printf(_(" -F, --format=c|d|t backup file format (should be automatic)\n"));
458 2 : printf(_(" -l, --list print summarized TOC of the archive\n"));
459 2 : printf(_(" -v, --verbose verbose mode\n"));
460 2 : printf(_(" -V, --version output version information, then exit\n"));
461 2 : printf(_(" -?, --help show this help, then exit\n"));
462 :
463 2 : printf(_("\nOptions controlling the restore:\n"));
464 2 : printf(_(" -a, --data-only restore only the data, no schema\n"));
465 2 : printf(_(" -c, --clean clean (drop) database objects before recreating\n"));
466 2 : printf(_(" -C, --create create the target database\n"));
467 2 : printf(_(" -e, --exit-on-error exit on error, default is to continue\n"));
468 2 : printf(_(" -I, --index=NAME restore named index\n"));
469 2 : printf(_(" -j, --jobs=NUM use this many parallel jobs to restore\n"));
470 2 : printf(_(" -L, --use-list=FILENAME use table of contents from this file for\n"
471 : " selecting/ordering output\n"));
472 2 : printf(_(" -n, --schema=NAME restore only objects in this schema\n"));
473 2 : printf(_(" -N, --exclude-schema=NAME do not restore objects in this schema\n"));
474 2 : printf(_(" -O, --no-owner skip restoration of object ownership\n"));
475 2 : printf(_(" -P, --function=NAME(args) restore named function\n"));
476 2 : printf(_(" -s, --schema-only restore only the schema, no data\n"));
477 2 : printf(_(" -S, --superuser=NAME superuser user name to use for disabling triggers\n"));
478 2 : printf(_(" -t, --table=NAME restore named relation (table, view, etc.)\n"));
479 2 : printf(_(" -T, --trigger=NAME restore named trigger\n"));
480 2 : printf(_(" -x, --no-privileges skip restoration of access privileges (grant/revoke)\n"));
481 2 : printf(_(" -1, --single-transaction restore as a single transaction\n"));
482 2 : printf(_(" --disable-triggers disable triggers during data-only restore\n"));
483 2 : printf(_(" --enable-row-security enable row security\n"));
484 2 : printf(_(" --filter=FILENAME restore or skip objects based on expressions\n"
485 : " in FILENAME\n"));
486 2 : printf(_(" --if-exists use IF EXISTS when dropping objects\n"));
487 2 : printf(_(" --no-comments do not restore comment commands\n"));
488 2 : printf(_(" --no-data-for-failed-tables do not restore data of tables that could not be\n"
489 : " created\n"));
490 2 : printf(_(" --no-publications do not restore publications\n"));
491 2 : printf(_(" --no-security-labels do not restore security labels\n"));
492 2 : printf(_(" --no-subscriptions do not restore subscriptions\n"));
493 2 : printf(_(" --no-table-access-method do not restore table access methods\n"));
494 2 : printf(_(" --no-tablespaces do not restore tablespace assignments\n"));
495 2 : printf(_(" --section=SECTION restore named section (pre-data, data, or post-data)\n"));
496 2 : printf(_(" --strict-names require table and/or schema include patterns to\n"
497 : " match at least one entity each\n"));
498 2 : printf(_(" --transaction-size=N commit after every N objects\n"));
499 2 : printf(_(" --use-set-session-authorization\n"
500 : " use SET SESSION AUTHORIZATION commands instead of\n"
501 : " ALTER OWNER commands to set ownership\n"));
502 :
503 2 : printf(_("\nConnection options:\n"));
504 2 : printf(_(" -h, --host=HOSTNAME database server host or socket directory\n"));
505 2 : printf(_(" -p, --port=PORT database server port number\n"));
506 2 : printf(_(" -U, --username=NAME connect as specified database user\n"));
507 2 : printf(_(" -w, --no-password never prompt for password\n"));
508 2 : printf(_(" -W, --password force password prompt (should happen automatically)\n"));
509 2 : printf(_(" --role=ROLENAME do SET ROLE before restore\n"));
510 :
511 2 : printf(_("\n"
512 : "The options -I, -n, -N, -P, -t, -T, and --section can be combined and specified\n"
513 : "multiple times to select multiple objects.\n"));
514 2 : printf(_("\nIf no input file name is supplied, then standard input is used.\n\n"));
515 2 : printf(_("Report bugs to <%s>.\n"), PACKAGE_BUGREPORT);
516 2 : printf(_("%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL);
517 2 : }
518 :
519 : /*
520 : * read_restore_filters - retrieve object identifier patterns from file
521 : *
522 : * Parse the specified filter file for include and exclude patterns, and add
523 : * them to the relevant lists. If the filename is "-" then filters will be
524 : * read from STDIN rather than a file.
525 : */
526 : static void
527 20 : read_restore_filters(const char *filename, RestoreOptions *opts)
528 : {
529 : FilterStateData fstate;
530 : char *objname;
531 : FilterCommandType comtype;
532 : FilterObjectType objtype;
533 :
534 20 : filter_init(&fstate, filename, exit_nicely);
535 :
536 34 : while (filter_read_item(&fstate, &objname, &comtype, &objtype))
537 : {
538 22 : if (comtype == FILTER_COMMAND_TYPE_INCLUDE)
539 : {
540 16 : switch (objtype)
541 : {
542 0 : case FILTER_OBJECT_TYPE_NONE:
543 0 : break;
544 4 : case FILTER_OBJECT_TYPE_TABLE_DATA:
545 : case FILTER_OBJECT_TYPE_TABLE_DATA_AND_CHILDREN:
546 : case FILTER_OBJECT_TYPE_TABLE_AND_CHILDREN:
547 : case FILTER_OBJECT_TYPE_DATABASE:
548 : case FILTER_OBJECT_TYPE_EXTENSION:
549 : case FILTER_OBJECT_TYPE_FOREIGN_DATA:
550 4 : pg_log_filter_error(&fstate, _("%s filter for \"%s\" is not allowed"),
551 : "include",
552 : filter_object_type_name(objtype));
553 4 : exit_nicely(1);
554 :
555 4 : case FILTER_OBJECT_TYPE_FUNCTION:
556 4 : opts->selTypes = 1;
557 4 : opts->selFunction = 1;
558 4 : simple_string_list_append(&opts->functionNames, objname);
559 4 : break;
560 2 : case FILTER_OBJECT_TYPE_INDEX:
561 2 : opts->selTypes = 1;
562 2 : opts->selIndex = 1;
563 2 : simple_string_list_append(&opts->indexNames, objname);
564 2 : break;
565 2 : case FILTER_OBJECT_TYPE_SCHEMA:
566 2 : simple_string_list_append(&opts->schemaNames, objname);
567 2 : break;
568 2 : case FILTER_OBJECT_TYPE_TABLE:
569 2 : opts->selTypes = 1;
570 2 : opts->selTable = 1;
571 2 : simple_string_list_append(&opts->tableNames, objname);
572 2 : break;
573 2 : case FILTER_OBJECT_TYPE_TRIGGER:
574 2 : opts->selTypes = 1;
575 2 : opts->selTrigger = 1;
576 2 : simple_string_list_append(&opts->triggerNames, objname);
577 2 : break;
578 : }
579 12 : }
580 6 : else if (comtype == FILTER_COMMAND_TYPE_EXCLUDE)
581 : {
582 6 : switch (objtype)
583 : {
584 0 : case FILTER_OBJECT_TYPE_NONE:
585 0 : break;
586 4 : case FILTER_OBJECT_TYPE_TABLE_DATA:
587 : case FILTER_OBJECT_TYPE_TABLE_DATA_AND_CHILDREN:
588 : case FILTER_OBJECT_TYPE_DATABASE:
589 : case FILTER_OBJECT_TYPE_EXTENSION:
590 : case FILTER_OBJECT_TYPE_FOREIGN_DATA:
591 : case FILTER_OBJECT_TYPE_FUNCTION:
592 : case FILTER_OBJECT_TYPE_INDEX:
593 : case FILTER_OBJECT_TYPE_TABLE:
594 : case FILTER_OBJECT_TYPE_TABLE_AND_CHILDREN:
595 : case FILTER_OBJECT_TYPE_TRIGGER:
596 4 : pg_log_filter_error(&fstate, _("%s filter for \"%s\" is not allowed"),
597 : "exclude",
598 : filter_object_type_name(objtype));
599 4 : exit_nicely(1);
600 :
601 2 : case FILTER_OBJECT_TYPE_SCHEMA:
602 2 : simple_string_list_append(&opts->schemaExcludeNames, objname);
603 2 : break;
604 : }
605 2 : }
606 : else
607 : {
608 : Assert(comtype == FILTER_COMMAND_TYPE_NONE);
609 : Assert(objtype == FILTER_OBJECT_TYPE_NONE);
610 : }
611 :
612 14 : if (objname)
613 14 : free(objname);
614 : }
615 :
616 12 : filter_free(&fstate);
617 12 : }
|