
In ExecInitAppend it initialises all the subplans...

for (i = 0; i < nplans; i++)
	{
...
appendstate->as_whichplan = i;
exec_append_initialize_next(node);
..
	}

And then at the end of the function, it initialises the first plan
again...

appendstate->as_whichplan = 0;
exec_append_initialize_next(node);

	return TRUE;

Is this code correct? Should the first plan really be initialised twice?

Tue, 08 Feb 2000 14:26:48 +1100
Chris Bitmead <chrisb@nimrod.itg.telstra.com.au>
ExecInitAppend
Chris Bitmead <chrisb@nimrod.itg.telstra.com.au> writes:
> In ExecInitAppend it initialises all the subplans...
> And then at the end of the function, it initialises the first plan
> again...
> Is this code correct? Should the first plan really be initialised twice?

Probably not --- I imagine that's wasting memory, or worse.  Do things
still work if you remove the extra initialize call?

			regards, tom lane

Mon, 07 Feb 2000 23:27:10 -0500
Tom Lane <tgl@sss.pgh.pa.us>
Re: [HACKERS] ExecInitAppend 
Tom Lane wrote:
> 
> Chris Bitmead <chrisb@nimrod.itg.telstra.com.au> writes:
> > In ExecInitAppend it initialises all the subplans...
> > And then at the end of the function, it initialises the first plan
> > again...
> > Is this code correct? Should the first plan really be initialised twice?
> 
> Probably not --- I imagine that's wasting memory, or worse.  Do things
> still work if you remove the extra initialize call?

This code looks ugly because it sets appendstate->as_whichplan so that
exec_append_initialise_next knows which plan it's supposed to initialise
-
yucky side effect.

I suspect it will stop working if the last call is removed because it
*may*
be relying on the first plan to be initialised last, so that the estate
variables are initialised to the first plan. It may work if the plans
are initialised in reverse order, but the right way is probably to 
reorganise the code.

Tue, 08 Feb 2000 15:46:52 +1100
Chris Bitmead <chrisb@nimrod.itg.telstra.com.au>
Re: [HACKERS] ExecInitAppend