@@ -457,8 +457,6 @@ do_backup_instance(void)
457
457
/* Initialize size summary */
458
458
current .data_bytes = 0 ;
459
459
460
- current .tablespace_map_exists = false;
461
-
462
460
/* Obtain current timeline */
463
461
if (is_remote_backup )
464
462
{
@@ -898,7 +896,7 @@ check_server_version(void)
898
896
current .backup_mode == BACKUP_MODE_DIFF_PTRACK ;
899
897
900
898
/* Save server_version to use it in future */
901
- res = pgut_execute (backup_conn , "show server_version" , 0 , NULL );
899
+ res = pgut_execute (backup_conn , "show server_version" , 0 , NULL , true );
902
900
StrNCpy (server_version_str , PQgetvalue (res , 0 , 0 ), sizeof (server_version_str ));
903
901
PQclear (res );
904
902
}
@@ -921,7 +919,7 @@ check_system_identifiers(void)
921
919
922
920
res = pgut_execute (backup_conn ,
923
921
"SELECT system_identifier FROM pg_control_system()" ,
924
- 0 , NULL );
922
+ 0 , NULL , true );
925
923
val = PQgetvalue (res , 0 , 0 );
926
924
927
925
if (!parse_uint64 (val , & system_id_conn ))
@@ -951,7 +949,7 @@ confirm_block_size(const char *name, int blcksz)
951
949
char * endp ;
952
950
int block_size ;
953
951
954
- res = pgut_execute (backup_conn , "SELECT current_setting($1)" , 1 , & name );
952
+ res = pgut_execute (backup_conn , "SELECT current_setting($1)" , 1 , & name , true );
955
953
if (PQntuples (res ) != 1 || PQnfields (res ) != 1 )
956
954
elog (ERROR , "cannot get %s: %s" , name , PQerrorMessage (backup_conn ));
957
955
@@ -987,12 +985,14 @@ pg_start_backup(const char *label, bool smooth, pgBackup *backup)
987
985
res = pgut_execute (conn ,
988
986
"SELECT pg_start_backup($1, $2, false)" ,
989
987
2 ,
990
- params );
988
+ params ,
989
+ true);
991
990
else
992
991
res = pgut_execute (conn ,
993
992
"SELECT pg_start_backup($1, $2)" ,
994
993
2 ,
995
- params );
994
+ params ,
995
+ true);
996
996
997
997
/* Extract timeline and LSN from results of pg_start_backup() */
998
998
XLogDataFromLSN (PQgetvalue (res , 0 , 0 ), & xlogid , & xrecoff );
@@ -1043,13 +1043,13 @@ pg_switch_wal(PGconn *conn)
1043
1043
PGresult * res ;
1044
1044
1045
1045
/* Remove annoying NOTICE messages generated by backend */
1046
- res = pgut_execute (conn , "SET client_min_messages = warning;" , 0 , NULL );
1046
+ res = pgut_execute (conn , "SET client_min_messages = warning;" , 0 , NULL , true );
1047
1047
PQclear (res );
1048
1048
1049
1049
if (server_version >= 100000 )
1050
- res = pgut_execute (conn , "SELECT * FROM pg_switch_wal()" , 0 , NULL );
1050
+ res = pgut_execute (conn , "SELECT * FROM pg_switch_wal()" , 0 , NULL , true );
1051
1051
else
1052
- res = pgut_execute (conn , "SELECT * FROM pg_switch_xlog()" , 0 , NULL );
1052
+ res = pgut_execute (conn , "SELECT * FROM pg_switch_xlog()" , 0 , NULL , true );
1053
1053
1054
1054
PQclear (res );
1055
1055
}
@@ -1065,7 +1065,7 @@ pg_ptrack_support(void)
1065
1065
1066
1066
res_db = pgut_execute (backup_conn ,
1067
1067
"SELECT proname FROM pg_proc WHERE proname='ptrack_version'" ,
1068
- 0 , NULL );
1068
+ 0 , NULL , true );
1069
1069
if (PQntuples (res_db ) == 0 )
1070
1070
{
1071
1071
PQclear (res_db );
@@ -1075,7 +1075,7 @@ pg_ptrack_support(void)
1075
1075
1076
1076
res_db = pgut_execute (backup_conn ,
1077
1077
"SELECT ptrack_version()" ,
1078
- 0 , NULL );
1078
+ 0 , NULL , true );
1079
1079
if (PQntuples (res_db ) == 0 )
1080
1080
{
1081
1081
PQclear (res_db );
@@ -1100,7 +1100,7 @@ pg_ptrack_enable(void)
1100
1100
{
1101
1101
PGresult * res_db ;
1102
1102
1103
- res_db = pgut_execute (backup_conn , "show ptrack_enable" , 0 , NULL );
1103
+ res_db = pgut_execute (backup_conn , "show ptrack_enable" , 0 , NULL , true );
1104
1104
1105
1105
if (strcmp (PQgetvalue (res_db , 0 , 0 ), "on" ) != 0 )
1106
1106
{
@@ -1117,7 +1117,7 @@ pg_is_in_recovery(void)
1117
1117
{
1118
1118
PGresult * res_db ;
1119
1119
1120
- res_db = pgut_execute (backup_conn , "SELECT pg_is_in_recovery()" , 0 , NULL );
1120
+ res_db = pgut_execute (backup_conn , "SELECT pg_is_in_recovery()" , 0 , NULL , true );
1121
1121
1122
1122
if (PQgetvalue (res_db , 0 , 0 )[0 ] == 't' )
1123
1123
{
@@ -1136,7 +1136,7 @@ pg_archive_enabled(void)
1136
1136
{
1137
1137
PGresult * res_db ;
1138
1138
1139
- res_db = pgut_execute (backup_conn , "show archive_mode" , 0 , NULL );
1139
+ res_db = pgut_execute (backup_conn , "show archive_mode" , 0 , NULL , true );
1140
1140
1141
1141
if (strcmp (PQgetvalue (res_db , 0 , 0 ), "off" ) == 0 )
1142
1142
{
@@ -1145,7 +1145,7 @@ pg_archive_enabled(void)
1145
1145
}
1146
1146
PQclear (res_db );
1147
1147
1148
- res_db = pgut_execute (backup_conn , "show archive_command" , 0 , NULL );
1148
+ res_db = pgut_execute (backup_conn , "show archive_command" , 0 , NULL , true );
1149
1149
if (strlen (PQgetvalue (res_db , 0 , 0 )) == 0 )
1150
1150
{
1151
1151
PQclear (res_db );
@@ -1170,7 +1170,7 @@ pg_ptrack_clear(void)
1170
1170
params [0 ] = palloc (64 );
1171
1171
params [1 ] = palloc (64 );
1172
1172
res_db = pgut_execute (backup_conn , "SELECT datname, oid, dattablespace FROM pg_database" ,
1173
- 0 , NULL );
1173
+ 0 , NULL , true );
1174
1174
1175
1175
for (i = 0 ; i < PQntuples (res_db ); i ++ )
1176
1176
{
@@ -1184,12 +1184,12 @@ pg_ptrack_clear(void)
1184
1184
tblspcOid = atoi (PQgetvalue (res_db , i , 2 ));
1185
1185
1186
1186
tmp_conn = pgut_connect (dbname );
1187
- res = pgut_execute (tmp_conn , "SELECT pg_ptrack_clear()" , 0 , NULL );
1187
+ res = pgut_execute (tmp_conn , "SELECT pg_ptrack_clear()" , 0 , NULL , true );
1188
1188
1189
1189
sprintf (params [0 ], "%i" , dbOid );
1190
1190
sprintf (params [1 ], "%i" , tblspcOid );
1191
1191
res = pgut_execute (tmp_conn , "SELECT pg_ptrack_get_and_clear_db($1, $2)" ,
1192
- 2 , (const char * * )params );
1192
+ 2 , (const char * * )params , true );
1193
1193
PQclear (res );
1194
1194
1195
1195
pgut_disconnect (tmp_conn );
@@ -1215,7 +1215,7 @@ pg_ptrack_get_and_clear_db(Oid dbOid, Oid tblspcOid)
1215
1215
sprintf (params [0 ], "%i" , dbOid );
1216
1216
res_db = pgut_execute (backup_conn ,
1217
1217
"SELECT datname FROM pg_database WHERE oid=$1" ,
1218
- 1 , (const char * * ) params );
1218
+ 1 , (const char * * ) params , true );
1219
1219
/*
1220
1220
* If database is not found, it's not an error.
1221
1221
* It could have been deleted since previous backup.
@@ -1236,7 +1236,7 @@ pg_ptrack_get_and_clear_db(Oid dbOid, Oid tblspcOid)
1236
1236
sprintf (params [0 ], "%i" , dbOid );
1237
1237
sprintf (params [1 ], "%i" , tblspcOid );
1238
1238
res = pgut_execute (backup_conn , "SELECT pg_ptrack_get_and_clear_db($1, $2)" ,
1239
- 2 , (const char * * )params );
1239
+ 2 , (const char * * )params , true );
1240
1240
1241
1241
if (PQnfields (res ) != 1 )
1242
1242
elog (ERROR , "cannot perform pg_ptrack_get_and_clear_db()" );
@@ -1277,7 +1277,7 @@ pg_ptrack_get_and_clear(Oid tablespace_oid, Oid db_oid, Oid rel_filenode,
1277
1277
sprintf (params [0 ], "%i" , db_oid );
1278
1278
res_db = pgut_execute (backup_conn ,
1279
1279
"SELECT datname FROM pg_database WHERE oid=$1" ,
1280
- 1 , (const char * * ) params );
1280
+ 1 , (const char * * ) params , true );
1281
1281
/*
1282
1282
* If database is not found, it's not an error.
1283
1283
* It could have been deleted since previous backup.
@@ -1297,7 +1297,7 @@ pg_ptrack_get_and_clear(Oid tablespace_oid, Oid db_oid, Oid rel_filenode,
1297
1297
sprintf (params [0 ], "%i" , tablespace_oid );
1298
1298
sprintf (params [1 ], "%i" , rel_filenode );
1299
1299
res = pgut_execute (tmp_conn , "SELECT pg_ptrack_get_and_clear($1, $2)" ,
1300
- 2 , (const char * * )params );
1300
+ 2 , (const char * * )params , true );
1301
1301
1302
1302
if (PQnfields (res ) != 1 )
1303
1303
elog (ERROR , "cannot get ptrack file from database \"%s\" by tablespace oid %u and relation oid %u" ,
@@ -1315,7 +1315,7 @@ pg_ptrack_get_and_clear(Oid tablespace_oid, Oid db_oid, Oid rel_filenode,
1315
1315
sprintf (params [0 ], "%i" , tablespace_oid );
1316
1316
sprintf (params [1 ], "%i" , rel_filenode );
1317
1317
res = pgut_execute (backup_conn , "SELECT pg_ptrack_get_and_clear($1, $2)" ,
1318
- 2 , (const char * * )params );
1318
+ 2 , (const char * * )params , true );
1319
1319
1320
1320
if (PQnfields (res ) != 1 )
1321
1321
elog (ERROR , "cannot get ptrack file from pg_global tablespace and relation oid %u" ,
@@ -1472,10 +1472,10 @@ wait_replica_wal_lsn(XLogRecPtr lsn, bool is_start_backup)
1472
1472
{
1473
1473
if (server_version >= 100000 )
1474
1474
res = pgut_execute (backup_conn , "SELECT pg_last_wal_replay_lsn()" ,
1475
- 0 , NULL );
1475
+ 0 , NULL , true );
1476
1476
else
1477
1477
res = pgut_execute (backup_conn , "SELECT pg_last_xlog_replay_location()" ,
1478
- 0 , NULL );
1478
+ 0 , NULL , true );
1479
1479
}
1480
1480
/*
1481
1481
* For lsn from pg_stop_backup() we need it only to be received by
@@ -1485,10 +1485,10 @@ wait_replica_wal_lsn(XLogRecPtr lsn, bool is_start_backup)
1485
1485
{
1486
1486
if (server_version >= 100000 )
1487
1487
res = pgut_execute (backup_conn , "SELECT pg_last_wal_receive_lsn()" ,
1488
- 0 , NULL );
1488
+ 0 , NULL , true );
1489
1489
else
1490
1490
res = pgut_execute (backup_conn , "SELECT pg_last_xlog_receive_location()" ,
1491
- 0 , NULL );
1491
+ 0 , NULL , true );
1492
1492
}
1493
1493
1494
1494
/* Extract timeline and LSN from result */
@@ -1555,7 +1555,7 @@ pg_stop_backup(pgBackup *backup)
1555
1555
1556
1556
/* Remove annoying NOTICE messages generated by backend */
1557
1557
res = pgut_execute (conn , "SET client_min_messages = warning;" ,
1558
- 0 , NULL );
1558
+ 0 , NULL , true );
1559
1559
PQclear (res );
1560
1560
1561
1561
/* Create restore point */
@@ -1576,7 +1576,7 @@ pg_stop_backup(pgBackup *backup)
1576
1576
params [0 ] = name ;
1577
1577
1578
1578
res = pgut_execute (conn , "SELECT pg_create_restore_point($1)" ,
1579
- 1 , params );
1579
+ 1 , params , true );
1580
1580
PQclear (res );
1581
1581
1582
1582
pfree (backup_id );
@@ -1610,13 +1610,11 @@ pg_stop_backup(pgBackup *backup)
1610
1610
}
1611
1611
else
1612
1612
{
1613
- if (current .tablespace_map_exists )
1614
- {
1615
- /* We cannot execute pg_read_file after pg_stop_backup */
1616
- tablespace_map_content = pgut_execute (conn ,
1617
- "SELECT pg_read_file('tablespace_map')" ,
1618
- 0 , NULL );
1619
- }
1613
+
1614
+ tablespace_map_content = pgut_execute (conn ,
1615
+ "SELECT pg_read_file('tablespace_map');" ,
1616
+ 0 , NULL , false);
1617
+
1620
1618
sent = pgut_send (conn ,
1621
1619
"SELECT"
1622
1620
" pg_read_file('backup_label') as labelfile,"
@@ -1739,11 +1737,8 @@ pg_stop_backup(pgBackup *backup)
1739
1737
*/
1740
1738
if (exclusive_backup )
1741
1739
{
1742
- if (current .tablespace_map_exists )
1743
- {
1740
+ if (PQresultStatus (tablespace_map_content ) == PGRES_TUPLES_OK )
1744
1741
val = PQgetvalue (tablespace_map_content , 0 , 0 );
1745
- PQclear (tablespace_map_content );
1746
- }
1747
1742
}
1748
1743
else
1749
1744
val = PQgetvalue (res , 0 , 4 );
@@ -1776,6 +1771,7 @@ pg_stop_backup(pgBackup *backup)
1776
1771
file -> path = strdup (PG_TABLESPACE_MAP_FILE );
1777
1772
parray_append (backup_files_list , file );
1778
1773
}
1774
+ PQclear (tablespace_map_content );
1779
1775
}
1780
1776
PQclear (res );
1781
1777
if (stream_wal )
@@ -1832,7 +1828,7 @@ checkpoint_timeout(void)
1832
1828
const char * hintmsg ;
1833
1829
int val_int ;
1834
1830
1835
- res = pgut_execute (backup_conn , "show checkpoint_timeout" , 0 , NULL );
1831
+ res = pgut_execute (backup_conn , "show checkpoint_timeout" , 0 , NULL , true );
1836
1832
val = PQgetvalue (res , 0 , 0 );
1837
1833
1838
1834
if (!parse_int (val , & val_int , OPTION_UNIT_S , & hintmsg ))
@@ -2691,7 +2687,7 @@ get_last_ptrack_lsn(void)
2691
2687
uint32 xrecoff ;
2692
2688
XLogRecPtr lsn ;
2693
2689
2694
- res = pgut_execute (backup_conn , "select pg_ptrack_control_lsn()" , 0 , NULL );
2690
+ res = pgut_execute (backup_conn , "select pg_ptrack_control_lsn()" , 0 , NULL , true );
2695
2691
2696
2692
/* Extract timeline and LSN from results of pg_start_backup() */
2697
2693
XLogDataFromLSN (PQgetvalue (res , 0 , 0 ), & xlogid , & xrecoff );
0 commit comments