|
31 | 31 | #include "access/tableam.h"
|
32 | 32 | #include "access/transam.h"
|
33 | 33 | #include "access/xact.h"
|
| 34 | +#include "catalog/indexing.h" |
34 | 35 | #include "catalog/namespace.h"
|
35 | 36 | #include "catalog/pg_database.h"
|
36 | 37 | #include "catalog/pg_inherits.h"
|
@@ -1294,6 +1295,7 @@ vac_update_datfrozenxid(void)
|
1294 | 1295 | MultiXactId lastSaneMinMulti;
|
1295 | 1296 | bool bogus = false;
|
1296 | 1297 | bool dirty = false;
|
| 1298 | + ScanKeyData key[1]; |
1297 | 1299 |
|
1298 | 1300 | /*
|
1299 | 1301 | * Restrict this task to one backend per database. This avoids race
|
@@ -1411,10 +1413,25 @@ vac_update_datfrozenxid(void)
|
1411 | 1413 | /* Now fetch the pg_database tuple we need to update. */
|
1412 | 1414 | relation = table_open(DatabaseRelationId, RowExclusiveLock);
|
1413 | 1415 |
|
1414 |
| - /* Fetch a copy of the tuple to scribble on */ |
1415 |
| - tuple = SearchSysCacheCopy1(DATABASEOID, ObjectIdGetDatum(MyDatabaseId)); |
| 1416 | + /* |
| 1417 | + * Get the pg_database tuple to scribble on. Note that this does not |
| 1418 | + * directly rely on the syscache to avoid issues with flattened toast |
| 1419 | + * values for the in-place update. |
| 1420 | + */ |
| 1421 | + ScanKeyInit(&key[0], |
| 1422 | + Anum_pg_database_oid, |
| 1423 | + BTEqualStrategyNumber, F_OIDEQ, |
| 1424 | + ObjectIdGetDatum(MyDatabaseId)); |
| 1425 | + |
| 1426 | + scan = systable_beginscan(relation, DatabaseOidIndexId, true, |
| 1427 | + NULL, 1, key); |
| 1428 | + tuple = systable_getnext(scan); |
| 1429 | + tuple = heap_copytuple(tuple); |
| 1430 | + systable_endscan(scan); |
| 1431 | + |
1416 | 1432 | if (!HeapTupleIsValid(tuple))
|
1417 | 1433 | elog(ERROR, "could not find tuple for database %u", MyDatabaseId);
|
| 1434 | + |
1418 | 1435 | dbform = (Form_pg_database) GETSTRUCT(tuple);
|
1419 | 1436 |
|
1420 | 1437 | /*
|
|
0 commit comments