mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
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
This commit is contained in:
@ -178,6 +178,7 @@ SELECT tableoid::regclass, * FROM p1;
|
||||
SELECT tableoid::regclass, * FROM p2;
|
||||
INSERT INTO pt VALUES (1, 'xyzzy'); -- ERROR
|
||||
INSERT INTO pt VALUES (2, 'xyzzy');
|
||||
UPDATE pt set a = 1 where a = 2; -- ERROR
|
||||
SELECT tableoid::regclass, * FROM pt;
|
||||
SELECT tableoid::regclass, * FROM p1;
|
||||
SELECT tableoid::regclass, * FROM p2;
|
||||
|
@ -344,6 +344,8 @@ SELECT tableoid::regclass, * FROM p2;
|
||||
INSERT INTO pt VALUES (1, 'xyzzy'); -- ERROR
|
||||
ERROR: cannot route inserted tuples to a foreign table
|
||||
INSERT INTO pt VALUES (2, 'xyzzy');
|
||||
UPDATE pt set a = 1 where a = 2; -- ERROR
|
||||
ERROR: cannot route inserted tuples to a foreign table
|
||||
SELECT tableoid::regclass, * FROM pt;
|
||||
tableoid | a | b
|
||||
----------+---+-------
|
||||
|
Reference in New Issue
Block a user