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: Chao Li <li.evan.chao@gmail.com>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-03-12T08:38:56Z
Lists: pgsql-hackers
On 20.02.26 18:16, Paul A Jungwirth wrote:
> On Fri, Feb 13, 2026 at 12:00 PM Paul A Jungwirth
> <pj@illuminatedcomputing.com> wrote:
>>
>> Here is another round to fix a few rebase conflicts.
>
> I realized we didn't have any tests for v18's new feature to say
> `UPDATE ... RETURNING OLD.foo, NEW.foo`. These patches add a small
> test for `RETURNING OLD.valid_at, NEW.valid_at` when you say `UPDATE
> FOR PORTION OF valid_at`. This seems worth testing since that column
> gets set in an automatic way, not via the normal SET syntax. No fixes
> were needed.
>
> I also corrected the commit message, which still referred to the
> without_overlaps function that we renamed to
> {range,multirange}_minus_multi.
>
> As far as I know nothing else here is waiting on me, but please
> correct me if I've overlooked something.
>
> Rebased to 18bcdb75d1.
Hi Paul,
Review of v67-0001-Add-range_get_constructor2-to-lsyscache.patch and
v67-0002-Add-UPDATE-DELETE-FOR-PORTION-OF.patch:
1) In src/backend/parser/analyze.c, transformForPortionOfClause():
The variable range_name is not very useful; using
forPortionOf->range_name is clearer.
Try making the forPortionOf argument const.
The initialization strat = RTOverlapStrategyNumber; is confusing.
2) src/backend/parser/gram.y
Explain the %prec in opt_alias with a comment. Maybe the production
name should be more specific if it's only applicable to some specific
statement.
3) In the test src/test/regress/expected/for_portion_of.out:
3.1)
Fix the wording of the error message here (remove "period", add back in
later patch):
+ERROR: column or period "invalid_at" of relation "for_portion_of_test"
does not exist
3.2)
Could this error message have a location pointer?
+ERROR: range lower bound must be less than or equal to range upper bound
3.3)
Improve wording of this error message:
+ERROR: got a NULL FOR PORTION OF target
("FOR PORTION OF target was null"?)
3.4)
+-- Updating the non-range part of the PK:
This test updates the id column but the SELECT afterwards only shows
rows for the old id value. The SELECT ought to use something like
WHERE id = '[1,2)' OR id = '[6,7)'
3.5)
-- UPDATE FOR PORTION OF in a CTE:
I think this test is meant to show that the UPDATE FOR PORTION OF
... RETURNING returns only the updated rows, not the inserted
"leftovers".
First, it would be good if the comment was more clear about what it's
trying to demonstrate.
And then, is there a reason for this behavior versus the alternatives?
SQL standard, other implementations?
3.6)
+-- Not visible to UPDATE:
+-- Tuples updated/inserted within the CTE are not visible to the main
query yet,
+-- but neither are old tuples the CTE changed:
Is this behavior the same or different from the way normal queries
work? Could be clarified in the comment either way.
3.7)
+-- UPDATE ... RETURNING returns only the updated values (not the
inserted side values)
This test looks redundant with earlier tests. Otherwise, maybe add a
comment about how it's different.
3.8)
+-- test that we run triggers on the UPDATE/DELETEd row and the INSERTed
rows
Please indent the non-first rows of the CREATE TRIGGER statements.
4) In src/test/subscription/t/034_temporal.pl
+[4,5)|[2000-01-01,2010-01-01)|a}, 'replicated temporal_unique DEFAULT');
The change from FULL to DEFAULT seems wrong.
5) NULL bounds
A general comment: In particular after studying these tests in detail,
I'm suspicious that it's a good idea to interpret null bounds as
unbounded. Expressions could return null for nested reasons, it would
be very hard to follow that. Null values should mean "unknown",
unbounded should be explicit. We have the keyword UNBOUNDED already,
maybe you could use that? Or do you want to be able to return
unboundedness from an expression?
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