Commit 4e96693
committed
PostgreSQL: Edit and delete rows of a partitioned table
limit1() identifies the row by its ctid, which is unique only within a
single relation. A partitioned table is not one relation, so the
condition is evaluated in every partition and matches whatever row sits
at the same (block, offset) in each of them. Editing or deleting one row
of a table with 64 partitions can affect 64 rows.
The ctid is used only when the row has no unique key, which is also the
case where the damage goes unnoticed - the affected rows are unrelated to
the edited one.
Matching (tableoid, ctid) restricts the condition to the partition
holding the row. tableoid is a system column of every table, so the
statement keeps its behaviour on ordinary tables, and tables using
INHERITS are fixed as well.1 parent 0bd9ef7 commit 4e96693
3 files changed
Lines changed: 25 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
490 | 490 | | |
491 | 491 | | |
492 | 492 | | |
493 | | - | |
| 493 | + | |
494 | 494 | | |
495 | 495 | | |
496 | 496 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
588 | 588 | | |
589 | 589 | | |
590 | 590 | | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
591 | 614 | | |
592 | 615 | | |
593 | 616 | | |
| |||
0 commit comments