mirror of
https://github.com/postgres/postgres.git
synced 2025-09-05 02:22:28 +03:00
Use a private memory context to store rule information in each relcache
entry that has rules. This allows us to release the rule parsetrees on relcache flush without needing a working freeObject() routine. Formerly, the rule trees were leaked permanently at relcache flush. Also, clean up handling of rule creation and deletion --- there was not sufficient locking of the relation being modified, and there was no reliable notification of other backends that a relcache reload was needed. Also, clean up relcache.c code so that scans of system tables needed to load a relcache entry are done in the caller's memory context, not in CacheMemoryContext. This prevents any un-pfreed memory from those scans from becoming a permanent memory leak.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.76 2000/06/15 03:32:22 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.77 2000/06/30 07:04:22 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -1332,11 +1332,11 @@ RewriteQuery(Query *parsetree, bool *instead_flag, List **qual_products)
|
||||
rt_entry = rt_fetch(result_relation, parsetree->rtable);
|
||||
rt_entry_relation = heap_openr(rt_entry->relname, AccessShareLock);
|
||||
rt_entry_locks = rt_entry_relation->rd_rules;
|
||||
heap_close(rt_entry_relation, AccessShareLock);
|
||||
|
||||
if (rt_entry_locks != NULL)
|
||||
{
|
||||
List *locks = matchLocks(event, rt_entry_locks, result_relation, parsetree);
|
||||
List *locks = matchLocks(event, rt_entry_locks,
|
||||
result_relation, parsetree);
|
||||
|
||||
product_queries = fireRules(parsetree,
|
||||
result_relation,
|
||||
@@ -1346,13 +1346,15 @@ RewriteQuery(Query *parsetree, bool *instead_flag, List **qual_products)
|
||||
qual_products);
|
||||
}
|
||||
|
||||
heap_close(rt_entry_relation, AccessShareLock);
|
||||
|
||||
return product_queries;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* to avoid infinite recursion, we restrict the number of times a query
|
||||
* can be rewritten. Detecting cycles is left for the reader as an excercise.
|
||||
* can be rewritten. Detecting cycles is left for the reader as an exercise.
|
||||
*/
|
||||
#ifndef REWRITE_INVOKE_MAX
|
||||
#define REWRITE_INVOKE_MAX 10
|
||||
@@ -1373,8 +1375,6 @@ deepRewriteQuery(Query *parsetree)
|
||||
bool instead;
|
||||
List *qual_products = NIL;
|
||||
|
||||
|
||||
|
||||
if (++numQueryRewriteInvoked > REWRITE_INVOKE_MAX)
|
||||
{
|
||||
elog(ERROR, "query rewritten %d times, may contain cycles",
|
||||
|
Reference in New Issue
Block a user