forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit00b4146
committed
Require empty Bitmapsets to be represented as NULL.
When I designed the Bitmapset module, I set things up so that an emptyBitmapset could be represented either by a NULL pointer, or by anallocated object all of whose bits are zero. I've recently come tothe conclusion that that was a bad idea and we should instead have aconvention like the longstanding invariant for Lists, whereby an emptylist is represented by NIL and nothing else.To do this, we need to fix bms_intersect, bms_difference, and a coupleof other functions to check for having produced an empty result; butthen we can replace bms_is_empty(a) by a simple "a == NULL" test.This is very likely a (marginal) win performance-wise, because wecall bms_is_empty many more times than those other functions puttogether. However, the real reason to do it is that we have variousplaces that have hand-implemented a rule about "this Bitmapsetvariable must be exactly NULL if empty", so that they can usechecks-for-null in place of bms_is_empty calls in particularly hotcode paths. That is a really fragile, mistake-prone way to do things,and I'm surprised that we've seldom been bitten by it. It's not welldocumented at all which variables have this property, so you can'treadily tell which code might be violating those conventions. Bymaking the convention universal, we can eliminate a subtle source ofbugs.Patch by me; thanks to Nathan Bossart and Richard Guo for review.Discussion:https://postgr.es/m/1159933.1677621588@sss.pgh.pa.us1 parent141225b commit00b4146
2 files changed
+57
-23
lines changedLines changed: 52 additions & 18 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
5 | 5 |
| |
6 | 6 |
| |
7 | 7 |
| |
8 |
| - | |
9 |
| - | |
10 |
| - | |
11 |
| - | |
| 8 | + | |
| 9 | + | |
12 | 10 |
| |
13 | 11 |
| |
14 | 12 |
| |
| |||
66 | 64 |
| |
67 | 65 |
| |
68 | 66 |
| |
| 67 | + | |
| 68 | + | |
69 | 69 |
| |
70 | 70 |
| |
71 | 71 |
| |
| |||
104 | 104 |
| |
105 | 105 |
| |
106 | 106 |
| |
107 |
| - | |
| 107 | + | |
108 | 108 |
| |
109 | 109 |
| |
110 |
| - | |
| 110 | + | |
111 | 111 |
| |
112 | 112 |
| |
113 | 113 |
| |
| |||
151 | 151 |
| |
152 | 152 |
| |
153 | 153 |
| |
154 |
| - | |
| 154 | + | |
155 | 155 |
| |
156 |
| - | |
| 156 | + | |
157 | 157 |
| |
158 | 158 |
| |
159 | 159 |
| |
| |||
282 | 282 |
| |
283 | 283 |
| |
284 | 284 |
| |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
285 | 291 |
| |
286 | 292 |
| |
287 | 293 |
| |
| |||
300 | 306 |
| |
301 | 307 |
| |
302 | 308 |
| |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
303 | 318 |
| |
304 | 319 |
| |
305 | 320 |
| |
306 | 321 |
| |
307 | 322 |
| |
308 | 323 |
| |
| 324 | + | |
309 | 325 |
| |
310 | 326 |
| |
311 | 327 |
| |
| |||
323 | 339 |
| |
324 | 340 |
| |
325 | 341 |
| |
326 |
| - | |
| 342 | + | |
327 | 343 |
| |
328 | 344 |
| |
329 | 345 |
| |
| |||
362 | 378 |
| |
363 | 379 |
| |
364 | 380 |
| |
365 |
| - | |
| 381 | + | |
366 | 382 |
| |
367 | 383 |
| |
368 |
| - | |
| 384 | + | |
369 | 385 |
| |
370 | 386 |
| |
371 | 387 |
| |
| |||
554 | 570 |
| |
555 | 571 |
| |
556 | 572 |
| |
557 |
| - | |
| 573 | + | |
558 | 574 |
| |
559 | 575 |
| |
560 | 576 |
| |
| |||
696 | 712 |
| |
697 | 713 |
| |
698 | 714 |
| |
699 |
| - | |
| 715 | + | |
700 | 716 |
| |
701 |
| - | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
702 | 720 |
| |
703 |
| - | |
704 |
| - | |
| 721 | + | |
| 722 | + | |
705 | 723 |
| |
706 | 724 |
| |
707 | 725 |
| |
708 | 726 |
| |
709 |
| - | |
710 |
| - | |
711 | 727 |
| |
712 | 728 |
| |
713 | 729 |
| |
| |||
786 | 802 |
| |
787 | 803 |
| |
788 | 804 |
| |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
789 | 811 |
| |
790 | 812 |
| |
791 | 813 |
| |
| |||
922 | 944 |
| |
923 | 945 |
| |
924 | 946 |
| |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
925 | 953 |
| |
926 | 954 |
| |
927 | 955 |
| |
| |||
943 | 971 |
| |
944 | 972 |
| |
945 | 973 |
| |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
946 | 980 |
| |
947 | 981 |
| |
948 | 982 |
| |
|
Lines changed: 5 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
5 | 5 |
| |
6 | 6 |
| |
7 | 7 |
| |
8 |
| - | |
9 |
| - | |
10 |
| - | |
11 |
| - | |
| 8 | + | |
| 9 | + | |
12 | 10 |
| |
13 | 11 |
| |
14 | 12 |
| |
| |||
102 | 100 |
| |
103 | 101 |
| |
104 | 102 |
| |
105 |
| - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
106 | 106 |
| |
107 | 107 |
| |
108 | 108 |
| |
|
0 commit comments
Comments
(0)