mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2024-12-12 11:45:24 +02:00
PGPRO-2573: use parray_bsearch
This commit is contained in:
parent
0c40a75f7f
commit
ca44e739a3
@ -1035,27 +1035,6 @@ is_prolific(parray *backup_list, pgBackup *target_backup)
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if target_backup in backup_list. Use if bsearch cannot be trusted.
|
||||
*/
|
||||
bool
|
||||
in_backup_list(parray *backup_list, pgBackup *target_backup)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!target_backup)
|
||||
elog(ERROR, "Target backup cannot be NULL");
|
||||
|
||||
for (i = 0; i < parray_num(backup_list); i++)
|
||||
{
|
||||
pgBackup *tmp_backup = (pgBackup *) parray_get(backup_list, i);
|
||||
|
||||
if (tmp_backup->start_time == target_backup->start_time)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find parent base FULL backup for current backup using parent_backup_link
|
||||
*/
|
||||
|
14
src/delete.c
14
src/delete.c
@ -282,11 +282,11 @@ do_retention_internal(void)
|
||||
|
||||
pgBackup *backup = (pgBackup *) parray_get(backup_list, i);
|
||||
|
||||
if (in_backup_list(to_keep_list, backup))
|
||||
if (parray_bsearch(to_keep_list, backup, pgBackupCompareIdDesc))
|
||||
action = "Keep";
|
||||
|
||||
if (in_backup_list(to_purge_list, backup))
|
||||
action = "Purge";
|
||||
if (parray_bsearch(to_purge_list, backup, pgBackupCompareIdDesc))
|
||||
action = "Keep";
|
||||
|
||||
if (backup->recovery_time == 0)
|
||||
actual_window = 0;
|
||||
@ -365,7 +365,9 @@ do_retention_internal(void)
|
||||
continue;
|
||||
|
||||
/* If parent of current backup is also in keep list, go to the next */
|
||||
if (in_backup_list(to_keep_list, keep_backup->parent_backup_link))
|
||||
if (parray_bsearch(to_keep_list,
|
||||
keep_backup->parent_backup_link,
|
||||
pgBackupCompareIdDesc))
|
||||
{
|
||||
/* make keep list a bit sparse */
|
||||
elog(INFO, "Sparsing keep list, remove %s", base36enc(keep_backup->start_time));
|
||||
@ -388,7 +390,9 @@ do_retention_internal(void)
|
||||
}
|
||||
|
||||
/* Check that ancestor is in purge_list */
|
||||
if (!in_backup_list(to_purge_list, full_backup))
|
||||
if (!parray_bsearch(to_purge_list,
|
||||
full_backup,
|
||||
pgBackupCompareIdDesc))
|
||||
{
|
||||
elog(WARNING, "Skip backup %s for merging, "
|
||||
"because his FULL parent is not marked for purge", base36enc(keep_backup->start_time));
|
||||
|
Loading…
Reference in New Issue
Block a user