@@ -153,7 +153,7 @@ write_backup_status(pgBackup *backup, BackupStatus status,
153153
154154 /* lock backup in exclusive mode */
155155 if (!lock_backup (tmp , strict , true))
156- elog (ERROR , "Cannot lock backup %s directory" , base36enc (backup -> start_time ));
156+ elog (ERROR , "Cannot lock backup %s directory" , backup_id_of (backup ));
157157
158158 write_backup (tmp , strict );
159159
@@ -193,7 +193,7 @@ lock_backup(pgBackup *backup, bool strict, bool exclusive)
193193
194194 join_path_components (lock_file , backup -> root_dir , BACKUP_LOCK_FILE );
195195
196- rc = grab_excl_lock_file (backup -> root_dir , base36enc (backup -> start_time ), strict );
196+ rc = grab_excl_lock_file (backup -> root_dir , backup_id_of (backup ), strict );
197197
198198 if (rc == LOCK_FAIL_TIMEOUT )
199199 return false;
@@ -258,7 +258,7 @@ lock_backup(pgBackup *backup, bool strict, bool exclusive)
258258 * freed some space on filesystem, thanks to unlinking of BACKUP_RO_LOCK_FILE.
259259 * If somebody concurrently acquired exclusive lock file first, then we should give up.
260260 */
261- if (grab_excl_lock_file (backup -> root_dir , base36enc (backup -> start_time ), strict ) == LOCK_FAIL_TIMEOUT )
261+ if (grab_excl_lock_file (backup -> root_dir , backup_id_of (backup ), strict ) == LOCK_FAIL_TIMEOUT )
262262 return false;
263263
264264 return true;
@@ -521,7 +521,7 @@ grab_excl_lock_file(const char *root_dir, const char *backup_id, bool strict)
521521 }
522522
523523// elog(LOG, "Acquired exclusive lock for backup %s after %ds",
524- // base36enc (backup->start_time ),
524+ // backup_id_of (backup),
525525// LOCK_TIMEOUT - ntries + LOCK_STALE_TIMEOUT - empty_tries);
526526
527527 return LOCK_OK ;
@@ -561,7 +561,7 @@ wait_shared_owners(pgBackup *backup)
561561 {
562562 if (interrupted )
563563 elog (ERROR , "Interrupted while locking backup %s" ,
564- base36enc (backup -> start_time ));
564+ backup_id_of (backup ));
565565
566566 if (encoded_pid == my_pid )
567567 break ;
@@ -573,10 +573,10 @@ wait_shared_owners(pgBackup *backup)
573573 if ((ntries % LOG_FREQ ) == 0 )
574574 {
575575 elog (WARNING , "Process %d is using backup %s in shared mode, and is still running" ,
576- encoded_pid , base36enc (backup -> start_time ));
576+ encoded_pid , backup_id_of (backup ));
577577
578578 elog (WARNING , "Waiting %u seconds on lock for backup %s" , ntries ,
579- base36enc (backup -> start_time ));
579+ backup_id_of (backup ));
580580 }
581581
582582 sleep (1 );
@@ -604,7 +604,7 @@ wait_shared_owners(pgBackup *backup)
604604 if (ntries <= 0 )
605605 {
606606 elog (WARNING , "Cannot to lock backup %s in exclusive mode, because process %u owns shared lock" ,
607- base36enc (backup -> start_time ), encoded_pid );
607+ backup_id_of (backup ), encoded_pid );
608608 return 1 ;
609609 }
610610
@@ -963,15 +963,15 @@ catalog_get_backup_list(InstanceState *instanceState, time_t requested_backup_id
963963
964964 if (!backup )
965965 {
966- backup = pgut_new (pgBackup );
966+ backup = pgut_new0 (pgBackup );
967967 pgBackupInit (backup );
968968 backup -> start_time = base36dec (data_ent -> d_name );
969969 }
970- else if (strcmp (base36enc (backup -> start_time ), data_ent -> d_name ) != 0 )
970+ else if (strcmp (backup_id_of (backup ), data_ent -> d_name ) != 0 )
971971 {
972972 /* TODO there is no such guarantees */
973973 elog (WARNING , "backup ID in control file \"%s\" doesn't match name of the backup folder \"%s\"" ,
974- base36enc (backup -> start_time ), backup_conf_path );
974+ backup_id_of (backup ), backup_conf_path );
975975 }
976976
977977 backup -> root_dir = pgut_strdup (data_path );
@@ -1010,7 +1010,7 @@ catalog_get_backup_list(InstanceState *instanceState, time_t requested_backup_id
10101010 {
10111011 pgBackup * curr = parray_get (backups , i );
10121012 pgBackup * * ancestor ;
1013- pgBackup key ;
1013+ pgBackup key = { 0 } ;
10141014
10151015 if (curr -> backup_mode == BACKUP_MODE_FULL )
10161016 continue ;
@@ -1180,7 +1180,7 @@ get_backup_filelist(pgBackup *backup, bool strict)
11801180
11811181 /* redundant sanity? */
11821182 if (!files )
1183- elog (strict ? ERROR : WARNING , "Failed to get file list for backup %s" , base36enc (backup -> start_time ));
1183+ elog (strict ? ERROR : WARNING , "Failed to get file list for backup %s" , backup_id_of (backup ));
11841184
11851185 return files ;
11861186}
@@ -1206,7 +1206,7 @@ catalog_lock_backup_list(parray *backup_list, int from_idx, int to_idx, bool str
12061206 pgBackup * backup = (pgBackup * ) parray_get (backup_list , i );
12071207 if (!lock_backup (backup , strict , exclusive ))
12081208 elog (ERROR , "Cannot lock backup %s directory" ,
1209- base36enc (backup -> start_time ));
1209+ backup_id_of (backup ));
12101210 }
12111211}
12121212
@@ -1239,7 +1239,7 @@ catalog_get_last_data_backup(parray *backup_list, TimeLineID tli, time_t current
12391239 return NULL ;
12401240
12411241 elog (LOG , "Latest valid FULL backup: %s" ,
1242- base36enc (full_backup -> start_time ));
1242+ backup_id_of (full_backup ));
12431243
12441244 /* FULL backup is found, lets find his latest child */
12451245 for (i = 0 ; i < parray_num (backup_list ); i ++ )
@@ -1255,13 +1255,13 @@ catalog_get_last_data_backup(parray *backup_list, TimeLineID tli, time_t current
12551255 /* broken chain */
12561256 case ChainIsBroken :
12571257 elog (WARNING , "Backup %s has missing parent: %s. Cannot be a parent" ,
1258- base36enc (backup -> start_time ), base36enc (tmp_backup -> parent_backup ));
1258+ backup_id_of (backup ), base36enc (tmp_backup -> parent_backup ));
12591259 continue ;
12601260
12611261 /* chain is intact, but at least one parent is invalid */
12621262 case ChainIsInvalid :
12631263 elog (WARNING , "Backup %s has invalid parent: %s. Cannot be a parent" ,
1264- base36enc (backup -> start_time ), base36enc (tmp_backup -> start_time ));
1264+ backup_id_of (backup ), backup_id_of (tmp_backup ));
12651265 continue ;
12661266
12671267 /* chain is ok */
@@ -1280,7 +1280,7 @@ catalog_get_last_data_backup(parray *backup_list, TimeLineID tli, time_t current
12801280 else
12811281 {
12821282 elog (WARNING , "Backup %s has status: %s. Cannot be a parent." ,
1283- base36enc (backup -> start_time ), status2str (backup -> status ));
1283+ backup_id_of (backup ), status2str (backup -> status ));
12841284 }
12851285 }
12861286
@@ -1366,7 +1366,7 @@ get_multi_timeline_parent(parray *backup_list, parray *tli_list,
13661366 return NULL ;
13671367 else
13681368 elog (LOG , "Latest valid full backup: %s, tli: %i" ,
1369- base36enc (ancestor_backup -> start_time ), ancestor_backup -> tli );
1369+ backup_id_of (ancestor_backup ), ancestor_backup -> tli );
13701370
13711371 /* At this point we found suitable full backup,
13721372 * now we must find his latest child, suitable to be
@@ -1871,7 +1871,7 @@ catalog_get_timelines(InstanceState *instanceState, InstanceConfig *instance)
18711871 {
18721872 elog (LOG , "Pinned backup %s is ignored for the "
18731873 "purpose of WAL retention" ,
1874- base36enc (backup -> start_time ));
1874+ backup_id_of (backup ));
18751875 continue ;
18761876 }
18771877
@@ -2057,7 +2057,7 @@ catalog_get_timelines(InstanceState *instanceState, InstanceConfig *instance)
20572057 elog (LOG , "Archive backup %s to stay consistent "
20582058 "protect from purge WAL interval "
20592059 "between %s and %s on timeline %i" ,
2060- base36enc (backup -> start_time ),
2060+ backup_id_of (backup ),
20612061 begin_segno_str , end_segno_str , backup -> tli );
20622062
20632063 if (tlinfo -> keep_segments == NULL )
@@ -2266,7 +2266,7 @@ pin_backup(pgBackup *target_backup, pgSetBackupParams *set_backup_params)
22662266 if (target_backup -> expire_time == 0 )
22672267 {
22682268 elog (WARNING , "Backup %s is not pinned, nothing to unpin" ,
2269- base36enc (target_backup -> start_time ));
2269+ backup_id_of (target_backup ));
22702270 return ;
22712271 }
22722272 target_backup -> expire_time = 0 ;
@@ -2286,11 +2286,11 @@ pin_backup(pgBackup *target_backup, pgSetBackupParams *set_backup_params)
22862286 char expire_timestamp [100 ];
22872287
22882288 time2iso (expire_timestamp , lengthof (expire_timestamp ), target_backup -> expire_time , false);
2289- elog (INFO , "Backup %s is pinned until '%s'" , base36enc (target_backup -> start_time ),
2289+ elog (INFO , "Backup %s is pinned until '%s'" , backup_id_of (target_backup ),
22902290 expire_timestamp );
22912291 }
22922292 else
2293- elog (INFO , "Backup %s is unpinned" , base36enc (target_backup -> start_time ));
2293+ elog (INFO , "Backup %s is unpinned" , backup_id_of (target_backup ));
22942294
22952295 return ;
22962296}
@@ -2310,7 +2310,7 @@ add_note(pgBackup *target_backup, char *note)
23102310 {
23112311 target_backup -> note = NULL ;
23122312 elog (INFO , "Removing note from backup %s" ,
2313- base36enc (target_backup -> start_time ));
2313+ backup_id_of (target_backup ));
23142314 }
23152315 else
23162316 {
@@ -2325,7 +2325,7 @@ add_note(pgBackup *target_backup, char *note)
23252325
23262326 target_backup -> note = note_string ;
23272327 elog (INFO , "Adding note to backup %s: '%s'" ,
2328- base36enc (target_backup -> start_time ), target_backup -> note );
2328+ backup_id_of (target_backup ), target_backup -> note );
23292329 }
23302330
23312331 /* Update backup.control */
@@ -2644,7 +2644,7 @@ write_backup_filelist(pgBackup *backup, parray *files, const char *root,
26442644static pgBackup *
26452645readBackupControlFile (const char * path )
26462646{
2647- pgBackup * backup = pgut_new (pgBackup );
2647+ pgBackup * backup = pgut_new0 (pgBackup );
26482648 char * backup_mode = NULL ;
26492649 char * start_lsn = NULL ;
26502650 char * stop_lsn = NULL ;
@@ -3047,7 +3047,7 @@ find_parent_full_backup(pgBackup *current_backup)
30473047 base36enc (base_full_backup -> parent_backup ));
30483048 else
30493049 elog (WARNING , "Failed to find parent FULL backup for %s" ,
3050- base36enc (current_backup -> start_time ));
3050+ backup_id_of (current_backup ));
30513051 return NULL ;
30523052 }
30533053
0 commit comments