Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 3 additions & 18 deletions src/bin/pg_dump/pg_backup.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ typedef enum _teSection
SECTION_POST_DATA /* stuff to be processed after data */
} teSection;

<<<<<<< HEAD
/* We need one enum entry per prepared query in pg_dump */
enum _dumpPreparedQueries
{
Expand All @@ -79,8 +78,6 @@ enum _dumpPreparedQueries
NUM_PREP_QUERIES /* must be last */
};

=======
>>>>>>> f81e97d0475cd4bc597adc23b665bd84fbf79a0d
/* Parameters needed by ConnectDatabase; same for dump and restore */
typedef struct _connParams
{
Expand Down Expand Up @@ -204,14 +201,11 @@ typedef struct _dumpOptions

int sequence_data; /* dump sequence data even in schema-only mode */
int do_nothing;
<<<<<<< HEAD
int coll_unknown;

/* GPDB */
bool dumpGpPolicy;
bool isGPbackend;
=======
int coll_unknown;
>>>>>>> f81e97d0475cd4bc597adc23b665bd84fbf79a0d
} DumpOptions;

/*
Expand Down Expand Up @@ -294,19 +288,10 @@ typedef void (*SetupWorkerPtrType) (Archive *AH);
* Main archiver interface.
*/

<<<<<<< HEAD
extern void ConnectDatabase(Archive *AH,
const char *dbname,
const char *pghost,
const char *pgport,
const char *username,
trivalue prompt_password,
bool binary_upgrade);
=======
extern void ConnectDatabase(Archive *AHX,
const ConnParams *cparams,
bool isReconnect);
>>>>>>> f81e97d0475cd4bc597adc23b665bd84fbf79a0d
bool isReconnect,
bool binary_upgrade);
extern void DisconnectDatabase(Archive *AHX);
extern PGconn *GetConnection(Archive *AHX);

Expand Down
66 changes: 4 additions & 62 deletions src/bin/pg_dump/pg_backup_archiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,14 +416,7 @@ RestoreArchive(Archive *AHX)
AHX->minRemoteVersion = 0;
AHX->maxRemoteVersion = 9999999;

<<<<<<< HEAD
ConnectDatabase(AHX, ropt->dbname,
ropt->pghost, ropt->pgport, ropt->username,
ropt->promptPassword,
false);
=======
ConnectDatabase(AHX, &ropt->cparams, false);
>>>>>>> f81e97d0475cd4bc597adc23b665bd84fbf79a0d
ConnectDatabase(AHX, &ropt->cparams, false, false);

/*
* If we're talking to the DB directly, don't send comments since they
Expand Down Expand Up @@ -4241,14 +4234,7 @@ restore_toc_entries_postfork(ArchiveHandle *AH, TocEntry *pending_list)
/*
* Now reconnect the single parent connection.
*/
<<<<<<< HEAD
ConnectDatabase((Archive *) AH, ropt->dbname,
ropt->pghost, ropt->pgport, ropt->username,
ropt->promptPassword,
false);
=======
ConnectDatabase((Archive *) AH, &ropt->cparams, true);
>>>>>>> f81e97d0475cd4bc597adc23b665bd84fbf79a0d
ConnectDatabase((Archive *) AH, &ropt->cparams, true, false);

/* re-establish fixed state */
_doSetFixedOutputState(AH);
Expand Down Expand Up @@ -4913,57 +4899,13 @@ CloneArchive(ArchiveHandle *AH)
* Connect our new clone object to the database, using the same connection
* parameters used for the original connection.
*/
ConnectDatabase((Archive *) clone, &clone->public.ropt->cparams, true);
ConnectDatabase((Archive *) clone, &clone->public.ropt->cparams, true,
false);

/* re-establish fixed state */
if (AH->mode == archModeRead)
<<<<<<< HEAD
{
RestoreOptions *ropt = AH->public.ropt;

Assert(AH->connection == NULL);

/* this also sets clone->connection */
ConnectDatabase((Archive *) clone, ropt->dbname,
ropt->pghost, ropt->pgport, ropt->username,
ropt->promptPassword, false);

/* re-establish fixed state */
_doSetFixedOutputState(clone);
}
else
{
PQExpBufferData connstr;
char *pghost;
char *pgport;
char *username;

Assert(AH->connection != NULL);

/*
* Even though we are technically accessing the parent's database
* object here, these functions are fine to be called like that
* because all just return a pointer and do not actually send/receive
* any data to/from the database.
*/
initPQExpBuffer(&connstr);
appendPQExpBufferStr(&connstr, "dbname=");
appendConnStrVal(&connstr, PQdb(AH->connection));
pghost = PQhost(AH->connection);
pgport = PQport(AH->connection);
username = PQuser(AH->connection);

/* this also sets clone->connection */
ConnectDatabase((Archive *) clone, connstr.data,
pghost, pgport, username, TRI_NO, false);

termPQExpBuffer(&connstr);
/* setupDumpWorker will fix up connection state */
}
=======
_doSetFixedOutputState(clone);
/* in write case, setupDumpWorker will fix up connection state */
>>>>>>> f81e97d0475cd4bc597adc23b665bd84fbf79a0d

/* Let the format-specific code have a chance too */
clone->ClonePtr(clone);
Expand Down
50 changes: 9 additions & 41 deletions src/bin/pg_dump/pg_backup_db.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,7 @@
#include "pg_backup_utils.h"

static void _check_database_version(ArchiveHandle *AH);
<<<<<<< HEAD
static PGconn *_connectDB(ArchiveHandle *AH, const char *newdbname, const char *newUser);
static void notice_processor(void *arg pg_attribute_unused(), const char *message);
=======
static void notice_processor(void *arg, const char *message);
>>>>>>> f81e97d0475cd4bc597adc23b665bd84fbf79a0d

static void
_check_database_version(ArchiveHandle *AH)
Expand Down Expand Up @@ -99,7 +94,7 @@ ReconnectToServer(ArchiveHandle *AH, const char *dbname)
*/
AH->connection = NULL; /* dodge error check in ConnectDatabase */

ConnectDatabase((Archive *) AH, &ropt->cparams, true);
ConnectDatabase((Archive *) AH, &ropt->cparams, true, false);

PQfinish(oldConn);
}
Expand All @@ -117,17 +112,9 @@ ReconnectToServer(ArchiveHandle *AH, const char *dbname)
*/
void
ConnectDatabase(Archive *AHX,
<<<<<<< HEAD
const char *dbname,
const char *pghost,
const char *pgport,
const char *username,
trivalue prompt_password,
bool binary_upgrade)
=======
const ConnParams *cparams,
bool isReconnect)
>>>>>>> f81e97d0475cd4bc597adc23b665bd84fbf79a0d
bool isReconnect,
bool binary_upgrade)
{
ArchiveHandle *AH = (ArchiveHandle *) AHX;
trivalue prompt_password;
Expand All @@ -149,28 +136,10 @@ ConnectDatabase(Archive *AHX,
* Start the connection. Loop until we have a password if requested by
* backend.
*/
const char *keywords[8];
const char *values[8];
const char *keywords[9];
const char *values[9];
do
{
<<<<<<< HEAD
keywords[0] = "host";
values[0] = pghost;
keywords[1] = "port";
values[1] = pgport;
keywords[2] = "user";
values[2] = username;
keywords[3] = "password";
values[3] = password;
keywords[4] = "dbname";
values[4] = dbname;
keywords[5] = "fallback_application_name";
values[5] = progname;
keywords[6] = NULL;
values[6] = NULL;
=======
const char *keywords[8];
const char *values[8];
int i = 0;

/*
Expand Down Expand Up @@ -198,7 +167,6 @@ ConnectDatabase(Archive *AHX,
keywords[i] = NULL;
values[i++] = NULL;
Assert(i <= lengthof(keywords));
>>>>>>> f81e97d0475cd4bc597adc23b665bd84fbf79a0d

new_pass = false;
AH->connection = PQconnectdbParams(keywords, values, true);
Expand Down Expand Up @@ -259,11 +227,11 @@ ConnectDatabase(Archive *AHX,
*/
if (binary_upgrade)
{
keywords[6] = "options";
values[6] = AH->public.remoteVersion < GPDB7_MAJOR_PGVERSION ?
keywords[7] = "options";
values[7] = AH->public.remoteVersion < GPDB7_MAJOR_PGVERSION ?
"-c gp_session_role=utility" : "-c gp_role=utility";
keywords[7] = NULL;
values[7] = NULL;
keywords[8] = NULL;
values[8] = NULL;
AH->connection = PQconnectdbParams(keywords, values, true);
}
PQsetNoticeProcessor(AH->connection, notice_processor, NULL);
Expand Down