forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commita923e21
committed
Fix detection of unseekable files for fseek() and ftello() with MSVC
Calling fseek() or ftello() on a handle to a non-seeking device such asa pipe or a communications device is not supported. Unfortunately,MSVC's flavor of these routines, _fseeki64() and _ftelli64(), do notreturn an error when given a pipe as handle. Some of the logic ofpg_dump and restore relies on these routines to check if a handle isseekable, causing failures when passing the contents of pg_dump topg_restore through a pipe, for example.This commit introduces wrappers for fseeko() and ftello() on MSVC so asany callers are able to properly detect the cases of non-seekablehandles. This relies mainly on GetFileType(), sharing a bit of codewith the MSVC port for fstat(). The code in charge of getting a filetype is refactored into a new file called win32common.c, shared bywin32stat.c and the new win32fseek.c. It includes the MSVC ports forfseeko() and ftello().Like765f5df, this is backpatched down to 14, where the fstat()implementation for MSVC is able to understand about files larger than4GB in size. Using a TAP test for that is proving to be tricky asIPC::Run handles the pipes by itself, still I have been able to checkthe fix manually.Reported-by: Daniel WatzingerAuthor: Juan José Santamaría Flecha, Michael PaquierDiscussion:https://postgr.es/m/CAC+AXB26a4EmxM2suXxPpJaGrqAdxracd7hskLg-zxtPB50h7A@mail.gmail.comBackpatch-through: 141 parentc03c2ea commita923e21
File tree
8 files changed
+166
-22
lines changed- src
- include/port
- port
- tools/msvc
8 files changed
+166
-22
lines changedLines changed: 6 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
16492 | 16492 |
| |
16493 | 16493 |
| |
16494 | 16494 |
| |
| 16495 | + | |
| 16496 | + | |
| 16497 | + | |
| 16498 | + | |
| 16499 | + | |
| 16500 | + | |
16495 | 16501 |
| |
16496 | 16502 |
| |
16497 | 16503 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1894 | 1894 |
| |
1895 | 1895 |
| |
1896 | 1896 |
| |
| 1897 | + | |
1897 | 1898 |
| |
1898 | 1899 |
| |
1899 | 1900 |
| |
|
Lines changed: 9 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
204 | 204 |
| |
205 | 205 |
| |
206 | 206 |
| |
| 207 | + | |
| 208 | + | |
| 209 | + | |
207 | 210 |
| |
208 | 211 |
| |
209 |
| - | |
| 212 | + | |
| 213 | + | |
210 | 214 |
| |
211 | 215 |
| |
212 | 216 |
| |
213 | 217 |
| |
214 |
| - | |
215 |
| - | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
216 | 222 |
| |
217 | 223 |
| |
218 | 224 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
29 | 29 |
| |
30 | 30 |
| |
31 | 31 |
| |
| 32 | + | |
32 | 33 |
| |
33 | 34 |
| |
34 | 35 |
| |
35 | 36 |
| |
| 37 | + | |
36 | 38 |
| |
37 | 39 |
| |
38 | 40 |
| |
|
Lines changed: 68 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + |
Lines changed: 75 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + |
Lines changed: 3 additions & 19 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
258 | 258 |
| |
259 | 259 |
| |
260 | 260 |
| |
261 |
| - | |
262 | 261 |
| |
263 | 262 |
| |
264 |
| - | |
265 |
| - | |
266 |
| - | |
267 |
| - | |
268 |
| - | |
269 |
| - | |
| 263 | + | |
270 | 264 |
| |
271 | 265 |
| |
272 | 266 |
| |
273 | 267 |
| |
274 | 268 |
| |
275 |
| - | |
276 |
| - | |
277 |
| - | |
278 |
| - | |
279 |
| - | |
280 |
| - | |
281 |
| - | |
282 |
| - | |
283 |
| - | |
284 |
| - | |
285 |
| - | |
| 269 | + | |
| 270 | + | |
286 | 271 |
| |
287 |
| - | |
288 | 272 |
| |
289 | 273 |
| |
290 | 274 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
108 | 108 |
| |
109 | 109 |
| |
110 | 110 |
| |
| 111 | + | |
111 | 112 |
| |
112 | 113 |
| |
113 | 114 |
| |
| 115 | + | |
114 | 116 |
| |
115 | 117 |
| |
116 | 118 |
| |
|
0 commit comments
Comments
(0)