@@ -110,6 +110,9 @@ static void check_external_for_tablespaces(parray *external_list,
110
110
PGconn * backup_conn );
111
111
static parray * get_database_map (PGconn * pg_startbackup_conn );
112
112
113
+ /* pgpro specific functions */
114
+ static bool pgpro_support (PGconn * conn );
115
+
113
116
/* Ptrack functions */
114
117
static void pg_ptrack_clear (PGconn * backup_conn );
115
118
static bool pg_ptrack_support (PGconn * backup_conn );
@@ -658,6 +661,7 @@ pgdata_basic_setup(ConnectionOptions conn_opt, PGNodeInfo *nodeInfo)
658
661
nodeInfo -> block_size = BLCKSZ ;
659
662
nodeInfo -> wal_block_size = XLOG_BLCKSZ ;
660
663
nodeInfo -> is_superuser = pg_is_superuser (cur_conn );
664
+ nodeInfo -> pgpro_support = pgpro_support (cur_conn );
661
665
662
666
current .from_replica = pg_is_in_recovery (cur_conn );
663
667
@@ -845,7 +849,7 @@ do_backup(time_t start_time, bool no_validate,
845
849
static void
846
850
check_server_version (PGconn * conn , PGNodeInfo * nodeInfo )
847
851
{
848
- PGresult * res ;
852
+ PGresult * res = NULL ;
849
853
850
854
/* confirm server version */
851
855
nodeInfo -> server_version = PQserverVersion (conn );
@@ -871,39 +875,45 @@ check_server_version(PGconn *conn, PGNodeInfo *nodeInfo)
871
875
"server version is %s, must be %s or higher for backup from replica" ,
872
876
nodeInfo -> server_version_str , "9.6" );
873
877
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 );
877
880
878
881
/*
879
882
* Check major version of connected PostgreSQL and major version of
880
883
* compiled PostgreSQL.
881
884
*/
882
885
#ifdef PGPRO_VERSION
883
- if (PQresultStatus ( res ) == PGRES_FATAL_ERROR )
886
+ if (! res )
884
887
/* It seems we connected to PostgreSQL (not Postgres Pro) */
885
888
elog (ERROR , "%s was built with Postgres Pro %s %s, "
886
889
"but connection is made with PostgreSQL %s" ,
887
890
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
+ }
894
900
#else
895
- if (PQresultStatus ( res ) != PGRES_FATAL_ERROR )
901
+ if (res )
896
902
/* It seems we connected to Postgres Pro (not PostgreSQL) */
897
903
elog (ERROR , "%s was built with PostgreSQL %s, "
898
904
"but connection is made with Postgres Pro %s %s" ,
899
905
PROGRAM_NAME , PG_MAJORVERSION ,
900
906
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
+ }
904
913
#endif
905
914
906
- PQclear (res );
915
+ if (res )
916
+ PQclear (res );
907
917
908
918
/* Do exclusive backup only for PostgreSQL 9.5 */
909
919
exclusive_backup = nodeInfo -> server_version < 90600 ||
@@ -1106,6 +1116,30 @@ pg_ptrack_support(PGconn *backup_conn)
1106
1116
return true;
1107
1117
}
1108
1118
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
+
1109
1143
/*
1110
1144
* Fill 'datname to Oid' map
1111
1145
*
0 commit comments