Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 142E49FB30A for ; Mon, 14 May 2007 17:48:36 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 95062-09 for ; Mon, 14 May 2007 17:48:30 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.238]) by postgresql.org (Postfix) with ESMTP id EAD369FB25C for ; Mon, 14 May 2007 17:48:30 -0300 (ADT) Received: by wx-out-0506.google.com with SMTP id i28so1614998wxd for ; Mon, 14 May 2007 13:48:30 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:from:to:cc:references:in-reply-to:subject:date:message-id:mime-version:content-type:content-transfer-encoding:x-mailer:thread-index:content-language; b=eLJmerObGBlLJ0U+UJN32u5yG6No0RjP0ajmVZDcr/yfKmNhh169pWkOiG7kVyM7I14crPy1PXxTJ6KLZ3jT30JGAr08dapYlLjZUHP0YlMVnL06GYQkcvAQt+qckcW2u5PXCcnSeQ1IcH9pVks5fvqvZKtLXamE+a7r9UQGywg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:from:to:cc:references:in-reply-to:subject:date:message-id:mime-version:content-type:content-transfer-encoding:x-mailer:thread-index:content-language; b=XcY7hlGlpribOOpB3/mtA2BNluIw3A29vjD0iEZVf6ASliJs59DgabNFSoa4/+G4noNs5qvCckKrOVRAlC1TJhWbd737LfJtBPZ3AIsVUNwge67GQDjV1OfKvawjPiSC37UrIAyemcIDCug569SZX3tYtPwqWANvcj0oEXgqCxk= Received: by 10.90.72.10 with SMTP id u10mr5522906aga.1179175709266; Mon, 14 May 2007 13:48:29 -0700 (PDT) Received: from progrobt ( [66.224.81.242]) by mx.google.com with ESMTP id 9sm18212945wrl.2007.05.14.13.48.27; Mon, 14 May 2007 13:48:28 -0700 (PDT) From: "Rob Tester" To: "'Alvaro Herrera'" Cc: References: <20070513181154.GB11750@alvh.no-ip.org> In-Reply-To: <20070513181154.GB11750@alvh.no-ip.org> Subject: Re: Trouble returning a text field from an SRF Date: Mon, 14 May 2007 13:47:52 -0700 Message-ID: <07ec01c79669$25dad7a0$719086e0$@com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Office Outlook 12.0 thread-index: AceVijFjUCYZYcyMTMyjEURgAu+5LwA3uM/g Content-Language: en-us X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/23 X-Sequence-Number: 6530 I created my tuple that way and set the Datum using DirectFunctionCall1(...), but there still seems to be a limitation at = 65535 chars for the data. When my string is 65535 (or shorter) I get the text back. When it is longer I get nothing for the string, but the rest of = the tuple is intact. My tuple descriptor: CREATE TYPE testText AS (alevel integer, someText text); Code in my pgLib extension: //Code that handles the initial SRF stuff omitted . . . . textOut=3Dpalloc(MIN_SIZE*count); if (textOut){ strcpy(textOut,"TEST=3D>"); for(pointCnt=3D0;pointCntEND"); values[0]=3D Int32GetDatum(strlen(textOut)); values[1]=3D DirectFunctionCall1(textin,PointerGetDatum(textOut)); tuple=3Dheap_formtuple(tupDesc, values, nulls); result =3D HeapTupleGetDatum(tuple); SRF_RETURN_NEXT(funcctx, result); } . . . . This function works great as long as strlen(textOut)<=3D65535 after = that, I get nothing for the someText value in my return type. Any thoughts on how to get the rest of my strings when they are over = 65535 bytes in length? -----Original Message----- From: Alvaro Herrera [mailto:alvherre@commandprompt.com]=20 Sent: Sunday, May 13, 2007 11:12 AM To: Rob Tester Cc: pgsql-interfaces@postgresql.org Subject: Re: [INTERFACES] Trouble returning a text field from an SRF Rob Tester escribi=F3: > I have written several postgres extensions in the past. = However,currently I > am having difficulty with an extension returning a tuple. Basically I = want > to return a tuple containing an integer and a very large variable = length > string. I created a type on Postgres that contains two fields (int4 = and > text). Originally, I was using buildTupleFromCStrings(). My function = works > fine and everything is cool, until my string becomes large. At that > point NULL is returned in my tuple (I believe that this is > because Postgres is using char type conversion on the string). So, my > question is how can I return the large string as part of my tuple? Is there > a Datum function that will allow me to convert a text* into a datum? = Any > help or a push in the right direction would be appreciated. You can use things like DirectFunctionCall1(textin, CStringGetDatum(the-c-string)) which returns a Datum containing a Text with the C-string in it. I would normally try to use heap_form_tuple instead of buildTupleFromCStrings if possible, but I wouldn't think that the latter would fail on too large texts. It's hard to say what's failing without actually seeing the code anyway. Maybe the problem is failure to handle TOAST at some level. --=20 Alvaro Herrera = http://www.CommandPrompt.com/ The PostgreSQL Company - Command Prompt, Inc.