Re: 7.2 crash...

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Rod Taylor <rbt(at)zort(dot)ca>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: 7.2 crash...
Date: 2002-03-22 05:04:39
Message-ID: 200203220504.g2M54d621486@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Tom Lane wrote:
> "Rod Taylor" <rbt(at)zort(dot)ca> writes:
> > 7.2 crashes with the below function:
> > CREATE OR REPLACE FUNCTION runMaintenance()
> > RETURNS BOOL AS '
> > VACUUM;
> > SELECT TRUE;
> > ' LANGUAGE sql;
>
> AFAICS there is no way that we can support VACUUM inside a function;
> the forced transaction commits that VACUUM performs will recycle any
> memory allocated by the function executor, leading to death and
> destruction upon return from VACUUM.
>
> Accordingly, what we really need is a way of preventing VACUUM from
> executing in the above scenario. The IsTransactionBlock() test it
> already has isn't sufficient.
>
> I have thought of something that probably would be sufficient:
>
> if (!MemoryContextContains(QueryContext, vacstmt))
> elog(ERROR, "VACUUM cannot be executed from a function");
>
> This is truly, horribly ugly ... but it'd get the job done, because only
> interactive queries will generate parsetrees in QueryContext.
>
> Can someone think of a better way?

Well, this could would be in vacuum.c, right? Seems like a nice
central location for it. I don't see it as terribly ugly only because
the issue is that we can't run vacuum inside a memory context that can't
be free'ed by vacuum.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message pgsql-bugs 2002-03-25 22:27:51 Bug #623: Compling 7.2 on a Tru64 V5.1 UNIX
Previous Message Tom Lane 2002-03-22 04:22:58 Re: 7.2 crash...

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2002-03-22 05:05:24 Re: Where to get official SQL spec (was Re: Domain Support)
Previous Message Gavin Sherry 2002-03-22 04:42:48 Re: Again, sorry, caching, (Tom What do you think: function