Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6287eb7

Browse files
committed
Separate fetch of pg_autovacuum tuple into its own function.
1 parent8aaecaf commit6287eb7

File tree

1 file changed

+35
-14
lines changed

1 file changed

+35
-14
lines changed

‎src/backend/postmaster/autovacuum.c

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.35 2007/03/2320:56:39 alvherre Exp $
13+
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.36 2007/03/2321:23:13 alvherre Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -127,6 +127,7 @@ static void test_rel_for_autovac(Oid relid, PgStat_StatTabEntry *tabentry,
127127
List**toast_table_ids);
128128
staticvoidautovacuum_do_vac_analyze(Oidrelid,booldovacuum,
129129
booldoanalyze,intfreeze_min_age);
130+
staticHeapTupleget_pg_autovacuum_tuple_relid(RelationavRel,Oidrelid);
130131
staticvoidautovac_report_activity(VacuumStmt*vacstmt,Oidrelid);
131132
staticvoidavl_sighup_handler(SIGNAL_ARGS);
132133
staticvoidavlauncher_shutdown(SIGNAL_ARGS);
@@ -933,9 +934,7 @@ do_autovacuum(PgStat_StatDBEntry *dbentry)
933934
Form_pg_classclassForm= (Form_pg_class)GETSTRUCT(tuple);
934935
Form_pg_autovacuumavForm=NULL;
935936
PgStat_StatTabEntry*tabentry;
936-
SysScanDescavScan;
937937
HeapTupleavTup;
938-
ScanKeyDataentry[1];
939938
Oidrelid;
940939

941940
/* Consider only regular and toast tables. */
@@ -952,16 +951,8 @@ do_autovacuum(PgStat_StatDBEntry *dbentry)
952951

953952
relid=HeapTupleGetOid(tuple);
954953

955-
/* See if we have a pg_autovacuum entry for this relation. */
956-
ScanKeyInit(&entry[0],
957-
Anum_pg_autovacuum_vacrelid,
958-
BTEqualStrategyNumber,F_OIDEQ,
959-
ObjectIdGetDatum(relid));
960-
961-
avScan=systable_beginscan(avRel,AutovacuumRelidIndexId, true,
962-
SnapshotNow,1,entry);
963-
964-
avTup=systable_getnext(avScan);
954+
/* Fetch the pg_autovacuum tuple for the relation, if any */
955+
avTup=get_pg_autovacuum_tuple_relid(avRel,relid);
965956

966957
if (HeapTupleIsValid(avTup))
967958
avForm= (Form_pg_autovacuum)GETSTRUCT(avTup);
@@ -978,7 +969,8 @@ do_autovacuum(PgStat_StatDBEntry *dbentry)
978969
test_rel_for_autovac(relid,tabentry,classForm,avForm,
979970
&vacuum_tables,&toast_table_ids);
980971

981-
systable_endscan(avScan);
972+
if (HeapTupleIsValid(avTup))
973+
heap_freetuple(avTup);
982974
}
983975

984976
heap_endscan(relScan);
@@ -1030,6 +1022,35 @@ do_autovacuum(PgStat_StatDBEntry *dbentry)
10301022
CommitTransactionCommand();
10311023
}
10321024

1025+
/*
1026+
* Returns a copy of the pg_autovacuum tuple for the given relid, or NULL if
1027+
* there isn't any. avRel is pg_autovacuum, already open and suitably locked.
1028+
*/
1029+
staticHeapTuple
1030+
get_pg_autovacuum_tuple_relid(RelationavRel,Oidrelid)
1031+
{
1032+
ScanKeyDataentry[1];
1033+
SysScanDescavScan;
1034+
HeapTupleavTup;
1035+
1036+
ScanKeyInit(&entry[0],
1037+
Anum_pg_autovacuum_vacrelid,
1038+
BTEqualStrategyNumber,F_OIDEQ,
1039+
ObjectIdGetDatum(relid));
1040+
1041+
avScan=systable_beginscan(avRel,AutovacuumRelidIndexId, true,
1042+
SnapshotNow,1,entry);
1043+
1044+
avTup=systable_getnext(avScan);
1045+
1046+
if (HeapTupleIsValid(avTup))
1047+
avTup=heap_copytuple(avTup);
1048+
1049+
systable_endscan(avScan);
1050+
1051+
returnavTup;
1052+
}
1053+
10331054
/*
10341055
* test_rel_for_autovac
10351056
*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp