forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit2973d7d
committed
Fix PageAddItem BRIN bug
BRIN was relying on the ability to remove a tuple from an index page,then putting another tuple in the same line pointer. But PageAddItemrefuses to add a tuple beyond the first free item past the last useditem, and in particular, it rejects an attempt to add an item to anempty page anywhere other than the first line pointer. PageAddItemissues a WARNING and indicates to the caller that it failed, which inturn causes the BRIN calling code to issue a PANIC, so the wholesequence looks like this:WARNING: specified item offset is too largePANIC: failed to add BRIN tupleTo fix, create a new function PageAddItemExtended which is likePageAddItem except that the two boolean arguments become a flags bitmap;the "overwrite" and "is_heap" boolean flags in PageAddItem becomePAI_OVERWITE and PAI_IS_HEAP flags in the new function, and a new flagPAI_ALLOW_FAR_OFFSET enables the behavior required by BRIN.PageAddItem() retains its original signature, for compatibility withthird-party modules (other callers in core code are not modified,either).Also, in the belt-and-suspenders spirit, I added a new sanity check inbrinGetTupleForHeapBlock to raise an error if an TID found in the revmapis not marked as live by the page header. This causes it to react with"ERROR: corrupted BRIN index" to the bug at hand, rather than a hardcrash.Backpatch to 9.5.Bug reported by Andreas Seltenreich as detected by his handy sqlsmithfuzzer.Discussion:https://www.postgresql.org/message-id/87mvni77jh.fsf@elite.ansel.ydns.eu1 parent73f5acc commit2973d7d
File tree
5 files changed
+60
-18
lines changed- src
- backend
- access/brin
- storage/page
- include/storage
5 files changed
+60
-18
lines changedLines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
179 | 179 |
| |
180 | 180 |
| |
181 | 181 |
| |
182 |
| - | |
183 |
| - | |
| 182 | + | |
| 183 | + | |
184 | 184 |
| |
185 | 185 |
| |
186 | 186 |
| |
|
Lines changed: 4 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
266 | 266 |
| |
267 | 267 |
| |
268 | 268 |
| |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
269 | 273 |
| |
270 | 274 |
| |
271 | 275 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
193 | 193 |
| |
194 | 194 |
| |
195 | 195 |
| |
196 |
| - | |
| 196 | + | |
| 197 | + | |
197 | 198 |
| |
198 | 199 |
| |
199 | 200 |
| |
|
Lines changed: 47 additions & 15 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
153 | 153 |
| |
154 | 154 |
| |
155 | 155 |
| |
156 |
| - | |
| 156 | + | |
157 | 157 |
| |
158 |
| - | |
159 |
| - | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
160 | 161 |
| |
161 |
| - | |
| 162 | + | |
162 | 163 |
| |
163 | 164 |
| |
164 | 165 |
| |
| |||
167 | 168 |
| |
168 | 169 |
| |
169 | 170 |
| |
170 |
| - | |
| 171 | + | |
171 | 172 |
| |
172 | 173 |
| |
| 174 | + | |
| 175 | + | |
| 176 | + | |
173 | 177 |
| |
174 | 178 |
| |
175 | 179 |
| |
176 |
| - | |
177 |
| - | |
178 |
| - | |
179 |
| - | |
180 |
| - | |
181 |
| - | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
182 | 185 |
| |
183 | 186 |
| |
184 | 187 |
| |
| |||
209 | 212 |
| |
210 | 213 |
| |
211 | 214 |
| |
212 |
| - | |
| 215 | + | |
213 | 216 |
| |
214 | 217 |
| |
215 | 218 |
| |
| |||
257 | 260 |
| |
258 | 261 |
| |
259 | 262 |
| |
260 |
| - | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
261 | 268 |
| |
262 | 269 |
| |
263 | 270 |
| |
264 | 271 |
| |
265 | 272 |
| |
266 |
| - | |
| 273 | + | |
| 274 | + | |
267 | 275 |
| |
268 | 276 |
| |
269 | 277 |
| |
| |||
275 | 283 |
| |
276 | 284 |
| |
277 | 285 |
| |
278 |
| - | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
279 | 290 |
| |
280 | 291 |
| |
281 | 292 |
| |
| |||
323 | 334 |
| |
324 | 335 |
| |
325 | 336 |
| |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
326 | 358 |
| |
327 | 359 |
| |
328 | 360 |
| |
|
Lines changed: 5 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
390 | 390 |
| |
391 | 391 |
| |
392 | 392 |
| |
| 393 | + | |
| 394 | + | |
| 395 | + | |
393 | 396 |
| |
394 | 397 |
| |
395 | 398 |
| |
396 | 399 |
| |
397 | 400 |
| |
| 401 | + | |
| 402 | + | |
398 | 403 |
| |
399 | 404 |
| |
400 | 405 |
| |
|
0 commit comments
Comments
(0)