@@ -33,6 +33,31 @@ 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
+
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
+ }
36
61
37
62
static void
38
63
_check_database_version (ArchiveHandle * AH )
@@ -47,6 +72,7 @@ _check_database_version(ArchiveHandle *AH)
47
72
exit_horribly (modulename , "could not get server_version from libpq\n" );
48
73
49
74
/* TODO select pgpro_version, pgpro_edition */
75
+ get_pgpro_version (AH );
50
76
51
77
AH -> public .remoteVersionStr = pg_strdup (remoteversion_str );
52
78
AH -> public .remoteVersion = remoteversion ;
0 commit comments