Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e49fa4e

Browse files
committed
Merge branch 'PGPRO9_6_pg_upgrade_fixes' into PGPRO9_6
2 parents 52ae6dc + 30dd091 commit e49fa4e

File tree

4 files changed

+86
-4
lines changed

4 files changed

+86
-4
lines changed

src/bin/pg_dump/pg_backup.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,14 @@ typedef struct _dumpOptions
162162
char *outputSuperuser;
163163
} DumpOptions;
164164

165+
typedef enum _pgproEdition
166+
{
167+
NONE,
168+
STANDART,
169+
STANDART_CERTIFIED,
170+
ENTERPRISE,
171+
} pgproEdition;
172+
165173
/*
166174
* We may want to have some more user-readable data, but in the mean
167175
* time this gives us some abstraction and type checking.
@@ -174,6 +182,8 @@ typedef struct Archive
174182
int verbose;
175183
char *remoteVersionStr; /* server's version string */
176184
int remoteVersion; /* same in numeric form */
185+
int pgproremoteVersion; /* pgpro server's version in numeric form */
186+
pgproEdition pgproremoteEdition; /* pgpro server's edition. */
177187
bool isStandby; /* is server a standby node */
178188

179189
int minRemoteVersion; /* allowable range */

src/bin/pg_dump/pg_backup_db.c

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,74 @@ 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+
static void get_pgpro_edition(ArchiveHandle *AH);
38+
39+
static void
40+
get_pgpro_version(ArchiveHandle *AH)
41+
{
42+
char *query = "SELECT pgpro_version()";
43+
PGresult *res;
44+
const char *pgpro_remoteversion_str;
45+
46+
res = PQexec(AH->connection, query);
47+
/* If the query failed, it means that remote cluster is not PgPro. */
48+
if (PQresultStatus(res) != PGRES_TUPLES_OK)
49+
{
50+
AH->public.pgproremoteVersion = 0;
51+
fprintf(stdout, "pgpro server version: 0; %s version: %s\n", progname, PG_VERSION);
52+
}
53+
else
54+
{
55+
pgpro_remoteversion_str = pg_strdup(PQgetvalue(res, 0, 0));
56+
AH->public.pgproremoteVersion = 1;
57+
fprintf(stdout, "pgpro server version: %s; %s version: %s\n",
58+
pgpro_remoteversion_str, progname, PG_VERSION);
59+
}
60+
PQclear(res);
61+
}
62+
63+
static void
64+
get_pgpro_edition(ArchiveHandle *AH)
65+
{
66+
char *query = "SELECT pgpro_edition()";
67+
PGresult *res;
68+
const char *pgpro_remoteEdition_str;
69+
70+
res = PQexec(AH->connection, query);
71+
/* If the query failed, it means that remote cluster is not PgPro. */
72+
if (PQresultStatus(res) != PGRES_TUPLES_OK)
73+
{
74+
AH->public.pgproremoteEdition = NONE;
75+
fprintf(stdout, "pgpro server edition: 0; %s version: %s\n", progname, PG_VERSION);
76+
}
77+
else
78+
{
79+
pgpro_remoteEdition_str = pg_strdup(PQgetvalue(res, 0, 0));
80+
81+
fprintf(stdout, "pgpro server edition: %s; %s version: %s\n",
82+
pgpro_remoteEdition_str, progname, PG_VERSION);
83+
84+
if (strcmp(pgpro_remoteEdition_str, "standard") == 0)
85+
AH->public.pgproremoteEdition = STANDART;
86+
else if (strcmp(pgpro_remoteEdition_str, "standard-certified") == 0)
87+
AH->public.pgproremoteEdition = STANDART_CERTIFIED;
88+
else if (strcmp(pgpro_remoteEdition_str, "enterprise") == 0)
89+
{
90+
AH->public.pgproremoteEdition = ENTERPRISE;
91+
if (AH->public.remoteVersion >= 90600)
92+
exit_horribly(NULL, "pg_upgrade for 64bit-xid is not implemented yet"
93+
"Use pg_dump/pg_restore instead.\n");
94+
}
95+
else
96+
{
97+
write_msg(NULL, "Unrecognized pgpro edition: %s\n",
98+
pgpro_remoteEdition_str);
99+
exit_horribly(NULL, "aborting because of unrecognized pgpro edition\n");
100+
}
101+
}
102+
PQclear(res);
103+
}
36104

37105
static void
38106
_check_database_version(ArchiveHandle *AH)
@@ -60,6 +128,9 @@ _check_database_version(ArchiveHandle *AH)
60128
exit_horribly(NULL, "aborting because of server version mismatch\n");
61129
}
62130

131+
get_pgpro_version(AH);
132+
get_pgpro_edition(AH);
133+
63134
/*
64135
* When running against 9.0 or later, check if we are in recovery mode,
65136
* which means we are on a hot standby.

src/bin/pg_dump/pg_dump.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6285,10 +6285,10 @@ getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
62856285
* is not.
62866286
*/
62876287
resetPQExpBuffer(query);
6288-
if (fout->remoteVersion >= 90600)
6288+
if (fout->remoteVersion >= 90600 && fout->pgproremoteVersion > 0)
62896289
{
62906290
/*
6291-
* In 9.6 we add INCLUDING columns functionality
6291+
* In PGPRO9_6 we add INCLUDING columns functionality
62926292
* that requires new fields to be added.
62936293
* i.indnkeyattrs is new, and besides we should use
62946294
* i.indnatts instead of t.relnatts for index relations.

src/include/catalog/catversion.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@
5050
* YYYYMMDD are the date of the change, and N is the number of the change
5151
* on that day. (Hopefully we'll never commit ten independent sets of
5252
* catalog changes on the same day...)
53+
* For PGPRO we added also P - the number of the PGPRO specific catalog change.
5354
*/
5455

55-
/* yyyymmddN */
56-
#define CATALOG_VERSION_NO 201608131
56+
/* yyyymmddNP */
57+
#define CATALOG_VERSION_NO 2016081311
5758

5859
#endif

0 commit comments

Comments
 (0)