postgresql/contrib/postgres_fdw
Peter Eisentraut 8e72d914c5 Add UPDATE/DELETE FOR PORTION OF
This is an extension of the UPDATE and DELETE commands to do a
"temporal update/delete" based on a range or multirange column.  The
user can say UPDATE t FOR PORTION OF valid_at FROM '2001-01-01' TO
'2002-01-01' SET ... (or likewise with DELETE) where valid_at is a
range or multirange column.

The command is automatically limited to rows overlapping the targeted
portion, and only history within those bounds is changed.  If a row
represents history partly inside and partly outside the bounds, then
the command truncates the row's application time to fit within the
targeted portion, then it inserts one or more "temporal leftovers":
new rows containing all the original values, except with the
application-time column changed to only represent the untouched part
of history.

To compute the temporal leftovers that are required, we use the *_minus_multi
set-returning functions defined in 5eed8ce50c.

- Added bison support for FOR PORTION OF syntax.  The bounds must be
  constant, so we forbid column references, subqueries, etc. We do
  accept functions like NOW().
- Added logic to executor to insert new rows for the "temporal
  leftover" part of a record touched by a FOR PORTION OF query.
- Documented FOR PORTION OF.
- Added tests.

Author: Paul A. Jungwirth <pj@illuminatedcomputing.com>
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://www.postgresql.org/message-id/flat/ec498c3d-5f2b-48ec-b989-5561c8aa2024%40illuminatedcomputing.com
2026-04-01 19:06:03 +02:00
..
expected Add UPDATE/DELETE FOR PORTION OF 2026-04-01 19:06:03 +02:00
specs postgres_fdw: Add more test coverage for EvalPlanQual testing. 2025-11-06 12:15:00 +09:00
sql Add UPDATE/DELETE FOR PORTION OF 2026-04-01 19:06:03 +02:00
t ALTER SUBSCRIPTION ... SERVER test. 2026-03-18 10:15:51 -07:00
.gitignore Fix EvalPlanQual handling of foreign/custom joins in ExecScanFetch. 2025-10-15 17:15:00 +09:00
connection.c Reduce header inclusions via execnodes.h 2026-03-16 14:34:57 +01:00
deparse.c Remove bits* typedefs. 2026-03-30 16:12:08 -05:00
Makefile CREATE SUBSCRIPTION ... SERVER. 2026-03-06 08:27:56 -08:00
meson.build CREATE SUBSCRIPTION ... SERVER. 2026-03-06 08:27:56 -08:00
option.c Update copyright for 2026 2026-01-01 13:24:10 -05:00
postgres_fdw--1.0--1.1.sql postgres_fdw: Add functions to discard cached connections. 2021-01-26 15:35:54 +09:00
postgres_fdw--1.0.sql Add postgres_fdw contrib module. 2013-02-21 05:27:16 -05:00
postgres_fdw--1.1--1.2.sql postgres_fdw: Extend postgres_fdw_get_connections to return remote backend PID. 2025-03-03 08:51:30 +09:00
postgres_fdw--1.2--1.3.sql CREATE SUBSCRIPTION ... SERVER. 2026-03-06 08:27:56 -08:00
postgres_fdw.c Reduce header inclusions via execnodes.h 2026-03-16 14:34:57 +01:00
postgres_fdw.control CREATE SUBSCRIPTION ... SERVER. 2026-03-06 08:27:56 -08:00
postgres_fdw.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
shippable.c Switch SysCacheIdentifier to a typedef enum 2026-02-18 09:58:38 +09:00