Re: How to write a c-function to return multiple bytea rows - Mailing list pgsql-hackers

From Gregory Stark
Subject Re: How to write a c-function to return multiple bytea rows
Date
Msg-id 87hcj5k9mv.fsf@oxford.xeocode.com
Whole thread Raw
In response to How to write a c-function to return multiple bytea rows  ("Billow Gao" <billowgy@gmail.com>)
List pgsql-hackers
I don't know if it's the proximate source of your problem but your
MemoryContextSwitchTo() calls are mixed up. You're reusing the same oldcontext
variable for both the switch you're doing in the main body and the switch
you're doing in the inner loop. At the very least you should use two different
oldcontext variables, currently I think you're leaving the memory context set
to the per_query_ctx. 

But I think in this situation you're going to end up just doing the whole
thing in per_query_ctx anyways. The only part you can avoid that for is the
pallocing of the heap_form_tuple args and the actual heap_form_tuple call. The
tuple will be copied when you call tuplestore_puttuple (which should be done
in the same context the tuplestore was created in).

--  Gregory Stark EnterpriseDB          http://www.enterprisedb.com Get trained by Bruce Momjian - ask me about
EnterpriseDB'sPostgreSQL training!
 


pgsql-hackers by date:

Previous
From: "Jonah H. Harris"
Date:
Subject: Re: quotas once again
Next
From: "Tom Dunstan"
Date:
Subject: Re: unclear enum error messages