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 <
[email protected]>
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.1.1.1.2.1 1996/10/04 20:37:09 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.1.1.1.2.2 1996/10/04 20:38:49 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
VRelList vrl, cur;
Datum d;
char *rname;
+ char rkind;
int16 smgrno;
bool n;
ScanKeyData pgckey;
+ bool found = false;
StartTransactionCommand();
while (HeapTupleIsValid(pgctup = heap_getnext(pgcscan, 0, &buf))) {
+ found = true;
+
/*
* We have to be careful not to vacuum the archive (since it
* already contains vacuumed tuples), and not to vacuum
continue;
}
+ d = (Datum) heap_getattr(pgctup, buf, Anum_pg_class_relkind,
+ pgcdesc, &n);
+
+ rkind = DatumGetChar(d);
+
+ /* skip system relations */
+ if (rkind != 'r') {
+ ReleaseBuffer(buf);
+ elog(NOTICE, "Vacuum: can not process index and certain system tables" );
+ continue;
+ }
+
/* get a relation list entry for this guy */
old = MemoryContextSwitchTo((MemoryContext)portalmem);
if (vrl == (VRelList) NULL) {
/* wei hates it if you forget to do this */
ReleaseBuffer(buf);
}
+ if (found == false)
+ elog(NOTICE, "Vacuum: table not found" );
+
heap_close(pgclass);
heap_endscan(pgcscan);