Skip to content

Commit 94370e4

Browse files
author
Sergey Fukanchik
committed
[PBCKP-314] move err_i to the beginning of a function.
1 parent b8d6ab0 commit 94370e4

File tree

6 files changed

+26
-44
lines changed

6 files changed

+26
-44
lines changed

src/backup.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ do_backup_pg(InstanceState *instanceState, PGconn *backup_conn,
111111
time_t start_time, end_time;
112112
char pretty_time[20];
113113
char pretty_bytes[20];
114+
err_i err = $noerr();
115+
114116

115117
elog(INFO, "Database backup start");
116118
if(current.external_dir_str)
@@ -250,7 +252,6 @@ do_backup_pg(InstanceState *instanceState, PGconn *backup_conn,
250252
if (current.stream)
251253
{
252254
char stream_xlog_path[MAXPGPATH];
253-
err_i err;
254255

255256
join_path_components(stream_xlog_path, current.database_dir, PG_XLOG_DIR);
256257
err = $i(pioMakeDir, current.backup_location, .path = stream_xlog_path,
@@ -406,15 +407,11 @@ do_backup_pg(InstanceState *instanceState, PGconn *backup_conn,
406407
join_path_components(dirpath, current.database_dir, file->rel_path);
407408

408409
elog(LOG, "Create directory '%s'", dirpath);
410+
err = $i(pioMakeDir, current.backup_location, .path = dirpath,
411+
.mode = DIR_PERMISSION, .strict = false);
412+
if ($haserr(err))
409413
{
410-
err_i err;
411-
412-
err = $i(pioMakeDir, current.backup_location, .path = dirpath,
413-
.mode = DIR_PERMISSION, .strict = false);
414-
if ($haserr(err))
415-
{
416-
elog(WARNING, "%s", $errmsg(err));
417-
}
414+
elog(WARNING, "%s", $errmsg(err));
418415
}
419416
}
420417

src/catalog.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,7 +1461,7 @@ pgBackupInitDir(pgBackup *backup, const char *backup_instance_path)
14611461
int i;
14621462
char temp[MAXPGPATH];
14631463
parray *subdirs;
1464-
err_i err;
1464+
err_i err = $noerr();
14651465

14661466
/* Try to create backup directory at first */
14671467
err = create_backup_dir(backup, backup_instance_path);
@@ -1500,7 +1500,6 @@ pgBackupInitDir(pgBackup *backup, const char *backup_instance_path)
15001500
/* create directories for actual backup files */
15011501
for (i = 0; i < parray_num(subdirs); i++)
15021502
{
1503-
err_i err;
15041503
join_path_components(temp, backup->root_dir, parray_get(subdirs, i));
15051504
err = $i(pioMakeDir, backup->backup_location, .path = temp,
15061505
.mode = DIR_PERMISSION, .strict = false);

src/catchup.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,8 @@ do_catchup(const char *source_pgdata, const char *dest_pgdata, int num_threads,
633633
ssize_t transfered_datafiles_bytes = 0;
634634
ssize_t transfered_walfiles_bytes = 0;
635635
char pretty_source_bytes[20];
636+
err_i err = $noerr();
637+
636638

637639
source_conn = catchup_init_state(&source_node_info, source_pgdata, dest_pgdata);
638640
catchup_preflight_checks(&source_node_info, source_conn, source_pgdata, dest_pgdata);
@@ -705,8 +707,6 @@ do_catchup(const char *source_pgdata, const char *dest_pgdata, int num_threads,
705707
join_path_components(dest_xlog_path, dest_pgdata, PG_XLOG_DIR);
706708
if (!dry_run)
707709
{
708-
err_i err;
709-
710710
err = $i(pioMakeDir, local_location, .path = dest_xlog_path,
711711
.mode = DIR_PERMISSION, .strict = false);
712712
if($haserr(err))
@@ -829,8 +829,6 @@ do_catchup(const char *source_pgdata, const char *dest_pgdata, int num_threads,
829829
elog(LOG, "Create directory '%s'", dirpath);
830830
if (!dry_run)
831831
{
832-
err_i err;
833-
834832
err = $i(pioMakeDir, local_location, .path = dirpath,
835833
.mode = DIR_PERMISSION, .strict = false);
836834
if ($haserr(err))
@@ -870,8 +868,6 @@ do_catchup(const char *source_pgdata, const char *dest_pgdata, int num_threads,
870868

871869
if (!dry_run)
872870
{
873-
err_i err;
874-
875871
/* create tablespace directory */
876872
err = $i(pioMakeDir, local_location, .path = linked_path,
877873
.mode = file->mode, .strict = false);

src/dir.c

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,8 @@ create_data_directories(parray *dest_files, const char *data_dir, const char *ba
852852
parray *links = NULL;
853853
mode_t pg_tablespace_mode = DIR_PERMISSION;
854854
char to_path[MAXPGPATH];
855+
err_i err = $noerr();
856+
855857

856858
if (waldir_path && !dir_is_empty(waldir_path, location))
857859
{
@@ -933,15 +935,11 @@ create_data_directories(parray *dest_files, const char *data_dir, const char *ba
933935
waldir_path, to_path);
934936

935937
/* create tablespace directory from waldir_path*/
938+
err = $i(pioMakeDir, drive, .path = waldir_path,
939+
.mode = pg_tablespace_mode, .strict = false);
940+
if ($haserr(err))
936941
{
937-
err_i err;
938-
939-
err = $i(pioMakeDir, drive, .path = waldir_path,
940-
.mode = pg_tablespace_mode, .strict = false);
941-
if ($haserr(err))
942-
{
943-
elog(WARNING, "%s", $errmsg(err));
944-
}
942+
elog(WARNING, "%s", $errmsg(err));
945943
}
946944

947945
/* create link to linked_path */
@@ -984,15 +982,11 @@ create_data_directories(parray *dest_files, const char *data_dir, const char *ba
984982
linked_path, to_path);
985983

986984
/* create tablespace directory */
985+
err = $i(pioMakeDir, drive, .path = linked_path,
986+
.mode = pg_tablespace_mode, .strict = false);
987+
if ($haserr(err))
987988
{
988-
err_i err;
989-
990-
err = $i(pioMakeDir, drive, .path = linked_path,
991-
.mode = pg_tablespace_mode, .strict = false);
992-
if ($haserr(err))
993-
{
994-
elog(WARNING, "%s", $errmsg(err));
995-
}
989+
elog(WARNING, "%s", $errmsg(err));
996990
}
997991

998992
/* create link to linked_path */
@@ -1011,15 +1005,11 @@ create_data_directories(parray *dest_files, const char *data_dir, const char *ba
10111005
join_path_components(to_path, data_dir, dir->rel_path);
10121006

10131007
// TODO check exit code
1008+
err = $i(pioMakeDir, drive, .path = to_path, .mode = dir->mode,
1009+
.strict = false);
1010+
if ($haserr(err))
10141011
{
1015-
err_i err;
1016-
1017-
err = $i(pioMakeDir, drive, .path = to_path, .mode = dir->mode,
1018-
.strict = false);
1019-
if ($haserr(err))
1020-
{
1021-
elog(WARNING, "%s", $errmsg(err));
1022-
}
1012+
elog(WARNING, "%s", $errmsg(err));
10231013
}
10241014
}
10251015

src/merge.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,8 @@ merge_chain(InstanceState *instanceState,
461461
/* in-place merge flags */
462462
bool compression_match = false;
463463
bool program_version_match = false;
464+
err_i err = $noerr();
465+
464466
/* It's redundant to check block checksumms during merge */
465467
skip_block_validation = true;
466468

@@ -641,7 +643,6 @@ merge_chain(InstanceState *instanceState,
641643
{
642644
char dirpath[MAXPGPATH];
643645
char new_container[MAXPGPATH];
644-
err_i err;
645646

646647
makeExternalDirPathByNum(new_container, full_external_prefix,
647648
file->external_dir_num);

src/restore.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,7 @@ restore_chain(pgBackup *dest_backup, parray *parent_chain,
720720
size_t total_bytes = 0;
721721
char pretty_time[20];
722722
time_t start_time, end_time;
723+
err_i err = $noerr();
723724

724725
/* Preparations for actual restoring */
725726
time2iso(timestamp, lengthof(timestamp), dest_backup->start_time, false);
@@ -818,7 +819,6 @@ restore_chain(pgBackup *dest_backup, parray *parent_chain,
818819
for (i = 0; i < parray_num(external_dirs); i++)
819820
{
820821
char *dirpath = parray_get(external_dirs, i);
821-
err_i err;
822822

823823
err = $i(pioMakeDir, dest_backup->database_location,
824824
.path = dirpath, .mode = DIR_PERMISSION, .strict = false);
@@ -844,7 +844,6 @@ restore_chain(pgBackup *dest_backup, parray *parent_chain,
844844
{
845845
char *external_path;
846846
char dirpath[MAXPGPATH];
847-
err_i err;
848847

849848
if (parray_num(external_dirs) < file->external_dir_num - 1)
850849
elog(ERROR, "Inconsistent external directory backup metadata");

0 commit comments

Comments
 (0)