ExecForPortionOfLeftovers() assumed that any result relation with ri_RootResultRelInfo should reinsert temporal leftovers through the root relation. That is correct for partitioned tables, where tuple routing is needed, but it is wrong for plain inheritance. When UPDATE/DELETE FOR PORTION OF is run on an inheritance parent and a child row is split, the leftover rows must be inserted back into the child relation. Reinserting through the parent can lose child-only columns and place the leftover rows in the wrong relation. Fix this by distinguishing partitioned-table routing from plain inheritance. For partitioned tables, keep using the root leftover slot and insert through the root relation. For plain inheritance children, use a leftover slot matching the child relation and insert directly into the child. Also keep translating the application-time column attno for child relations, so multiple-inheritance cases with different attribute numbers are handled correctly. Added an ExecInitForPortionOf function to set up the ForPortionOfState for each child table, which keeps most of these decisions localized instead of spread out through ExecForPortionOfLeftovers. Incidentally clarified a comment about the rangetype stored in ForPortionOfState. Add regression tests for UPDATE and DELETE FOR PORTION OF on inheritance children, including a multiple-inheritance case where the range column has a different attnum in the parent and child. Author: jian he <jian.universality@gmail.com> Co-authored-by: Chao Li <li.evan.chao@gmail.com> Reviewed-by: Paul A. Jungwirth <pj@illuminatedcomputing.com> Discussion: https://www.postgresql.org/message-id/flat/4245F94D-84F1-4E05-BF81-C458A6CF9901%40gmail.com |
||
|---|---|---|
| .github | ||
| config | ||
| contrib | ||
| doc | ||
| src | ||
| .dir-locals.el | ||
| .editorconfig | ||
| .git-blame-ignore-revs | ||
| .gitattributes | ||
| .gitignore | ||
| .mailmap | ||
| aclocal.m4 | ||
| configure | ||
| configure.ac | ||
| COPYRIGHT | ||
| GNUmakefile.in | ||
| HISTORY | ||
| Makefile | ||
| meson.build | ||
| meson_options.txt | ||
| README.md | ||
PostgreSQL Database Management System
This directory contains the source code distribution of the PostgreSQL database management system.
PostgreSQL is an advanced object-relational database management system that supports an extended subset of the SQL standard, including transactions, foreign keys, subqueries, triggers, user-defined types and functions. This distribution also contains C language bindings.
Copyright and license information can be found in the file COPYRIGHT.
General documentation about this version of PostgreSQL can be found at https://www.postgresql.org/docs/devel/. In particular, information about building PostgreSQL from the source code can be found at https://www.postgresql.org/docs/devel/installation.html.
The latest version of this software, and related software, may be obtained at https://www.postgresql.org/download/. For more information look at our web site located at https://www.postgresql.org/.