ExecInitAppend
ExecInitAppend
От:
Chris Bitmead <chrisb@nimrod.itg.telstra.com.au>
Дата:
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?
Re: [HACKERS] ExecInitAppend
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Chris Bitmead 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
Re: [HACKERS] ExecInitAppend
От:
Chris Bitmead <chrisb@nimrod.itg.telstra.com.au>
Дата:
Tom Lane wrote: > > Chris Bitmead 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.