@@ -54,6 +54,7 @@ static pthread_t stream_thread;
54
54
static int is_ptrack_enable = false;
55
55
bool is_ptrack_support = false;
56
56
bool is_checksum_enabled = false;
57
+ bool exclusive_backup = false;
57
58
58
59
/* Backup connections */
59
60
static PGconn * backup_conn = NULL ;
@@ -64,7 +65,6 @@ static PGconn *backup_conn_replication = NULL;
64
65
static int server_version = 0 ;
65
66
static char server_version_str [100 ] = "" ;
66
67
67
- static bool exclusive_backup = false;
68
68
/* Is pg_start_backup() was executed */
69
69
static bool backup_in_progress = false;
70
70
/* Is pg_stop_backup() was sent */
@@ -1600,25 +1600,19 @@ pg_stop_backup(pgBackup *backup)
1600
1600
*/
1601
1601
sent = pgut_send (conn ,
1602
1602
"SELECT"
1603
- " labelfile,"
1604
1603
" txid_snapshot_xmax(txid_current_snapshot()),"
1605
1604
" current_timestamp(0)::timestamptz,"
1606
1605
" lsn,"
1606
+ " labelfile,"
1607
1607
" spcmapfile"
1608
1608
" FROM pg_stop_backup(false)" ,
1609
1609
0 , NULL , WARNING );
1610
1610
}
1611
1611
else
1612
1612
{
1613
1613
1614
- tablespace_map_content = pgut_execute (conn ,
1615
- "SELECT pg_read_file('tablespace_map', 0, size, true)"
1616
- " FROM pg_stat_file('tablespace_map', true)" ,
1617
- 0 , NULL , true);
1618
-
1619
1614
sent = pgut_send (conn ,
1620
1615
"SELECT"
1621
- " pg_read_file('backup_label') as labelfile,"
1622
1616
" txid_snapshot_xmax(txid_current_snapshot()),"
1623
1617
" current_timestamp(0)::timestamptz,"
1624
1618
" pg_stop_backup() as lsn" ,
@@ -1676,7 +1670,7 @@ pg_stop_backup(pgBackup *backup)
1676
1670
backup_in_progress = false;
1677
1671
1678
1672
/* Extract timeline and LSN from results of pg_stop_backup() */
1679
- XLogDataFromLSN (PQgetvalue (res , 0 , 3 ), & xlogid , & xrecoff );
1673
+ XLogDataFromLSN (PQgetvalue (res , 0 , 2 ), & xlogid , & xrecoff );
1680
1674
/* Calculate LSN */
1681
1675
stop_backup_lsn = (XLogRecPtr ) ((uint64 ) xlogid << 32 ) | xrecoff ;
1682
1676
@@ -1690,61 +1684,57 @@ pg_stop_backup(pgBackup *backup)
1690
1684
(uint32 ) (stop_backup_lsn >> 32 ), (uint32 ) (stop_backup_lsn ));
1691
1685
1692
1686
/* Write backup_label and tablespace_map */
1693
- Assert (PQnfields (res ) >= 4 );
1694
- pgBackupGetPath (& current , path , lengthof (path ), DATABASE_DIR );
1695
-
1696
- /* Write backup_label */
1697
- join_path_components (backup_label , path , PG_BACKUP_LABEL_FILE );
1698
- fp = fopen (backup_label , "w" );
1699
- if (fp == NULL )
1700
- elog (ERROR , "can't open backup label file \"%s\": %s" ,
1701
- backup_label , strerror (errno ));
1702
-
1703
- len = strlen (PQgetvalue (res , 0 , 0 ));
1704
- if (fwrite (PQgetvalue (res , 0 , 0 ), 1 , len , fp ) != len ||
1705
- fflush (fp ) != 0 ||
1706
- fsync (fileno (fp )) != 0 ||
1707
- fclose (fp ))
1708
- elog (ERROR , "can't write backup label file \"%s\": %s" ,
1709
- backup_label , strerror (errno ));
1710
-
1711
- /*
1712
- * It's vital to check if backup_files_list is initialized,
1713
- * because we could get here because the backup was interrupted
1714
- */
1715
- if (backup_files_list )
1687
+ if (!exclusive_backup )
1716
1688
{
1717
- file = pgFileNew (backup_label , true);
1718
- calc_file_checksum (file );
1719
- free (file -> path );
1720
- file -> path = strdup (PG_BACKUP_LABEL_FILE );
1721
- parray_append (backup_files_list , file );
1689
+ Assert (PQnfields (res ) >= 4 );
1690
+ pgBackupGetPath (& current , path , lengthof (path ), DATABASE_DIR );
1691
+
1692
+ /* Write backup_label */
1693
+ join_path_components (backup_label , path , PG_BACKUP_LABEL_FILE );
1694
+ fp = fopen (backup_label , "w" );
1695
+ if (fp == NULL )
1696
+ elog (ERROR , "can't open backup label file \"%s\": %s" ,
1697
+ backup_label , strerror (errno ));
1698
+
1699
+ len = strlen (PQgetvalue (res , 0 , 3 ));
1700
+ if (fwrite (PQgetvalue (res , 0 , 3 ), 1 , len , fp ) != len ||
1701
+ fflush (fp ) != 0 ||
1702
+ fsync (fileno (fp )) != 0 ||
1703
+ fclose (fp ))
1704
+ elog (ERROR , "can't write backup label file \"%s\": %s" ,
1705
+ backup_label , strerror (errno ));
1706
+
1707
+ /*
1708
+ * It's vital to check if backup_files_list is initialized,
1709
+ * because we could get here because the backup was interrupted
1710
+ */
1711
+ if (backup_files_list )
1712
+ {
1713
+ file = pgFileNew (backup_label , true);
1714
+ calc_file_checksum (file );
1715
+ free (file -> path );
1716
+ file -> path = strdup (PG_BACKUP_LABEL_FILE );
1717
+ parray_append (backup_files_list , file );
1718
+ }
1722
1719
}
1723
1720
1724
- if (sscanf (PQgetvalue (res , 0 , 1 ), XID_FMT , & recovery_xid ) != 1 )
1721
+ if (sscanf (PQgetvalue (res , 0 , 0 ), XID_FMT , & recovery_xid ) != 1 )
1725
1722
elog (ERROR ,
1726
1723
"result of txid_snapshot_xmax() is invalid: %s" ,
1727
1724
PQerrorMessage (conn ));
1728
- if (!parse_time (PQgetvalue (res , 0 , 2 ), & recovery_time ))
1725
+ if (!parse_time (PQgetvalue (res , 0 , 1 ), & recovery_time ))
1729
1726
elog (ERROR ,
1730
1727
"result of current_timestamp is invalid: %s" ,
1731
1728
PQerrorMessage (conn ));
1732
1729
1733
- /* Get content for tablespace_map from pg_read_file('tablespace_map') in case of exclusive
1734
- * or from stop_backup results in case of non-exclusive backup
1730
+ /* Get content for tablespace_map from stop_backup results
1731
+ * in case of non-exclusive backup
1735
1732
*/
1736
- if (exclusive_backup )
1737
- {
1738
- Assert (tablespace_map_content );
1739
-
1740
- if (PQresultStatus (tablespace_map_content ) == PGRES_TUPLES_OK )
1741
- val = PQgetvalue (tablespace_map_content , 0 , 0 );
1742
- }
1743
- else
1733
+ if (!exclusive_backup )
1744
1734
val = PQgetvalue (res , 0 , 4 );
1745
1735
1746
1736
/* Write tablespace_map */
1747
- if (val && strlen (val ) > 0 )
1737
+ if (! exclusive_backup && val && strlen (val ) > 0 )
1748
1738
{
1749
1739
char tablespace_map [MAXPGPATH ];
1750
1740
0 commit comments