X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 0CC57D1B45B for ; Fri, 30 Jan 2004 01:08:12 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 96744-05 for ; Thu, 29 Jan 2004 21:07:44 -0400 (AST) Received: from internet.potentialtech.com (h-66-167-251-6.PHLAPAFG.covad.net [66.167.251.6]) by svr1.postgresql.org (Postfix) with ESMTP id ED877D1B4EF for ; Thu, 29 Jan 2004 21:07:40 -0400 (AST) Received: from potentialtech.com (pa-plum1c-102.pit.adelphia.net [24.53.179.102]) by internet.potentialtech.com (Postfix) with ESMTP id C346569A4B; Thu, 29 Jan 2004 20:07:43 -0500 (EST) Message-ID: <4019AE5C.3090701@potentialtech.com> Date: Thu, 29 Jan 2004 20:07:40 -0500 From: Bill Moran User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.4) Gecko/20031005 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Josh Berkus Cc: pgsql-sql@postgresql.org Subject: Re: [PERFORM] Set-Returning Functions WAS: On the performance of References: <40152FF2.8000007@potentialtech.com> <200401291121.54048.josh@agliodbs.com> <4019629C.3040307@potentialtech.com> <200401291517.19647.josh@agliodbs.com> In-Reply-To: <200401291517.19647.josh@agliodbs.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/15 X-Sequence-Number: 16706 Josh Berkus wrote: > Bill, > >>I don't understand at all. If I do "SELECT * FROM >>set_returning_function()" and all I'm going to do is iterate through the >>columns and rows, adding them to a two dimensional array that will be >>marshalled as a SOAP message, what about not knowing the nature of the >>return set can cause me to get no data? > > Because that's not the syntax for a function that returns SETOF RECORD. > > The syntax is: > > SELECT * > FROM set_returning_function(var1, var2) AS alias (col1 TYPE, col2 TYPE); > > That is, if the function definition does not contain a clear row structure, > the query has to contain one. > > This does not apply to functions that are based on a table or composite type: > > CREATE FUNCTION .... RETURNS SETOF table1 ... > CREATE FUNCTION .... RETURNS SETOF comp_type > > Can be called with: > > SELECT * FROM some_function(var1, var2) as alias; > > What this means is that you have to know the structure of the result set, > either at function creation time or at function execution time. Yep. You're right, I hadn't looked at that, but I'm probably better off creating types and returning setof those types as much as possible. >>One of the things I love about working with open source databases is I >>don't see a lot of that. The people on these lists are almost always >>smarter than me, and I find that comforting ;) > > Flattery will get you everywhere. Really? I'll have to use it more often. -- Bill Moran Potential Technologies http://www.potentialtech.com