pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Ron <ronljohnsonjr@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Ad hoc SETOF type definition?
Date: Tue, 26 Sep 2023 11:09:52 -0700
Message-ID: <e7b3900c-dfec-4058-d7d0-0e0ce2749172@aklaver.com> (raw)
In-Reply-To: <73c7a357-62fe-3274-7f27-7ef9adc3b9b5@gmail.com>
References: <9707e21e-eed3-3c06-821e-e935eab4c098@gmail.com>
	<432138.1695750386@sss.pgh.pa.us>
	<73c7a357-62fe-3274-7f27-7ef9adc3b9b5@gmail.com>


On 9/26/23 11:03 AM, Ron wrote:
> On 9/26/23 12:46, Tom Lane wrote:
>> Ron<ronljohnsonjr@gmail.com>  writes:
>>> Is there a way to define the SETOF record on the fly, like you do with
>>> RETURNS TABLE (f1 type1, f2 type2)?
>> Doesn't RETURNS TABLE meet the need already?
>
> That rationale means that RETURN SETOF is not needed, and can be 
> removed from Pg, since "RETURNS TABLE meet the need already".
>
> But of course there /are/ times when RETURN SETOF /is/ useful.
>
> So... can ad hoc SETOF definitions be created in the function 
> definition, or is CREATE TYPE the only way to do it?


That is what RETURNS TABLE does:

https://www.postgresql.org/docs/current/sql-createfunction.html

"/|column_name|/

    The name of an output column in the |RETURNS TABLE| syntax. This is
    effectively another way of declaring a named |OUT| parameter, except
    that |RETURNS TABLE| also implies |RETURNS SETOF|.

"

>
> -- 
> Born in Arizona, moved to Babylonia.

view thread (10+ messages)  latest in thread

Message-ID: <e7b3900c-dfec-4058-d7d0-0e0ce2749172@aklaver.com>
Permalink:  ../e7b3900c-dfec-4058-d7d0-0e0ce2749172@aklaver.com/
Also on:    postgresql.org/message-id/e7b3900c-dfec-4058-d7d0-0e0ce2749172@aklaver.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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, ronljohnsonjr@gmail.com
  Subject: Re: Ad hoc SETOF type definition?
  In-Reply-To: <e7b3900c-dfec-4058-d7d0-0e0ce2749172@aklaver.com>
  References: <9707e21e-eed3-3c06-821e-e935eab4c098@gmail.com> <432138.1695750386@sss.pgh.pa.us> <73c7a357-62fe-3274-7f27-7ef9adc3b9b5@gmail.com> <e7b3900c-dfec-4058-d7d0-0e0ce2749172@aklaver.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