@@ -34,6 +34,7 @@ static void _check_database_version(ArchiveHandle *AH);
34
34
static PGconn * _connectDB (ArchiveHandle * AH , const char * newdbname , const char * newUser );
35
35
static void notice_processor (void * arg , const char * message );
36
36
static void get_pgpro_version (ArchiveHandle * AH );
37
+ static void get_pgpro_edition (ArchiveHandle * AH );
37
38
38
39
static void
39
40
get_pgpro_version (ArchiveHandle * AH )
@@ -59,6 +60,49 @@ get_pgpro_version(ArchiveHandle *AH)
59
60
PQclear (res );
60
61
}
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
+ exit_horribly (NULL , "aborting because of unrecognized pgpro edition\n" );
104
+ }
105
+
62
106
static void
63
107
_check_database_version (ArchiveHandle * AH )
64
108
{
@@ -71,9 +115,6 @@ _check_database_version(ArchiveHandle *AH)
71
115
if (remoteversion == 0 || !remoteversion_str )
72
116
exit_horribly (modulename , "could not get server_version from libpq\n" );
73
117
74
- /* TODO select pgpro_version, pgpro_edition */
75
- get_pgpro_version (AH );
76
-
77
118
AH -> public .remoteVersionStr = pg_strdup (remoteversion_str );
78
119
AH -> public .remoteVersion = remoteversion ;
79
120
if (!AH -> archiveRemoteVersion )
@@ -88,6 +129,9 @@ _check_database_version(ArchiveHandle *AH)
88
129
exit_horribly (NULL , "aborting because of server version mismatch\n" );
89
130
}
90
131
132
+ get_pgpro_version (AH );
133
+ get_pgpro_edition (AH );
134
+
91
135
/*
92
136
* When running against 9.0 or later, check if we are in recovery mode,
93
137
* which means we are on a hot standby.
0 commit comments