Coding help

From: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Coding help
Date: 2002-08-16 04:02:02
Message-ID: 200208160002.02165.matthew@zeut.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello, I'm playing with creating an auto vacuum daemon, but it is my first
time inside the pg source code and I'm a bit lost.

I have gotten as far as having a vacuum daemon created on postmaster startup.
It's just a fork from the postmaster, cribbed mostly from the stat collector
code.

Inside the main loop of the autovac daemon, I am trying to call vacuum() but I
get the following error:
FATAL: VACUUM cannot be executed from a function

I don't understand why it thinks I'm in a function, I believe the error is
being generated by this is vacuum.c:

/* Running VACUUM from a function would free the function context */
if (vacstmt->vacuum && !MemoryContextContains(QueryContext, vacstmt))
elog(ERROR, "%s cannot be executed from a function", stmttype);

So, I assume it has something to do with the memory context that I'm in when I
call the vacuum command, so I have been playing with switching contexts and
such, but I have had no luck, obviously I don't really know what is going on
here.

The code snippet that is actually calling the vacuum looks like this:
{
VacuumStmt *n = makeNode(VacuumStmt);
n->vacuum = true;
n->analyze = false;
n->full = false;
n->freeze = false;
n->verbose = false;
n->relation = NULL;
n->va_cols = NIL;
vacuum(n);
}

Any help would be greatly appreciated.

Thanks,

Matt

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2002-08-16 04:10:54 Re: Open 7.3 items
Previous Message Christopher Kings-Lynne 2002-08-16 03:02:47 more fulltextindex stuff