forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit6b7819a
committed
Fix overflow check and comment in GIN posting list encoding.
The comment did not match what the code actually did for integers withthe 43rd bit set. You get an integer like that, if you have a postinglist with two adjacent TIDs that are more than 2^31 blocks apart.According to the comment, we would store that in 6 bytes, with nocontinuation bit on the 6th byte, but in reality, the code encodes itusing 7 bytes, with a continuation bit on the 6th byte as normal.The decoding routine also handled these 7-byte integers correctly, exceptfor an overflow check that assumed that one integer needs at most 6 bytes.Fix the overflow check, and fix the comment to match what the codeactually does. Also fix the comment that claimed that there are 17 unusedbits in the 64-bit representation of an item pointer. In reality, thereare 64-32-11=21.Fitting any item pointer into max 6 bytes was an important property whenthis was written, because in the old pre-9.4 format, item pointers werestored as plain arrays, with 6 bytes for every item pointer. The maximumof 6 bytes per integer in the new format guaranteed that we could convertany page from the old format to the new format after upgrade, so that thenew format was never larger than the old format. But we hardly need toworry about that anymore, and running into that problem during upgrade,where an item pointer is expanded from 6 to 7 bytes such that the datadoesn't fit on a page anymore, is implausible in practice anyway.Backpatch to all supported versions.This also includes a little test module to test these large distancesbetween item pointers, without requiring a 16 TB table. It is notbackpatched, I'm including it more for the benefit of future developmentof new posting list formats.Discussion:https://www.postgresql.org/message-id/33bfc20a-5c86-f50c-f5a5-58e9925d05ff%40iki.fiReviewed-by: Masahiko Sawada, Alexander Korotkov1 parent8cc6016 commit6b7819a
1 file changed
+26
-9
lines changedLines changed: 26 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
23 | 23 |
| |
24 | 24 |
| |
25 | 25 |
| |
26 |
| - | |
| 26 | + | |
27 | 27 |
| |
28 | 28 |
| |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
29 | 35 |
| |
30 | 36 |
| |
31 | 37 |
| |
32 |
| - | |
33 |
| - | |
34 |
| - | |
| 38 | + | |
| 39 | + | |
35 | 40 |
| |
36 | 41 |
| |
37 | 42 |
| |
38 | 43 |
| |
39 | 44 |
| |
40 | 45 |
| |
41 |
| - | |
| 46 | + | |
| 47 | + | |
42 | 48 |
| |
43 | 49 |
| |
44 | 50 |
| |
| 51 | + | |
45 | 52 |
| |
46 | 53 |
| |
47 | 54 |
| |
| |||
73 | 80 |
| |
74 | 81 |
| |
75 | 82 |
| |
| 83 | + | |
| 84 | + | |
| 85 | + | |
76 | 86 |
| |
77 | 87 |
| |
78 | 88 |
| |
| |||
126 | 136 |
| |
127 | 137 |
| |
128 | 138 |
| |
| 139 | + | |
129 | 140 |
| |
130 | 141 |
| |
131 | 142 |
| |
132 | 143 |
| |
| 144 | + | |
133 | 145 |
| |
134 | 146 |
| |
135 | 147 |
| |
136 | 148 |
| |
| 149 | + | |
137 | 150 |
| |
138 | 151 |
| |
139 | 152 |
| |
140 | 153 |
| |
| 154 | + | |
141 | 155 |
| |
142 | 156 |
| |
143 | 157 |
| |
144 | 158 |
| |
| 159 | + | |
145 | 160 |
| |
146 | 161 |
| |
147 | 162 |
| |
148 | 163 |
| |
| 164 | + | |
149 | 165 |
| |
150 | 166 |
| |
151 | 167 |
| |
152 | 168 |
| |
153 |
| - | |
| 169 | + | |
154 | 170 |
| |
155 | 171 |
| |
| 172 | + | |
156 | 173 |
| |
157 | 174 |
| |
158 | 175 |
| |
| |||
208 | 225 |
| |
209 | 226 |
| |
210 | 227 |
| |
211 |
| - | |
| 228 | + | |
212 | 229 |
| |
213 | 230 |
| |
214 | 231 |
| |
215 | 232 |
| |
216 |
| - | |
| 233 | + | |
217 | 234 |
| |
218 | 235 |
| |
219 |
| - | |
| 236 | + | |
220 | 237 |
| |
221 | 238 |
| |
222 | 239 |
| |
|
0 commit comments
Comments
(0)