1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2024-12-13 11:53:59 +02:00

PGPRO-2589: Binary search for catalog_get_backup_list()

This commit is contained in:
Arthur Zakirov 2019-03-28 16:58:14 +03:00
parent b2cb9cf940
commit 65dd94d664

View File

@ -386,25 +386,18 @@ catalog_get_backup_list(time_t requested_backup_id)
/* Link incremental backups with their ancestors.*/ /* Link incremental backups with their ancestors.*/
for (i = 0; i < parray_num(backups); i++) for (i = 0; i < parray_num(backups); i++)
{ {
pgBackup *curr = parray_get(backups, i); pgBackup *curr = parray_get(backups, i);
pgBackup **ancestor;
int j; pgBackup key;
if (curr->backup_mode == BACKUP_MODE_FULL) if (curr->backup_mode == BACKUP_MODE_FULL)
continue; continue;
for (j = 0; j < parray_num(backups); j++) key.start_time = curr->parent_backup;
{ ancestor = (pgBackup **) parray_bsearch(backups, &key,
pgBackup *ancestor = parray_get(backups, j); pgBackupCompareIdDesc);
if (ancestor)
if (ancestor->start_time == curr->parent_backup) curr->parent_backup_link = *ancestor;
{
curr->parent_backup_link = ancestor;
/* elog(INFO, "curr %s, ancestor %s j=%d", base36enc_dup(curr->start_time),
base36enc_dup(ancestor->start_time), j); */
break;
}
}
} }
return backups; return backups;
@ -1035,9 +1028,12 @@ find_parent_full_backup(pgBackup *current_backup)
if (base_full_backup->backup_mode != BACKUP_MODE_FULL) if (base_full_backup->backup_mode != BACKUP_MODE_FULL)
{ {
if (base_full_backup->parent_backup)
elog(WARNING, "Backup %s is missing", elog(WARNING, "Backup %s is missing",
base36enc(base_full_backup->parent_backup)); base36enc(base_full_backup->parent_backup));
else
elog(WARNING, "Failed to find parent FULL backup for %s",
base36enc(current_backup->start_time));
return NULL; return NULL;
} }