@@ -934,6 +934,8 @@ do_backup(time_t start_time)
934
934
static void
935
935
check_server_version (void )
936
936
{
937
+ PGresult * res ;
938
+
937
939
/* confirm server version */
938
940
server_version = PQserverVersion (backup_conn );
939
941
@@ -958,6 +960,39 @@ check_server_version(void)
958
960
"server version is %s, must be %s or higher for backup from replica" ,
959
961
server_version_str , "9.6" );
960
962
963
+ res = pgut_execute_extended (backup_conn , "SELECT pgpro_edition()" ,
964
+ 0 , NULL , true, true);
965
+
966
+ /*
967
+ * Check major version of connected PostgreSQL and major version of
968
+ * compiled PostgreSQL.
969
+ */
970
+ #ifdef PGPRO_VERSION
971
+ if (PQresultStatus (res ) == PGRES_FATAL_ERROR )
972
+ /* It seems we connected to PostgreSQL (not Postgres Pro) */
973
+ elog (ERROR , "%s was built with Postgres Pro %s %s, "
974
+ "but connection made with PostgreSQL %s" ,
975
+ PROGRAM_NAME , PG_MAJORVERSION , PGPRO_EDITION , server_version_str );
976
+ else if (strcmp (server_version_str , PG_MAJORVERSION ) != 0 &&
977
+ strcmp (PQgetvalue (res , 0 , 0 ), PGPRO_EDITION ) != 0 )
978
+ elog (ERROR , "%s was built with Postgres Pro %s %s, "
979
+ "but connection made with Postgres Pro %s %s" ,
980
+ PROGRAM_NAME , PG_MAJORVERSION , PGPRO_EDITION ,
981
+ server_version_str , PQgetvalue (res , 0 , 0 ));
982
+ #else
983
+ if (PQresultStatus (res ) != PGRES_FATAL_ERROR )
984
+ /* It seems we connected to Postgres Pro (not PostgreSQL) */
985
+ elog (ERROR , "%s was built with PostgreSQL %s, "
986
+ "but connection made with Postgres Pro %s %s" ,
987
+ PROGRAM_NAME , PG_MAJORVERSION ,
988
+ server_version_str , PQgetvalue (res , 0 , 0 ));
989
+ else if (strcmp (server_version_str , PG_MAJORVERSION ) != 0 )
990
+ elog (ERROR , "%s was built with PostgreSQL %s, but connection made with %s" ,
991
+ PROGRAM_NAME , PG_MAJORVERSION , server_version_str );
992
+ #endif
993
+
994
+ PQclear (res );
995
+
961
996
/* Do exclusive backup only for PostgreSQL 9.5 */
962
997
exclusive_backup = server_version < 90600 ||
963
998
current .backup_mode == BACKUP_MODE_DIFF_PTRACK ;
@@ -997,7 +1032,7 @@ confirm_block_size(const char *name, int blcksz)
997
1032
char * endp ;
998
1033
int block_size ;
999
1034
1000
- res = pgut_execute (backup_conn , "SELECT pg_catalog.current_setting($1)" , 1 , & name , true );
1035
+ res = pgut_execute (backup_conn , "SELECT pg_catalog.current_setting($1)" , 1 , & name );
1001
1036
if (PQntuples (res ) != 1 || PQnfields (res ) != 1 )
1002
1037
elog (ERROR , "cannot get %s: %s" , name , PQerrorMessage (backup_conn ));
1003
1038
@@ -1033,14 +1068,12 @@ pg_start_backup(const char *label, bool smooth, pgBackup *backup)
1033
1068
res = pgut_execute (conn ,
1034
1069
"SELECT pg_catalog.pg_start_backup($1, $2, false)" ,
1035
1070
2 ,
1036
- params ,
1037
- true);
1071
+ params );
1038
1072
else
1039
1073
res = pgut_execute (conn ,
1040
1074
"SELECT pg_catalog.pg_start_backup($1, $2)" ,
1041
1075
2 ,
1042
- params ,
1043
- true);
1076
+ params );
1044
1077
1045
1078
/* Extract timeline and LSN from results of pg_start_backup() */
1046
1079
XLogDataFromLSN (PQgetvalue (res , 0 , 0 ), & xlogid , & xrecoff );
@@ -1091,13 +1124,13 @@ pg_switch_wal(PGconn *conn)
1091
1124
PGresult * res ;
1092
1125
1093
1126
/* Remove annoying NOTICE messages generated by backend */
1094
- res = pgut_execute (conn , "SET client_min_messages = warning;" , 0 , NULL , true );
1127
+ res = pgut_execute (conn , "SET client_min_messages = warning;" , 0 , NULL );
1095
1128
PQclear (res );
1096
1129
1097
1130
if (server_version >= 100000 )
1098
- res = pgut_execute (conn , "SELECT * FROM pg_catalog.pg_switch_wal()" , 0 , NULL , true );
1131
+ res = pgut_execute (conn , "SELECT * FROM pg_catalog.pg_switch_wal()" , 0 , NULL );
1099
1132
else
1100
- res = pgut_execute (conn , "SELECT * FROM pg_catalog.pg_switch_xlog()" , 0 , NULL , true );
1133
+ res = pgut_execute (conn , "SELECT * FROM pg_catalog.pg_switch_xlog()" , 0 , NULL );
1101
1134
1102
1135
PQclear (res );
1103
1136
}
@@ -1113,7 +1146,7 @@ pg_ptrack_support(void)
1113
1146
1114
1147
res_db = pgut_execute (backup_conn ,
1115
1148
"SELECT proname FROM pg_proc WHERE proname='ptrack_version'" ,
1116
- 0 , NULL , true );
1149
+ 0 , NULL );
1117
1150
if (PQntuples (res_db ) == 0 )
1118
1151
{
1119
1152
PQclear (res_db );
@@ -1123,7 +1156,7 @@ pg_ptrack_support(void)
1123
1156
1124
1157
res_db = pgut_execute (backup_conn ,
1125
1158
"SELECT pg_catalog.ptrack_version()" ,
1126
- 0 , NULL , true );
1159
+ 0 , NULL );
1127
1160
if (PQntuples (res_db ) == 0 )
1128
1161
{
1129
1162
PQclear (res_db );
@@ -1148,7 +1181,7 @@ pg_ptrack_enable(void)
1148
1181
{
1149
1182
PGresult * res_db ;
1150
1183
1151
- res_db = pgut_execute (backup_conn , "show ptrack_enable" , 0 , NULL , true );
1184
+ res_db = pgut_execute (backup_conn , "show ptrack_enable" , 0 , NULL );
1152
1185
1153
1186
if (strcmp (PQgetvalue (res_db , 0 , 0 ), "on" ) != 0 )
1154
1187
{
@@ -1165,7 +1198,7 @@ pg_checksum_enable(void)
1165
1198
{
1166
1199
PGresult * res_db ;
1167
1200
1168
- res_db = pgut_execute (backup_conn , "show data_checksums" , 0 , NULL , true );
1201
+ res_db = pgut_execute (backup_conn , "show data_checksums" , 0 , NULL );
1169
1202
1170
1203
if (strcmp (PQgetvalue (res_db , 0 , 0 ), "on" ) != 0 )
1171
1204
{
@@ -1182,7 +1215,7 @@ pg_is_in_recovery(void)
1182
1215
{
1183
1216
PGresult * res_db ;
1184
1217
1185
- res_db = pgut_execute (backup_conn , "SELECT pg_catalog.pg_is_in_recovery()" , 0 , NULL , true );
1218
+ res_db = pgut_execute (backup_conn , "SELECT pg_catalog.pg_is_in_recovery()" , 0 , NULL );
1186
1219
1187
1220
if (PQgetvalue (res_db , 0 , 0 )[0 ] == 't' )
1188
1221
{
@@ -1207,7 +1240,7 @@ pg_ptrack_clear(void)
1207
1240
params [0 ] = palloc (64 );
1208
1241
params [1 ] = palloc (64 );
1209
1242
res_db = pgut_execute (backup_conn , "SELECT datname, oid, dattablespace FROM pg_database" ,
1210
- 0 , NULL , true );
1243
+ 0 , NULL );
1211
1244
1212
1245
for (i = 0 ; i < PQntuples (res_db ); i ++ )
1213
1246
{
@@ -1221,12 +1254,12 @@ pg_ptrack_clear(void)
1221
1254
tblspcOid = atoi (PQgetvalue (res_db , i , 2 ));
1222
1255
1223
1256
tmp_conn = pgut_connect (dbname );
1224
- res = pgut_execute (tmp_conn , "SELECT pg_catalog.pg_ptrack_clear()" , 0 , NULL , true );
1257
+ res = pgut_execute (tmp_conn , "SELECT pg_catalog.pg_ptrack_clear()" , 0 , NULL );
1225
1258
1226
1259
sprintf (params [0 ], "%i" , dbOid );
1227
1260
sprintf (params [1 ], "%i" , tblspcOid );
1228
1261
res = pgut_execute (tmp_conn , "SELECT pg_catalog.pg_ptrack_get_and_clear_db($1, $2)" ,
1229
- 2 , (const char * * )params , true );
1262
+ 2 , (const char * * )params );
1230
1263
PQclear (res );
1231
1264
1232
1265
pgut_disconnect (tmp_conn );
@@ -1252,7 +1285,7 @@ pg_ptrack_get_and_clear_db(Oid dbOid, Oid tblspcOid)
1252
1285
sprintf (params [0 ], "%i" , dbOid );
1253
1286
res_db = pgut_execute (backup_conn ,
1254
1287
"SELECT datname FROM pg_database WHERE oid=$1" ,
1255
- 1 , (const char * * ) params , true );
1288
+ 1 , (const char * * ) params );
1256
1289
/*
1257
1290
* If database is not found, it's not an error.
1258
1291
* It could have been deleted since previous backup.
@@ -1273,7 +1306,7 @@ pg_ptrack_get_and_clear_db(Oid dbOid, Oid tblspcOid)
1273
1306
sprintf (params [0 ], "%i" , dbOid );
1274
1307
sprintf (params [1 ], "%i" , tblspcOid );
1275
1308
res = pgut_execute (backup_conn , "SELECT pg_catalog.pg_ptrack_get_and_clear_db($1, $2)" ,
1276
- 2 , (const char * * )params , true );
1309
+ 2 , (const char * * )params );
1277
1310
1278
1311
if (PQnfields (res ) != 1 )
1279
1312
elog (ERROR , "cannot perform pg_ptrack_get_and_clear_db()" );
@@ -1318,7 +1351,7 @@ pg_ptrack_get_and_clear(Oid tablespace_oid, Oid db_oid, Oid rel_filenode,
1318
1351
sprintf (params [0 ], "%i" , db_oid );
1319
1352
res_db = pgut_execute (backup_conn ,
1320
1353
"SELECT datname FROM pg_database WHERE oid=$1" ,
1321
- 1 , (const char * * ) params , true );
1354
+ 1 , (const char * * ) params );
1322
1355
/*
1323
1356
* If database is not found, it's not an error.
1324
1357
* It could have been deleted since previous backup.
@@ -1338,7 +1371,7 @@ pg_ptrack_get_and_clear(Oid tablespace_oid, Oid db_oid, Oid rel_filenode,
1338
1371
sprintf (params [0 ], "%i" , tablespace_oid );
1339
1372
sprintf (params [1 ], "%i" , rel_filenode );
1340
1373
res = pgut_execute (tmp_conn , "SELECT pg_catalog.pg_ptrack_get_and_clear($1, $2)" ,
1341
- 2 , (const char * * )params , true );
1374
+ 2 , (const char * * )params );
1342
1375
1343
1376
if (PQnfields (res ) != 1 )
1344
1377
elog (ERROR , "cannot get ptrack file from database \"%s\" by tablespace oid %u and relation oid %u" ,
@@ -1356,7 +1389,7 @@ pg_ptrack_get_and_clear(Oid tablespace_oid, Oid db_oid, Oid rel_filenode,
1356
1389
sprintf (params [0 ], "%i" , tablespace_oid );
1357
1390
sprintf (params [1 ], "%i" , rel_filenode );
1358
1391
res = pgut_execute (backup_conn , "SELECT pg_catalog.pg_ptrack_get_and_clear($1, $2)" ,
1359
- 2 , (const char * * )params , true );
1392
+ 2 , (const char * * )params );
1360
1393
1361
1394
if (PQnfields (res ) != 1 )
1362
1395
elog (ERROR , "cannot get ptrack file from pg_global tablespace and relation oid %u" ,
@@ -1537,10 +1570,10 @@ wait_replica_wal_lsn(XLogRecPtr lsn, bool is_start_backup)
1537
1570
{
1538
1571
if (server_version >= 100000 )
1539
1572
res = pgut_execute (backup_conn , "SELECT pg_catalog.pg_last_wal_replay_lsn()" ,
1540
- 0 , NULL , true );
1573
+ 0 , NULL );
1541
1574
else
1542
1575
res = pgut_execute (backup_conn , "SELECT pg_catalog.pg_last_xlog_replay_location()" ,
1543
- 0 , NULL , true );
1576
+ 0 , NULL );
1544
1577
}
1545
1578
/*
1546
1579
* For lsn from pg_stop_backup() we need it only to be received by
@@ -1550,10 +1583,10 @@ wait_replica_wal_lsn(XLogRecPtr lsn, bool is_start_backup)
1550
1583
{
1551
1584
if (server_version >= 100000 )
1552
1585
res = pgut_execute (backup_conn , "SELECT pg_catalog.pg_last_wal_receive_lsn()" ,
1553
- 0 , NULL , true );
1586
+ 0 , NULL );
1554
1587
else
1555
1588
res = pgut_execute (backup_conn , "SELECT pg_catalog.pg_last_xlog_receive_location()" ,
1556
- 0 , NULL , true );
1589
+ 0 , NULL );
1557
1590
}
1558
1591
1559
1592
/* Extract timeline and LSN from result */
@@ -1620,7 +1653,7 @@ pg_stop_backup(pgBackup *backup)
1620
1653
1621
1654
/* Remove annoying NOTICE messages generated by backend */
1622
1655
res = pgut_execute (conn , "SET client_min_messages = warning;" ,
1623
- 0 , NULL , true );
1656
+ 0 , NULL );
1624
1657
PQclear (res );
1625
1658
1626
1659
/* Create restore point */
@@ -1638,7 +1671,7 @@ pg_stop_backup(pgBackup *backup)
1638
1671
params [0 ] = name ;
1639
1672
1640
1673
res = pgut_execute (conn , "SELECT pg_catalog.pg_create_restore_point($1)" ,
1641
- 1 , params , true );
1674
+ 1 , params );
1642
1675
PQclear (res );
1643
1676
}
1644
1677
@@ -1901,7 +1934,7 @@ checkpoint_timeout(void)
1901
1934
const char * hintmsg ;
1902
1935
int val_int ;
1903
1936
1904
- res = pgut_execute (backup_conn , "show checkpoint_timeout" , 0 , NULL , true );
1937
+ res = pgut_execute (backup_conn , "show checkpoint_timeout" , 0 , NULL );
1905
1938
val = PQgetvalue (res , 0 , 0 );
1906
1939
1907
1940
if (!parse_int (val , & val_int , OPTION_UNIT_S , & hintmsg ))
@@ -2586,7 +2619,7 @@ get_last_ptrack_lsn(void)
2586
2619
uint32 xrecoff ;
2587
2620
XLogRecPtr lsn ;
2588
2621
2589
- res = pgut_execute (backup_conn , "select pg_catalog.pg_ptrack_control_lsn()" , 0 , NULL , true );
2622
+ res = pgut_execute (backup_conn , "select pg_catalog.pg_ptrack_control_lsn()" , 0 , NULL );
2590
2623
2591
2624
/* Extract timeline and LSN from results of pg_start_backup() */
2592
2625
XLogDataFromLSN (PQgetvalue (res , 0 , 0 ), & xlogid , & xrecoff );
0 commit comments