@@ -33,6 +33,74 @@ static const char *modulename = gettext_noop("archiver (db)");
33
33
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
+ 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
+ }
36
104
37
105
static void
38
106
_check_database_version (ArchiveHandle * AH )
@@ -60,6 +128,9 @@ _check_database_version(ArchiveHandle *AH)
60
128
exit_horribly (NULL , "aborting because of server version mismatch\n" );
61
129
}
62
130
131
+ get_pgpro_version (AH );
132
+ get_pgpro_edition (AH );
133
+
63
134
/*
64
135
* When running against 9.0 or later, check if we are in recovery mode,
65
136
* which means we are on a hot standby.
0 commit comments