Allow UPDATE to move rows between partitions.
authorRobert Haas <rhaas@postgresql.org>
Fri, 19 Jan 2018 20:33:06 +0000 (15:33 -0500)
committerRobert Haas <rhaas@postgresql.org>
Fri, 19 Jan 2018 20:33:06 +0000 (15:33 -0500)
commit2f178441044be430f6b4d626e4dae68a9a6f6cec
tree131e7547b169b2bc42f638f1ca1b50ae6e146b70
parent7f17fd6fc7125b41218bc99ccfa8165e2d730cd9
Allow UPDATE to move rows between partitions.

When an UPDATE causes a row to no longer match the partition
constraint, try to move it to a different partition where it does
match the partition constraint.  In essence, the UPDATE is split into
a DELETE from the old partition and an INSERT into the new one.  This
can lead to surprising behavior in concurrency scenarios because
EvalPlanQual rechecks won't work as they normally did; the known
problems are documented.  (There is a pending patch to improve the
situation further, but it needs more review.)

Amit Khandekar, reviewed and tested by Amit Langote, David Rowley,
Rajkumar Raghuwanshi, Dilip Kumar, Amul Sul, Thomas Munro, Γlvaro
Herrera, Amit Kapila, and me.  A few final revisions by me.

Discussion: http://postgr.es/m/CAJ3gD9do9o2ccQ7j7+tSgiE1REY65XRiMb=yJO3u3QhyP8EEPQ@mail.gmail.com
27 files changed:
contrib/file_fdw/input/file_fdw.source
contrib/file_fdw/output/file_fdw.source
doc/src/sgml/ddl.sgml
doc/src/sgml/ref/update.sgml
doc/src/sgml/trigger.sgml
src/backend/commands/copy.c
src/backend/commands/trigger.c
src/backend/executor/execPartition.c
src/backend/executor/nodeModifyTable.c
src/backend/nodes/copyfuncs.c
src/backend/nodes/equalfuncs.c
src/backend/nodes/outfuncs.c
src/backend/nodes/readfuncs.c
src/backend/optimizer/path/allpaths.c
src/backend/optimizer/plan/createplan.c
src/backend/optimizer/plan/planner.c
src/backend/optimizer/prep/prepunion.c
src/backend/optimizer/util/pathnode.c
src/include/executor/execPartition.h
src/include/nodes/execnodes.h
src/include/nodes/plannodes.h
src/include/nodes/relation.h
src/include/optimizer/pathnode.h
src/include/optimizer/planner.h
src/test/regress/expected/update.out
src/test/regress/sql/update.sql
src/tools/pgindent/typedefs.list