forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit14e5680
committed
Improve parser's reporting of statement start locations.
Up to now, the parser's reporting of a statement's stmt_locationincluded any preceding whitespace or comments. This isn't reallydesirable but was done to avoid accounting honestly for nonterminalsthat reduce to empty. It causes problems for pg_stat_statements,which partially compensates by manually stripping whitespace, butis not bright enough to strip /*-style comments. There will bemore problems with an upcoming patch to improve reporting of errorsin extension scripts, so it's time to do something about this.The thing we have to do to make it work right is to adjustYYLLOC_DEFAULT to scan the inputs of each production to find thefirst one that has a valid location (i.e., did not reduce toempty). In theory this adds a little bit of per-reduction overhead,but in practice it's negligible. I checked by measuring the timeto run raw_parser() on the contents of information_schema.sql, andthere was basically no change.Having done that, we can rely on any nonterminal that didn't reduceto completely empty to have a correct starting location, and we don'tneed the kluges the stmtmulti production formerly used.This should have a side benefit of allowing parse error reports toinclude an error position in some cases where they formerly failed todo so, due to trying to report the position of an empty nonterminal.I did not go looking for an example though. The one previously knowncase where that could happen (OptSchemaEltList) no longer needs thekluge it had; but I rather doubt that that was the only case.Discussion:https://postgr.es/m/ZvV1ClhnbJLCz7Sm@msg.df7cb.de1 parent7c4d3fe commit14e5680
File tree
4 files changed
+34
-46
lines changed- contrib/pg_stat_statements
- expected
- sql
- src/backend
- nodes
- parser
4 files changed
+34
-46
lines changedLines changed: 3 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
19 | 19 |
| |
20 | 20 |
| |
21 | 21 |
| |
| 22 | + | |
22 | 23 |
| |
23 |
| - | |
| 24 | + | |
24 | 25 |
| |
25 | 26 |
| |
26 | 27 |
| |
| |||
129 | 130 |
| |
130 | 131 |
| |
131 | 132 |
| |
132 |
| - | |
| 133 | + | |
133 | 134 |
| |
134 | 135 |
| |
135 | 136 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
| 15 | + | |
15 | 16 |
| |
16 |
| - | |
| 17 | + | |
17 | 18 |
| |
18 | 19 |
| |
19 | 20 |
| |
|
Lines changed: 6 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
90 | 90 |
| |
91 | 91 |
| |
92 | 92 |
| |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
93 | 99 |
| |
94 | 100 |
| |
95 | 101 |
| |
|
Lines changed: 23 additions & 43 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
67 | 67 |
| |
68 | 68 |
| |
69 | 69 |
| |
70 |
| - | |
71 |
| - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
72 | 75 |
| |
73 | 76 |
| |
74 | 77 |
| |
75 |
| - | |
76 |
| - | |
77 |
| - | |
78 |
| - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
79 | 87 |
| |
80 | 88 |
| |
81 |
| - | |
82 |
| - | |
83 |
| - | |
84 |
| - | |
85 |
| - | |
86 |
| - | |
87 |
| - | |
88 |
| - | |
89 |
| - | |
90 |
| - | |
91 |
| - | |
92 |
| - | |
93 |
| - | |
94 |
| - | |
95 |
| - | |
96 |
| - | |
97 |
| - | |
98 |
| - | |
99 |
| - | |
100 |
| - | |
101 |
| - | |
102 |
| - | |
103 | 89 |
| |
104 | 90 |
| |
105 | 91 |
| |
| |||
930 | 916 |
| |
931 | 917 |
| |
932 | 918 |
| |
933 |
| - | |
| 919 | + | |
934 | 920 |
| |
935 | 921 |
| |
936 | 922 |
| |
937 | 923 |
| |
938 | 924 |
| |
939 | 925 |
| |
940 | 926 |
| |
941 |
| - | |
| 927 | + | |
942 | 928 |
| |
943 | 929 |
| |
944 | 930 |
| |
945 | 931 |
| |
946 | 932 |
| |
947 | 933 |
| |
948 | 934 |
| |
949 |
| - | |
| 935 | + | |
950 | 936 |
| |
951 | 937 |
| |
952 | 938 |
| |
953 | 939 |
| |
954 | 940 |
| |
955 | 941 |
| |
956 | 942 |
| |
957 |
| - | |
| 943 | + | |
958 | 944 |
| |
959 | 945 |
| |
960 | 946 |
| |
961 | 947 |
| |
962 | 948 |
| |
963 |
| - | |
964 |
| - | |
965 |
| - | |
966 |
| - | |
967 |
| - | |
968 |
| - | |
969 |
| - | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
970 | 952 |
| |
971 | 953 |
| |
972 | 954 |
| |
| |||
976 | 958 |
| |
977 | 959 |
| |
978 | 960 |
| |
979 |
| - | |
| 961 | + | |
980 | 962 |
| |
981 | 963 |
| |
982 | 964 |
| |
983 | 965 |
| |
984 | 966 |
| |
985 | 967 |
| |
986 |
| - | |
| 968 | + | |
987 | 969 |
| |
988 | 970 |
| |
989 | 971 |
| |
| |||
1584 | 1566 |
| |
1585 | 1567 |
| |
1586 | 1568 |
| |
1587 |
| - | |
1588 |
| - | |
1589 | 1569 |
| |
1590 | 1570 |
| |
1591 | 1571 |
| |
|
0 commit comments
Comments
(0)