@@ -110,6 +110,9 @@ static void check_external_for_tablespaces(parray *external_list,
110110 PGconn * backup_conn );
111111static parray * get_database_map (PGconn * pg_startbackup_conn );
112112
113+ /* pgpro specific functions */
114+ static bool pgpro_support (PGconn * conn );
115+
113116/* Ptrack functions */
114117static void pg_ptrack_clear (PGconn * backup_conn );
115118static bool pg_ptrack_support (PGconn * backup_conn );
@@ -658,6 +661,7 @@ pgdata_basic_setup(ConnectionOptions conn_opt, PGNodeInfo *nodeInfo)
658661 nodeInfo -> block_size = BLCKSZ ;
659662 nodeInfo -> wal_block_size = XLOG_BLCKSZ ;
660663 nodeInfo -> is_superuser = pg_is_superuser (cur_conn );
664+ nodeInfo -> pgpro_support = pgpro_support (cur_conn );
661665
662666 current .from_replica = pg_is_in_recovery (cur_conn );
663667
@@ -845,7 +849,7 @@ do_backup(time_t start_time, bool no_validate,
845849static void
846850check_server_version (PGconn * conn , PGNodeInfo * nodeInfo )
847851{
848- PGresult * res ;
852+ PGresult * res = NULL ;
849853
850854 /* confirm server version */
851855 nodeInfo -> server_version = PQserverVersion (conn );
@@ -871,39 +875,45 @@ check_server_version(PGconn *conn, PGNodeInfo *nodeInfo)
871875 "server version is %s, must be %s or higher for backup from replica" ,
872876 nodeInfo -> server_version_str , "9.6" );
873877
874- /* TODO: search pg_proc for pgpro_edition before calling */
875- res = pgut_execute_extended (conn , "SELECT pgpro_edition()" ,
876- 0 , NULL , true, true);
878+ if (nodeInfo -> pgpro_support )
879+ res = pgut_execute (conn , "SELECT pgpro_edition()" , 0 , NULL );
877880
878881 /*
879882 * Check major version of connected PostgreSQL and major version of
880883 * compiled PostgreSQL.
881884 */
882885#ifdef PGPRO_VERSION
883- if (PQresultStatus ( res ) == PGRES_FATAL_ERROR )
886+ if (! res )
884887 /* It seems we connected to PostgreSQL (not Postgres Pro) */
885888 elog (ERROR , "%s was built with Postgres Pro %s %s, "
886889 "but connection is made with PostgreSQL %s" ,
887890 PROGRAM_NAME , PG_MAJORVERSION , PGPRO_EDITION , nodeInfo -> server_version_str );
888- else if (strcmp (nodeInfo -> server_version_str , PG_MAJORVERSION ) != 0 &&
889- strcmp (PQgetvalue (res , 0 , 0 ), PGPRO_EDITION ) != 0 )
890- elog (ERROR , "%s was built with Postgres Pro %s %s, "
891- "but connection is made with Postgres Pro %s %s" ,
892- PROGRAM_NAME , PG_MAJORVERSION , PGPRO_EDITION ,
893- nodeInfo -> server_version_str , PQgetvalue (res , 0 , 0 ));
891+ else
892+ {
893+ if (strcmp (nodeInfo -> server_version_str , PG_MAJORVERSION ) != 0 &&
894+ strcmp (PQgetvalue (res , 0 , 0 ), PGPRO_EDITION ) != 0 )
895+ elog (ERROR , "%s was built with Postgres Pro %s %s, "
896+ "but connection is made with Postgres Pro %s %s" ,
897+ PROGRAM_NAME , PG_MAJORVERSION , PGPRO_EDITION ,
898+ nodeInfo -> server_version_str , PQgetvalue (res , 0 , 0 ));
899+ }
894900#else
895- if (PQresultStatus ( res ) != PGRES_FATAL_ERROR )
901+ if (res )
896902 /* It seems we connected to Postgres Pro (not PostgreSQL) */
897903 elog (ERROR , "%s was built with PostgreSQL %s, "
898904 "but connection is made with Postgres Pro %s %s" ,
899905 PROGRAM_NAME , PG_MAJORVERSION ,
900906 nodeInfo -> server_version_str , PQgetvalue (res , 0 , 0 ));
901- else if (strcmp (nodeInfo -> server_version_str , PG_MAJORVERSION ) != 0 )
902- elog (ERROR , "%s was built with PostgreSQL %s, but connection is made with %s" ,
903- PROGRAM_NAME , PG_MAJORVERSION , nodeInfo -> server_version_str );
907+ else
908+ {
909+ if (strcmp (nodeInfo -> server_version_str , PG_MAJORVERSION ) != 0 )
910+ elog (ERROR , "%s was built with PostgreSQL %s, but connection is made with %s" ,
911+ PROGRAM_NAME , PG_MAJORVERSION , nodeInfo -> server_version_str );
912+ }
904913#endif
905914
906- PQclear (res );
915+ if (res )
916+ PQclear (res );
907917
908918 /* Do exclusive backup only for PostgreSQL 9.5 */
909919 exclusive_backup = nodeInfo -> server_version < 90600 ||
@@ -1106,6 +1116,30 @@ pg_ptrack_support(PGconn *backup_conn)
11061116 return true;
11071117}
11081118
1119+ /*
1120+ * Check if the instance is PostgresPro fork.
1121+ */
1122+ static bool
1123+ pgpro_support (PGconn * conn )
1124+ {
1125+ PGresult * res ;
1126+
1127+ res = pgut_execute (conn ,
1128+ "SELECT proname FROM pg_proc WHERE proname='pgpro_edition'" ,
1129+ 0 , NULL );
1130+
1131+ if (PQresultStatus (res ) == PGRES_TUPLES_OK &&
1132+ (PQntuples (res ) == 1 ) &&
1133+ (strcmp (PQgetvalue (res , 0 , 0 ), "pgpro_edition" ) == 0 ))
1134+ {
1135+ PQclear (res );
1136+ return true;
1137+ }
1138+
1139+ PQclear (res );
1140+ return false;
1141+ }
1142+
11091143/*
11101144 * Fill 'datname to Oid' map
11111145 *
0 commit comments