Skip to content

Commit 77c5915

Browse files
committed
PGPRO-2071: Refactor pg_probackup configure set/get, use InstanceConfig
1 parent 141ba33 commit 77c5915

29 files changed

+2291
-2211
lines changed

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
PROGRAM = pg_probackup
22

33
# utils
4-
OBJS = src/utils/json.o src/utils/logger.o src/utils/parray.o \
5-
src/utils/pgut.o src/utils/thread.o
4+
OBJS = src/utils/configuration.o src/utils/json.o src/utils/logger.o \
5+
src/utils/parray.o src/utils/pgut.o src/utils/thread.o
66

77
OBJS += src/archive.o src/backup.o src/catalog.o src/configure.o src/data.o \
88
src/delete.o src/dir.o src/fetch.o src/help.o src/init.o src/merge.o \

gen_probackup_project.pl

+2-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ sub build_pgprobackup
149149
'validate.c'
150150
);
151151
$probackup->AddFiles(
152-
'contrib/pg_probackup/src/utils',
152+
'contrib/pg_probackup/src/utils',
153+
'configuration.c',
153154
'json.c',
154155
'logger.c',
155156
'parray.c',

msvs/template.pg_probackup.vcxproj

+2
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@
187187
<ClCompile Include="..\src\show.c" />
188188
<ClCompile Include="..\src\status.c" />
189189
<ClCompile Include="..\src\util.c" />
190+
<ClCompile Include="..\src\utils\configuration.c" />
190191
<ClCompile Include="..\src\utils\logger.c" />
191192
<ClCompile Include="..\src\utils\parray.c" />
192193
<ClCompile Include="..\src\utils\pgut.c" />
@@ -201,6 +202,7 @@
201202
<ClInclude Include="@PGSRC@\bin\pg_rewind\datapagemap.h" />
202203
<ClInclude Include="@PGSRC@\bin\pg_rewind\logging.h" />
203204
<ClInclude Include="..\src\pg_probackup.h" />
205+
<ClInclude Include="..\src\utils\configuration.h" />
204206
<ClInclude Include="..\src\utils\logger.h" />
205207
<ClInclude Include="..\src\utils\parray.h" />
206208
<ClInclude Include="..\src\utils\pgut.h" />

msvs/template.pg_probackup96.vcxproj

+2
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@
186186
<ClCompile Include="..\src\show.c" />
187187
<ClCompile Include="..\src\status.c" />
188188
<ClCompile Include="..\src\util.c" />
189+
<ClCompile Include="..\src\utils\configuration.c" />
189190
<ClCompile Include="..\src\utils\logger.c" />
190191
<ClCompile Include="..\src\utils\parray.c" />
191192
<ClCompile Include="..\src\utils\pgut.c" />
@@ -199,6 +200,7 @@
199200
<ClInclude Include="@PGSRC@\bin\pg_rewind\datapagemap.h" />
200201
<ClInclude Include="@PGSRC@\bin\pg_rewind\logging.h" />
201202
<ClInclude Include="..\src\pg_probackup.h" />
203+
<ClInclude Include="..\src\utils\configuration.h" />
202204
<ClInclude Include="..\src\utils\logger.h" />
203205
<ClInclude Include="..\src\utils\parray.h" />
204206
<ClInclude Include="..\src\utils\pgut.h" />

msvs/template.pg_probackup_2.vcxproj

+2
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@
182182
<ClCompile Include="..\src\show.c" />
183183
<ClCompile Include="..\src\status.c" />
184184
<ClCompile Include="..\src\util.c" />
185+
<ClCompile Include="..\src\utils\configuration.c" />
185186
<ClCompile Include="..\src\utils\logger.c" />
186187
<ClCompile Include="..\src\utils\parray.c" />
187188
<ClCompile Include="..\src\utils\pgut.c" />
@@ -194,6 +195,7 @@
194195
<ClInclude Include="@PGSRC@\bin\pg_rewind\datapagemap.h" />
195196
<ClInclude Include="@PGSRC@\bin\pg_rewind\logging.h" />
196197
<ClInclude Include="..\src\pg_probackup.h" />
198+
<ClInclude Include="..\src\utils\configuration.h" />
197199
<ClInclude Include="..\src\utils\logger.h" />
198200
<ClInclude Include="..\src\utils\parray.h" />
199201
<ClInclude Include="..\src\utils\pgut.h" />

src/archive.c

+6-7
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ do_archive_push(char *wal_file_path, char *wal_file_name, bool overwrite)
2828
char absolute_wal_file_path[MAXPGPATH];
2929
char current_dir[MAXPGPATH];
3030
int64 system_id;
31-
pgBackupConfig *config;
3231
bool is_compress = false;
3332

3433
if (wal_file_name == NULL && wal_file_path == NULL)
@@ -44,16 +43,16 @@ do_archive_push(char *wal_file_path, char *wal_file_name, bool overwrite)
4443
elog(ERROR, "getcwd() error");
4544

4645
/* verify that archive-push --instance parameter is valid */
47-
config = readBackupCatalogConfigFile();
4846
system_id = get_system_identifier(current_dir);
4947

50-
if (config->pgdata == NULL)
48+
if (instance_config.pgdata == NULL)
5149
elog(ERROR, "cannot read pg_probackup.conf for this instance");
5250

53-
if(system_id != config->system_identifier)
51+
if(system_id != instance_config.system_identifier)
5452
elog(ERROR, "Refuse to push WAL segment %s into archive. Instance parameters mismatch."
5553
"Instance '%s' should have SYSTEM_ID = %ld instead of %ld",
56-
wal_file_name, instance_name, config->system_identifier, system_id);
54+
wal_file_name, instance_name, instance_config.system_identifier,
55+
system_id);
5756

5857
/* Create 'archlog_path' directory. Do nothing if it already exists. */
5958
dir_create_dir(arclog_path, DIR_PERMISSION);
@@ -63,11 +62,11 @@ do_archive_push(char *wal_file_path, char *wal_file_name, bool overwrite)
6362

6463
elog(INFO, "pg_probackup archive-push from %s to %s", absolute_wal_file_path, backup_wal_file_path);
6564

66-
if (compress_alg == PGLZ_COMPRESS)
65+
if (instance_config.compress_alg == PGLZ_COMPRESS)
6766
elog(ERROR, "pglz compression is not supported");
6867

6968
#ifdef HAVE_LIBZ
70-
if (compress_alg == ZLIB_COMPRESS)
69+
if (instance_config.compress_alg == ZLIB_COMPRESS)
7170
is_compress = IsXLogFileName(wal_file_name);
7271
#endif
7372

0 commit comments

Comments
 (0)