postgresql/contrib
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
..
amcheck Use UnlockReleaseBuffer() in more places 2026-03-27 15:56:29 -04:00
auth_delay Update copyright for 2026 2026-01-01 13:24:10 -05:00
auto_explain instrumentation: Keep time fields as instrtime, convert in callers 2026-01-09 13:38:00 -05:00
basebackup_to_shell Update copyright for 2026 2026-01-01 13:24:10 -05:00
basic_archive Fix dereference in a couple of GUC check hooks 2026-03-24 16:45:39 +01:00
bloom Discount the metapage when estimating number of index pages visited. 2026-03-20 14:50:53 -04:00
bool_plperl Update copyright for 2026 2026-01-01 13:24:10 -05:00
btree_gin Use fallthrough attribute instead of comment 2026-02-19 08:51:12 +01:00
btree_gist Improve type handling of varlena structures 2026-02-11 07:33:24 +09:00
citext Update copyright for 2026 2026-01-01 13:24:10 -05:00
cube Mark commented out code as unused 2026-01-22 12:44:07 +01:00
dblink Avoid including vacuum.h in tableam.h and heapam.h. 2026-03-31 12:43:52 -05:00
dict_int Update copyright for 2026 2026-01-01 13:24:10 -05:00
dict_xsyn Replace pg_mblen() with bounds-checked versions. 2026-02-09 12:44:04 +13:00
earthdistance Update copyright for 2026 2026-01-01 13:24:10 -05:00
file_fdw file_fdw: Add regression test for file_fdw with ON_ERROR='set_null' 2026-03-16 12:13:11 +09:00
fuzzystrmatch fuzzystrmatch: use pg_ascii_toupper(). 2026-01-12 08:54:04 -08:00
hstore Reduce header inclusions via execnodes.h 2026-03-16 14:34:57 +01:00
hstore_plperl Change StaticAssertVariableIsOfType to be a declaration 2026-02-03 08:46:02 +01:00
hstore_plpython Change StaticAssertVariableIsOfType to be a declaration 2026-02-03 08:46:02 +01:00
intagg Update copyright for 2026 2026-01-01 13:24:10 -05:00
intarray Harden _int_matchsel() against being attached to the wrong operator. 2026-02-09 10:14:22 -05:00
isn Fix additional fallthrough warnings from clang 2026-02-23 07:40:19 +01:00
jsonb_plperl Update copyright for 2026 2026-01-01 13:24:10 -05:00
jsonb_plpython Change StaticAssertVariableIsOfType to be a declaration 2026-02-03 08:46:02 +01:00
lo Update copyright for 2026 2026-01-01 13:24:10 -05:00
ltree Fix more multibyte issues in ltree. 2026-02-26 12:23:22 -08:00
ltree_plpython Change StaticAssertVariableIsOfType to be a declaration 2026-02-03 08:46:02 +01:00
oid2name Use pg_malloc_object() and pg_alloc_array() variants in frontend code 2026-02-27 18:59:41 +09:00
pageinspect Remove bits* typedefs. 2026-03-30 16:12:08 -05:00
passwordcheck Update copyright for 2026 2026-01-01 13:24:10 -05:00
pg_buffercache Reduce header inclusions via execnodes.h 2026-03-16 14:34:57 +01:00
pg_freespacemap Update copyright for 2026 2026-01-01 13:24:10 -05:00
pg_logicalinspect Update copyright for 2026 2026-01-01 13:24:10 -05:00
pg_overexplain Remove PlannedStmt->resultRelations in favor of resultRelationRelids 2026-03-30 09:51:28 -04:00
pg_plan_advice pg_plan_advice: Avoid assertion failure with partitionwise aggregate. 2026-03-30 09:58:25 -04:00
pg_prewarm Don't include wait_event.h in pgstat.h 2026-03-06 16:24:58 +01:00
pg_stat_statements Avoid memory leak on error while parsing pg_stat_statements dump file 2026-03-27 12:25:10 +02:00
pg_surgery Update copyright for 2026 2026-01-01 13:24:10 -05:00
pg_trgm Fix local-variable shadowing in pg_trgm's printSourceNFA(). 2026-03-02 14:40:29 -05:00
pg_visibility Add all required calls to TupleDescFinalize() 2026-03-16 11:45:49 +13:00
pg_walinspect Report detailed errors from XLogFindNextRecord() failures. 2026-03-24 22:33:09 +09:00
pgcrypto Use fallthrough attribute instead of comment 2026-02-19 08:51:12 +01:00
pgrowlocks Thread flags through begin-scan APIs 2026-03-30 12:27:24 -04:00
pgstattuple pgstattuple: Optimize pgstattuple_approx() with streaming read 2026-03-14 15:06:13 +09:00
postgres_fdw Add UPDATE/DELETE FOR PORTION OF 2026-04-01 19:06:03 +02:00
seg psql: Make \d+ partition list formatting consistent with other objects 2026-03-30 11:06:42 +09:00
sepgsql Update copyright for 2026 2026-01-01 13:24:10 -05:00
spi Update copyright for 2026 2026-01-01 13:24:10 -05:00
sslinfo Update copyright for 2026 2026-01-01 13:24:10 -05:00
start-scripts Remove gratuitous references to postmaster program 2023-01-26 10:48:32 +01:00
tablefunc Avoid including vacuum.h in tableam.h and heapam.h. 2026-03-31 12:43:52 -05:00
tcn Update copyright for 2026 2026-01-01 13:24:10 -05:00
test_decoding Add UPDATE/DELETE FOR PORTION OF 2026-04-01 19:06:03 +02:00
tsm_system_rows Update copyright for 2026 2026-01-01 13:24:10 -05:00
tsm_system_time Reduce header inclusions via execnodes.h 2026-03-16 14:34:57 +01:00
unaccent Update Unicode data to Unicode 17.0.0 2026-03-20 08:42:50 +01:00
uuid-ossp Fix accidentally cast away qualifiers 2026-01-26 16:02:31 +01:00
vacuumlo Update copyright for 2026 2026-01-01 13:24:10 -05:00
xml2 Reduce header inclusions via execnodes.h 2026-03-16 14:34:57 +01:00
contrib-global.mk Respect TEMP_CONFIG when pg_regress_check and friends are called 2016-02-27 12:28:21 -05:00
Makefile Add pg_plan_advice contrib module. 2026-03-12 13:00:43 -04:00
meson.build Add pg_plan_advice contrib module. 2026-03-12 13:00:43 -04:00
README Rename 'gmake' to 'make' in docs and recommended commands 2014-02-12 17:29:19 -05:00

The PostgreSQL contrib tree
---------------------------

This subtree contains porting tools, analysis utilities, and plug-in
features that are not part of the core PostgreSQL system, mainly
because they address a limited audience or are too experimental to be
part of the main source tree.  This does not preclude their
usefulness.

User documentation for each module appears in the main SGML
documentation.

When building from the source distribution, these modules are not
built automatically, unless you build the "world" target.  You can
also build and install them all by running "make all" and "make
install" in this directory; or to build and install just one selected
module, do the same in that module's subdirectory.

Some directories supply new user-defined functions, operators, or
types.  To make use of one of these modules, after you have installed
the code you need to register the new SQL objects in the database
system by executing a CREATE EXTENSION command.  In a fresh database,
you can simply do

    CREATE EXTENSION module_name;

See the PostgreSQL documentation for more information about this
procedure.