Обсуждение: ExecStoreTuple going into infinite loop

Поиск
Список
Период
Сортировка

ExecStoreTuple going into infinite loop

От
Atri Sharma
Дата:
Hi all,

I am trying to build and store multiple tuples.The code is:

ExecClearTuple(slot);

/The code for fetching the data from which tuple will be formed../
for(;x<y;x++){
tuple = BuildTupleFromCStrings(TupleDescGetAttInMetadata(node->ss.ss_currentRelation->rd_att),
values);
ExecStoreTuple(tuple, slot, InvalidBuffer, false);
}

return (slot);


When I am including the ExecClearTuple(slot),the result only includes
the last tuple that was built.If I do not include
ExecClearTuple(slot),the code goes into an infinite loop.

Please help.

Atri
-- 
Regards,

Atri
l'apprenant


Re: ExecStoreTuple going into infinite loop

От
Merlin Moncure
Дата:
On Wed, Jun 6, 2012 at 5:36 AM, Atri Sharma <atri.jiit@gmail.com> wrote:
> Hi all,
>
> I am trying to build and store multiple tuples.The code is:
>
> ExecClearTuple(slot);
>
> /The code for fetching the data from which tuple will be formed../
> for(;x<y;x++){
> tuple = BuildTupleFromCStrings(TupleDescGetAttInMetadata(node->ss.ss_currentRelation->rd_att),
> values);
> ExecStoreTuple(tuple, slot, InvalidBuffer, false);
> }
>
> return (slot);
>
>
> When I am including the ExecClearTuple(slot),the result only includes
> the last tuple that was built.If I do not include
> ExecClearTuple(slot),the code goes into an infinite loop.
>
> Please help.

I've answered off list.  The context here is fdw iteration. Atri was
trying to return multiple rows inside the iteration which is not how
the function is designed to work.  (also this would be more
appropriate question for -general).

merlin


Re: ExecStoreTuple going into infinite loop

От
Tom Lane
Дата:
Atri Sharma <atri.jiit@gmail.com> writes:
> Hi all,
> I am trying to build and store multiple tuples.The code is:

> ExecClearTuple(slot);

> /The code for fetching the data from which tuple will be formed../
> for(;x<y;x++){
> tuple = BuildTupleFromCStrings(TupleDescGetAttInMetadata(node->ss.ss_currentRelation->rd_att),
> values);
> ExecStoreTuple(tuple, slot, InvalidBuffer, false);
> }

> return (slot);

> When I am including the ExecClearTuple(slot),the result only includes
> the last tuple that was built.

I am not sure why you find this surprising.  A tuple slot can only hold
one tuple.

If you're trying to build a set-returning function, you need a
tuplestore not a tuple slot.  Or else restructure the code to return
each tuple as it's built.  Look at existing SRFs for examples.
        regards, tom lane