mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2024-12-11 11:41:33 +02:00
do not throw an error if database is not found while performing ptrack backup
This commit is contained in:
parent
a42add54a1
commit
a5e8a54d82
35
src/backup.c
35
src/backup.c
@ -826,8 +826,13 @@ pg_ptrack_get_and_clear(Oid tablespace_oid, Oid db_oid, Oid rel_oid,
|
|||||||
res_db = pgut_execute(backup_conn,
|
res_db = pgut_execute(backup_conn,
|
||||||
"SELECT datname FROM pg_database WHERE oid=$1",
|
"SELECT datname FROM pg_database WHERE oid=$1",
|
||||||
1, (const char **) params);
|
1, (const char **) params);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If database is not found, it's not an error.
|
||||||
|
* It could have been deleted since previous backup.
|
||||||
|
*/
|
||||||
if (PQntuples(res_db) != 1 || PQnfields(res_db) != 1)
|
if (PQntuples(res_db) != 1 || PQnfields(res_db) != 1)
|
||||||
elog(ERROR, "cannot find database by oid %u", db_oid);
|
return NULL;
|
||||||
|
|
||||||
dbname = pstrdup(PQgetvalue(res_db, 0, 0));
|
dbname = pstrdup(PQgetvalue(res_db, 0, 0));
|
||||||
PQclear(res_db);
|
PQclear(res_db);
|
||||||
@ -1877,22 +1882,24 @@ make_pagemap_from_ptrack(parray *files)
|
|||||||
/* get ptrack map for all segments of the relation in a raw format */
|
/* get ptrack map for all segments of the relation in a raw format */
|
||||||
ptrack_nonparsed = pg_ptrack_get_and_clear(tablespace_oid, db_oid,
|
ptrack_nonparsed = pg_ptrack_get_and_clear(tablespace_oid, db_oid,
|
||||||
rel_oid, &ptrack_nonparsed_size);
|
rel_oid, &ptrack_nonparsed_size);
|
||||||
|
if (ptrack_nonparsed != NULL)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* FIXME When do we cut VARHDR from ptrack_nonparsed?
|
||||||
|
* Compute the beginning of the ptrack map related to this segment
|
||||||
|
*/
|
||||||
|
start_addr = (RELSEG_SIZE/HEAPBLOCKS_PER_BYTE)*p->segno;
|
||||||
|
|
||||||
/*
|
if (start_addr + RELSEG_SIZE/HEAPBLOCKS_PER_BYTE > ptrack_nonparsed_size)
|
||||||
* FIXME When do we cut VARHDR from ptrack_nonparsed?
|
p->pagemap.bitmapsize = ptrack_nonparsed_size - start_addr;
|
||||||
* Compute the beginning of the ptrack map related to this segment
|
else
|
||||||
*/
|
p->pagemap.bitmapsize = RELSEG_SIZE/HEAPBLOCKS_PER_BYTE;
|
||||||
start_addr = (RELSEG_SIZE/HEAPBLOCKS_PER_BYTE)*p->segno;
|
|
||||||
|
|
||||||
if (start_addr + RELSEG_SIZE/HEAPBLOCKS_PER_BYTE > ptrack_nonparsed_size)
|
p->pagemap.bitmap = pg_malloc(p->pagemap.bitmapsize);
|
||||||
p->pagemap.bitmapsize = ptrack_nonparsed_size - start_addr;
|
memcpy(p->pagemap.bitmap, ptrack_nonparsed+start_addr, p->pagemap.bitmapsize);
|
||||||
else
|
|
||||||
p->pagemap.bitmapsize = RELSEG_SIZE/HEAPBLOCKS_PER_BYTE;
|
|
||||||
|
|
||||||
p->pagemap.bitmap = pg_malloc(p->pagemap.bitmapsize);
|
pg_free(ptrack_nonparsed);
|
||||||
memcpy(p->pagemap.bitmap, ptrack_nonparsed+start_addr, p->pagemap.bitmapsize);
|
}
|
||||||
|
|
||||||
pg_free(ptrack_nonparsed);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user