Re: Ad hoc SETOF type definition?

2023-09-27 Thread Merlin Moncure
On Tue, Sep 26, 2023 at 1:15 PM Tom Lane wrote > it clear that the type exists independently of the function. (Our > behavior of automatically making composite types for tables seems to > me to have been a rather unfortunate choice.) > I really like this behavior and exploit it heavily, in orde

Re: Ad hoc SETOF type definition?

2023-09-26 Thread Ron
On 9/26/23 16:29, Adrian Klaver wrote: [snip] As a very simple example: This is EXACTLY what I was looking for.  Thank you. create table source(id integer, fld_1 varchar); insert into source values (1, 'cat'), (2, 'dog'), (3, 'fish'); CREATE OR REPLACE FUNCTION public.table_return(multipli

Re: Ad hoc SETOF type definition?

2023-09-26 Thread Adrian Klaver
On 9/26/23 13:29, Adrian Klaver wrote: On 9/26/23 12:30, Ron wrote: On 9/26/23 13:15, Tom Lane wrote: Ron writes: On 9/26/23 12:46, Tom Lane wrote: I'm not really sure what functionality you think is missing from RETURNS TABLE, granting that you do want to return a set of rows and not exac

Re: Ad hoc SETOF type definition?

2023-09-26 Thread Adrian Klaver
On 9/26/23 12:30, Ron wrote: On 9/26/23 13:15, Tom Lane wrote: Ron writes: On 9/26/23 12:46, Tom Lane wrote: I'm not really sure what functionality you think is missing from RETURNS TABLE, granting that you do want to return a set of rows and not exactly one row. There might be some other

Re: Ad hoc SETOF type definition?

2023-09-26 Thread Ron
On 9/26/23 13:15, Tom Lane wrote: Ron writes: On 9/26/23 12:46, Tom Lane wrote: Ron 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

Re: Ad hoc SETOF type definition?

2023-09-26 Thread Tom Lane
Ron writes: > On 9/26/23 12:46, Tom Lane wrote: >> Ron 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 re

Re: Ad hoc SETOF type definition?

2023-09-26 Thread Adrian Klaver
On 9/26/23 11:03 AM, Ron wrote: On 9/26/23 12:46, Tom Lane wrote: Ron 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 ca

Re: Ad hoc SETOF type definition?

2023-09-26 Thread Ron
On 9/26/23 12:46, Tom Lane wrote: Ron 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 "RETU

Re: Ad hoc SETOF type definition?

2023-09-26 Thread Tom Lane
Ron 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? regards, tom lane

Ad hoc SETOF type definition?

2023-09-26 Thread Ron
Pg 9.6.24 (Yes, I know it's EOL.) This simple "programming example" function works perfectly. However, it requires me to create the TYPE "foo". CREATE TYPE foo AS (tab_name TEXT, num_pages INT); CREATE FUNCTION dba.blarge()     RETURNS SETOF foo     LANGUAGE plpgsql     AS $$     DECLARE