pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bill Moran <wmoran@potentialtech.com>
To: Josh Berkus <josh@agliodbs.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: [PERFORM] Set-Returning Functions WAS: On the performance of
Date: Thu, 29 Jan 2004 20:07:40 -0500
Message-ID: <4019AE5C.3090701@potentialtech.com> (raw)
In-Reply-To: <200401291517.19647.josh@agliodbs.com>
References: <40152FF2.8000007@potentialtech.com>
	<200401291121.54048.josh@agliodbs.com>
	<4019629C.3040307@potentialtech.com>
	<200401291517.19647.josh@agliodbs.com>

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




view thread (4+ messages)

Message-ID: <4019AE5C.3090701@potentialtech.com>
Permalink:  ../4019AE5C.3090701@potentialtech.com/
Also on:    postgresql.org/message-id/4019AE5C.3090701@potentialtech.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: wmoran@potentialtech.com, josh@agliodbs.com
  Subject: Re: [PERFORM] Set-Returning Functions WAS: On the performance of
  In-Reply-To: <4019AE5C.3090701@potentialtech.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox