forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commite3a87b4
committed
Re-implement the ereport() macro using __VA_ARGS__.
Now that we require C99, we can depend on __VA_ARGS__ to work, andrevising ereport() to use it has several significant benefits:* The extra parentheses around the auxiliary function calls are nowoptional. Aside from being a bit less ugly, this removes a commongotcha for new contributors, because in some cases the compiler errorsyou got from forgetting them were unintelligible.* The auxiliary function calls are now evaluated as a comma expressionlist rather than as extra arguments to errfinish(). This means thatcompilers can be expected to warn about no-op expressions in the list,allowing detection of several other common mistakes such as forgettingto add errmsg(...) when converting an elog() call to ereport().* Unlike the situation with extra function arguments, comma expressionsare guaranteed to be evaluated left-to-right, so this removes platformdependency in the order of the auxiliary function calls. While thatdependency hasn't caused us big problems in the past, this change doesallow dropping some rather shaky assumptions around errcontext() domainhandling.There's no intention to make wholesale changes of existing ereportcalls, but as proof-of-concept this patch removes the extra parensfrom a couple of calls in postgres.c.While new code can be written either way, code intended to beback-patched will need to use extra parens for awhile yet. It seemsworth back-patching this change into v12, so as to reduce the windowwhere we have to be careful about that by one year. Hence, this patchis careful to preserve ABI compatibility; a followup HEAD-only patchwill make some additional simplifications.Andres Freund and Tom LaneDiscussion:https://postgr.es/m/CA+fd4k6N8EjNvZpM8nme+y+05mz-SM8Z_BgkixzkA34R+ej0Kw@mail.gmail.com1 parentcef27ae commite3a87b4
File tree
4 files changed
+49
-42
lines changed- doc/src/sgml
- src
- backend
- tcop
- utils/error
- include/utils
4 files changed
+49
-42
lines changedLines changed: 30 additions & 16 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
103 | 103 |
| |
104 | 104 |
| |
105 | 105 |
| |
106 |
| - | |
| 106 | + | |
107 | 107 |
| |
108 |
| - | |
| 108 | + | |
109 | 109 |
| |
110 | 110 |
| |
111 | 111 |
| |
| |||
116 | 116 |
| |
117 | 117 |
| |
118 | 118 |
| |
119 |
| - | |
120 |
| - | |
| 119 | + | |
| 120 | + | |
121 | 121 |
| |
122 | 122 |
| |
123 | 123 |
| |
124 | 124 |
| |
125 |
| - | |
126 |
| - | |
127 |
| - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
128 | 139 |
| |
129 | 140 |
| |
130 | 141 |
| |
131 | 142 |
| |
132 | 143 |
| |
133 | 144 |
| |
134 |
| - | |
135 |
| - | |
136 |
| - | |
137 |
| - | |
138 |
| - | |
139 |
| - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
140 | 151 |
| |
141 | 152 |
| |
142 | 153 |
| |
| 154 | + | |
| 155 | + | |
| 156 | + | |
143 | 157 |
| |
144 | 158 |
| |
145 | 159 |
| |
146 | 160 |
| |
147 |
| - | |
148 |
| - | |
| 161 | + | |
| 162 | + | |
149 | 163 |
| |
150 | 164 |
| |
151 | 165 |
| |
| |||
390 | 404 |
| |
391 | 405 |
| |
392 | 406 |
| |
393 |
| - | |
| 407 | + | |
394 | 408 |
| |
395 | 409 |
| |
396 | 410 |
| |
|
Lines changed: 7 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3720 | 3720 |
| |
3721 | 3721 |
| |
3722 | 3722 |
| |
3723 |
| - | |
3724 |
| - | |
3725 |
| - | |
| 3723 | + | |
| 3724 | + | |
| 3725 | + | |
3726 | 3726 |
| |
3727 | 3727 |
| |
3728 |
| - | |
3729 |
| - | |
3730 |
| - | |
3731 |
| - | |
| 3728 | + | |
| 3729 | + | |
| 3730 | + | |
| 3731 | + | |
3732 | 3732 |
| |
3733 | 3733 |
| |
3734 | 3734 |
| |
|
Lines changed: 0 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1116 | 1116 |
| |
1117 | 1117 |
| |
1118 | 1118 |
| |
1119 |
| - | |
1120 |
| - | |
1121 |
| - | |
1122 |
| - | |
1123 |
| - | |
1124 |
| - | |
1125 |
| - | |
1126 |
| - | |
1127 |
| - | |
1128 |
| - | |
1129 | 1119 |
| |
1130 | 1120 |
| |
1131 | 1121 |
| |
|
Lines changed: 12 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
91 | 91 |
| |
92 | 92 |
| |
93 | 93 |
| |
94 |
| - | |
95 |
| - | |
96 |
| - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
97 | 97 |
| |
98 | 98 |
| |
99 | 99 |
| |
100 | 100 |
| |
101 | 101 |
| |
102 | 102 |
| |
103 | 103 |
| |
| 104 | + | |
| 105 | + | |
| 106 | + | |
104 | 107 |
| |
105 | 108 |
| |
106 | 109 |
| |
| |||
118 | 121 |
| |
119 | 122 |
| |
120 | 123 |
| |
121 |
| - | |
| 124 | + | |
122 | 125 |
| |
123 | 126 |
| |
124 | 127 |
| |
125 |
| - | |
| 128 | + | |
126 | 129 |
| |
127 | 130 |
| |
128 | 131 |
| |
129 | 132 |
| |
130 |
| - | |
| 133 | + | |
131 | 134 |
| |
132 | 135 |
| |
133 | 136 |
| |
134 | 137 |
| |
135 |
| - | |
| 138 | + | |
136 | 139 |
| |
137 | 140 |
| |
138 | 141 |
| |
139 | 142 |
| |
140 | 143 |
| |
141 |
| - | |
142 |
| - | |
| 144 | + | |
| 145 | + | |
143 | 146 |
| |
144 | 147 |
| |
145 | 148 |
| |
|
0 commit comments
Comments
(0)