forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit774171c
committed
Improve reporting of errors in extension script files.
Previously, CREATE/ALTER EXTENSION gave basically no usefulcontext about errors reported while executing script files.I think the idea was that you could run the same commandsmanually to see the error, but that's often quite inconvenient.Let's improve that.If we get an error during raw parsing, we won't have a currentstatement identified by a RawStmt node, but we should always geta syntax error position. Show the portion of the script fromthe last semicolon-newline before the error position to the firstone after it. There are cases where this might show only afragment of a statement, but that should be uncommon, and itseems better than showing the whole script file.Without an error cursor, if we have gotten past raw parsing (whichwe probably have), we can report just the current SQL statement asan item of error context.In any case also report the script file name as error context,since it might not be entirely obvious which of a series ofupdate scripts failed. We can also show an approximate scriptline number in case whatever we printed of the query isn'tsufficiently identifiable.The error-context code path is already exercised by sometest_extensions test cases, but add tests for the syntax-errorpath.Discussion:https://postgr.es/m/ZvV1ClhnbJLCz7Sm@msg.df7cb.de1 parent14e5680 commit774171c
File tree
8 files changed
+244
-3
lines changed- src
- backend/commands
- test/modules/test_extensions
- expected
- sql
- tools/pgindent
8 files changed
+244
-3
lines changedLines changed: 165 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
54 | 54 |
| |
55 | 55 |
| |
56 | 56 |
| |
| 57 | + | |
57 | 58 |
| |
58 | 59 |
| |
59 | 60 |
| |
| |||
107 | 108 |
| |
108 | 109 |
| |
109 | 110 |
| |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
110 | 122 |
| |
111 | 123 |
| |
112 | 124 |
| |
| |||
670 | 682 |
| |
671 | 683 |
| |
672 | 684 |
| |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
673 | 813 |
| |
674 | 814 |
| |
675 | 815 |
| |
| 816 | + | |
| 817 | + | |
676 | 818 |
| |
677 | 819 |
| |
678 | 820 |
| |
| |||
682 | 824 |
| |
683 | 825 |
| |
684 | 826 |
| |
685 |
| - | |
| 827 | + | |
686 | 828 |
| |
| 829 | + | |
| 830 | + | |
687 | 831 |
| |
688 | 832 |
| |
689 | 833 |
| |
690 | 834 |
| |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
691 | 848 |
| |
692 | 849 |
| |
693 | 850 |
| |
| |||
709 | 866 |
| |
710 | 867 |
| |
711 | 868 |
| |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
712 | 873 |
| |
713 | 874 |
| |
714 | 875 |
| |
| |||
778 | 939 |
| |
779 | 940 |
| |
780 | 941 |
| |
| 942 | + | |
| 943 | + | |
781 | 944 |
| |
782 | 945 |
| |
783 | 946 |
| |
| |||
1054 | 1217 |
| |
1055 | 1218 |
| |
1056 | 1219 |
| |
1057 |
| - | |
| 1220 | + | |
1058 | 1221 |
| |
1059 | 1222 |
| |
1060 | 1223 |
| |
|
Lines changed: 3 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
13 | 13 |
| |
14 | 14 |
| |
15 | 15 |
| |
16 |
| - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
17 | 19 |
| |
18 | 20 |
| |
19 | 21 |
| |
|
Lines changed: 42 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
72 | 72 |
| |
73 | 73 |
| |
74 | 74 |
| |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
75 | 91 |
| |
76 | 92 |
| |
77 | 93 |
| |
| |||
295 | 311 |
| |
296 | 312 |
| |
297 | 313 |
| |
| 314 | + | |
| 315 | + | |
| 316 | + | |
298 | 317 |
| |
299 | 318 |
| |
300 | 319 |
| |
| |||
307 | 326 |
| |
308 | 327 |
| |
309 | 328 |
| |
| 329 | + | |
| 330 | + | |
| 331 | + | |
310 | 332 |
| |
311 | 333 |
| |
312 | 334 |
| |
| |||
323 | 345 |
| |
324 | 346 |
| |
325 | 347 |
| |
| 348 | + | |
| 349 | + | |
326 | 350 |
| |
327 | 351 |
| |
328 | 352 |
| |
| |||
331 | 355 |
| |
332 | 356 |
| |
333 | 357 |
| |
| 358 | + | |
| 359 | + | |
| 360 | + | |
334 | 361 |
| |
335 | 362 |
| |
336 | 363 |
| |
| |||
379 | 406 |
| |
380 | 407 |
| |
381 | 408 |
| |
| 409 | + | |
| 410 | + | |
| 411 | + | |
382 | 412 |
| |
383 | 413 |
| |
384 | 414 |
| |
385 | 415 |
| |
386 | 416 |
| |
| 417 | + | |
| 418 | + | |
387 | 419 |
| |
388 | 420 |
| |
389 | 421 |
| |
390 | 422 |
| |
391 | 423 |
| |
392 | 424 |
| |
| 425 | + | |
| 426 | + | |
393 | 427 |
| |
394 | 428 |
| |
395 | 429 |
| |
396 | 430 |
| |
397 | 431 |
| |
| 432 | + | |
| 433 | + | |
398 | 434 |
| |
399 | 435 |
| |
400 | 436 |
| |
401 | 437 |
| |
402 | 438 |
| |
| 439 | + | |
| 440 | + | |
403 | 441 |
| |
404 | 442 |
| |
405 | 443 |
| |
406 | 444 |
| |
407 | 445 |
| |
| 446 | + | |
| 447 | + | |
408 | 448 |
| |
409 | 449 |
| |
410 | 450 |
| |
411 | 451 |
| |
412 | 452 |
| |
| 453 | + | |
| 454 | + | |
413 | 455 |
| |
414 | 456 |
| |
415 | 457 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
15 | 15 |
| |
16 | 16 |
| |
17 | 17 |
| |
| 18 | + | |
| 19 | + | |
18 | 20 |
| |
19 | 21 |
| |
20 | 22 |
| |
|
Lines changed: 4 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
28 | 28 |
| |
29 | 29 |
| |
30 | 30 |
| |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
31 | 35 |
| |
32 | 36 |
| |
33 | 37 |
| |
|
Lines changed: 14 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 | + |
Lines changed: 13 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 | + |
0 commit comments
Comments
(0)