forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit802fe92
committed
cube: pure parser and reentrant scanner
Use the flex %option reentrant and the bison option %pure-parser tomake the generated scanner and parser pure, reentrant, andthread-safe.Make the generated scanner use palloc() etc. instead of malloc() etc.Previously, we only used palloc() for the buffer, but flex would stilluse malloc() for its internal structures. As a result, there could besome small memory leaks in case of uncaught errors. (We do catchnormal syntax errors as soft errors.) Now, all the memory is underpalloc() control, so there are no more such issues.Simplify flex scan buffer management: Instead of constructing thebuffer from pieces and then using yy_scan_buffer(), we can just useyy_scan_string(), which does the same thing internally. (Actually, weuse yy_scan_bytes() here because we already have the length.)The previous code was necessary because we allocated the buffer withpalloc() and the rest of the state was handled by malloc(). But thisis no longer the case; everything is under palloc() now.(We could even get rid of the yylex_destroy() call and just let thememory context cleanup handle everything. But for now, we preservethe existing behavior.)Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>Reviewed-by: Andreas Karlsson <andreas@proxel.se>Discussion:https://www.postgresql.org/message-id/flat/eb6faeac-2a8a-4b69-9189-c33c520e5b7b@eisentraut.org1 parent477728b commit802fe92
4 files changed
+74
-52
lines changedLines changed: 4 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
120 | 120 |
| |
121 | 121 |
| |
122 | 122 |
| |
| 123 | + | |
123 | 124 |
| |
124 |
| - | |
| 125 | + | |
125 | 126 |
| |
126 |
| - | |
| 127 | + | |
127 | 128 |
| |
128 | 129 |
| |
129 |
| - | |
| 130 | + | |
130 | 131 |
| |
131 | 132 |
| |
132 | 133 |
| |
|
Lines changed: 11 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
59 | 59 |
| |
60 | 60 |
| |
61 | 61 |
| |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
62 | 67 |
| |
63 |
| - | |
| 68 | + | |
64 | 69 |
| |
65 | 70 |
| |
| 71 | + | |
66 | 72 |
| |
67 |
| - | |
68 |
| - | |
| 73 | + | |
| 74 | + | |
69 | 75 |
| |
70 | 76 |
| |
71 | 77 |
| |
72 |
| - | |
| 78 | + | |
| 79 | + |
Lines changed: 6 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7 | 7 |
| |
8 | 8 |
| |
9 | 9 |
| |
| 10 | + | |
10 | 11 |
| |
11 | 12 |
| |
12 | 13 |
| |
13 | 14 |
| |
14 |
| - | |
15 |
| - | |
16 |
| - | |
17 |
| - | |
18 |
| - | |
19 |
| - | |
20 |
| - | |
21 |
| - | |
22 |
| - | |
23 | 15 |
| |
24 | 16 |
| |
25 | 17 |
| |
| |||
40 | 32 |
| |
41 | 33 |
| |
42 | 34 |
| |
| 35 | + | |
| 36 | + | |
| 37 | + | |
43 | 38 |
| |
44 | 39 |
| |
45 | 40 |
| |
| |||
75 | 70 |
| |
76 | 71 |
| |
77 | 72 |
| |
| 73 | + | |
| 74 | + | |
78 | 75 |
| |
79 | 76 |
| |
80 | 77 |
| |
|
Lines changed: 53 additions & 36 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
6 | 6 |
| |
7 | 7 |
| |
8 | 8 |
| |
9 |
| - | |
10 |
| - | |
11 |
| - | |
12 |
| - | |
13 | 9 |
| |
14 |
| - | |
15 |
| - | |
| 10 | + | |
16 | 11 |
| |
17 | 12 |
| |
18 | 13 |
| |
| |||
30 | 25 |
| |
31 | 26 |
| |
32 | 27 |
| |
33 |
| - | |
34 |
| - | |
35 |
| - | |
36 |
| - | |
37 | 28 |
| |
38 | 29 |
| |
| 30 | + | |
| 31 | + | |
39 | 32 |
| |
40 | 33 |
| |
41 | 34 |
| |
42 | 35 |
| |
43 | 36 |
| |
44 | 37 |
| |
| 38 | + | |
| 39 | + | |
| 40 | + | |
45 | 41 |
| |
46 | 42 |
| |
47 | 43 |
| |
| |||
55 | 51 |
| |
56 | 52 |
| |
57 | 53 |
| |
58 |
| - | |
59 |
| - | |
60 |
| - | |
61 |
| - | |
62 |
| - | |
63 |
| - | |
64 |
| - | |
65 |
| - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
66 | 62 |
| |
67 | 63 |
| |
68 | 64 |
| |
| |||
74 | 70 |
| |
75 | 71 |
| |
76 | 72 |
| |
| 73 | + | |
77 | 74 |
| |
78 | 75 |
| |
| 76 | + | |
| 77 | + | |
79 | 78 |
| |
80 | 79 |
| |
81 | 80 |
| |
| |||
99 | 98 |
| |
100 | 99 |
| |
101 | 100 |
| |
102 |
| - | |
| 101 | + | |
103 | 102 |
| |
104 | 103 |
| |
| 104 | + | |
105 | 105 |
| |
106 |
| - | |
107 |
| - | |
108 |
| - | |
109 |
| - | |
110 |
| - | |
| 106 | + | |
| 107 | + | |
111 | 108 |
| |
112 |
| - | |
113 |
| - | |
114 |
| - | |
115 |
| - | |
116 |
| - | |
117 |
| - | |
118 |
| - | |
119 |
| - | |
| 109 | + | |
120 | 110 |
| |
121 |
| - | |
| 111 | + | |
| 112 | + | |
122 | 113 |
| |
123 | 114 |
| |
124 | 115 |
| |
125 | 116 |
| |
126 | 117 |
| |
127 | 118 |
| |
128 | 119 |
| |
129 |
| - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
130 | 147 |
| |
131 |
| - | |
132 |
| - | |
| 148 | + | |
| 149 | + | |
133 | 150 |
|
0 commit comments
Comments
(0)