Skip to content

Commit a42fff0

Browse files
committed
WIP. TODO: parse pgpro_remoteversion_str
1 parent fb84c7a commit a42fff0

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

src/bin/pg_dump/pg_backup.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ typedef struct Archive
174174
int verbose;
175175
char *remoteVersionStr; /* server's version string */
176176
int remoteVersion; /* same in numeric form */
177+
int pgproremoteVersion; /* pgpro server's version in numeric form */
177178
bool isStandby; /* is server a standby node */
178179

179180
int minRemoteVersion; /* allowable range */

src/bin/pg_dump/pg_backup_db.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,31 @@ static const char *modulename = gettext_noop("archiver (db)");
3333
static void _check_database_version(ArchiveHandle *AH);
3434
static PGconn *_connectDB(ArchiveHandle *AH, const char *newdbname, const char *newUser);
3535
static void notice_processor(void *arg, const char *message);
36+
static void get_pgpro_version(ArchiveHandle *AH);
37+
38+
static void
39+
get_pgpro_version(ArchiveHandle *AH)
40+
{
41+
char *query = "SELECT pgpro_version()";
42+
PGresult *res;
43+
const char *pgpro_remoteversion_str;
44+
45+
res = PQexec(AH->connection, query);
46+
/* If the query failed, it means that remote cluster is not PgPro. */
47+
if (PQresultStatus(res) != PGRES_TUPLES_OK)
48+
{
49+
AH->public.pgproremoteVersion = 0;
50+
fprintf(stdout, "pgpro server version: 0; %s version: %s\n", progname, PG_VERSION);
51+
}
52+
else
53+
{
54+
pgpro_remoteversion_str = pg_strdup(PQgetvalue(res, 0, 0));
55+
AH->public.pgproremoteVersion = 1;
56+
fprintf(stdout, "pgpro server version: %s; %s version: %s\n",
57+
pgpro_remoteversion_str, progname, PG_VERSION);
58+
}
59+
PQclear(res);
60+
}
3661

3762
static void
3863
_check_database_version(ArchiveHandle *AH)
@@ -47,6 +72,7 @@ _check_database_version(ArchiveHandle *AH)
4772
exit_horribly(modulename, "could not get server_version from libpq\n");
4873

4974
/* TODO select pgpro_version, pgpro_edition */
75+
get_pgpro_version(AH);
5076

5177
AH->public.remoteVersionStr = pg_strdup(remoteversion_str);
5278
AH->public.remoteVersion = remoteversion;

src/bin/pg_dump/pg_dump.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6281,7 +6281,7 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
62816281
*/
62826282
resetPQExpBuffer(query);
62836283
/* TODO check pgpro_version instead of just remoteVersion */
6284-
if (fout->remoteVersion >= 90600)
6284+
if (fout->remoteVersion >= 90600 && fout->pgproremoteVersion > 0)
62856285
{
62866286
/*
62876287
* In 9.6 we add INCLUDING columns functionality

0 commit comments

Comments
 (0)