Re: BUG #18190: PL/pgSQL does not document comparison operations on RECORD (or ROW) types

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Karl O(dot) Pinc" <kop(at)karlpinc(dot)com>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #18190: PL/pgSQL does not document comparison operations on RECORD (or ROW) types
Date: 2023-11-12 15:53:34
Message-ID: 1740510.1699804414@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Karl O. Pinc" <kop(at)karlpinc(dot)com> writes:
> Perhaps I'm too used to reading the PL/pgSQL chapter, which
> makes it sound like RECORD variables are strictly a PL/pgSQL
> construct. (And maybe they are.) It's unclear why this would matter,
> and how such a thought would throw off my searching. But something
> did.

Variables in general are a PL/pgSQL construct, but RECORD can be
used in other contexts; for example as the argument or return type
of a function, whether it's in PL/pgSQL or not. (Some PLs may
reject that, but that's an implementation shortcoming of the PL.)
Also, the result of any ROW() constructor is of type RECORD unless
it's cast to some named composite type.

> (FWIW, The sentence "Note that RECORD is not a true data type,
> only a placeholder." is pretty mysterious. I don't see anything
> that informs me about what a RECORD variable is, composite,
> ROW type, or whatever.)

I think you are on to something here. I'm not very sure what we
should write instead of what's there, but I think that that sentence
predates our invention of polymorphic types. It would likely be
better to frame RECORD as a polymorphic type that can range over
(only) composite types, and to provide cross-references to the
main docs' sections about composites (and maybe polymorphics).

Too caffeine-deprived to propose any specific wording, but
I think this area could use some work.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2023-11-13 02:42:27 Re: Bug with GIN index over JSONB data: "ERROR: buffer 10112 is not owned by resource owner"
Previous Message Karl O. Pinc 2023-11-12 15:22:44 Re: BUG #18190: PL/pgSQL does not document comparison operations on RECORD (or ROW) types