Skip to content

Commit cbb3edc

Browse files
committed
> - it excludes system-relation too (relkind == 's'). (Note: Vacuum updates
pg_class > by overwriting existing tuple for vacrel, so there are no many reasons to vacuum pg_class). > > It can be done somewhere in _vc_getrels - near to checks against archive relations > and relations on the write-once storage managers... > > Excuse me - I forgot to say about this. > Attached is the recently posted fix for this. Thanks. Submitted by: Bruce Momjian <maillist@candle.pha.pa.us>
1 parent 93c7dcf commit cbb3edc

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

src/backend/commands/vacuum.c

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.1.1.1 1996/07/09 06:21:22 scrappy Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.1.1.1.2.1 1996/10/04 20:37:09 scrappy Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -44,10 +44,10 @@
4444
bool VacuumRunning = false;
4545

4646
/* non-export function prototypes */
47-
static void _vc_init(char *vacrel);
48-
static void _vc_shutdown(char *vacrel);
49-
static void _vc_vacuum(char *vacrel);
50-
static VRelList _vc_getrels(Portal p, char *vacrel);
47+
static void _vc_init(void);
48+
static void _vc_shutdown(void);
49+
static void _vc_vacuum(NameData *VacRelP);
50+
static VRelList _vc_getrels(Portal p, NameData *VacRelP);
5151
static void _vc_vacone(Portal p, VRelList curvrl);
5252
static void _vc_vacheap(Portal p, VRelList curvrl, Relation onerel);
5353
static void _vc_vacindices(VRelList curvrl, Relation onerel);
@@ -65,14 +65,24 @@ static bool _vc_isarchrel(char *rname);
6565
void
6666
vacuum(char *vacrel)
6767
{
68+
NameData VacRel;
69+
70+
/* vacrel gets de-allocated on transaction commit */
71+
6872
/* initialize vacuum cleaner */
69-
_vc_init(vacrel);
73+
_vc_init();
7074

7175
/* vacuum the database */
72-
_vc_vacuum(vacrel);
76+
if (vacrel)
77+
{
78+
strcpy(VacRel.data,vacrel);
79+
_vc_vacuum(&VacRel);
80+
}
81+
else
82+
_vc_vacuum(NULL);
7383

7484
/* clean up */
75-
_vc_shutdown(vacrel);
85+
_vc_shutdown();
7686
}
7787

7888
/*
@@ -93,7 +103,7 @@ vacuum(char *vacrel)
93103
* PostgresMain().
94104
*/
95105
static void
96-
_vc_init(char *vacrel)
106+
_vc_init()
97107
{
98108
int fd;
99109

@@ -116,7 +126,7 @@ _vc_init(char *vacrel)
116126
}
117127

118128
static void
119-
_vc_shutdown(char *vacrel)
129+
_vc_shutdown()
120130
{
121131
/* on entry, not in a transaction */
122132
if (unlink("pg_vlock") < 0)
@@ -147,7 +157,7 @@ vc_abort()
147157
* locks at one time.
148158
*/
149159
static void
150-
_vc_vacuum(char *vacrel)
160+
_vc_vacuum(NameData *VacRelP)
151161
{
152162
VRelList vrl, cur;
153163
char *pname;
@@ -166,7 +176,7 @@ _vc_vacuum(char *vacrel)
166176
pfree(pname);
167177

168178
/* get list of relations */
169-
vrl = _vc_getrels(p, vacrel);
179+
vrl = _vc_getrels(p, VacRelP);
170180

171181
/* vacuum each heap relation */
172182
for (cur = vrl; cur != (VRelList) NULL; cur = cur->vrl_next)
@@ -178,7 +188,7 @@ _vc_vacuum(char *vacrel)
178188
}
179189

180190
static VRelList
181-
_vc_getrels(Portal p, char *vacrel)
191+
_vc_getrels(Portal p, NameData *VacRelP)
182192
{
183193
Relation pgclass;
184194
TupleDesc pgcdesc;
@@ -196,10 +206,10 @@ _vc_getrels(Portal p, char *vacrel)
196206

197207
StartTransactionCommand();
198208

199-
if (vacrel) {
209+
if (VacRelP->data) {
200210
ScanKeyEntryInitialize(&pgckey, 0x0, Anum_pg_class_relname,
201211
NameEqualRegProcedure,
202-
PointerGetDatum(vacrel));
212+
PointerGetDatum(VacRelP->data));
203213
} else {
204214
ScanKeyEntryInitialize(&pgckey, 0x0, Anum_pg_class_relkind,
205215
CharacterEqualRegProcedure, CharGetDatum('r'));

0 commit comments

Comments
 (0)