@@ -877,33 +877,33 @@ do_backup(time_t start_time)
877
877
static void
878
878
check_server_version (void )
879
879
{
880
- PGresult * res ;
881
-
882
880
/* confirm server version */
883
881
server_version = PQserverVersion (backup_conn );
884
882
883
+ if (server_version == 0 )
884
+ elog (ERROR , "Unknown server version %d" , server_version );
885
+
886
+ if (server_version < 100000 )
887
+ sprintf (server_version_str , "%d.%d" ,
888
+ server_version / 10000 ,
889
+ (server_version / 100 ) % 100 );
890
+ else
891
+ sprintf (server_version_str , "%d" ,
892
+ server_version / 10000 );
893
+
885
894
if (server_version < 90500 )
886
895
elog (ERROR ,
887
- "server version is %d.%d.%d, must be %s or higher" ,
888
- server_version / 10000 ,
889
- (server_version / 100 ) % 100 ,
890
- server_version % 100 , "9.5" );
896
+ "server version is %s, must be %s or higher" ,
897
+ server_version_str , "9.5" );
891
898
892
899
if (from_replica && server_version < 90600 )
893
900
elog (ERROR ,
894
- "server version is %d.%d.%d, must be %s or higher for backup from replica" ,
895
- server_version / 10000 ,
896
- (server_version / 100 ) % 100 ,
897
- server_version % 100 , "9.6" );
901
+ "server version is %s, must be %s or higher for backup from replica" ,
902
+ server_version_str , "9.6" );
898
903
899
904
/* Do exclusive backup only for PostgreSQL 9.5 */
900
905
exclusive_backup = server_version < 90600 ||
901
906
current .backup_mode == BACKUP_MODE_DIFF_PTRACK ;
902
-
903
- /* Save server_version to use it in future */
904
- res = pgut_execute (backup_conn , "show server_version" , 0 , NULL , true);
905
- StrNCpy (server_version_str , PQgetvalue (res , 0 , 0 ), sizeof (server_version_str ));
906
- PQclear (res );
907
907
}
908
908
909
909
/*
@@ -940,7 +940,7 @@ confirm_block_size(const char *name, int blcksz)
940
940
char * endp ;
941
941
int block_size ;
942
942
943
- res = pgut_execute (backup_conn , "SELECT current_setting($1)" , 1 , & name , true);
943
+ res = pgut_execute (backup_conn , "SELECT pg_catalog. current_setting($1)" , 1 , & name , true);
944
944
if (PQntuples (res ) != 1 || PQnfields (res ) != 1 )
945
945
elog (ERROR , "cannot get %s: %s" , name , PQerrorMessage (backup_conn ));
946
946
@@ -974,13 +974,13 @@ pg_start_backup(const char *label, bool smooth, pgBackup *backup)
974
974
params [1 ] = smooth ? "false" : "true" ;
975
975
if (!exclusive_backup )
976
976
res = pgut_execute (conn ,
977
- "SELECT pg_start_backup($1, $2, false)" ,
977
+ "SELECT pg_catalog. pg_start_backup($1, $2, false)" ,
978
978
2 ,
979
979
params ,
980
980
true);
981
981
else
982
982
res = pgut_execute (conn ,
983
- "SELECT pg_start_backup($1, $2)" ,
983
+ "SELECT pg_catalog. pg_start_backup($1, $2)" ,
984
984
2 ,
985
985
params ,
986
986
true);
@@ -1038,9 +1038,9 @@ pg_switch_wal(PGconn *conn)
1038
1038
PQclear (res );
1039
1039
1040
1040
if (server_version >= 100000 )
1041
- res = pgut_execute (conn , "SELECT * FROM pg_switch_wal()" , 0 , NULL , true);
1041
+ res = pgut_execute (conn , "SELECT * FROM pg_catalog. pg_switch_wal()" , 0 , NULL , true);
1042
1042
else
1043
- res = pgut_execute (conn , "SELECT * FROM pg_switch_xlog()" , 0 , NULL , true);
1043
+ res = pgut_execute (conn , "SELECT * FROM pg_catalog. pg_switch_xlog()" , 0 , NULL , true);
1044
1044
1045
1045
PQclear (res );
1046
1046
}
@@ -1065,7 +1065,7 @@ pg_ptrack_support(void)
1065
1065
PQclear (res_db );
1066
1066
1067
1067
res_db = pgut_execute (backup_conn ,
1068
- "SELECT ptrack_version()" ,
1068
+ "SELECT pg_catalog. ptrack_version()" ,
1069
1069
0 , NULL , true);
1070
1070
if (PQntuples (res_db ) == 0 )
1071
1071
{
@@ -1125,7 +1125,7 @@ pg_is_in_recovery(void)
1125
1125
{
1126
1126
PGresult * res_db ;
1127
1127
1128
- res_db = pgut_execute (backup_conn , "SELECT pg_is_in_recovery()" , 0 , NULL , true);
1128
+ res_db = pgut_execute (backup_conn , "SELECT pg_catalog. pg_is_in_recovery()" , 0 , NULL , true);
1129
1129
1130
1130
if (PQgetvalue (res_db , 0 , 0 )[0 ] == 't' )
1131
1131
{
@@ -1164,11 +1164,11 @@ pg_ptrack_clear(void)
1164
1164
tblspcOid = atoi (PQgetvalue (res_db , i , 2 ));
1165
1165
1166
1166
tmp_conn = pgut_connect (dbname );
1167
- res = pgut_execute (tmp_conn , "SELECT pg_ptrack_clear()" , 0 , NULL , true);
1167
+ res = pgut_execute (tmp_conn , "SELECT pg_catalog. pg_ptrack_clear()" , 0 , NULL , true);
1168
1168
1169
1169
sprintf (params [0 ], "%i" , dbOid );
1170
1170
sprintf (params [1 ], "%i" , tblspcOid );
1171
- res = pgut_execute (tmp_conn , "SELECT pg_ptrack_get_and_clear_db($1, $2)" ,
1171
+ res = pgut_execute (tmp_conn , "SELECT pg_catalog. pg_ptrack_get_and_clear_db($1, $2)" ,
1172
1172
2 , (const char * * )params , true);
1173
1173
PQclear (res );
1174
1174
@@ -1215,7 +1215,7 @@ pg_ptrack_get_and_clear_db(Oid dbOid, Oid tblspcOid)
1215
1215
1216
1216
sprintf (params [0 ], "%i" , dbOid );
1217
1217
sprintf (params [1 ], "%i" , tblspcOid );
1218
- res = pgut_execute (backup_conn , "SELECT pg_ptrack_get_and_clear_db($1, $2)" ,
1218
+ res = pgut_execute (backup_conn , "SELECT pg_catalog. pg_ptrack_get_and_clear_db($1, $2)" ,
1219
1219
2 , (const char * * )params , true);
1220
1220
1221
1221
if (PQnfields (res ) != 1 )
@@ -1276,7 +1276,7 @@ pg_ptrack_get_and_clear(Oid tablespace_oid, Oid db_oid, Oid rel_filenode,
1276
1276
tmp_conn = pgut_connect (dbname );
1277
1277
sprintf (params [0 ], "%i" , tablespace_oid );
1278
1278
sprintf (params [1 ], "%i" , rel_filenode );
1279
- res = pgut_execute (tmp_conn , "SELECT pg_ptrack_get_and_clear($1, $2)" ,
1279
+ res = pgut_execute (tmp_conn , "SELECT pg_catalog. pg_ptrack_get_and_clear($1, $2)" ,
1280
1280
2 , (const char * * )params , true);
1281
1281
1282
1282
if (PQnfields (res ) != 1 )
@@ -1294,7 +1294,7 @@ pg_ptrack_get_and_clear(Oid tablespace_oid, Oid db_oid, Oid rel_filenode,
1294
1294
*/
1295
1295
sprintf (params [0 ], "%i" , tablespace_oid );
1296
1296
sprintf (params [1 ], "%i" , rel_filenode );
1297
- res = pgut_execute (backup_conn , "SELECT pg_ptrack_get_and_clear($1, $2)" ,
1297
+ res = pgut_execute (backup_conn , "SELECT pg_catalog. pg_ptrack_get_and_clear($1, $2)" ,
1298
1298
2 , (const char * * )params , true);
1299
1299
1300
1300
if (PQnfields (res ) != 1 )
@@ -1475,10 +1475,10 @@ wait_replica_wal_lsn(XLogRecPtr lsn, bool is_start_backup)
1475
1475
if (is_start_backup )
1476
1476
{
1477
1477
if (server_version >= 100000 )
1478
- res = pgut_execute (backup_conn , "SELECT pg_last_wal_replay_lsn()" ,
1478
+ res = pgut_execute (backup_conn , "SELECT pg_catalog. pg_last_wal_replay_lsn()" ,
1479
1479
0 , NULL , true);
1480
1480
else
1481
- res = pgut_execute (backup_conn , "SELECT pg_last_xlog_replay_location()" ,
1481
+ res = pgut_execute (backup_conn , "SELECT pg_catalog. pg_last_xlog_replay_location()" ,
1482
1482
0 , NULL , true);
1483
1483
}
1484
1484
/*
@@ -1488,10 +1488,10 @@ wait_replica_wal_lsn(XLogRecPtr lsn, bool is_start_backup)
1488
1488
else
1489
1489
{
1490
1490
if (server_version >= 100000 )
1491
- res = pgut_execute (backup_conn , "SELECT pg_last_wal_receive_lsn()" ,
1491
+ res = pgut_execute (backup_conn , "SELECT pg_catalog. pg_last_wal_receive_lsn()" ,
1492
1492
0 , NULL , true);
1493
1493
else
1494
- res = pgut_execute (backup_conn , "SELECT pg_last_xlog_receive_location()" ,
1494
+ res = pgut_execute (backup_conn , "SELECT pg_catalog. pg_last_xlog_receive_location()" ,
1495
1495
0 , NULL , true);
1496
1496
}
1497
1497
@@ -1575,7 +1575,7 @@ pg_stop_backup(pgBackup *backup)
1575
1575
base36enc (backup -> start_time ));
1576
1576
params [0 ] = name ;
1577
1577
1578
- res = pgut_execute (conn , "SELECT pg_create_restore_point($1)" ,
1578
+ res = pgut_execute (conn , "SELECT pg_catalog. pg_create_restore_point($1)" ,
1579
1579
1 , params , true);
1580
1580
PQclear (res );
1581
1581
}
@@ -1600,22 +1600,22 @@ pg_stop_backup(pgBackup *backup)
1600
1600
*/
1601
1601
sent = pgut_send (conn ,
1602
1602
"SELECT"
1603
- " txid_snapshot_xmax(txid_current_snapshot()),"
1603
+ " pg_catalog. txid_snapshot_xmax(pg_catalog. txid_current_snapshot()),"
1604
1604
" current_timestamp(0)::timestamptz,"
1605
1605
" lsn,"
1606
1606
" labelfile,"
1607
1607
" spcmapfile"
1608
- " FROM pg_stop_backup(false)" ,
1608
+ " FROM pg_catalog. pg_stop_backup(false)" ,
1609
1609
0 , NULL , WARNING );
1610
1610
}
1611
1611
else
1612
1612
{
1613
1613
1614
1614
sent = pgut_send (conn ,
1615
1615
"SELECT"
1616
- " txid_snapshot_xmax(txid_current_snapshot()),"
1616
+ " pg_catalog. txid_snapshot_xmax(pg_catalog. txid_current_snapshot()),"
1617
1617
" current_timestamp(0)::timestamptz,"
1618
- " pg_stop_backup() as lsn" ,
1618
+ " pg_catalog. pg_stop_backup() as lsn" ,
1619
1619
0 , NULL , WARNING );
1620
1620
}
1621
1621
pg_stop_backup_is_sent = true;
@@ -2118,8 +2118,8 @@ parse_backup_filelist_filenames(parray *files, const char *root)
2118
2118
continue ;
2119
2119
}
2120
2120
2121
- /* Check files located inside database directories */
2122
- if (filename [0 ] != '\0' && file -> dbOid != 0 )
2121
+ /* Check files located inside database directories including directory 'global' */
2122
+ if (filename [0 ] != '\0' && file -> tblspcOid != 0 )
2123
2123
{
2124
2124
if (strcmp (filename , "pg_internal.init" ) == 0 )
2125
2125
{
@@ -2679,7 +2679,7 @@ get_last_ptrack_lsn(void)
2679
2679
uint32 xrecoff ;
2680
2680
XLogRecPtr lsn ;
2681
2681
2682
- res = pgut_execute (backup_conn , "select pg_ptrack_control_lsn()" , 0 , NULL , true);
2682
+ res = pgut_execute (backup_conn , "select pg_catalog. pg_ptrack_control_lsn()" , 0 , NULL , true);
2683
2683
2684
2684
/* Extract timeline and LSN from results of pg_start_backup() */
2685
2685
XLogDataFromLSN (PQgetvalue (res , 0 , 0 ), & xlogid , & xrecoff );
@@ -2727,7 +2727,7 @@ pg_ptrack_get_block(backup_files_args *arguments,
2727
2727
//elog(LOG, "db %i pg_ptrack_get_block(%i, %i, %u)",dbOid, tblsOid, relOid, blknum);
2728
2728
res = pgut_execute_parallel (arguments -> thread_backup_conn ,
2729
2729
arguments -> thread_cancel_conn ,
2730
- "SELECT pg_ptrack_get_block_2($1, $2, $3, $4)" ,
2730
+ "SELECT pg_catalog. pg_ptrack_get_block_2($1, $2, $3, $4)" ,
2731
2731
4 , (const char * * )params , true);
2732
2732
2733
2733
if (PQnfields (res ) != 1 )
@@ -2755,4 +2755,4 @@ pg_ptrack_get_block(backup_files_args *arguments,
2755
2755
pfree (params [3 ]);
2756
2756
2757
2757
return result ;
2758
- }
2758
+ }
0 commit comments