Re: RETURNS TABLE function returns nothingness

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alexander Farber <alexander(dot)farber(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: RETURNS TABLE function returns nothingness
Date: 2016-09-02 17:45:07
Message-ID: 23454.1472838307@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Alexander Farber <alexander(dot)farber(at)gmail(dot)com> writes:
> If I'd like to always return exactly 1 row -
> why wouldn't just RETURN work?

Because RETURNS TABLE means it's RETURNS SETOF something,
which means the number of rows it produces is equal to the
number of RETURN NEXTs executed. RETURN, per se, has exactly
zero impact on the number of rows produced; it just stops execution.

I think you can say RETURNS RECORD with a few OUT parameters
to get the effect you're looking for.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Dorian Hoxha 2016-09-02 18:34:47 Re: What limits Postgres performance when the whole database lives in cache?
Previous Message Adrian Klaver 2016-09-02 17:40:46 Re: RETURNS TABLE function returns nothingness