Re: Is a function to a 1-component record type undeclarable?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Chapman Flack <chap(at)anastigmatix(dot)net>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Is a function to a 1-component record type undeclarable?
Date: 2021-11-22 16:15:23
Message-ID: 3740439.1637597723@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Chapman Flack <chap(at)anastigmatix(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2021-11-22 16:25:45 Re: Isn't it better with "autovacuum worker...." instead of "worker took too long to start; canceled" specific to "auto
Previous Message Petr Jelinek 2021-11-22 16:01:46 Re: logical decoding and replication of sequences