- Notifications
You must be signed in to change notification settings - Fork5
Commitb853eb9
committed
Improve handling of ereport(ERROR) and elog(ERROR).
In commit71450d7, we added code to informsuitably-intelligent compilers that ereport() doesn't return if the elevelis ERROR or higher. This patch extends that to elog(), and also fixes adouble-evaluation hazard that the previous commit created in ereport(),as well as reducing the emitted code size.The elog() improvement requires the compiler to support __VA_ARGS__, whichshould be available in just about anything nowadays since it's required byC99. But our minimum language baseline is still C89, so add a configuretest for that.The previous commit assumed that ereport's elevel could be evaluated twice,which isn't terribly safe --- there are already counterexamples in xlog.c.On compilers that have __builtin_constant_p, we can use that to protect thesecond test, since there's no possible optimization gain if the compilerdoesn't know the value of elevel. Otherwise, use a local variable insidethe macros to prevent double evaluation. The local-variable solution isinferior because (a) it leads to useless code being emitted when elevelisn't constant, and (b) it increases the optimization level needed for thecompiler to recognize that subsequent code is unreachable. But it seemsbetter than not teaching non-gcc compilers about unreachability at all.Lastly, if the compiler has __builtin_unreachable(), we can use thatinstead of abort(), resulting in a noticeable code savings since nofunction call is actually emitted. However, it seems wise to do this onlyin non-assert builds. In an assert build, continue to use abort(), so thatthe behavior will be predictable and debuggable if the "impossible"happens.These changes involve making the ereport and elog macros emit do-whilestatement blocks not just expressions, which forces small changes ina few call sites.Andres Freund, Tom Lane, Heikki Linnakangas1 parent4ae5ee6 commitb853eb9
File tree
12 files changed
+361
-15
lines changed- config
- contrib
- cube
- seg
- src
- backend
- bootstrap
- parser
- replication
- include
- utils
12 files changed
+361
-15
lines changedLines changed: 58 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
122 | 122 |
| |
123 | 123 |
| |
124 | 124 |
| |
125 |
| - | |
| 125 | + | |
126 | 126 |
| |
127 | 127 |
| |
128 | 128 |
| |
| |||
161 | 161 |
| |
162 | 162 |
| |
163 | 163 |
| |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
164 | 221 |
| |
165 | 222 |
| |
166 | 223 |
| |
|
Lines changed: 178 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
15659 | 15659 |
| |
15660 | 15660 |
| |
15661 | 15661 |
| |
| 15662 | + | |
| 15663 | + | |
| 15664 | + | |
| 15665 | + | |
| 15666 | + | |
| 15667 | + | |
| 15668 | + | |
| 15669 | + | |
| 15670 | + | |
| 15671 | + | |
| 15672 | + | |
| 15673 | + | |
| 15674 | + | |
| 15675 | + | |
| 15676 | + | |
| 15677 | + | |
| 15678 | + | |
| 15679 | + | |
| 15680 | + | |
| 15681 | + | |
| 15682 | + | |
| 15683 | + | |
| 15684 | + | |
| 15685 | + | |
| 15686 | + | |
| 15687 | + | |
| 15688 | + | |
| 15689 | + | |
| 15690 | + | |
| 15691 | + | |
| 15692 | + | |
| 15693 | + | |
| 15694 | + | |
| 15695 | + | |
| 15696 | + | |
| 15697 | + | |
| 15698 | + | |
| 15699 | + | |
| 15700 | + | |
| 15701 | + | |
| 15702 | + | |
| 15703 | + | |
| 15704 | + | |
| 15705 | + | |
| 15706 | + | |
| 15707 | + | |
| 15708 | + | |
| 15709 | + | |
| 15710 | + | |
| 15711 | + | |
| 15712 | + | |
| 15713 | + | |
| 15714 | + | |
| 15715 | + | |
| 15716 | + | |
| 15717 | + | |
| 15718 | + | |
| 15719 | + | |
| 15720 | + | |
| 15721 | + | |
| 15722 | + | |
| 15723 | + | |
| 15724 | + | |
| 15725 | + | |
| 15726 | + | |
| 15727 | + | |
| 15728 | + | |
| 15729 | + | |
| 15730 | + | |
| 15731 | + | |
| 15732 | + | |
| 15733 | + | |
| 15734 | + | |
| 15735 | + | |
| 15736 | + | |
| 15737 | + | |
| 15738 | + | |
| 15739 | + | |
| 15740 | + | |
| 15741 | + | |
| 15742 | + | |
| 15743 | + | |
| 15744 | + | |
| 15745 | + | |
| 15746 | + | |
| 15747 | + | |
| 15748 | + | |
| 15749 | + | |
| 15750 | + | |
| 15751 | + | |
| 15752 | + | |
| 15753 | + | |
| 15754 | + | |
| 15755 | + | |
| 15756 | + | |
| 15757 | + | |
| 15758 | + | |
| 15759 | + | |
| 15760 | + | |
| 15761 | + | |
| 15762 | + | |
| 15763 | + | |
| 15764 | + | |
| 15765 | + | |
| 15766 | + | |
| 15767 | + | |
| 15768 | + | |
| 15769 | + | |
| 15770 | + | |
| 15771 | + | |
| 15772 | + | |
| 15773 | + | |
| 15774 | + | |
| 15775 | + | |
| 15776 | + | |
| 15777 | + | |
| 15778 | + | |
| 15779 | + | |
| 15780 | + | |
| 15781 | + | |
| 15782 | + | |
| 15783 | + | |
| 15784 | + | |
| 15785 | + | |
| 15786 | + | |
| 15787 | + | |
| 15788 | + | |
| 15789 | + | |
| 15790 | + | |
| 15791 | + | |
| 15792 | + | |
| 15793 | + | |
| 15794 | + | |
| 15795 | + | |
| 15796 | + | |
| 15797 | + | |
| 15798 | + | |
| 15799 | + | |
| 15800 | + | |
| 15801 | + | |
| 15802 | + | |
| 15803 | + | |
| 15804 | + | |
| 15805 | + | |
| 15806 | + | |
| 15807 | + | |
| 15808 | + | |
| 15809 | + | |
| 15810 | + | |
| 15811 | + | |
| 15812 | + | |
| 15813 | + | |
| 15814 | + | |
| 15815 | + | |
| 15816 | + | |
| 15817 | + | |
| 15818 | + | |
| 15819 | + | |
| 15820 | + | |
| 15821 | + | |
| 15822 | + | |
| 15823 | + | |
| 15824 | + | |
| 15825 | + | |
| 15826 | + | |
| 15827 | + | |
| 15828 | + | |
| 15829 | + | |
| 15830 | + | |
| 15831 | + | |
| 15832 | + | |
| 15833 | + | |
| 15834 | + | |
| 15835 | + | |
| 15836 | + | |
| 15837 | + | |
| 15838 | + | |
| 15839 | + | |
15662 | 15840 |
| |
15663 | 15841 |
| |
15664 | 15842 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1106 | 1106 |
| |
1107 | 1107 |
| |
1108 | 1108 |
| |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
1109 | 1112 |
| |
1110 | 1113 |
| |
1111 | 1114 |
| |
|
Lines changed: 7 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
11 | 11 |
| |
12 | 12 |
| |
13 | 13 |
| |
14 |
| - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
15 | 21 |
| |
16 | 22 |
| |
17 | 23 |
| |
|
Lines changed: 7 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
10 | 10 |
| |
11 | 11 |
| |
12 | 12 |
| |
13 |
| - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
14 | 20 |
| |
15 | 21 |
| |
16 | 22 |
| |
|
Lines changed: 7 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
42 | 42 |
| |
43 | 43 |
| |
44 | 44 |
| |
45 |
| - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
46 | 52 |
| |
47 | 53 |
| |
48 | 54 |
| |
|
Lines changed: 7 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
42 | 42 |
| |
43 | 43 |
| |
44 | 44 |
| |
45 |
| - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
46 | 52 |
| |
47 | 53 |
| |
48 | 54 |
| |
|
Lines changed: 7 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
19 | 19 |
| |
20 | 20 |
| |
21 | 21 |
| |
22 |
| - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
23 | 29 |
| |
24 | 30 |
| |
25 | 31 |
| |
|
Lines changed: 12 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
748 | 748 |
| |
749 | 749 |
| |
750 | 750 |
| |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
751 | 763 |
| |
752 | 764 |
| |
753 | 765 |
| |
|
Lines changed: 9 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
635 | 635 |
| |
636 | 636 |
| |
637 | 637 |
| |
| 638 | + | |
| 639 | + | |
| 640 | + | |
638 | 641 |
| |
639 | 642 |
| |
640 | 643 |
| |
| 644 | + | |
| 645 | + | |
| 646 | + | |
641 | 647 |
| |
642 | 648 |
| |
643 | 649 |
| |
| 650 | + | |
| 651 | + | |
| 652 | + | |
644 | 653 |
| |
645 | 654 |
| |
646 | 655 |
| |
|
0 commit comments
Comments
(0)