Re: Is a function to a 1-component record type undeclarable? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Is a function to a 1-component record type undeclarable?
Date
Msg-id 3740439.1637597723@sss.pgh.pa.us
Whole thread Raw
In response to Is a function to a 1-component record type undeclarable?  (Chapman Flack <chap@anastigmatix.net>)
Responses Re: Is a function to a 1-component record type undeclarable?
List pgsql-hackers
Chapman Flack <chap@anastigmatix.net> writes:
> The same declaration can be changed to have just one OUT parameter:

> CREATE FUNCTION dup(in int, out f text)
>     AS $$ SELECT CAST($1 AS text) || ' is text' $$
>     LANGUAGE SQL;

> But it then behaves as a function returning a text scalar, not a record.

Yup, that's intentional, and documented.  It seems more useful to allow
you to declare a scalar-returning function in this style, if you wish,
than to make it mean a one-component record.  If you really want a
one-component composite type, you can declare such a type explicitly
and return that.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Petr Jelinek
Date:
Subject: Re: logical decoding and replication of sequences
Next
From: Alvaro Herrera
Date:
Subject: Re: Isn't it better with "autovacuum worker...." instead of "worker took too long to start; canceled" specific to "auto