public inbox for [email protected]
help / color / mirror / Atom feedFrom: Tom Lane <[email protected]>
To: Aleksander Alekseev <[email protected]>
Cc: [email protected]
Cc: Viliam ġurina <[email protected]>
Subject: Re: MIN/MAX functions for a record
Date: Fri, 22 Mar 2024 11:12:55 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAJ7c6TNpEfJJSrJvQJmVT5z8=8cPaq-JHNY3ZbmP63rif5Kiow@mail.gmail.com>
References: <CAO=iB8L4WYSNxCJ8GURRjQsrXEQ2-zn3FiCsh2LMqvWq2WcONg@mail.gmail.com>
<CAJ7c6TNpEfJJSrJvQJmVT5z8=8cPaq-JHNY3ZbmP63rif5Kiow@mail.gmail.com>
Aleksander Alekseev <[email protected]> writes:
>> In my queries I often need to do MIN/MAX for tuples, for example:
>> SELECT MAX(row(year, month))
>> FROM (VALUES(2025, 1), (2024,2)) x(year, month);
>> This query throws:
>> ERROR: function max(record) does not exist
>> Was this ever discussed or is there something preventing the implementation?
> I believe it would be challenging to implement max(record) that would
> work reasonably well in a general case.
As long as you define it as "works the same way record comparison
does", ie base it on record_cmp(), I don't think it would be much
more than a finger exercise [*]. And why would you want it to act
any differently from record_cmp()? Those semantics have been
established for a long time.
regards, tom lane
[*] Although conceivably there are some challenges in getting
record_cmp's caching logic to work in the context of an aggregate.
view thread (3+ messages) latest in thread
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 using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected]
Subject: Re: MIN/MAX functions for a record
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox