Re: MIN/MAX functions for a record
Aleksander Alekseev <aleksander@timescale.com>
From: Aleksander Alekseev <aleksander@timescale.com>
To: pgsql-hackers@lists.postgresql.org
Cc: Viliam Ďurina <viliam.durina@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>
Date: 2024-03-23T10:59:17Z
Lists: pgsql-hackers
Attachments
- v1-0001-Support-MIN-MAX-record-aggregates-WIP.patch (application/octet-stream) patch v1-0001
Hi, > Exactly Tom, I see no fundamental problem for it not to be implemented, since comparison operator is already implemented. In fact, MIN/MAX should work for all types for which comparison operator is defined. On second thought, this should work reasonably well. PFA a WIP patch. At this point it implements only MAX(record), no MIN, no tests: ``` =# SELECT MAX(row(year, month)) FROM (VALUES(2025, 1), (2024,2)) x(year, month); max ---------- (2025,1) ``` One thing I'm not 100% sure of is whether record_larger() should make a copy of its arguments or the current implementation is safe. -- Best regards, Aleksander Alekseev
Commits
-
Add min and max aggregates for composite types (records).
- a0f1fce80c03 18.0 landed