Skip site navigation (1) Skip section navigation (2)

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-04-14 16:52:53
Message-ID: 200204141652.g3EGqrr10859@candle.pha.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-hackers
Here is a patch with a fix outlined by Tom:
	
	test=> CREATE OR REPLACE FUNCTION runMaintenance()
	test-> RETURNS BOOL AS '
	test'>   VACUUM;
	test'>   SELECT TRUE;
	test'> ' LANGUAGE sql;
	CREATE
	test=> 
	test=> select runMaintenance();
	ERROR:  VACUUM cannot be executed from a function

Looks good.  Will commit after typical delay.

---------------------------------------------------------------------------

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?
> 
> 			regards, tom lane
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
> 
> http://www.postgresql.org/users-lounge/docs/faq.html
> 

-- 
  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

Responses

pgsql-hackers by date

Next:From: Bruce MomjianDate: 2002-04-14 16:55:49
Subject: Re: regexp character class locale awareness patch
Previous:From: pgsql-bugsDate: 2002-04-14 16:52:22
Subject: Bug #633: CASE statement evaluation does not short-circut

pgsql-bugs by date

Next:From: Tom LaneDate: 2002-04-14 17:15:30
Subject: Re: 7.2 crash...
Previous:From: pgsql-bugsDate: 2002-04-14 16:52:22
Subject: Bug #633: CASE statement evaluation does not short-circut

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group