Commit 5c7038d
committed
Refactor pipe_read_line to return the full line
Commit 5b2f4af refactored find_other_exec() and in the process
created pipe_read_line() into a static routine for reading a single
line of output, aimed at reading version numbers. Commit a7e8ece
later exposed it externally in order to read a postgresql.conf GUC
using "postgres -C ..". Further, f06b1c5 also made use of it for
reading a version string much like find_other_exec(). The internal
variable remained "pgver", even when used for other purposes.
Since the function requires passing a buffer and its size, and at
most size - 1 bytes will be read via fgets(), there is a truncation
risk when using this for reading GUCs (like how pg_rewind does,
though the risk in this case is marginal).
To keep this as generic functionality for reading a line from a pipe,
this refactors pipe_read_line() into returning an allocated buffer
containing all of the line to remove the risk of silent truncation.
Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Reviewed-by: Álvaro Herrera <alvherre@alvh.no-ip.org>
Reviewed-by: John Naylor <johncnaylorls@gmail.com>
Discussion: https://postgr.es/m/DEDF73CE-D528-49A3-9089-B3592FD671A9@yesql.se1 parent c01f6ef commit 5c7038d
File tree
4 files changed
+36
-25
lines changed- src
- bin
- pg_rewind
- pg_upgrade
- common
- include
4 files changed
+36
-25
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1055 | 1055 | | |
1056 | 1056 | | |
1057 | 1057 | | |
1058 | | - | |
1059 | | - | |
| 1058 | + | |
1060 | 1059 | | |
1061 | 1060 | | |
1062 | 1061 | | |
| |||
1105 | 1104 | | |
1106 | 1105 | | |
1107 | 1106 | | |
1108 | | - | |
1109 | | - | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
1110 | 1110 | | |
1111 | | - | |
| 1111 | + | |
1112 | 1112 | | |
1113 | | - | |
| 1113 | + | |
1114 | 1114 | | |
1115 | 1115 | | |
1116 | | - | |
1117 | | - | |
1118 | 1116 | | |
1119 | 1117 | | |
1120 | 1118 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
431 | 431 | | |
432 | 432 | | |
433 | 433 | | |
434 | | - | |
| 434 | + | |
435 | 435 | | |
436 | 436 | | |
437 | 437 | | |
| |||
442 | 442 | | |
443 | 443 | | |
444 | 444 | | |
445 | | - | |
| 445 | + | |
446 | 446 | | |
447 | 447 | | |
448 | 448 | | |
| |||
456 | 456 | | |
457 | 457 | | |
458 | 458 | | |
| 459 | + | |
| 460 | + | |
459 | 461 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| |||
328 | 330 | | |
329 | 331 | | |
330 | 332 | | |
331 | | - | |
| 333 | + | |
332 | 334 | | |
333 | 335 | | |
334 | 336 | | |
| |||
346 | 348 | | |
347 | 349 | | |
348 | 350 | | |
349 | | - | |
| 351 | + | |
350 | 352 | | |
351 | 353 | | |
352 | 354 | | |
| 355 | + | |
| 356 | + | |
353 | 357 | | |
| 358 | + | |
354 | 359 | | |
| 360 | + | |
355 | 361 | | |
356 | 362 | | |
357 | 363 | | |
358 | 364 | | |
359 | 365 | | |
360 | | - | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
361 | 369 | | |
362 | 370 | | |
363 | | - | |
| 371 | + | |
364 | 372 | | |
365 | | - | |
| 373 | + | |
| 374 | + | |
366 | 375 | | |
367 | 376 | | |
368 | 377 | | |
369 | 378 | | |
370 | | - | |
| 379 | + | |
371 | 380 | | |
372 | 381 | | |
373 | 382 | | |
374 | 383 | | |
375 | 384 | | |
| 385 | + | |
376 | 386 | | |
377 | | - | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
378 | 390 | | |
379 | | - | |
380 | | - | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
381 | 394 | | |
382 | | - | |
383 | | - | |
384 | | - | |
| 395 | + | |
| 396 | + | |
385 | 397 | | |
386 | 398 | | |
387 | | - | |
388 | | - | |
| 399 | + | |
389 | 400 | | |
390 | 401 | | |
391 | 402 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
140 | | - | |
| 140 | + | |
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| |||
0 commit comments