forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit6f164e6
committed
Unify parsing logic for command-line integer options
Most of the integer options for command-line binaries now make use of asingle routine able to do the job, fixing issues with the detection ofsloppy values caused for example by the use of atoi(), that fails onstrings beginning with numerical characters with junk trailingcharacters.This commit cuts down the number of strings requiring translation by 26per my count, switching the code to have two error types for invalid andout-of-range values instead.Much more could be done here, with float or even int64 options, butint32 was the most appealing case as it is possible to rely on strtol()to do the job reliably. Note that there are some exceptions for now,like pg_ctl or pg_upgrade that use their own logging logic. A couple ofnegative TAP tests required some adjustments for the new errorsgenerated.pg_dump and pg_restore tracked the maximum number of parallel jobswithin the option parsing. The code is refactored a bit to track thatin the code dedicated to parallelism instead.Author: Kyotaro Horiguchi, Michael PaquierReviewed-by: David Rowley, Álvaro HerreraDiscussion:https://postgr.es/m/CALj2ACXqdG9WhqVoJ9zYf-iZt7sgK7Szv5USs=he6NnWQ2ofTA@mail.gmail.com1 parent6beb38c commit6f164e6
File tree
17 files changed
+177
-199
lines changed- src
- bin
- pg_amcheck
- pg_basebackup
- pg_checksums
- pg_dump
- t
- pgbench
- t
- scripts
- fe_utils
- include/fe_utils
17 files changed
+177
-199
lines changedLines changed: 3 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
| 15 | + | |
15 | 16 |
| |
16 | 17 |
| |
17 | 18 |
| |
| |||
326 | 327 |
| |
327 | 328 |
| |
328 | 329 |
| |
329 |
| - | |
330 |
| - | |
331 |
| - | |
332 |
| - | |
| 330 | + | |
| 331 | + | |
333 | 332 |
| |
334 |
| - | |
335 | 333 |
| |
336 | 334 |
| |
337 | 335 |
| |
|
Lines changed: 7 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
31 | 31 |
| |
32 | 32 |
| |
33 | 33 |
| |
| 34 | + | |
34 | 35 |
| |
35 | 36 |
| |
36 | 37 |
| |
| |||
2371 | 2372 |
| |
2372 | 2373 |
| |
2373 | 2374 |
| |
2374 |
| - | |
2375 |
| - | |
2376 |
| - | |
2377 |
| - | |
| 2375 | + | |
| 2376 | + | |
2378 | 2377 |
| |
2379 |
| - | |
2380 | 2378 |
| |
2381 | 2379 |
| |
2382 | 2380 |
| |
| |||
2409 | 2407 |
| |
2410 | 2408 |
| |
2411 | 2409 |
| |
2412 |
| - | |
2413 |
| - | |
2414 |
| - | |
2415 |
| - | |
| 2410 | + | |
| 2411 | + | |
| 2412 | + | |
2416 | 2413 |
| |
2417 |
| - | |
| 2414 | + | |
2418 | 2415 |
| |
2419 | 2416 |
| |
2420 | 2417 |
| |
|
Lines changed: 8 additions & 15 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
15 | 15 |
| |
16 | 16 |
| |
17 | 17 |
| |
| 18 | + | |
18 | 19 |
| |
19 | 20 |
| |
20 | 21 |
| |
21 | 22 |
| |
22 | 23 |
| |
23 | 24 |
| |
24 | 25 |
| |
| 26 | + | |
25 | 27 |
| |
26 | 28 |
| |
27 | 29 |
| |
| |||
532 | 534 |
| |
533 | 535 |
| |
534 | 536 |
| |
535 |
| - | |
536 |
| - | |
537 |
| - | |
538 |
| - | |
539 |
| - | |
540 | 537 |
| |
541 | 538 |
| |
542 | 539 |
| |
| |||
549 | 546 |
| |
550 | 547 |
| |
551 | 548 |
| |
552 |
| - | |
553 |
| - | |
554 |
| - | |
555 |
| - | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
556 | 552 |
| |
557 |
| - | |
| 553 | + | |
558 | 554 |
| |
559 | 555 |
| |
560 | 556 |
| |
| |||
574 | 570 |
| |
575 | 571 |
| |
576 | 572 |
| |
577 |
| - | |
578 |
| - | |
579 |
| - | |
580 |
| - | |
| 573 | + | |
| 574 | + | |
581 | 575 |
| |
582 |
| - | |
583 | 576 |
| |
584 | 577 |
| |
585 | 578 |
| |
|
Lines changed: 10 additions & 15 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
13 | 13 |
| |
14 | 14 |
| |
15 | 15 |
| |
| 16 | + | |
16 | 17 |
| |
17 | 18 |
| |
18 | 19 |
| |
| |||
23 | 24 |
| |
24 | 25 |
| |
25 | 26 |
| |
| 27 | + | |
26 | 28 |
| |
27 | 29 |
| |
28 | 30 |
| |
| |||
739 | 741 |
| |
740 | 742 |
| |
741 | 743 |
| |
742 |
| - | |
743 |
| - | |
744 |
| - | |
745 |
| - | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
746 | 747 |
| |
747 |
| - | |
| 748 | + | |
748 | 749 |
| |
749 | 750 |
| |
750 | 751 |
| |
| |||
763 | 764 |
| |
764 | 765 |
| |
765 | 766 |
| |
766 |
| - | |
767 |
| - | |
768 |
| - | |
769 |
| - | |
770 |
| - | |
771 | 767 |
| |
772 | 768 |
| |
773 | 769 |
| |
| |||
820 | 816 |
| |
821 | 817 |
| |
822 | 818 |
| |
823 |
| - | |
824 |
| - | |
825 |
| - | |
826 |
| - | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
827 | 822 |
| |
828 |
| - | |
| 823 | + | |
829 | 824 |
| |
830 | 825 |
| |
831 | 826 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
15 | 15 |
| |
16 | 16 |
| |
17 | 17 |
| |
| 18 | + | |
| 19 | + | |
| 20 | + | |
18 | 21 |
| |
19 | 22 |
| |
20 | 23 |
| |
|
Lines changed: 5 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
15 | 15 |
| |
16 | 16 |
| |
17 | 17 |
| |
| 18 | + | |
18 | 19 |
| |
19 | 20 |
| |
20 | 21 |
| |
| |||
24 | 25 |
| |
25 | 26 |
| |
26 | 27 |
| |
| 28 | + | |
27 | 29 |
| |
28 | 30 |
| |
29 | 31 |
| |
| |||
518 | 520 |
| |
519 | 521 |
| |
520 | 522 |
| |
521 |
| - | |
522 |
| - | |
523 |
| - | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
524 | 526 |
| |
525 |
| - | |
526 | 527 |
| |
527 | 528 |
| |
528 | 529 |
| |
|
Lines changed: 13 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
33 | 33 |
| |
34 | 34 |
| |
35 | 35 |
| |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
36 | 49 |
| |
37 | 50 |
| |
38 | 51 |
| |
|
Lines changed: 11 additions & 36 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
56 | 56 |
| |
57 | 57 |
| |
58 | 58 |
| |
| 59 | + | |
59 | 60 |
| |
60 | 61 |
| |
61 | 62 |
| |
| |||
322 | 323 |
| |
323 | 324 |
| |
324 | 325 |
| |
325 |
| - | |
326 | 326 |
| |
327 | 327 |
| |
328 | 328 |
| |
329 | 329 |
| |
330 | 330 |
| |
331 | 331 |
| |
332 |
| - | |
333 | 332 |
| |
334 | 333 |
| |
335 | 334 |
| |
| |||
487 | 486 |
| |
488 | 487 |
| |
489 | 488 |
| |
490 |
| - | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
491 | 493 |
| |
492 | 494 |
| |
493 | 495 |
| |
| |||
550 | 552 |
| |
551 | 553 |
| |
552 | 554 |
| |
553 |
| - | |
554 |
| - | |
555 |
| - | |
556 |
| - | |
| 555 | + | |
| 556 | + | |
557 | 557 |
| |
558 |
| - | |
559 | 558 |
| |
560 | 559 |
| |
561 | 560 |
| |
| |||
588 | 587 |
| |
589 | 588 |
| |
590 | 589 |
| |
591 |
| - | |
592 |
| - | |
593 |
| - | |
594 |
| - | |
| 590 | + | |
| 591 | + | |
595 | 592 |
| |
596 |
| - | |
597 | 593 |
| |
598 | 594 |
| |
599 | 595 |
| |
| |||
607 | 603 |
| |
608 | 604 |
| |
609 | 605 |
| |
610 |
| - | |
611 |
| - | |
612 |
| - | |
613 |
| - | |
614 |
| - | |
615 |
| - | |
616 |
| - | |
617 |
| - | |
618 |
| - | |
| 606 | + | |
| 607 | + | |
619 | 608 |
| |
620 |
| - | |
621 |
| - | |
622 | 609 |
| |
623 | 610 |
| |
624 | 611 |
| |
| |||
720 | 707 |
| |
721 | 708 |
| |
722 | 709 |
| |
723 |
| - | |
724 |
| - | |
725 |
| - | |
726 |
| - | |
727 |
| - | |
728 |
| - | |
729 |
| - | |
730 |
| - | |
731 |
| - | |
732 |
| - | |
733 |
| - | |
734 |
| - | |
735 | 710 |
| |
736 | 711 |
| |
737 | 712 |
| |
|
Lines changed: 5 additions & 17 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
46 | 46 |
| |
47 | 47 |
| |
48 | 48 |
| |
| 49 | + | |
49 | 50 |
| |
50 | 51 |
| |
51 | 52 |
| |
| |||
181 | 182 |
| |
182 | 183 |
| |
183 | 184 |
| |
184 |
| - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
185 | 189 |
| |
186 | 190 |
| |
187 | 191 |
| |
| |||
344 | 348 |
| |
345 | 349 |
| |
346 | 350 |
| |
347 |
| - | |
348 |
| - | |
349 |
| - | |
350 |
| - | |
351 |
| - | |
352 |
| - | |
353 |
| - | |
354 |
| - | |
355 |
| - | |
356 |
| - | |
357 |
| - | |
358 |
| - | |
359 |
| - | |
360 |
| - | |
361 |
| - | |
362 |
| - | |
363 | 351 |
| |
364 | 352 |
| |
365 | 353 |
| |
|
0 commit comments
Comments
(0)