Separate fetch of pg_autovacuum tuple into its own function.
This commit is contained in:
parent
8aaecaf809
commit
6287eb7adc
@ -10,7 +10,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.35 2007/03/23 20:56:39 alvherre Exp $
|
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.36 2007/03/23 21:23:13 alvherre Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -127,6 +127,7 @@ static void test_rel_for_autovac(Oid relid, PgStat_StatTabEntry *tabentry,
|
|||||||
List **toast_table_ids);
|
List **toast_table_ids);
|
||||||
static void autovacuum_do_vac_analyze(Oid relid, bool dovacuum,
|
static void autovacuum_do_vac_analyze(Oid relid, bool dovacuum,
|
||||||
bool doanalyze, int freeze_min_age);
|
bool doanalyze, int freeze_min_age);
|
||||||
|
static HeapTuple get_pg_autovacuum_tuple_relid(Relation avRel, Oid relid);
|
||||||
static void autovac_report_activity(VacuumStmt *vacstmt, Oid relid);
|
static void autovac_report_activity(VacuumStmt *vacstmt, Oid relid);
|
||||||
static void avl_sighup_handler(SIGNAL_ARGS);
|
static void avl_sighup_handler(SIGNAL_ARGS);
|
||||||
static void avlauncher_shutdown(SIGNAL_ARGS);
|
static void avlauncher_shutdown(SIGNAL_ARGS);
|
||||||
@ -933,9 +934,7 @@ do_autovacuum(PgStat_StatDBEntry *dbentry)
|
|||||||
Form_pg_class classForm = (Form_pg_class) GETSTRUCT(tuple);
|
Form_pg_class classForm = (Form_pg_class) GETSTRUCT(tuple);
|
||||||
Form_pg_autovacuum avForm = NULL;
|
Form_pg_autovacuum avForm = NULL;
|
||||||
PgStat_StatTabEntry *tabentry;
|
PgStat_StatTabEntry *tabentry;
|
||||||
SysScanDesc avScan;
|
|
||||||
HeapTuple avTup;
|
HeapTuple avTup;
|
||||||
ScanKeyData entry[1];
|
|
||||||
Oid relid;
|
Oid relid;
|
||||||
|
|
||||||
/* Consider only regular and toast tables. */
|
/* Consider only regular and toast tables. */
|
||||||
@ -952,16 +951,8 @@ do_autovacuum(PgStat_StatDBEntry *dbentry)
|
|||||||
|
|
||||||
relid = HeapTupleGetOid(tuple);
|
relid = HeapTupleGetOid(tuple);
|
||||||
|
|
||||||
/* See if we have a pg_autovacuum entry for this relation. */
|
/* Fetch the pg_autovacuum tuple for the relation, if any */
|
||||||
ScanKeyInit(&entry[0],
|
avTup = get_pg_autovacuum_tuple_relid(avRel, relid);
|
||||||
Anum_pg_autovacuum_vacrelid,
|
|
||||||
BTEqualStrategyNumber, F_OIDEQ,
|
|
||||||
ObjectIdGetDatum(relid));
|
|
||||||
|
|
||||||
avScan = systable_beginscan(avRel, AutovacuumRelidIndexId, true,
|
|
||||||
SnapshotNow, 1, entry);
|
|
||||||
|
|
||||||
avTup = systable_getnext(avScan);
|
|
||||||
|
|
||||||
if (HeapTupleIsValid(avTup))
|
if (HeapTupleIsValid(avTup))
|
||||||
avForm = (Form_pg_autovacuum) GETSTRUCT(avTup);
|
avForm = (Form_pg_autovacuum) GETSTRUCT(avTup);
|
||||||
@ -978,7 +969,8 @@ do_autovacuum(PgStat_StatDBEntry *dbentry)
|
|||||||
test_rel_for_autovac(relid, tabentry, classForm, avForm,
|
test_rel_for_autovac(relid, tabentry, classForm, avForm,
|
||||||
&vacuum_tables, &toast_table_ids);
|
&vacuum_tables, &toast_table_ids);
|
||||||
|
|
||||||
systable_endscan(avScan);
|
if (HeapTupleIsValid(avTup))
|
||||||
|
heap_freetuple(avTup);
|
||||||
}
|
}
|
||||||
|
|
||||||
heap_endscan(relScan);
|
heap_endscan(relScan);
|
||||||
@ -1030,6 +1022,35 @@ do_autovacuum(PgStat_StatDBEntry *dbentry)
|
|||||||
CommitTransactionCommand();
|
CommitTransactionCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns a copy of the pg_autovacuum tuple for the given relid, or NULL if
|
||||||
|
* there isn't any. avRel is pg_autovacuum, already open and suitably locked.
|
||||||
|
*/
|
||||||
|
static HeapTuple
|
||||||
|
get_pg_autovacuum_tuple_relid(Relation avRel, Oid relid)
|
||||||
|
{
|
||||||
|
ScanKeyData entry[1];
|
||||||
|
SysScanDesc avScan;
|
||||||
|
HeapTuple avTup;
|
||||||
|
|
||||||
|
ScanKeyInit(&entry[0],
|
||||||
|
Anum_pg_autovacuum_vacrelid,
|
||||||
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
|
ObjectIdGetDatum(relid));
|
||||||
|
|
||||||
|
avScan = systable_beginscan(avRel, AutovacuumRelidIndexId, true,
|
||||||
|
SnapshotNow, 1, entry);
|
||||||
|
|
||||||
|
avTup = systable_getnext(avScan);
|
||||||
|
|
||||||
|
if (HeapTupleIsValid(avTup))
|
||||||
|
avTup = heap_copytuple(avTup);
|
||||||
|
|
||||||
|
systable_endscan(avScan);
|
||||||
|
|
||||||
|
return avTup;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* test_rel_for_autovac
|
* test_rel_for_autovac
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user