Skip to content

Commit ed5d71e

Browse files
committed
Make some functions and variables (from backup.c) accessible from other compilation units
1 parent fffa8b1 commit ed5d71e

File tree

2 files changed

+46
-36
lines changed

2 files changed

+46
-36
lines changed

src/backup.c

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
//const char *progname = "pg_probackup";
2828

2929
/* list of files contained in backup */
30-
static parray *backup_files_list = NULL;
30+
parray *backup_files_list = NULL;
3131

3232
/* We need critical section for datapagemap_add() in case of using threads */
3333
static pthread_mutex_t backup_pagemap_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -36,25 +36,7 @@ static pthread_mutex_t backup_pagemap_mutex = PTHREAD_MUTEX_INITIALIZER;
3636
bool exclusive_backup = false;
3737

3838
/* Is pg_start_backup() was executed */
39-
static bool backup_in_progress = false;
40-
41-
typedef struct PGStopBackupResult
42-
{
43-
/*
44-
* We will use values of snapshot_xid and invocation_time if there are
45-
* no transactions between start_lsn and stop_lsn.
46-
*/
47-
TransactionId snapshot_xid;
48-
time_t invocation_time;
49-
/*
50-
* Fields that store pg_catalog.pg_stop_backup() result
51-
*/
52-
XLogRecPtr lsn;
53-
size_t backup_label_content_len;
54-
char *backup_label_content;
55-
size_t tablespace_map_content_len;
56-
char *tablespace_map_content;
57-
} PGStopBackupResult;
39+
bool backup_in_progress = false;
5840

5941
/*
6042
* Backup routines
@@ -66,18 +48,9 @@ static void *backup_files(void *arg);
6648
static void do_backup_pg(InstanceState *instanceState, PGconn *backup_conn,
6749
PGNodeInfo *nodeInfo, bool no_sync, bool backup_logs);
6850

69-
static void pg_start_backup(const char *label, bool smooth, pgBackup *backup,
70-
PGNodeInfo *nodeInfo, PGconn *conn);
7151
static void pg_switch_wal(PGconn *conn);
72-
static void pg_silent_client_messages(PGconn *conn);
73-
static void pg_create_restore_point(PGconn *conn, time_t backup_start_time);
7452

7553
static void pg_stop_backup(InstanceState *instanceState, pgBackup *backup, PGconn *pg_startbackup_conn, PGNodeInfo *nodeInfo);
76-
static void pg_stop_backup_send(PGconn *conn, int server_version, bool is_started_on_replica, bool is_exclusive, char **query_text);
77-
78-
static XLogRecPtr wait_wal_lsn(const char *wal_segment_dir, XLogRecPtr lsn, bool is_start_lsn, TimeLineID tli,
79-
bool in_prev_segment, bool segment_only,
80-
int timeout_elevel, bool in_stream_dir);
8154

8255
static void check_external_for_tablespaces(parray *external_list,
8356
PGconn *backup_conn);
@@ -1062,7 +1035,7 @@ confirm_block_size(PGconn *conn, const char *name, int blcksz)
10621035
/*
10631036
* Notify start of backup to PostgreSQL server.
10641037
*/
1065-
static void
1038+
void
10661039
pg_start_backup(const char *label, bool smooth, pgBackup *backup,
10671040
PGNodeInfo *nodeInfo, PGconn *conn)
10681041
{
@@ -1297,7 +1270,7 @@ pg_is_superuser(PGconn *conn)
12971270
* Returns target LSN if such is found, failing that returns LSN of record prior to target LSN.
12981271
* Returns InvalidXLogRecPtr if 'segment_only' flag is used.
12991272
*/
1300-
static XLogRecPtr
1273+
XLogRecPtr
13011274
wait_wal_lsn(const char *wal_segment_dir, XLogRecPtr target_lsn, bool is_start_lsn, TimeLineID tli,
13021275
bool in_prev_segment, bool segment_only,
13031276
int timeout_elevel, bool in_stream_dir)
@@ -1459,7 +1432,7 @@ wait_wal_lsn(const char *wal_segment_dir, XLogRecPtr target_lsn, bool is_start_l
14591432
}
14601433

14611434
/* Remove annoying NOTICE messages generated by backend */
1462-
static void
1435+
void
14631436
pg_silent_client_messages(PGconn *conn)
14641437
{
14651438
PGresult *res;
@@ -1468,7 +1441,7 @@ pg_silent_client_messages(PGconn *conn)
14681441
PQclear(res);
14691442
}
14701443

1471-
static void
1444+
void
14721445
pg_create_restore_point(PGconn *conn, time_t backup_start_time)
14731446
{
14741447
PGresult *res;
@@ -1578,7 +1551,7 @@ pg_stop_backup_send(PGconn *conn, int server_version, bool is_started_on_replica
15781551
* parameters:
15791552
* -
15801553
*/
1581-
static void
1554+
void
15821555
pg_stop_backup_consume(PGconn *conn, int server_version,
15831556
bool is_exclusive, uint32 timeout, const char *query_text,
15841557
PGStopBackupResult *result)
@@ -1709,7 +1682,7 @@ pg_stop_backup_consume(PGconn *conn, int server_version,
17091682
/*
17101683
* helper routine used to write backup_label and tablespace_map in pg_stop_backup()
17111684
*/
1712-
static void
1685+
void
17131686
pg_stop_backup_write_file_helper(const char *path, const char *filename, const char *error_msg_filename,
17141687
const void *data, size_t len, parray *file_list)
17151688
{

src/pg_probackup.h

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,6 @@ typedef struct
600600
int ret;
601601
} backup_files_arg;
602602

603-
604603
typedef struct timelineInfo timelineInfo;
605604

606605
/* struct to collect info about timelines in WAL archive */
@@ -1260,4 +1259,42 @@ extern void start_WAL_streaming(PGconn *backup_conn, char *stream_dst_path,
12601259
ConnectionOptions *conn_opt,
12611260
XLogRecPtr startpos, TimeLineID starttli);
12621261
extern int wait_WAL_streaming_end(parray *backup_files_list);
1262+
1263+
/* external variables and functions, implemented in backup.c */
1264+
typedef struct PGStopBackupResult
1265+
{
1266+
/*
1267+
* We will use values of snapshot_xid and invocation_time if there are
1268+
* no transactions between start_lsn and stop_lsn.
1269+
*/
1270+
TransactionId snapshot_xid;
1271+
time_t invocation_time;
1272+
/*
1273+
* Fields that store pg_catalog.pg_stop_backup() result
1274+
*/
1275+
XLogRecPtr lsn;
1276+
size_t backup_label_content_len;
1277+
char *backup_label_content;
1278+
size_t tablespace_map_content_len;
1279+
char *tablespace_map_content;
1280+
} PGStopBackupResult;
1281+
1282+
extern bool backup_in_progress;
1283+
extern parray *backup_files_list;
1284+
1285+
extern void pg_start_backup(const char *label, bool smooth, pgBackup *backup,
1286+
PGNodeInfo *nodeInfo, PGconn *conn);
1287+
extern void pg_silent_client_messages(PGconn *conn);
1288+
extern void pg_create_restore_point(PGconn *conn, time_t backup_start_time);
1289+
extern void pg_stop_backup_send(PGconn *conn, int server_version, bool is_started_on_replica, bool is_exclusive, char **query_text);
1290+
extern void pg_stop_backup_consume(PGconn *conn, int server_version,
1291+
bool is_exclusive, uint32 timeout, const char *query_text,
1292+
PGStopBackupResult *result);
1293+
extern void pg_stop_backup_write_file_helper(const char *path, const char *filename, const char *error_msg_filename,
1294+
const void *data, size_t len, parray *file_list);
1295+
extern XLogRecPtr wait_wal_lsn(const char *wal_segment_dir, XLogRecPtr lsn, bool is_start_lsn, TimeLineID tli,
1296+
bool in_prev_segment, bool segment_only,
1297+
int timeout_elevel, bool in_stream_dir);
1298+
1299+
12631300
#endif /* PG_PROBACKUP_H */

0 commit comments

Comments
 (0)