PostgreSQL Source Code: src/bin/pg_dump/pg_backup.h File Reference (original) (raw)

Go to the source code of this file.

Data Structures
struct _connParams
struct _restoreOptions
struct _dumpOptions
struct Archive
struct CatalogId
Macros
#define NUM_PREP_QUERIES (PREPQUERY_GETDOMAINCONSTRAINTS + 1)
#define InvalidDumpId 0
#define appendStringLiteralAH(buf, str, AH) appendStringLiteral(buf, str, (AH)->encoding, (AH)->std_strings)
Typedefs
typedef enum trivalue trivalue
typedef enum _archiveFormat ArchiveFormat
typedef enum _archiveMode ArchiveMode
typedef enum _teSection teSection
typedef struct _connParams ConnParams
typedef struct _restoreOptions RestoreOptions
typedef struct _dumpOptions DumpOptions
typedef struct Archive Archive
typedef int DumpId
typedef void(* SetupWorkerPtrType) (Archive *AH)
Enumerations
enum trivalue { TRI_DEFAULT, TRI_NO, TRI_YES, TRI_DEFAULT, TRI_NO, TRI_YES, TRI_DEFAULT, TRI_NO, TRI_YES, TRI_DEFAULT, TRI_NO, TRI_YES }
enum _archiveFormat { archUnknown = 0 , archCustom = 1 , archTar = 3 , archNull = 4 , archDirectory = 5 }
enum _archiveMode { archModeAppend, archModeWrite, archModeRead }
enum _teSection { SECTION_NONE = 1 , SECTION_PRE_DATA, SECTION_DATA, SECTION_POST_DATA }
enum _dumpPreparedQueries { PREPQUERY_DUMPAGG, PREPQUERY_DUMPBASETYPE, PREPQUERY_DUMPCOMPOSITETYPE, PREPQUERY_DUMPDOMAIN, PREPQUERY_DUMPENUMTYPE, PREPQUERY_DUMPFUNC, PREPQUERY_DUMPOPR, PREPQUERY_DUMPRANGETYPE, PREPQUERY_DUMPTABLEATTACH, PREPQUERY_GETATTRIBUTESTATS, PREPQUERY_GETCOLUMNACLS, PREPQUERY_GETDOMAINCONSTRAINTS }
Functions
void ConnectDatabaseAhx (Archive *AHX, const ConnParams *cparams, bool isReconnect)
void DisconnectDatabase (Archive *AHX)
PGconn * GetConnection (Archive *AHX)
void WriteData (Archive *AHX, const void *data, size_t dLen)
int StartLO (Archive *AHX, Oid oid)
int EndLO (Archive *AHX, Oid oid)
void CloseArchive (Archive *AHX)
void SetArchiveOptions (Archive *AH, DumpOptions *dopt, RestoreOptions *ropt)
void ProcessArchiveRestoreOptions (Archive *AHX)
void RestoreArchive (Archive *AHX, bool append_data)
Archive * OpenArchive (const char *FileSpec, const ArchiveFormat fmt)
Archive * CreateArchive (const char *FileSpec, const ArchiveFormat fmt, const pg_compress_specification compression_spec, bool dosync, ArchiveMode mode, SetupWorkerPtrType setupDumpWorker, DataDirSyncMethod sync_method)
void PrintTOCSummary (Archive *AHX)
RestoreOptions * NewRestoreOptions (void)
DumpOptions * NewDumpOptions (void)
void InitDumpOptions (DumpOptions *opts)
DumpOptions * dumpOptionsFromRestoreOptions (RestoreOptions *ropt)
void SortTocFromFile (Archive *AHX)
void archputs (const char *s, Archive *AH)
int archprintf (Archive *AH, const char *fmt,...) pg_attribute_printf(2

appendStringLiteralAH

InvalidDumpId

NUM_PREP_QUERIES

Archive

ArchiveFormat

ArchiveMode

ConnParams

DumpId

DumpOptions

RestoreOptions

SetupWorkerPtrType

typedef void(* SetupWorkerPtrType) (Archive *AH)

teSection

trivalue

_archiveFormat

Enumerator
archUnknown
archCustom
archTar
archNull
archDirectory

Definition at line 39 of file pg_backup.h.

40{

enum _archiveFormat ArchiveFormat

_archiveMode

Enumerator
archModeAppend
archModeWrite
archModeRead

Definition at line 48 of file pg_backup.h.

49{

enum _archiveMode ArchiveMode

_dumpPreparedQueries

Enumerator
PREPQUERY_DUMPAGG
PREPQUERY_DUMPBASETYPE
PREPQUERY_DUMPCOMPOSITETYPE
PREPQUERY_DUMPDOMAIN
PREPQUERY_DUMPENUMTYPE
PREPQUERY_DUMPFUNC
PREPQUERY_DUMPOPR
PREPQUERY_DUMPRANGETYPE
PREPQUERY_DUMPTABLEATTACH
PREPQUERY_GETATTRIBUTESTATS
PREPQUERY_GETCOLUMNACLS
PREPQUERY_GETDOMAINCONSTRAINTS

Definition at line 64 of file pg_backup.h.

65{

78};

@ PREPQUERY_DUMPTABLEATTACH

@ PREPQUERY_DUMPRANGETYPE

@ PREPQUERY_GETATTRIBUTESTATS

@ PREPQUERY_DUMPCOMPOSITETYPE

@ PREPQUERY_GETCOLUMNACLS

@ PREPQUERY_GETDOMAINCONSTRAINTS

_teSection

Enumerator
SECTION_NONE
SECTION_PRE_DATA
SECTION_DATA
SECTION_POST_DATA

Definition at line 55 of file pg_backup.h.

trivalue

Enumerator
TRI_DEFAULT
TRI_NO
TRI_YES
TRI_DEFAULT
TRI_NO
TRI_YES
TRI_DEFAULT
TRI_NO
TRI_YES
TRI_DEFAULT
TRI_NO
TRI_YES

Definition at line 32 of file pg_backup.h.

archprintf()

int archprintf ( Archive * AH,
const char * fmt,
...
)

archputs()

void archputs ( const char * s,
Archive * AH
)

CloseArchive()

ConnectDatabaseAhx()

void ConnectDatabaseAhx ( Archive * AHX,
const ConnParams * cparams,
bool isReconnect
)

Definition at line 109 of file pg_backup_db.c.

112{

116

118 pg_fatal("already connected to a database");

119

120

122

124

127

130 prompt_password, true,

132

133

136

139

140

141

142

143

145 {

148 }

149

150

152

154

155

157}

void set_archive_cancel_info(ArchiveHandle *AH, PGconn *conn)

#define ALWAYS_SECURE_SEARCH_PATH_SQL

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)

int PQconnectionUsedPassword(const PGconn *conn)

char * PQpass(const PGconn *conn)

PQnoticeProcessor PQsetNoticeProcessor(PGconn *conn, PQnoticeProcessor proc, void *arg)

void PQclear(PGresult *res)

char * pg_strdup(const char *in)

PGresult * ExecuteSqlQueryForSingleRow(Archive *fout, const char *query)

static void _check_database_version(ArchiveHandle *AH)

static void notice_processor(void *arg, const char *message)

char * simple_prompt(const char *prompt, bool echo)

References _check_database_version(), ALWAYS_SECURE_SEARCH_PATH_SQL, ConnectDatabase(), _archiveHandle::connection, _connParams::dbname, ExecuteSqlQueryForSingleRow(), free, notice_processor(), _connParams::override_dbname, password, pg_fatal, pg_strdup(), _connParams::pghost, _connParams::pgport, PQclear(), PQconnectionUsedPassword(), PQpass(), PQsetNoticeProcessor(), progname, _connParams::promptPassword, _archiveHandle::savedPassword, set_archive_cancel_info(), simple_prompt(), TRI_NO, TRI_YES, and _connParams::username.

Referenced by CloneArchive(), main(), ReconnectToServer(), restore_toc_entries_postfork(), and RestoreArchive().

CreateArchive()

Definition at line 229 of file pg_backup_archiver.c.

235{

238

240}

static DataDirSyncMethod sync_method

static ArchiveHandle * _allocAH(const char *FileSpec, const ArchiveFormat fmt, const pg_compress_specification compression_spec, bool dosync, ArchiveMode mode, SetupWorkerPtrType setupWorkerPtr, DataDirSyncMethod sync_method)

static PgChecksumMode mode

static void setupDumpWorker(Archive *AH)

References _allocAH(), dosync, mode, setupDumpWorker(), and sync_method.

Referenced by main().

DisconnectDatabase()

void DisconnectDatabase ( Archive * AHX )

Definition at line 164 of file pg_backup_db.c.

165{

167 char errbuf[1];

168

170 return;

171

173 {

174

175

176

177

178

181

182

183

184

186 }

187

190}

int PQcancel(PGcancel *cancel, char *errbuf, int errbufsize)

PGTransactionStatusType PQtransactionStatus(const PGconn *conn)

void PQfinish(PGconn *conn)

PGcancel *volatile connCancel

References _archiveHandle::connCancel, _archiveHandle::connection, PQcancel(), PQfinish(), PQTRANS_ACTIVE, PQtransactionStatus(), and set_archive_cancel_info().

Referenced by archive_close_connection(), restore_toc_entries_prefork(), RestoreArchive(), and RunWorker().

dumpOptionsFromRestoreOptions()

Definition at line 163 of file pg_backup_archiver.c.

164{

166

167

199

200 return dopt;

201}

DumpOptions * NewDumpOptions(void)

int disable_dollar_quoting

const char * lockWaitTimeout

int disable_dollar_quoting

const char * lockWaitTimeout

References _restoreOptions::aclsSkip, _dumpOptions::aclsSkip, _restoreOptions::column_inserts, _dumpOptions::column_inserts, _restoreOptions::cparams, _dumpOptions::cparams, _restoreOptions::createDB, _connParams::dbname, _restoreOptions::disable_dollar_quoting, _dumpOptions::disable_dollar_quoting, _restoreOptions::disable_triggers, _dumpOptions::disable_triggers, _restoreOptions::dropSchema, _restoreOptions::dump_inserts, _dumpOptions::dump_inserts, _restoreOptions::dumpData, _dumpOptions::dumpData, _restoreOptions::dumpSchema, _dumpOptions::dumpSchema, _restoreOptions::dumpSections, _dumpOptions::dumpSections, _restoreOptions::dumpStatistics, _dumpOptions::dumpStatistics, _restoreOptions::enable_row_security, _dumpOptions::enable_row_security, _restoreOptions::if_exists, _dumpOptions::if_exists, _restoreOptions::include_everything, _dumpOptions::include_everything, _restoreOptions::lockWaitTimeout, _dumpOptions::lockWaitTimeout, NewDumpOptions(), _restoreOptions::no_comments, _dumpOptions::no_comments, _restoreOptions::no_policies, _dumpOptions::no_policies, _restoreOptions::no_publications, _dumpOptions::no_publications, _restoreOptions::no_security_labels, _dumpOptions::no_security_labels, _restoreOptions::no_subscriptions, _dumpOptions::no_subscriptions, _restoreOptions::noOwner, _restoreOptions::noTableAm, _restoreOptions::noTablespace, _dumpOptions::outputClean, _dumpOptions::outputCreateDB, _dumpOptions::outputNoOwner, _dumpOptions::outputNoTableAm, _dumpOptions::outputNoTablespaces, _dumpOptions::outputSuperuser, pg_strdup(), _connParams::pghost, _connParams::pgport, _connParams::promptPassword, _restoreOptions::sequence_data, _dumpOptions::sequence_data, _restoreOptions::superuser, _restoreOptions::use_setsessauth, _dumpOptions::use_setsessauth, and _connParams::username.

Referenced by SetArchiveOptions().

EndLO()

GetConnection()

InitDumpOptions()

NewDumpOptions()

NewRestoreOptions()

OpenArchive()

PrintTOCSummary()

void PrintTOCSummary ( Archive * AHX )

Definition at line 1287 of file pg_backup_archiver.c.

1288{

1295 const char *fmtName;

1296 char stamp_str[64];

1297

1298

1300

1304

1307 strcpy(stamp_str, "[unknown]");

1308

1309 ahprintf(AH, ";\n; Archive created at %s\n", stamp_str);

1310 ahprintf(AH, "; dbname: %s\n; TOC Entries: %d\n; Compression: %s\n",

1314

1316 {

1318 fmtName = "CUSTOM";

1319 break;

1321 fmtName = "DIRECTORY";

1322 break;

1324 fmtName = "TAR";

1325 break;

1326 default:

1327 fmtName = "UNKNOWN";

1328 }

1329

1330 ahprintf(AH, "; Dump Version: %d.%d-%d\n",

1332 ahprintf(AH, "; Format: %s\n", fmtName);

1333 ahprintf(AH, "; Integer: %d bytes\n", (int) AH->intSize);

1334 ahprintf(AH, "; Offset: %d bytes\n", (int) AH->offSize);

1336 ahprintf(AH, "; Dumped from database version: %s\n",

1339 ahprintf(AH, "; Dumped by pg_dump version: %s\n",

1341

1342 ahprintf(AH, ";\n;\n; Selected TOC Entries:\n;\n");

1343

1345 for (te = AH->toc->next; te != AH->toc; te = te->next)

1346 {

1347

1349 curSection = te->section;

1351

1354 {

1355 char *sanitized_name;

1356 char *sanitized_schema;

1357 char *sanitized_owner;

1358

1359

1360

1362 sanitized_schema = sanitize_line(te->namespace, true);

1364

1367 te->desc, sanitized_schema, sanitized_name,

1368 sanitized_owner);

1369

1370 free(sanitized_name);

1371 free(sanitized_schema);

1372 free(sanitized_owner);

1373 }

1375 {

1376 int i;

1377

1378 ahprintf(AH, ";\tdepends on:");

1379 for (i = 0; i < te->nDeps; i++)

1382 }

1383 }

1384

1385

1388

1391}

const char * get_compress_algorithm_name(pg_compress_algorithm algorithm)

#define PGDUMP_STRFTIME_FMT

static CompressFileHandle * SaveOutput(ArchiveHandle *AH)

static void StrictNamesCheck(RestoreOptions *ropt)

int ahprintf(ArchiveHandle *AH, const char *fmt,...)

static void RestoreOutput(ArchiveHandle *AH, CompressFileHandle *savedOutput)

static char * sanitize_line(const char *str, bool want_hyphen)

static void SetOutput(ArchiveHandle *AH, const char *filename, const pg_compress_specification compression_spec, bool append_data)

static int _tocEntryRequired(TocEntry *te, teSection curSection, ArchiveHandle *AH)

#define ARCHIVE_MAJOR(version)

#define ARCHIVE_MINOR(version)

#define ARCHIVE_REV(version)

char * archiveDumpVersion

pg_compress_specification compression_spec

char * archiveRemoteVersion

References _tocEntryRequired(), ahprintf(), pg_compress_specification::algorithm, archCustom, _archiveHandle::archdbname, archDirectory, ARCHIVE_MAJOR, ARCHIVE_MINOR, ARCHIVE_REV, _archiveHandle::archiveDumpVersion, _archiveHandle::archiveRemoteVersion, archTar, _tocEntry::catalogId, _archiveHandle::compression_spec, _archiveHandle::createDate, _tocEntry::dependencies, _tocEntry::desc, _tocEntry::dumpId, _restoreOptions::filename, _archiveHandle::format, free, get_compress_algorithm_name(), i, _archiveHandle::intSize, _tocEntry::nDeps, _tocEntry::next, _archiveHandle::offSize, CatalogId::oid, _tocEntry::owner, PG_COMPRESSION_NONE, PGDUMP_STRFTIME_FMT, _archiveHandle::public, REQ_DATA, REQ_SCHEMA, REQ_STATS, _tocEntry::reqs, RestoreOutput(), Archive::ropt, sanitize_line(), SaveOutput(), _tocEntry::section, SECTION_NONE, SECTION_PRE_DATA, SetOutput(), _restoreOptions::strict_names, StrictNamesCheck(), CatalogId::tableoid, _tocEntry::tag, _archiveHandle::toc, _archiveHandle::tocCount, _restoreOptions::verbose, and _archiveHandle::version.

Referenced by restore_one_database().

ProcessArchiveRestoreOptions()

void ProcessArchiveRestoreOptions ( Archive * AHX )

Definition at line 287 of file pg_backup_archiver.c.

288{

293

294

296 for (te = AH->toc->next; te != AH->toc; te = te->next)

297 {

298

299

300

301

302

303

305 {

307 {

309

310 break;

313 pg_log_warning("archive items not in correct section order");

314 break;

317 pg_log_warning("archive items not in correct section order");

318 break;

320

321 break;

322 default:

323 pg_fatal("unexpected section code %d",

325 break;

326 }

327 }

328

330 curSection = te->section;

331

333 }

334

335

338}

#define pg_log_warning(...)

References _tocEntryRequired(), archModeRead, _archiveHandle::mode, _tocEntry::next, pg_fatal, pg_log_warning, _archiveHandle::public, _tocEntry::reqs, Archive::ropt, _tocEntry::section, SECTION_DATA, SECTION_NONE, SECTION_POST_DATA, SECTION_PRE_DATA, _restoreOptions::strict_names, StrictNamesCheck(), and _archiveHandle::toc.

Referenced by main(), and restore_one_database().

RestoreArchive()

void RestoreArchive ( Archive * AHX,
bool append_data
)

Definition at line 347 of file pg_backup_archiver.c.

348{

351 bool parallel_mode;

354

356

357

358

359

361 if (parallel_mode)

362 {

363

365 pg_fatal("parallel restore is not supported with this archive file format");

366

367

369 pg_fatal("parallel restore is not supported with archives made by pre-8.0 pg_dump");

370

371

372

373

374

376 }

377

378

379

380

382 {

383 for (te = AH->toc->next; te != AH->toc; te = te->next)

384 {

386 {

388

390 pg_fatal("cannot restore from compressed archive (%s)",

392 else

393 break;

394 }

395 }

396 }

397

398

399

400

401

404

405

406

407

409 {

410 pg_log_info("connecting to database for restore");

412 pg_fatal("direct database connections are not supported in pre-1.3 archives");

413

414

415

416

417

418

421

423

424

425

426

427

429 }

430

431

432

433

434

435

436

437

438

439

441 {

442 bool no_schema_found = true;

443

444 for (te = AH->toc->next; te != AH->toc; te = te->next)

445 {

447 {

448 no_schema_found = false;

449 break;

450 }

451 }

452 if (no_schema_found)

453 {

455 pg_log_info("implied no-schema restore");

456 }

457 }

458

459

460

461

465

466 ahprintf(AH, "--\n-- PostgreSQL database dump\n--\n\n");

467

469 ahprintf(AH, "-- Dumped from database version %s\n",

472 ahprintf(AH, "-- Dumped by pg_dump version %s\n",

474

476

479

481 {

484 else

486 }

487

488

489

490

492

494

495

496

497

499 {

500 for (te = AH->toc->prev; te != AH->toc; te = te->prev)

501 {

503

504

505

506

507

508

509

510

512 {

513 if (strcmp(te->desc, "DATABASE") != 0 &&

514 strcmp(te->desc, "DATABASE PROPERTIES") != 0)

515 continue;

516 }

517

518

520 {

521 bool not_allowed_in_txn = false;

522

524

525

526

527

528

529

531 {

532 if (strcmp(te->desc, "DATABASE") == 0 ||

533 strcmp(te->desc, "DATABASE PROPERTIES") == 0)

534 {

535 not_allowed_in_txn = true;

538 else

540 }

541 }

542

543

546

547

548

549

550

551

552 if (strcmp(te->desc, "BLOB METADATA") == 0)

553 {

554

557 "SELECT pg_catalog.lo_unlink(oid) "

558 "FROM pg_catalog.pg_largeobject_metadata "

559 "WHERE oid = '", "'");

560 else

562 "SELECT pg_catalog.lo_unlink('",

563 "')");

564 }

565 else if (*te->dropStmt != '\0')

566 {

568 strncmp(te->dropStmt, "--", 2) == 0)

569 {

570

571

572

573

574

576 }

577 else

578 {

579

580

581

582

583

584

585

586 if (strcmp(te->desc, "BLOB") == 0)

587 {

589 }

590 else

591 {

593 char *dropStmtOrig = dropStmt;

595

596

597

598

599

600 if (strncmp(dropStmt, "ALTER TABLE", 11) == 0)

601 {

603 "ALTER TABLE IF EXISTS");

604 dropStmt = dropStmt + 11;

605 }

606

607

608

609

610

611

612

613

614

615

616

617

618

619

620

621

622

623

624

625

626 if (strcmp(te->desc, "DEFAULT") == 0 ||

627 strcmp(te->desc, "DATABASE PROPERTIES") == 0 ||

628 strncmp(dropStmt, "CREATE OR REPLACE VIEW", 22) == 0)

630 else

631 {

632 char buffer[40];

633 char *mark;

634

635 if (strcmp(te->desc, "CONSTRAINT") == 0 ||

636 strcmp(te->desc, "CHECK CONSTRAINT") == 0 ||

637 strcmp(te->desc, "FK CONSTRAINT") == 0)

638 strcpy(buffer, "DROP CONSTRAINT");

639 else

640 snprintf(buffer, sizeof(buffer), "DROP %s",

642

643 mark = strstr(dropStmt, buffer);

644

645 if (mark)

646 {

647 *mark = '\0';

649 dropStmt, buffer,

650 mark + strlen(buffer));

651 }

652 else

653 {

654

655 pg_log_warning("could not find where to insert IF EXISTS in statement \"%s\"",

656 dropStmtOrig);

658 }

659 }

660

662

665 }

666 }

667 }

668

669

670

671

672

674 {

675 if (not_allowed_in_txn)

676 {

679 else

682 }

684 {

686 {

689 }

690 else

691 ahprintf(AH, "COMMIT;\nBEGIN;\n");

693 }

694 }

695 }

696 }

697

698

699

700

701

702

703

704

705

706

707

708

709

712 }

713

714 if (parallel_mode)

715 {

716

717

718

721

722

725

727

728

731

732

736

737

740 }

741 else

742 {

743

744

745

746

747

748 bool haveACL = false;

749 bool havePostACL = false;

750

751 for (te = AH->toc->next; te != AH->toc; te = te->next)

752 {

754 continue;

755

757 {

760 break;

762 haveACL = true;

763 break;

765 havePostACL = true;

766 break;

767 }

768 }

769

770 if (haveACL)

771 {

772 for (te = AH->toc->next; te != AH->toc; te = te->next)

773 {

777 }

778 }

779

780 if (havePostACL)

781 {

782 for (te = AH->toc->next; te != AH->toc; te = te->next)

783 {

787 }

788 }

789 }

790

791

792

793

794

796 {

799 else

801 }

802

805

806 ahprintf(AH, "--\n-- PostgreSQL database dump complete\n--\n\n");

807

808

809

810

812

815

818}

void ParallelBackupEnd(ArchiveHandle *AH, ParallelState *pstate)

ParallelState * ParallelBackupStart(ArchiveHandle *AH)

char * supports_compression(const pg_compress_specification compression_spec)

int errmsg(const char *fmt,...)

Assert(PointerIsAligned(start, uint64))

static size_t append_data(char *buf, size_t size, size_t nmemb, void *userdata)

void ConnectDatabaseAhx(Archive *AHX, const ConnParams *cparams, bool isReconnect)

void DisconnectDatabase(Archive *AHX)

static void _becomeOwner(ArchiveHandle *AH, TocEntry *te)

static int restore_toc_entry(ArchiveHandle *AH, TocEntry *te, bool is_parallel)

static void buildTocEntryArrays(ArchiveHandle *AH)

static RestorePass _tocEntryRestorePass(TocEntry *te)

static void pending_list_header_init(TocEntry *l)

static void restore_toc_entries_parallel(ArchiveHandle *AH, ParallelState *pstate, TocEntry *pending_list)

static void dumpTimestamp(ArchiveHandle *AH, const char *msg, time_t tim)

static void _selectOutputSchema(ArchiveHandle *AH, const char *schemaName)

static void restore_toc_entries_prefork(ArchiveHandle *AH, TocEntry *pending_list)

static void restore_toc_entries_postfork(ArchiveHandle *AH, TocEntry *pending_list)

static void _doSetFixedOutputState(ArchiveHandle *AH)

void DropLOIfExists(ArchiveHandle *AH, Oid oid)

void IssueCommandPerBlob(ArchiveHandle *AH, TocEntry *te, const char *cmdBegin, const char *cmdEnd)

PQExpBuffer createPQExpBuffer(void)

void appendPQExpBuffer(PQExpBuffer str, const char *fmt,...)

void destroyPQExpBuffer(PQExpBuffer str)

void appendPQExpBufferStr(PQExpBuffer str, const char *data)

struct _tocEntry * currentTE

struct _tocEntry ** tocsByDumpId

PrepParallelRestorePtrType PrepParallelRestorePtr

PrintTocDataPtrType PrintTocDataPtr

pg_compress_specification compression_spec

static void StartTransaction(void)

static void CommitTransaction(void)

References _becomeOwner(), _doSetFixedOutputState(), _selectOutputSchema(), _tocEntryRestorePass(), ahprintf(), pg_compress_specification::algorithm, append_data(), appendPQExpBuffer(), appendPQExpBufferStr(), _archiveHandle::archiveDumpVersion, _archiveHandle::archiveRemoteVersion, Assert(), buildTocEntryArrays(), _tocEntry::catalogId, _archiveHandle::ClonePtr, CommitTransaction(), _restoreOptions::compression_spec, _archiveHandle::compression_spec, ConnectDatabaseAhx(), _archiveHandle::connection, _restoreOptions::cparams, _archiveHandle::createDate, _restoreOptions::createDB, createPQExpBuffer(), _archiveHandle::currentTE, _archiveHandle::currSchema, PQExpBufferData::data, _tocEntry::desc, destroyPQExpBuffer(), DisconnectDatabase(), DropLOIfExists(), _restoreOptions::dropSchema, _tocEntry::dropStmt, _restoreOptions::dumpSchema, dumpTimestamp(), errmsg(), _restoreOptions::filename, free, _tocEntry::hadDumper, _restoreOptions::if_exists, IssueCommandPerBlob(), K_VERS_1_3, K_VERS_1_8, Archive::maxRemoteVersion, Archive::minRemoteVersion, _tocEntry::next, _archiveHandle::noTocComments, Archive::numWorkers, CatalogId::oid, ParallelBackupEnd(), ParallelBackupStart(), pending_list_header_init(), PG_COMPRESSION_NONE, pg_fatal, pg_free(), pg_log_info, pg_log_warning, pg_strdup(), _archiveHandle::PrepParallelRestorePtr, _tocEntry::prev, _archiveHandle::PrintTocDataPtr, _archiveHandle::public, _archiveHandle::ReopenPtr, REQ_DATA, REQ_SCHEMA, REQ_STATS, _tocEntry::reqs, RESTORE_PASS_ACL, RESTORE_PASS_MAIN, RESTORE_PASS_POST_ACL, restore_toc_entries_parallel(), restore_toc_entries_postfork(), restore_toc_entries_prefork(), restore_toc_entry(), RestoreOutput(), Archive::ropt, SaveOutput(), SetOutput(), _restoreOptions::single_txn, snprintf, _archiveHandle::stage, STAGE_FINALIZING, STAGE_INITIALIZING, STAGE_PROCESSING, StartTransaction(), supports_compression(), _tocEntry::tag, _archiveHandle::toc, _archiveHandle::tocsByDumpId, _restoreOptions::txn_size, _archiveHandle::txnCount, _restoreOptions::useDB, Archive::verbose, and _archiveHandle::version.

Referenced by _CloseArchive(), main(), and restore_one_database().

SetArchiveOptions()

SortTocFromFile()

void SortTocFromFile ( Archive * AHX )

Definition at line 1554 of file pg_backup_archiver.c.

1555{

1558 FILE *fh;

1560

1561

1563

1564

1566 if (!fh)

1567 pg_fatal("could not open TOC file \"%s\": %m", ropt->tocFile);

1568

1570

1572 {

1573 char *cmnt;

1574 char *endptr;

1577

1578

1579 cmnt = strchr(linebuf.data, ';');

1580 if (cmnt != NULL)

1581 {

1582 cmnt[0] = '\0';

1583 linebuf.len = cmnt - linebuf.data;

1584 }

1585

1586

1587 if (strspn(linebuf.data, " \t\r\n") == linebuf.len)

1588 continue;

1589

1590

1591 id = strtol(linebuf.data, &endptr, 10);

1592 if (endptr == linebuf.data || id <= 0 || id > AH->maxDumpId ||

1594 {

1596 continue;

1597 }

1598

1599

1601 if (!te)

1602 pg_fatal("could not find entry for ID %d",

1603 id);

1604

1605

1606 ropt->idWanted[id - 1] = true;

1607

1608

1609

1610

1611

1612

1613

1614

1615

1616

1617

1618

1620 }

1621

1623

1624 if (fclose(fh) != 0)

1625 pg_fatal("could not close TOC file: %m");

1626}

static void _moveBefore(TocEntry *pos, TocEntry *te)

TocEntry * getTocEntryByDumpId(ArchiveHandle *AH, DumpId id)

bool pg_get_line_buf(FILE *stream, StringInfo buf)

void initStringInfo(StringInfo str)

References _moveBefore(), StringInfoData::data, getTocEntryByDumpId(), _restoreOptions::idWanted, initStringInfo(), StringInfoData::len, _archiveHandle::maxDumpId, PG_BINARY_R, pg_fatal, pg_free(), pg_get_line_buf(), pg_log_warning, pg_malloc0(), _archiveHandle::public, Archive::ropt, _archiveHandle::toc, and _restoreOptions::tocFile.

Referenced by restore_one_database().

StartLO()

WriteData()

void WriteData ( Archive * AHX,
const void * data,
size_t dLen
)