forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commita542d56
committed
ecpg: re-implement preprocessor's string management.
Most productions in the preprocessor grammar construct stringsrepresenting SQL or C statements or fragments thereof. Insteadof returning these as <str> results of the productions, returnthem as "location" values, taking advantage of Bison's flexibilityabout what a location is. We aren't really giving up anythingthereby, since ecpg's error reports have always just given linenumbers, and that's tracked separately. The advantage of thisis that a single instance of the YYLLOC_DEFAULT macro canperform all the work needed by the vast majority of productions,including all the ones made automatically by parse.pl. Thisavoids having large numbers of effectively-identical productions,which tickles an optimization inefficiency in recent versions ofclang. (This patch reduces the compilation time for preproc.oby more than 100-fold with clang 16, and is visibly helpful withgcc too.) The compiled parser is noticeably smaller as well.A disadvantage of this approach is that YYLLOC_DEFAULT is appliedbefore running the production's semantic action (if any). Thismeans it cannot use the method favored by cat_str() of free'ingall the input strings; if the action needs to look at the inputstrings, it'd be looking at dangling storage. As this stands,therefore, it leaks memory like a sieve. This is already a bigpatch though, and fixing the memory management seems like aseparable problem, so let's leave that for the next step.(This does remove some free() calls that I'd have had to touchanyway, in the expectation that the next step will managememory reclamation quite differently.)Most of the changes here are mindless substitution of "@n" for"$N" in grammar rules; see the changes to README.parser foran explanation.Discussion:https://postgr.es/m/2011420.1713493114@sss.pgh.pa.us1 parent6b00549 commita542d56
File tree
9 files changed
+752
-1216
lines changed- src/interfaces/ecpg/preproc
9 files changed
+752
-1216
lines changedLines changed: 26 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4 | 4 |
| |
5 | 5 |
| |
6 | 6 |
| |
7 |
| - | |
8 |
| - | |
| 7 | + | |
| 8 | + | |
9 | 9 |
| |
10 | 10 |
| |
11 | 11 |
| |
| |||
14 | 14 |
| |
15 | 15 |
| |
16 | 16 |
| |
17 |
| - | |
| 17 | + | |
| 18 | + | |
18 | 19 |
| |
19 | 20 |
| |
20 | 21 |
| |
21 | 22 |
| |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
22 | 42 |
| |
23 | 43 |
| |
24 | 44 |
| |
| |||
69 | 89 |
| |
70 | 90 |
| |
71 | 91 |
| |
72 |
| - | |
73 |
| - | |
74 |
| - | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
75 | 95 |
| |
76 | 96 |
| |
77 | 97 |
|
0 commit comments
Comments
(0)