Skip to content

Commit 3d62e2a

Browse files
committed
Refactoting. Move new state definitions to a separate header
1 parent 48b8f60 commit 3d62e2a

File tree

3 files changed

+50
-24
lines changed

3 files changed

+50
-24
lines changed

src/pg_probackup.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
1313
*
14-
* TODO:
14+
* TODO (see pg_probackup_state.h):
1515
*
1616
* Functions that work with a backup catalog accept catalogState,
1717
* which currently only contains pathes to backup catalog subdirectories
@@ -38,6 +38,7 @@
3838
*/
3939

4040
#include "pg_probackup.h"
41+
#include "pg_probackup_state.h"
4142

4243
#include "pg_getopt.h"
4344
#include "streamutil.h"

src/pg_probackup.h

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#ifndef PG_PROBACKUP_H
1111
#define PG_PROBACKUP_H
1212

13+
1314
#include "postgres_fe.h"
1415
#include "libpq-fe.h"
1516
#include "libpq-int.h"
@@ -39,6 +40,9 @@
3940
#include "datapagemap.h"
4041
#include "utils/thread.h"
4142

43+
#include "pg_probackup_state.h"
44+
45+
4246
#ifdef WIN32
4347
#define __thread __declspec(thread)
4448
#else
@@ -755,16 +759,6 @@ extern char *backup_path;
755759
extern char backup_instance_path[MAXPGPATH];
756760
extern char arclog_path[MAXPGPATH];
757761

758-
typedef struct CatalogState
759-
{
760-
/* $BACKUP_PATH */
761-
char catalog_path[MAXPGPATH]; //previously global var backup_path
762-
/* $BACKUP_PATH/backups */
763-
char backup_subdir_path[MAXPGPATH];
764-
/* $BACKUP_PATH/wal */
765-
char wal_subdir_path[MAXPGPATH]; // previously global var arclog_path
766-
} CatalogState;
767-
768762
/* ====== CatalogState (END) ======= */
769763

770764
/* common options */
@@ -797,19 +791,6 @@ extern bool dry_run;
797791

798792
/* ===== instanceState ===== */
799793
extern char *instance_name;
800-
typedef struct InstanceState
801-
{
802-
/* catalog, this instance belongs to */
803-
CatalogState *catalog_state;
804-
805-
char instance_name[MAXPGPATH]; //previously global var instance_name
806-
/* $BACKUP_PATH/backups/instance_name */
807-
char instance_backup_subdir_path[MAXPGPATH];
808-
/* $BACKUP_PATH/backups/instance_name */
809-
char instance_wal_subdir_path[MAXPGPATH]; // previously global var arclog_path
810-
811-
//TODO add config here
812-
} InstanceState;
813794

814795
/* ===== instanceState (END) ===== */
815796

src/pg_probackup_state.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* pg_probackup_state.h: Definitions of internal pg_probackup states
4+
*
5+
* Portions Copyright (c) 2021-2018, Postgres Professional
6+
*
7+
*-------------------------------------------------------------------------
8+
*/
9+
#ifndef PG_PROBACKUP_STATE_H
10+
#define PG_PROBACKUP_STATE_H
11+
12+
/* ====== CatalogState ======= */
13+
14+
typedef struct CatalogState
15+
{
16+
/* $BACKUP_PATH */
17+
char catalog_path[MAXPGPATH]; //previously global var backup_path
18+
/* $BACKUP_PATH/backups */
19+
char backup_subdir_path[MAXPGPATH];
20+
/* $BACKUP_PATH/wal */
21+
char wal_subdir_path[MAXPGPATH]; // previously global var arclog_path
22+
} CatalogState;
23+
24+
/* ====== CatalogState (END) ======= */
25+
26+
27+
/* ===== instanceState ===== */
28+
typedef struct InstanceState
29+
{
30+
/* catalog, this instance belongs to */
31+
CatalogState *catalog_state;
32+
33+
char instance_name[MAXPGPATH]; //previously global var instance_name
34+
/* $BACKUP_PATH/backups/instance_name */
35+
char instance_backup_subdir_path[MAXPGPATH];
36+
/* $BACKUP_PATH/backups/instance_name */
37+
char instance_wal_subdir_path[MAXPGPATH]; // previously global var arclog_path
38+
39+
//TODO add config here
40+
} InstanceState;
41+
42+
/* ===== instanceState (END) ===== */
43+
44+
#endif /* PG_PROBACKUP_STATE_H */

0 commit comments

Comments
 (0)