Conditionally execute Junk filter only when ORDER BY of columns

not in target list.
This commit is contained in:
Bruce Momjian 1998-07-19 03:46:29 +00:00
parent 62cd6e7b75
commit 5b4ca67147

View File

@ -26,7 +26,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.48 1998/06/15 19:28:19 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.49 1998/07/19 03:46:29 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -522,8 +522,27 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate)
* SELECT added by daveh@insightdist.com 5/20/98 to allow * SELECT added by daveh@insightdist.com 5/20/98 to allow
* ORDER/GROUP BY have an identifier missing from the target. * ORDER/GROUP BY have an identifier missing from the target.
*/ */
{
bool junk_filter_needed = false;
List *tlist;
if (operation == CMD_SELECT)
{
foreach(tlist, targetList)
{
TargetEntry *tle = lfirst(tlist);
if (tle->resdom->resjunk)
{
junk_filter_needed = true;
break;
}
}
}
if (operation == CMD_UPDATE || operation == CMD_DELETE || if (operation == CMD_UPDATE || operation == CMD_DELETE ||
operation == CMD_INSERT || operation == CMD_SELECT) operation == CMD_INSERT ||
(operation == CMD_SELECT && junk_filter_needed))
{ {
JunkFilter *j = (JunkFilter *) ExecInitJunkFilter(targetList); JunkFilter *j = (JunkFilter *) ExecInitJunkFilter(targetList);
estate->es_junkFilter = j; estate->es_junkFilter = j;
@ -533,6 +552,7 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate)
} }
else else
estate->es_junkFilter = NULL; estate->es_junkFilter = NULL;
}
/* ---------------- /* ----------------
* initialize the "into" relation * initialize the "into" relation