Re: sql function with empty row - Mailing list pgsql-general

From Adrian Klaver
Subject Re: sql function with empty row
Date
Msg-id 6dc24153-7c52-4bcd-1b2b-5ff31a1f3fec@aklaver.com
Whole thread Raw
In response to Re: sql function with empty row  (Philipp Kraus <philipp.kraus@tu-clausthal.de>)
List pgsql-general
On 05/16/2018 11:49 AM, Philipp Kraus wrote:
> 
>> Am 16.05.2018 um 20:40 schrieb Adrian Klaver <adrian.klaver@aklaver.com>:
>>

> 
> I have tested it on my data and it works also, but that is a little bit confusing, because imho setof is >= 0 rows
and
> without setof it is [0,1]. On this I know there exist only one or no record, so I choose the solution without setof

I gotta believe the difference is:

RETURNS substance
https://www.postgresql.org/docs/10/static/xfunc-sql.html#XFUNC-SQL-TABLE-FUNCTIONS
"
If the function is defined to return a composite type, the table 
function produces a column for each attribute of the composite type."

RETURNS SETOF substance

https://www.postgresql.org/docs/10/static/xfunc-sql.html#XFUNC-SQL-FUNCTIONS-RETURNING-SET

"When an SQL function is declared as returning SETOF sometype, the 
function's final query is executed to completion, and each row it 
outputs is returned as an element of the result set."


> 
> Thanks for help
> 
> Phil
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com


pgsql-general by date:

Previous
From: Philipp Kraus
Date:
Subject: Re: sql function with empty row
Next
From: Jonathan Marks
Date:
Subject: Re: Rapid disk usage spikes when updating large tables with GINindexes