- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit28317de
Ensure first ModifyTable rel initialized if all are pruned
Commitcbc1279 introduced tracking of unpruned relids to avoidprocessing pruned relations, and changed ExecInitModifyTable() toinitialize only unpruned result relations. As a result, MERGEstatements that prune all target partitions can now lead to crashesor incorrect behavior during execution.The crash occurs because some executor code paths rely onModifyTableState.resultRelInfo[0] being present and initialized,even when no result relations remain after pruning. For example,ExecMerge() and ExecMergeNotMatched() use the first resultRelInfoto determine the appropriate action. Similarly,ExecInitPartitionInfo() assumes that at least one result relationexists.To preserve these assumptions, ExecInitModifyTable() now includes thefirst result relation in the initialized result relation list if allresult relations for that ModifyTable were pruned. To enable that,ExecDoInitialPruning() ensures the first relation is locked if it waspruned and locking is necessary.To support this exception to the pruning logic, PlannedStmt nowincludes a list of RT indexes identifying the first result relationof each ModifyTable node in the plan. This allowsExecDoInitialPruning() to check whether each such relation waspruned and, if so, lock it if necessary.Bug: #18830Reported-by: Robins Tharakan <tharakan@gmail.com>Diagnozed-by: Tender Wang <tndrwang@gmail.com>Diagnozed-by: Dean Rasheed <dean.a.rasheed@gmail.com>Co-authored-by: Dean Rasheed <dean.a.rasheed@gmail.com>Reviewed-by: Tender Wang <tndrwang@gmail.com>Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com>Discussion:https://postgr.es/m/18830-1f31ea1dc930d444%40postgresql.org1 parent06fb561 commit28317de
File tree
13 files changed
+214
-18
lines changed- src
- backend
- commands
- executor
- optimizer/plan
- include
- executor
- nodes
- test/regress
- expected
- sql
13 files changed
+214
-18
lines changedLines changed: 12 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4575 | 4575 |
| |
4576 | 4576 |
| |
4577 | 4577 |
| |
4578 |
| - | |
| 4578 | + | |
| 4579 | + | |
| 4580 | + | |
| 4581 | + | |
| 4582 | + | |
| 4583 | + | |
| 4584 | + | |
| 4585 | + | |
| 4586 | + | |
4579 | 4587 |
| |
4580 | 4588 |
| |
4581 |
| - | |
| 4589 | + | |
| 4590 | + | |
| 4591 | + | |
4582 | 4592 |
| |
4583 | 4593 |
| |
4584 | 4594 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1006 | 1006 |
| |
1007 | 1007 |
| |
1008 | 1008 |
| |
1009 |
| - | |
| 1009 | + | |
1010 | 1010 |
| |
1011 | 1011 |
| |
1012 | 1012 |
| |
|
Lines changed: 30 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1819 | 1819 |
| |
1820 | 1820 |
| |
1821 | 1821 |
| |
| 1822 | + | |
1822 | 1823 |
| |
1823 | 1824 |
| |
1824 | 1825 |
| |
| |||
1867 | 1868 |
| |
1868 | 1869 |
| |
1869 | 1870 |
| |
| 1871 | + | |
| 1872 | + | |
| 1873 | + | |
| 1874 | + | |
| 1875 | + | |
| 1876 | + | |
| 1877 | + | |
| 1878 | + | |
| 1879 | + | |
| 1880 | + | |
| 1881 | + | |
| 1882 | + | |
| 1883 | + | |
| 1884 | + | |
| 1885 | + | |
| 1886 | + | |
| 1887 | + | |
| 1888 | + | |
| 1889 | + | |
| 1890 | + | |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
| 1894 | + | |
| 1895 | + | |
| 1896 | + | |
| 1897 | + | |
| 1898 | + | |
1870 | 1899 |
| |
1871 | 1900 |
| |
1872 | 1901 |
| |
| |||
2076 | 2105 |
| |
2077 | 2106 |
| |
2078 | 2107 |
| |
2079 |
| - | |
| 2108 | + | |
2080 | 2109 |
| |
2081 | 2110 |
| |
2082 | 2111 |
| |
|
Lines changed: 11 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
746 | 746 |
| |
747 | 747 |
| |
748 | 748 |
| |
749 |
| - | |
| 749 | + | |
750 | 750 |
| |
751 | 751 |
| |
752 | 752 |
| |
| |||
815 | 815 |
| |
816 | 816 |
| |
817 | 817 |
| |
818 |
| - | |
819 |
| - | |
820 |
| - | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
821 | 825 |
| |
822 | 826 |
| |
823 |
| - | |
| 827 | + | |
824 | 828 |
| |
825 | 829 |
| |
826 | 830 |
| |
827 | 831 |
| |
828 | 832 |
| |
829 |
| - | |
| 833 | + | |
830 | 834 |
| |
831 | 835 |
| |
832 | 836 |
| |
| |||
880 | 884 |
| |
881 | 885 |
| |
882 | 886 |
| |
883 |
| - | |
| 887 | + | |
884 | 888 |
| |
885 | 889 |
| |
886 | 890 |
| |
|
Lines changed: 28 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4471 | 4471 |
| |
4472 | 4472 |
| |
4473 | 4473 |
| |
| 4474 | + | |
4474 | 4475 |
| |
4475 | 4476 |
| |
4476 | 4477 |
| |
| |||
4490 | 4491 |
| |
4491 | 4492 |
| |
4492 | 4493 |
| |
| 4494 | + | |
| 4495 | + | |
| 4496 | + | |
| 4497 | + | |
| 4498 | + | |
| 4499 | + | |
| 4500 | + | |
| 4501 | + | |
| 4502 | + | |
| 4503 | + | |
| 4504 | + | |
| 4505 | + | |
4493 | 4506 |
| |
4494 | 4507 |
| |
4495 | 4508 |
| |
4496 | 4509 |
| |
4497 | 4510 |
| |
| 4511 | + | |
| 4512 | + | |
| 4513 | + | |
| 4514 | + | |
| 4515 | + | |
| 4516 | + | |
| 4517 | + | |
| 4518 | + | |
| 4519 | + | |
| 4520 | + | |
4498 | 4521 |
| |
4499 |
| - | |
| 4522 | + | |
4500 | 4523 |
| |
4501 | 4524 |
| |
4502 | 4525 |
| |
| |||
4537 | 4560 |
| |
4538 | 4561 |
| |
4539 | 4562 |
| |
| 4563 | + | |
4540 | 4564 |
| |
4541 | 4565 |
| |
4542 | 4566 |
| |
| |||
4735 | 4759 |
| |
4736 | 4760 |
| |
4737 | 4761 |
| |
4738 |
| - | |
| 4762 | + | |
4739 | 4763 |
| |
4740 | 4764 |
| |
4741 | 4765 |
| |
| |||
4832 | 4856 |
| |
4833 | 4857 |
| |
4834 | 4858 |
| |
4835 |
| - | |
| 4859 | + | |
4836 | 4860 |
| |
4837 | 4861 |
| |
4838 | 4862 |
| |
| |||
4979 | 5003 |
| |
4980 | 5004 |
| |
4981 | 5005 |
| |
4982 |
| - | |
| 5006 | + | |
4983 | 5007 |
| |
4984 | 5008 |
| |
4985 | 5009 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
562 | 562 |
| |
563 | 563 |
| |
564 | 564 |
| |
| 565 | + | |
565 | 566 |
| |
566 | 567 |
| |
567 | 568 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1248 | 1248 |
| |
1249 | 1249 |
| |
1250 | 1250 |
| |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
1251 | 1254 |
| |
1252 | 1255 |
| |
1253 | 1256 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
43 | 43 |
| |
44 | 44 |
| |
45 | 45 |
| |
46 |
| - | |
47 |
| - | |
| 46 | + | |
| 47 | + | |
48 | 48 |
| |
49 | 49 |
| |
50 | 50 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
680 | 680 |
| |
681 | 681 |
| |
682 | 682 |
| |
683 |
| - | |
| 683 | + | |
| 684 | + | |
684 | 685 |
| |
685 | 686 |
| |
686 | 687 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
138 | 138 |
| |
139 | 139 |
| |
140 | 140 |
| |
| 141 | + | |
| 142 | + | |
| 143 | + | |
141 | 144 |
| |
142 | 145 |
| |
143 | 146 |
| |
|
Lines changed: 7 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
102 | 102 |
| |
103 | 103 |
| |
104 | 104 |
| |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
105 | 112 |
| |
106 | 113 |
| |
107 | 114 |
| |
|
Lines changed: 82 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4662 | 4662 |
| |
4663 | 4663 |
| |
4664 | 4664 |
| |
| 4665 | + | |
| 4666 | + | |
| 4667 | + | |
| 4668 | + | |
| 4669 | + | |
| 4670 | + | |
| 4671 | + | |
| 4672 | + | |
| 4673 | + | |
| 4674 | + | |
| 4675 | + | |
| 4676 | + | |
| 4677 | + | |
| 4678 | + | |
| 4679 | + | |
| 4680 | + | |
| 4681 | + | |
| 4682 | + | |
| 4683 | + | |
| 4684 | + | |
| 4685 | + | |
| 4686 | + | |
| 4687 | + | |
| 4688 | + | |
| 4689 | + | |
| 4690 | + | |
| 4691 | + | |
| 4692 | + | |
| 4693 | + | |
| 4694 | + | |
| 4695 | + | |
| 4696 | + | |
| 4697 | + | |
| 4698 | + | |
| 4699 | + | |
| 4700 | + | |
| 4701 | + | |
| 4702 | + | |
| 4703 | + | |
| 4704 | + | |
| 4705 | + | |
| 4706 | + | |
| 4707 | + | |
| 4708 | + | |
| 4709 | + | |
| 4710 | + | |
| 4711 | + | |
| 4712 | + | |
| 4713 | + | |
| 4714 | + | |
| 4715 | + | |
| 4716 | + | |
| 4717 | + | |
| 4718 | + | |
| 4719 | + | |
| 4720 | + | |
| 4721 | + | |
| 4722 | + | |
| 4723 | + | |
| 4724 | + | |
| 4725 | + | |
| 4726 | + | |
| 4727 | + | |
| 4728 | + | |
| 4729 | + | |
| 4730 | + | |
| 4731 | + | |
| 4732 | + | |
| 4733 | + | |
| 4734 | + | |
| 4735 | + | |
| 4736 | + | |
| 4737 | + | |
| 4738 | + | |
| 4739 | + | |
| 4740 | + | |
| 4741 | + | |
| 4742 | + | |
| 4743 | + | |
| 4744 | + | |
| 4745 | + | |
| 4746 | + | |
4665 | 4747 |
| |
4666 | 4748 |
| |
4667 | 4749 |
| |
|
0 commit comments
Comments
(0)