forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit364ddc3
committed
Clean up jsonb code.
The main target of this cleanup is the convertJsonb() function, but I alsotouched a lot of other things that I spotted into in the process.The new convertToJsonb() function uses an output buffer that's resized ondemand, so the code to estimate of the size of JsonbValue is removed.The on-disk format was not changed, even though I refactored the structsused to handle it. The term "superheader" is replaced with "container".The jsonb_exists_any and jsonb_exists_all functions no longer sort the inputarray. That was a premature optimization, the idea being that if there areduplicates in the input array, you only need to check them once. Also,sorting the array saves some effort in the binary search used to find a keywithin an object. But there were drawbacks too: the sorting anddeduplicating obviously isn't free, and in the typical case there are noduplicates to remove, and the gain in the binary search was minimal. Removeall that, which makes the code simpler too.This includes a bug-fix; the total length of the elements in a jsonb arrayor object mustn't exceed 2^28. That is now checked.1 parent4d155d8 commit364ddc3
File tree
6 files changed
+556
-776
lines changed- src
- backend/utils/adt
- include/utils
6 files changed
+556
-776
lines changedLines changed: 5 additions & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
33 | 33 |
| |
34 | 34 |
| |
35 | 35 |
| |
36 |
| - | |
37 | 36 |
| |
38 | 37 |
| |
39 | 38 |
| |
| |||
65 | 64 |
| |
66 | 65 |
| |
67 | 66 |
| |
68 |
| - | |
| 67 | + | |
69 | 68 |
| |
70 | 69 |
| |
71 | 70 |
| |
| |||
79 | 78 |
| |
80 | 79 |
| |
81 | 80 |
| |
82 |
| - | |
| 81 | + | |
83 | 82 |
| |
84 | 83 |
| |
85 | 84 |
| |
| |||
97 | 96 |
| |
98 | 97 |
| |
99 | 98 |
| |
100 |
| - | |
| 99 | + | |
101 | 100 |
| |
102 | 101 |
| |
103 | 102 |
| |
| |||
130 | 129 |
| |
131 | 130 |
| |
132 | 131 |
| |
133 |
| - | |
| 132 | + | |
134 | 133 |
| |
135 | 134 |
| |
136 | 135 |
| |
| |||
249 | 248 |
| |
250 | 249 |
| |
251 | 250 |
| |
252 |
| - | |
253 | 251 |
| |
254 | 252 |
| |
255 | 253 |
| |
| |||
290 | 288 |
| |
291 | 289 |
| |
292 | 290 |
| |
293 |
| - | |
294 |
| - | |
295 | 291 |
| |
296 | 292 |
| |
297 | 293 |
| |
| |||
300 | 296 |
| |
301 | 297 |
| |
302 | 298 |
| |
303 |
| - | |
304 | 299 |
| |
305 | 300 |
| |
306 | 301 |
| |
| |||
312 | 307 |
| |
313 | 308 |
| |
314 | 309 |
| |
315 |
| - | |
316 | 310 |
| |
317 | 311 |
| |
318 | 312 |
| |
| |||
374 | 368 |
| |
375 | 369 |
| |
376 | 370 |
| |
377 |
| - | |
| 371 | + | |
378 | 372 |
| |
379 | 373 |
| |
380 | 374 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
80 | 80 |
| |
81 | 81 |
| |
82 | 82 |
| |
83 |
| - | |
| 83 | + | |
84 | 84 |
| |
85 | 85 |
| |
86 | 86 |
| |
| |||
487 | 487 |
| |
488 | 488 |
| |
489 | 489 |
| |
490 |
| - | |
| 490 | + | |
491 | 491 |
| |
492 | 492 |
| |
493 | 493 |
| |
|
Lines changed: 52 additions & 54 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
13 | 13 |
| |
14 | 14 |
| |
15 | 15 |
| |
| 16 | + | |
16 | 17 |
| |
17 | 18 |
| |
18 | 19 |
| |
| |||
34 | 35 |
| |
35 | 36 |
| |
36 | 37 |
| |
37 |
| - | |
38 |
| - | |
39 |
| - | |
40 |
| - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
41 | 41 |
| |
42 | 42 |
| |
43 | 43 |
| |
| |||
47 | 47 |
| |
48 | 48 |
| |
49 | 49 |
| |
50 |
| - | |
51 |
| - | |
52 |
| - | |
53 | 50 |
| |
| 51 | + | |
| 52 | + | |
| 53 | + | |
54 | 54 |
| |
55 |
| - | |
56 |
| - | |
57 |
| - | |
58 |
| - | |
59 |
| - | |
| 55 | + | |
| 56 | + | |
60 | 57 |
| |
61 |
| - | |
62 |
| - | |
63 |
| - | |
64 |
| - | |
65 |
| - | |
66 |
| - | |
67 |
| - | |
| 58 | + | |
68 | 59 |
| |
69 |
| - | |
70 |
| - | |
71 |
| - | |
72 |
| - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
73 | 72 |
| |
74 | 73 |
| |
75 | 74 |
| |
| |||
81 | 80 |
| |
82 | 81 |
| |
83 | 82 |
| |
84 |
| - | |
85 |
| - | |
86 |
| - | |
87 | 83 |
| |
| 84 | + | |
| 85 | + | |
| 86 | + | |
88 | 87 |
| |
89 |
| - | |
90 |
| - | |
| 88 | + | |
| 89 | + | |
91 | 90 |
| |
92 |
| - | |
93 |
| - | |
94 |
| - | |
95 |
| - | |
96 |
| - | |
97 |
| - | |
98 |
| - | |
99 |
| - | |
100 |
| - | |
101 |
| - | |
| 91 | + | |
102 | 92 |
| |
103 |
| - | |
104 |
| - | |
105 |
| - | |
106 |
| - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
107 | 105 |
| |
108 | 106 |
| |
109 | 107 |
| |
| |||
123 | 121 |
| |
124 | 122 |
| |
125 | 123 |
| |
126 |
| - | |
127 |
| - | |
| 124 | + | |
| 125 | + | |
128 | 126 |
| |
129 | 127 |
| |
130 | 128 |
| |
| |||
143 | 141 |
| |
144 | 142 |
| |
145 | 143 |
| |
146 |
| - | |
147 |
| - | |
| 144 | + | |
| 145 | + | |
148 | 146 |
| |
149 | 147 |
| |
150 | 148 |
| |
| |||
156 | 154 |
| |
157 | 155 |
| |
158 | 156 |
| |
159 |
| - | |
| 157 | + | |
160 | 158 |
| |
161 | 159 |
| |
162 | 160 |
| |
| |||
173 | 171 |
| |
174 | 172 |
| |
175 | 173 |
| |
176 |
| - | |
| 174 | + | |
177 | 175 |
| |
178 | 176 |
| |
179 | 177 |
| |
| |||
187 | 185 |
| |
188 | 186 |
| |
189 | 187 |
| |
190 |
| - | |
| 188 | + | |
191 | 189 |
| |
192 | 190 |
| |
193 | 191 |
| |
| |||
201 | 199 |
| |
202 | 200 |
| |
203 | 201 |
| |
204 |
| - | |
| 202 | + | |
205 | 203 |
| |
206 | 204 |
| |
207 | 205 |
| |
| |||
215 | 213 |
| |
216 | 214 |
| |
217 | 215 |
| |
218 |
| - | |
| 216 | + | |
219 | 217 |
| |
220 | 218 |
| |
221 | 219 |
| |
| |||
229 | 227 |
| |
230 | 228 |
| |
231 | 229 |
| |
232 |
| - | |
| 230 | + | |
233 | 231 |
| |
234 | 232 |
| |
235 | 233 |
| |
| |||
243 | 241 |
| |
244 | 242 |
| |
245 | 243 |
| |
246 |
| - | |
| 244 | + | |
247 | 245 |
| |
248 | 246 |
| |
249 | 247 |
| |
| |||
265 | 263 |
| |
266 | 264 |
| |
267 | 265 |
| |
268 |
| - | |
| 266 | + | |
269 | 267 |
| |
270 | 268 |
| |
271 | 269 |
| |
|
0 commit comments
Comments
(0)