Re: ExecStoreTuple going into infinite loop

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Atri Sharma <atri(dot)jiit(at)gmail(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ExecStoreTuple going into infinite loop
Date: 2012-06-06 14:11:42
Message-ID: 10308.1338991902@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Atri Sharma <atri(dot)jiit(at)gmail(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Florian Pflug 2012-06-06 14:16:00 Re: Ability to listen on two unix sockets
Previous Message Honza Horak 2012-06-06 13:50:56 Ability to listen on two unix sockets