I found this in my mailbox.  Is it any good?

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Index: src/backend/executor/execMain.c
===================================================================
RCS file: /usr/local/cvsroot/pgsql/src/backend/executor/execMain.c,v
retrieving revision 1.48
diff -c -r1.48 execMain.c
*** execMain.c	1998/06/15 19:28:19	1.48
--- execMain.c	1998/07/19 03:35:49
***************
*** 522,539 ****
  	 *        SELECT added by daveh@insightdist.com  5/20/98 to allow 
  	 *        ORDER/GROUP BY have an identifier missing from the target.
  	 */
- 	if (operation == CMD_UPDATE || operation == CMD_DELETE ||
- 		operation == CMD_INSERT || operation == CMD_SELECT)
  	{
! 		JunkFilter *j = (JunkFilter *) ExecInitJunkFilter(targetList);
! 		estate->es_junkFilter = j;
! 
  		if (operation == CMD_SELECT)
! 			tupType = j->jf_cleanTupType;
! 	}
! 	else
! 		estate->es_junkFilter = NULL;
  
  	/* ----------------
  	 *	initialize the "into" relation
  	 * ----------------
--- 522,559 ----
  	 *        SELECT added by daveh@insightdist.com  5/20/98 to allow 
  	 *        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 ||
+ 			operation == CMD_INSERT ||
+ 			(operation == CMD_SELECT && junk_filter_needed))
+ 		{
+ 			JunkFilter *j = (JunkFilter *) ExecInitJunkFilter(targetList);
+ 			estate->es_junkFilter = j;
+ 
+ 			if (operation == CMD_SELECT)
+ 				tupType = j->jf_cleanTupType;
+ 		}
+ 		else
+ 			estate->es_junkFilter = NULL;
+ 	}
+ 	
  	/* ----------------
  	 *	initialize the "into" relation
  	 * ----------------
Fri, 7 Jul 2000 14:51:26 -0400 (EDT)
Bruce Momjian <pgman@candle.pha.pa.us>
Is this useful
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> I found this in my mailbox.  Is it any good?

Seems to have been done long since --- see execMain.c, lines 809 ff.

Looking at that code, I wonder if it's still doing unnecessary work.
Why would we need a junkfilter for a DELETE?  We aren't going to be
constructing output tuples, are we?

			regards, tom lane

Fri, 07 Jul 2000 14:58:01 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: Is this useful 
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > I found this in my mailbox.  Is it any good?
> 
> Seems to have been done long since --- see execMain.c, lines 809 ff.
> 
> Looking at that code, I wonder if it's still doing unnecessary work.
> Why would we need a junkfilter for a DELETE?  We aren't going to be
> constructing output tuples, are we?

Good question.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Fri, 7 Jul 2000 15:01:07 -0400 (EDT)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: Re: Is this useful