forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit5392dd3
committed
Fix plpgsql's handling of -- comments following expressions.
Up to now, read_sql_construct() has collected all the source text fromthe statement or expression's initial token up to the character justbefore the "until" token. It normally tries to strip trailingwhitespace from that, largely for neatness. If there was a "-- text"comment after the expression, this resulted in removing the newlinethat terminates the comment, which creates a hazard if we try to pastethe collected text into a larger SQL construct without inserting anewline after it. In particular this caused our handling of CASEconstructs to fail if there's a comment after a WHEN expression.Commit4adead1 noticed a similar problem with cursor arguments,and worked around it through the rather crude hack of suppressingthe whitespace-trimming behavior for those. Rather than do thatand leave the hazard open for future hackers to trip over, let'sfix it properly. pl_scanner.c already has enough infrastructureto report the end location of the expression's last token, sowe can copy up to that location and never collect any trailingwhitespace or comment to begin with.Erik Wienhold and Tom Lane, per report from Michal Bartak.Back-patch to all supported branches.Discussion:https://postgr.es/m/CAAVzF_FjRoi8fOVuLCZhQJx6HATQ7MKm=aFOHWZODFnLmjX-xA@mail.gmail.com1 parent52b49b7 commit5392dd3
File tree
7 files changed
+76
-36
lines changed- src
- pl/plpgsql/src
- expected
- sql
- test/regress
- expected
- sql
7 files changed
+76
-36
lines changedLines changed: 17 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
681 | 681 |
| |
682 | 682 |
| |
683 | 683 |
| |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + |
Lines changed: 21 additions & 26 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
66 | 66 |
| |
67 | 67 |
| |
68 | 68 |
| |
69 |
| - | |
70 | 69 |
| |
71 | 70 |
| |
72 | 71 |
| |
| |||
895 | 894 |
| |
896 | 895 |
| |
897 | 896 |
| |
898 |
| - | |
| 897 | + | |
899 | 898 |
| |
900 | 899 |
| |
901 | 900 |
| |
| |||
981 | 980 |
| |
982 | 981 |
| |
983 | 982 |
| |
984 |
| - | |
| 983 | + | |
985 | 984 |
| |
986 | 985 |
| |
987 | 986 |
| |
| |||
1474 | 1473 |
| |
1475 | 1474 |
| |
1476 | 1475 |
| |
1477 |
| - | |
1478 | 1476 |
| |
1479 | 1477 |
| |
1480 | 1478 |
| |
| |||
1879 | 1877 |
| |
1880 | 1878 |
| |
1881 | 1879 |
| |
1882 |
| - | |
| 1880 | + | |
1883 | 1881 |
| |
1884 | 1882 |
| |
1885 | 1883 |
| |
| |||
2016 | 2014 |
| |
2017 | 2015 |
| |
2018 | 2016 |
| |
2019 |
| - | |
| 2017 | + | |
2020 | 2018 |
| |
2021 | 2019 |
| |
2022 | 2020 |
| |
| |||
2055 | 2053 |
| |
2056 | 2054 |
| |
2057 | 2055 |
| |
2058 |
| - | |
| 2056 | + | |
2059 | 2057 |
| |
2060 | 2058 |
| |
2061 | 2059 |
| |
| |||
2640 | 2638 |
| |
2641 | 2639 |
| |
2642 | 2640 |
| |
2643 |
| - | |
| 2641 | + | |
2644 | 2642 |
| |
2645 | 2643 |
| |
2646 | 2644 |
| |
| |||
2650 | 2648 |
| |
2651 | 2649 |
| |
2652 | 2650 |
| |
2653 |
| - | |
| 2651 | + | |
2654 | 2652 |
| |
2655 | 2653 |
| |
2656 | 2654 |
| |
| |||
2659 | 2657 |
| |
2660 | 2658 |
| |
2661 | 2659 |
| |
2662 |
| - | |
| 2660 | + | |
2663 | 2661 |
| |
2664 | 2662 |
| |
2665 | 2663 |
| |
| |||
2672 | 2670 |
| |
2673 | 2671 |
| |
2674 | 2672 |
| |
2675 |
| - | |
2676 | 2673 |
| |
2677 | 2674 |
| |
2678 | 2675 |
| |
| |||
2685 | 2682 |
| |
2686 | 2683 |
| |
2687 | 2684 |
| |
2688 |
| - | |
2689 | 2685 |
| |
2690 | 2686 |
| |
2691 | 2687 |
| |
2692 | 2688 |
| |
2693 | 2689 |
| |
2694 | 2690 |
| |
2695 | 2691 |
| |
| 2692 | + | |
2696 | 2693 |
| |
2697 | 2694 |
| |
2698 | 2695 |
| |
| |||
2743 | 2740 |
| |
2744 | 2741 |
| |
2745 | 2742 |
| |
| 2743 | + | |
| 2744 | + | |
2746 | 2745 |
| |
2747 | 2746 |
| |
2748 | 2747 |
| |
| |||
2753 | 2752 |
| |
2754 | 2753 |
| |
2755 | 2754 |
| |
2756 |
| - | |
| 2755 | + | |
2757 | 2756 |
| |
2758 | 2757 |
| |
2759 | 2758 |
| |
2760 | 2759 |
| |
2761 | 2760 |
| |
2762 | 2761 |
| |
2763 | 2762 |
| |
2764 |
| - | |
2765 |
| - | |
2766 |
| - | |
2767 |
| - | |
2768 |
| - | |
2769 |
| - | |
2770 |
| - | |
2771 |
| - | |
| 2763 | + | |
| 2764 | + | |
| 2765 | + | |
| 2766 | + | |
| 2767 | + | |
| 2768 | + | |
| 2769 | + | |
| 2770 | + | |
2772 | 2771 |
| |
2773 | 2772 |
| |
2774 | 2773 |
| |
| |||
3933 | 3932 |
| |
3934 | 3933 |
| |
3935 | 3934 |
| |
3936 |
| - | |
3937 |
| - | |
3938 |
| - | |
3939 |
| - | |
| 3935 | + | |
3940 | 3936 |
| |
3941 | 3937 |
| |
3942 | 3938 |
| |
3943 | 3939 |
| |
3944 | 3940 |
| |
3945 |
| - | |
3946 | 3941 |
| |
3947 | 3942 |
| |
3948 | 3943 |
| |
|
Lines changed: 17 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
184 | 184 |
| |
185 | 185 |
| |
186 | 186 |
| |
| 187 | + | |
| 188 | + | |
187 | 189 |
| |
188 | 190 |
| |
189 | 191 |
| |
| |||
197 | 199 |
| |
198 | 200 |
| |
199 | 201 |
| |
| 202 | + | |
| 203 | + | |
200 | 204 |
| |
201 | 205 |
| |
202 | 206 |
| |
| |||
210 | 214 |
| |
211 | 215 |
| |
212 | 216 |
| |
| 217 | + | |
| 218 | + | |
213 | 219 |
| |
214 | 220 |
| |
215 | 221 |
| |
| |||
298 | 304 |
| |
299 | 305 |
| |
300 | 306 |
| |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
301 | 318 |
| |
302 | 319 |
| |
303 | 320 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1317 | 1317 |
| |
1318 | 1318 |
| |
1319 | 1319 |
| |
| 1320 | + | |
1320 | 1321 |
| |
1321 | 1322 |
| |
1322 | 1323 |
| |
|
Lines changed: 14 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
486 | 486 |
| |
487 | 487 |
| |
488 | 488 |
| |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + |
Lines changed: 3 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2390 | 2390 |
| |
2391 | 2391 |
| |
2392 | 2392 |
| |
2393 |
| - | |
2394 |
| - | |
2395 |
| - | |
2396 |
| - | |
2397 |
| - | |
| 2393 | + | |
| 2394 | + | |
| 2395 | + | |
2398 | 2396 |
| |
2399 | 2397 |
| |
2400 | 2398 |
| |
|
Lines changed: 3 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2047 | 2047 |
| |
2048 | 2048 |
| |
2049 | 2049 |
| |
2050 |
| - | |
2051 |
| - | |
2052 |
| - | |
2053 |
| - | |
2054 |
| - | |
| 2050 | + | |
| 2051 | + | |
| 2052 | + | |
2055 | 2053 |
| |
2056 | 2054 |
| |
2057 | 2055 |
| |
|
0 commit comments
Comments
(0)