Skip to content

Commit 2036b3f

Browse files
committed
Disable VACUUM from being called from a function because function memory
would be cleared by vacuum; fix idea from Tom Lane.
1 parent 5b92d00 commit 2036b3f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/backend/commands/vacuum.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*
1515
* IDENTIFICATION
16-
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.223 2002/04/12 20:38:25 tgl Exp $
16+
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.224 2002/04/15 23:39:42 momjian Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -181,6 +181,10 @@ vacuum(VacuumStmt *vacstmt)
181181
if (IsTransactionBlock())
182182
elog(ERROR, "%s cannot run inside a BEGIN/END block", stmttype);
183183

184+
/* Running VACUUM from a function would free the function context */
185+
if (!MemoryContextContains(QueryContext, vacstmt))
186+
elog(ERROR, "%s cannot be executed from a function", stmttype);
187+
184188
/*
185189
* Send info about dead objects to the statistics collector
186190
*/

0 commit comments

Comments
 (0)