forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitac8d7e1
committed
Fix corruption of tableElts list by MergeAttributes().
Since commite7b3349, MergeAttributesdestructively modifies the input List, to which the caller'sCreateStmt still points. One may wonder whether this was already abug, but commitf0e4475 made thingsnoticeably worse by adding additional destructive modifications sothat the caller's List might, in the case of creation a partitionedtable, no longer even be structurally valid. Restore the status quoante by assigning the return value of MergeAttributes back tostmt->tableElts in the caller.In most of the places where DefineRelation is called, it doesn'tmatter what stmt->tableElts points to here or whether it's valid ornot, because the caller doesn't use the statement for anything afterDefineRelation returns anyway. However, ProcessUtilitySlow passes itto EventTriggerCollectSimpleCommand, and that function tries to invokecopyObject on it. If any of the CreateStmt's substructure is invalidat that point, undefined behavior will result.One might wonder whether this whole area needs further revision -perhaps DefineRelation() ought not to be destructively modifying thecaller-provided CreateStmt at all. However, that would be a behaviorchange for any event triggers using C code to inspect the CreateStmt,so for now, just fix the crash.Report by Amit Langote, who provided a somewhat different patch for it.Discussion:http://postgr.es/m/bf6a39a7-100a-74bd-1156-3c16a1429d88@lab.ntt.co.jp1 parent7f17ae0 commitac8d7e1
1 file changed
+9
-8
lines changedLines changed: 9 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
491 | 491 |
| |
492 | 492 |
| |
493 | 493 |
| |
494 |
| - | |
495 | 494 |
| |
496 | 495 |
| |
497 | 496 |
| |
| |||
614 | 613 |
| |
615 | 614 |
| |
616 | 615 |
| |
617 |
| - | |
| 616 | + | |
| 617 | + | |
618 | 618 |
| |
619 |
| - | |
620 |
| - | |
621 |
| - | |
622 |
| - | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
623 | 624 |
| |
624 | 625 |
| |
625 | 626 |
| |
626 | 627 |
| |
627 | 628 |
| |
628 | 629 |
| |
629 |
| - | |
| 630 | + | |
630 | 631 |
| |
631 | 632 |
| |
632 | 633 |
| |
| |||
667 | 668 |
| |
668 | 669 |
| |
669 | 670 |
| |
670 |
| - | |
| 671 | + | |
671 | 672 |
| |
672 | 673 |
| |
673 | 674 |
| |
|
0 commit comments
Comments
(0)