From: | Bill Moran <wmoran(at)potentialtech(dot)com> |
---|---|
To: | Josh Berkus <josh(at)agliodbs(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: [PERFORM] Set-Returning Functions WAS: On the performance of |
Date: | 2004-01-30 01:07:40 |
Message-ID: | 4019AE5C.3090701@potentialtech.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance pgsql-sql |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Stephan Szabo | 2004-01-30 01:20:57 | Re: query optimization differs between view and explicit |
Previous Message | Christopher Kings-Lynne | 2004-01-30 00:52:15 | Re: query optimization differs between view and explicit |
From | Date | Subject | |
---|---|---|---|
Next Message | Chris Travers | 2004-01-30 03:03:49 | Re: |
Previous Message | Josh Berkus | 2004-01-29 23:22:13 | Re: java.lang.StringIndexOutOfBoundsException: String index |