PostgreSQL Source Code: src/bin/pg_dump/pg_dumpall.c File Reference (original) (raw)

146{

169

170

171

172

208

210 };

211

214 char *pguser = NULL;

216 char *use_role = NULL;

227 int c,

228 ret;

231

236

237 if (argc > 1)

238 {

239 if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)

240 {

243 }

244 if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0)

245 {

248 }

249 }

250

253 {

255

258

259 if (ret == -1)

260 pg_fatal("program \"%s\" is needed by %s but was not found in the same directory as \"%s\"",

262 else

263 pg_fatal("program \"%s\" was found by \"%s\" but was not the same version as %s",

265 }

266

269

271 {

272 switch (c)

273 {

274 case 'a':

277 break;

278

279 case 'c':

281 break;

282

283 case 'd':

285 break;

286

287 case 'E':

291 break;

292

293 case 'f':

297 break;

298 case 'F':

300 break;

301 case 'g':

303 break;

304

305 case 'h':

307 break;

308

309 case 'l':

311 break;

312

313 case 'O':

315 break;

316

317 case 'p':

319 break;

320

321 case 'r':

323 break;

324

325 case 's':

328 break;

329

330 case 'S':

333 break;

334

335 case 't':

337 break;

338

339 case 'U':

342 break;

343

344 case 'v':

348 break;

349

350 case 'w':

351 prompt_password = TRI_NO;

353 break;

354

355 case 'W':

356 prompt_password = TRI_YES;

358 break;

359

360 case 'x':

363 break;

364

365 case 0:

366 break;

367

368 case 2:

371 break;

372

373 case 3:

377 break;

378

379 case 4:

382 break;

383

384 case 5:

387 break;

388

389 case 6:

391 break;

392

393 case 7:

396 break;

397

398 case 8:

400 break;

401

402 case 9:

406 break;

407

408 default:

409

412 }

413 }

414

415

417 {

418 pg_log_error("too many command-line arguments (first is \"%s\")",

422 }

423

424

429

430

437

438

445

446

449

450

457

459 pg_fatal("option %s requires option %s",

460 "--if-exists", "-c/--clean");

461

462

464

465

466

467

468

471 {

472 pg_log_error("option %s=d|c|t requires option %s",

473 "-F/--format", "-f/--file");

476 }

477

478

480 pg_fatal("option %s can only be used with %s=plain",

481 "--restrict-key", "--format");

482

483

485 pg_fatal("options %s and %s cannot be used together in non-text dump",

486 "--clean", "-g/--globals-only");

487

488

489

490

491

492

495 else

497

498

547

548

549

550

551

553 {

555

556

558 }

560 {

562 if (OPF)

563 pg_fatal("could not open output file \"%s\": %m",

565 }

566 else

568

569

570

571

575 pg_fatal("could not generate restrict key");

577 pg_fatal("invalid restrict key");

578

579

580

581

582

583

585 {

587 prompt_password, false,

589

591 pg_fatal("could not connect to database \"%s\"", pgdb);

592 }

593 else

594 {

596 prompt_password, false,

600 prompt_password, true,

602

604 {

605 pg_log_error("could not connect to databases \"postgres\" or \"template1\"\n"

606 "Please specify an alternative database.");

609 }

610 }

611

612

613

614

617

618

619

620

622 {

624 pg_fatal("invalid client encoding \"%s\" specified",

626 }

627

628

629

630

631

632

634

635

636

637

640

641

642 if (use_role)

643 {

645

649 }

650

651

654

655

657 {

662

663

664

665

666

667

668

671

672

674

675

678

679

681

684

685

687

688

690

691

692

693

694

695

699

700

705 ARCHIVE_OPTS(.tag = "default_transaction_read_only",

706 .description = "default_transaction_read_only",

708 .createStmt = qry->data));

710

711

713

723 .createStmt = qry->data));

725

726

727 appendPQExpBuffer(qry, "SET standard_conforming_strings = 'on';\n");

731 ARCHIVE_OPTS(.tag = "standard_conforming_strings",

732 .description = "standard_conforming_strings",

734 .createStmt = qry->data));

736 }

737 else

738 {

739 fprintf(OPF, "--\n-- PostgreSQL database cluster dump\n--\n\n");

740

743

744

745

746

747

748

749

750

751

753

754

755

756

757

758

759

760

761

762 fprintf(OPF, "SET default_transaction_read_only = off;\n\n");

763

764

765 fprintf(OPF, "SET client_encoding = '%s';\n",

767 fprintf(OPF, "SET standard_conforming_strings = on;\n");

769 }

770

772 {

773

774

775

776

777

778

779

780

781

782

783

784

786 {

789

792

795 }

796

797

798

799

800

802 {

803

805

806

808

809

812 }

813

814

817 }

818

820 {

821

822

823

824

826 }

827

830

832 {

834

837 fprintf(OPF, "--\n-- PostgreSQL database cluster dump complete\n--\n\n");

838

840 {

842

843

846 }

847 }

848 else

849 {

851

854

855

858 }

859

861}

void on_exit_close_archive(Archive *AHX)

#define Assert(condition)

#define PG_TEXTDOMAIN(domain)

int find_my_exec(const char *argv0, char *retpath)

void set_pglocale_pgservice(const char *argv0, const char *app)

int find_other_exec(const char *argv0, const char *target, const char *versionstr, char *retpath)

PGconn * ConnectDatabase(const char *dbname, const char *connection_string, const char *pghost, const char *pgport, const char *pguser, trivalue prompt_password, bool fail_on_error, const char *progname, const char **connstr, int *server_version, char *password, char *override_dbname)

char * generate_restrict_key(void)

bool valid_restrict_key(const char *restrict_key)

void create_or_open_dir(const char *dirname)

void fsync_fname(const char *fname, bool isdir)

int PQclientEncoding(const PGconn *conn)

int PQsetClientEncoding(PGconn *conn, const char *encoding)

@ DATA_DIR_SYNC_METHOD_FSYNC

int getopt_long(int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex)

#define required_argument

void pg_logging_increase_verbosity(void)

void pg_logging_init(const char *argv0)

void pg_logging_set_level(enum pg_log_level new_level)

#define pg_log_error_hint(...)

#define check_mut_excl_opts(set, opt,...)

void ProcessArchiveRestoreOptions(Archive *AHX)

RestoreOptions * NewRestoreOptions(void)

#define appendStringLiteralAH(buf, str, AH)

void CloseArchive(Archive *AHX)

Archive * CreateArchive(const char *FileSpec, const ArchiveFormat fmt, const pg_compress_specification compression_spec, bool dosync, ArchiveMode mode, SetupWorkerPtrType setupDumpWorker, DataDirSyncMethod sync_method)

void SetArchiveOptions(Archive *AH, DumpOptions *dopt, RestoreOptions *ropt)

void InitDumpOptions(DumpOptions *opts)

static void dumpTimestamp(const char *msg)

static int on_conflict_do_nothing

static void dropTablespaces(PGconn *conn)

static void expand_dbname_patterns(PGconn *conn, SimpleStringList *patterns, SimpleStringList *names)

static PQExpBuffer pgdumpopts

static int statistics_only

static int no_table_access_method

static int no_unlogged_table_data

static void check_for_invalid_global_names(PGconn *conn, SimpleStringList *database_exclude_names)

static int disable_triggers

static const char * connstr

static SimpleStringList database_exclude_patterns

static void dumpTablespaces(PGconn *conn)

static void dumpRoleMembership(PGconn *conn)

static char pg_dump_bin[MAXPGPATH]

static int no_publications

static char * restrict_key

static void dumpDatabases(PGconn *conn)

static ArchiveFormat parseDumpFormat(const char *format)

static int disable_dollar_quoting

static int no_tablespaces

static int no_toast_compression

static void executeCommand(PGconn *conn, const char *query)

static void dumpRoleGUCPrivs(PGconn *conn)

static void dumpRoles(PGconn *conn)

static int use_setsessauth

static int load_via_partition_root

static int column_inserts

static void read_dumpall_filters(const char *filename, SimpleStringList *pattern)

static void dropRoles(PGconn *conn)

static void dropDBs(PGconn *conn)

static int no_subscriptions

static int with_statistics

#define PGDUMP_VERSIONSTR

PGDLLIMPORT char * optarg

#define pg_encoding_to_char

static const char * pghost

static const char * pgport

const char * get_progname(const char *argv0)

size_t strlcpy(char *dst, const char *src, size_t siz)

bool quote_all_identifiers

void setFmtEncoding(int encoding)

void appendShellString(PQExpBuffer buf, const char *str)

SimpleStringListCell * head