8000 Oops, wrong message with the other patch...this was the patch for the… · s-monk/postgres@bf3473c · GitHub
[go: up one dir, main page]

Skip to content

Commit bf3473c

Browse files
committed
Oops, wrong message with the other patch...this was the patch for the other
comment, so here is the comment for the other patch *grin* > > You are right. I checked the gramar and saw the ability to use the > > parameter. I looked at the manual pages, and saw no reference to it. I > > tried running it, and found vacuum does nothing when you give it a table > > name. > > > > I checked a debug version of postgres, and the table name is passed to > > vacuum() in the variable (char *vacrel). The problem is that the vacuum > > spans transactions, and the vacrel name gets changed to '<vacuum>', > > which is the name of the portal that gets created in > > vacuum.c::_vc_vacuum(). vacuum.c::_vc_init() does a > > CommitTransactionCommand() which frees the memory allocated to vacrel. > > > > Should I change vacuum.c to copy the relation name to a local string > > variable of vacuum(), or do you recommend we allocate the table name in > > a different fashion? You are the man who knows the most about this. > > static NameData VacRel; Done. Attached is the patch. I have already applied it to the 2.0 tree. (Marc!) I tested it and it works. I also applied documentation patches to go with it. So now vacuum can be run for only one table if you wish. Submitted by: Bruce Momjian <maillist@candle.pha.pa.us>
1 parent cbb3edc commit bf3473c

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/backend/commands/vacuum.c

Lines changed: 20 additions & 1 deletion
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.2.1 1996/10/04 20:37:09 scrappy Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.1.1.1.2.2 1996/10/04 20:38:49 scrappy Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -200,9 +200,11 @@ _vc_getrels(Portal p, NameData *VacRelP)
200200
VRelList vrl, cur;
201201
Datum d;
202202
char *rname;
203+
char rkind;
203204
int16 smgrno;
204205
bool n;
205206
ScanKeyData pgckey;
207+
bool found = false;
206208

207209
StartTransactionCommand();
208210

@@ -225,6 +227,8 @@ _vc_getrels(Portal p, NameData *VacRelP)
225227

226228
while (HeapTupleIsValid(pgctup = heap_getnext(pgcscan, 0, &buf))) {
227229

230+
found = true;
231+
228232
/*
229233
* We have to be careful not to vacuum the archive (since it
230234
* already contains vacuumed tuples), and not to vacuum
@@ -252,6 +256,18 @@ _vc_getrels(Portal p, NameData *VacRelP)
252256
continue;
253257
}
254258

259+
d = (Datum) heap_getattr(pgctup, buf, Anum_pg_class_relkind,
260+
pgcdesc, &n);
261+
262+
rkind = DatumGetChar(d);
263+
264+
/* skip system relations */
265+
if (rkind != 'r') {
266+
ReleaseBuffer(buf);
267+
elog(NOTICE, "Vacuum: can not process index and certain system tables" );
268+
continue;
269+
}
270+
255271
/* get a relation list entry for this guy */
256272
old = MemoryContextSwitchTo((MemoryContext)portalmem);
257273
if (vrl == (VRelList) NULL) {
@@ -272,7 +288,10 @@ _vc_getrels(Portal p, NameData *VacRelP)
272288
/* wei hates it if you forget to do this */
273289
ReleaseBuffer(buf);
274290
}
291+
if (found == false)
292+
elog(NOTICE, "Vacuum: table not found" );
275293

294+
276295
heap_close(pgclass);
277296
heap_endscan(pgcscan);
278297

0 commit comments

Comments
 (0)
0