mirror of
https://github.com/postgres/postgres.git
synced 2025-11-29 23:43:17 +03:00
To suppress memory leakage in long-lived Lists, lremove() should pfree
the cons cell it's deleting from the list. Do this, and fix a few callers that were bogusly assuming it wouldn't free the cons cell.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.78 2002/12/12 15:49:32 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.79 2002/12/17 01:18:25 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -910,13 +910,18 @@ qual_is_redundant(Query *root,
|
||||
do
|
||||
{
|
||||
someadded = false;
|
||||
foreach(olditem, oldquals)
|
||||
/* cannot use foreach here because of possible lremove */
|
||||
olditem = oldquals;
|
||||
while (olditem)
|
||||
{
|
||||
RestrictInfo *oldrinfo = (RestrictInfo *) lfirst(olditem);
|
||||
Node *oldleft = (Node *) get_leftop(oldrinfo->clause);
|
||||
Node *oldright = (Node *) get_rightop(oldrinfo->clause);
|
||||
Node *newguy = NULL;
|
||||
|
||||
/* must advance olditem before lremove possibly pfree's it */
|
||||
olditem = lnext(olditem);
|
||||
|
||||
if (member(oldleft, equalvars))
|
||||
newguy = oldright;
|
||||
else if (member(oldright, equalvars))
|
||||
@@ -930,8 +935,6 @@ qual_is_redundant(Query *root,
|
||||
|
||||
/*
|
||||
* Remove this qual from list, since we don't need it anymore.
|
||||
* Note this doesn't break the foreach() loop, since lremove
|
||||
* doesn't touch the next-link of the removed cons cell.
|
||||
*/
|
||||
oldquals = lremove(oldrinfo, oldquals);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user