Re: SQL:2011 Application Time Update & Delete
Peter Eisentraut <peter@eisentraut.org>
From: Peter Eisentraut <peter@eisentraut.org>
To: Paul A Jungwirth <pj@illuminatedcomputing.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-11-12T07:42:07Z
Lists: pgsql-hackers
I have looked at the patch
v59-0004-Add-range_minus_multi-and-multirange_minus_multi.patch
This seems sound in principle.
Perhaps you could restate why you chose a set-returning function rather
than (what I suppose would be the other options) returning multirange or
an array of ranges. (I don't necessarily disagree, but it would be good
to be clear for everyone.) The point about allowing user-defined types
makes sense (but for example, I see types like multipolygon and
multipoint in postgis, so maybe those could also work?).
That said, I think there is a problem in your implementation. Note that
the added regression test cases for range return multiple rows but the
ones for multirange all return a single row with a set {....} value. I
think the problem is that your multirange_minus_multi() calls
multirange_minus_internal() which already returns a set, and you are
packing that set result into a single row.
A few other minor details:
* src/backend/utils/adt/rangetypes.c
+#include "utils/array.h"
seems to be unused.
+ typedef struct
+ {
+ RangeType *rs[2];
+ int n;
+ } range_minus_multi_fctx;
This could be written just as a struct, like
struct range_minus_multi_fctx
{
...
};
Wrapping it in a typedef doesn't achieve any additional useful
abstraction.
The code comment before range_minus_multi_internal() could first
explain briefly what the function does before going into the details
of the arguments. Because we can't assume that someone will have read
the descriptions of the higher-level functions first.
* src/include/catalog/pg_proc.dat
The prorows values for the two new functions should be the same?
(I suppose they are correct now seeing your implementation of
multirange_minus_multi(), but I'm not sure that was intended, as
discussed above.)
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Make ExecForPortionOfLeftovers() obey SRF protocol.
- 207cb2abcba0 19 (unreleased) landed
-
Add isolation tests for UPDATE/DELETE FOR PORTION OF
- b6ccd30d8ff6 19 (unreleased) landed
-
Add UPDATE/DELETE FOR PORTION OF
- 8e72d914c528 19 (unreleased) landed
-
Record range constructor functions in pg_range
- c257ba839718 19 (unreleased) landed
-
Add range_minus_multi and multirange_minus_multi functions
- 5eed8ce50ce9 19 (unreleased) landed
-
doc: Add section for temporal tables
- e4d8a2af07f5 19 (unreleased) landed
-
Add assertion check for WAL receiver state during stream-archive transition
- 65f4976189b6 19 (unreleased) cited