forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitd3b5775
committed
Improve type handling in pg_dump's compress file API
After0da243f got committed, we've received a report about a compilerwarning, related to the new LZ4File_gets() function: compress_lz4.c: In function 'LZ4File_gets': compress_lz4.c:492:19: warning: comparison of unsigned expression in '< 0' is always false [-Wtype-limits] 492 | if (dsize < 0)The reason is very simple - dsize is declared as size_t, which is anunsigned integer, and thus the check is pointless and we might fail tonotice an error in some cases (or fail in a strange way a bit later).The warning could have been silenced by simply changing the type, but werealized the API mostly assumes all the libraries use the same types andreport errors the same way (e.g. by returning 0 and/or negative value).But we can't make this assumption - the gzip/lz4 libraries alreadydisagree on some of this, and even if they did a library added in thefuture might not.The right solution is to define what the API does, and translate thelibrary-specific behavior in consistent way (so that the internal errorsare not exposed to users of our compression API). So this adjusts thedata types in a couple places, so that we don't miss library errors, andsimplifies and unifies the error reporting to simply return true/false(instead of e.g. size_t).While at it, make sure LZ4File_open_write() does not clobber errno incase open_func() fails.Author: Georgios KokolatosReported-by: Alexander LakhinReviewed-by: Tomas Vondra, Justin PryzbyDiscussion:https://postgr.es/m/33496f7c-3449-1426-d568-63f6bca2ac1f@gmail.com1 parenta326aac commitd3b5775
File tree
7 files changed
+148
-115
lines changed- src/bin/pg_dump
7 files changed
+148
-115
lines changedLines changed: 20 additions & 17 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
233 | 233 |
| |
234 | 234 |
| |
235 | 235 |
| |
236 |
| - | |
237 |
| - | |
| 236 | + | |
| 237 | + | |
238 | 238 |
| |
239 | 239 |
| |
240 |
| - | |
| 240 | + | |
241 | 241 |
| |
242 |
| - | |
243 |
| - | |
| 242 | + | |
| 243 | + | |
244 | 244 |
| |
245 | 245 |
| |
246 | 246 |
| |
| |||
249 | 249 |
| |
250 | 250 |
| |
251 | 251 |
| |
252 |
| - | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
253 | 256 |
| |
254 | 257 |
| |
255 |
| - | |
| 258 | + | |
256 | 259 |
| |
257 | 260 |
| |
258 | 261 |
| |
259 | 262 |
| |
260 |
| - | |
| 263 | + | |
261 | 264 |
| |
262 | 265 |
| |
263 | 266 |
| |
| |||
287 | 290 |
| |
288 | 291 |
| |
289 | 292 |
| |
290 |
| - | |
| 293 | + | |
291 | 294 |
| |
292 | 295 |
| |
293 | 296 |
| |
294 | 297 |
| |
295 | 298 |
| |
296 | 299 |
| |
297 |
| - | |
| 300 | + | |
298 | 301 |
| |
299 | 302 |
| |
300 |
| - | |
| 303 | + | |
301 | 304 |
| |
302 | 305 |
| |
303 | 306 |
| |
304 | 307 |
| |
305 |
| - | |
| 308 | + | |
306 | 309 |
| |
307 | 310 |
| |
308 | 311 |
| |
| |||
319 | 322 |
| |
320 | 323 |
| |
321 | 324 |
| |
322 |
| - | |
| 325 | + | |
323 | 326 |
| |
324 | 327 |
| |
325 | 328 |
| |
| |||
342 | 345 |
| |
343 | 346 |
| |
344 | 347 |
| |
345 |
| - | |
| 348 | + | |
346 | 349 |
| |
347 | 350 |
| |
348 | 351 |
| |
349 |
| - | |
| 352 | + | |
350 | 353 |
| |
351 | 354 |
| |
352 |
| - | |
| 355 | + | |
353 | 356 |
| |
354 | 357 |
| |
355 | 358 |
| |
356 |
| - | |
| 359 | + | |
357 | 360 |
| |
358 | 361 |
| |
359 | 362 |
| |
|
Lines changed: 4 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
262 | 262 |
| |
263 | 263 |
| |
264 | 264 |
| |
265 |
| - | |
| 265 | + | |
266 | 266 |
| |
267 | 267 |
| |
268 | 268 |
| |
| |||
275 | 275 |
| |
276 | 276 |
| |
277 | 277 |
| |
278 |
| - | |
| 278 | + | |
279 | 279 |
| |
280 |
| - | |
| 280 | + | |
281 | 281 |
| |
282 | 282 |
| |
283 |
| - | |
| 283 | + | |
284 | 284 |
| |
285 | 285 |
| |
286 | 286 |
| |
|
Lines changed: 29 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
100 | 100 |
| |
101 | 101 |
| |
102 | 102 |
| |
| 103 | + | |
| 104 | + | |
103 | 105 |
| |
104 |
| - | |
| 106 | + | |
105 | 107 |
| |
106 | 108 |
| |
107 | 109 |
| |
108 | 110 |
| |
109 | 111 |
| |
110 | 112 |
| |
111 | 113 |
| |
| 114 | + | |
| 115 | + | |
112 | 116 |
| |
113 |
| - | |
| 117 | + | |
114 | 118 |
| |
115 | 119 |
| |
116 | 120 |
| |
117 | 121 |
| |
| 122 | + | |
| 123 | + | |
| 124 | + | |
118 | 125 |
| |
119 |
| - | |
| 126 | + | |
| 127 | + | |
120 | 128 |
| |
121 | 129 |
| |
122 | 130 |
| |
| 131 | + | |
| 132 | + | |
123 | 133 |
| |
124 |
| - | |
| 134 | + | |
125 | 135 |
| |
126 | 136 |
| |
127 | 137 |
| |
| |||
130 | 140 |
| |
131 | 141 |
| |
132 | 142 |
| |
| 143 | + | |
| 144 | + | |
| 145 | + | |
133 | 146 |
| |
134 | 147 |
| |
135 | 148 |
| |
136 | 149 |
| |
137 | 150 |
| |
138 | 151 |
| |
| 152 | + | |
| 153 | + | |
| 154 | + | |
139 | 155 |
| |
140 | 156 |
| |
141 | 157 |
| |
142 | 158 |
| |
143 | 159 |
| |
| 160 | + | |
| 161 | + | |
144 | 162 |
| |
145 |
| - | |
| 163 | + | |
146 | 164 |
| |
147 | 165 |
| |
148 | 166 |
| |
| 167 | + | |
| 168 | + | |
149 | 169 |
| |
150 |
| - | |
| 170 | + | |
151 | 171 |
| |
152 | 172 |
| |
153 |
| - | |
154 |
| - | |
| 173 | + | |
| 174 | + | |
155 | 175 |
| |
156 | 176 |
| |
157 | 177 |
| |
| |||
178 | 198 |
| |
179 | 199 |
| |
180 | 200 |
| |
181 |
| - | |
| 201 | + | |
182 | 202 |
|
0 commit comments
Comments
(0)