forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit8149e9f
committed
Properly detoast data in brin_form_tuple
brin_form_tuple failed to consider the values may be toasted, insertingthe toast pointer into the index. This may easily result in indexcorruption, as the toast data may be deleted and cleaned up by vacuum.The cleanup however does not care about indexes, leaving invalid toastpointers behind, which triggers errors like this: ERROR: missing chunk number 0 for toast value 16433 in pg_toast_16426A less severe consequence are inconsistent failures due to the index rowbeing too large, depending on whether brin_form_tuple operated on plainor toasted version of the row. For example CREATE TABLE t (val TEXT); INSERT INTO t VALUES ('... long value ...') CREATE INDEX idx ON t USING brin (val);would likely succeed, as the row would likely include toast pointer.Switching the order of INSERT and CREATE INDEX would likely fail: ERROR: index row size 8712 exceeds maximum 8152 for index "idx"because this happens before the row values are toasted.The bug exists since PostgreSQL 9.5 where BRIN indexes were introduced.So backpatch all the way back.Author: Tomas VondraReviewed-by: Alvaro HerreraBackpatch-through: 9.5Discussion:https://postgr.es/m/20201001184133.oq5uq75sb45pu3aw@developmentDiscussion:https://postgr.es/m/20201104010544.zexj52mlldagzowv%40development1 parentf078110 commit8149e9f
File tree
3 files changed
+170
-1
lines changed- src
- backend/access/brin
- test/regress
- expected
- sql
3 files changed
+170
-1
lines changedLines changed: 90 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
35 | 35 |
| |
36 | 36 |
| |
37 | 37 |
| |
| 38 | + | |
38 | 39 |
| |
39 | 40 |
| |
40 | 41 |
| |
| |||
100 | 101 |
| |
101 | 102 |
| |
102 | 103 |
| |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
103 | 110 |
| |
104 | 111 |
| |
105 | 112 |
| |
| |||
108 | 115 |
| |
109 | 116 |
| |
110 | 117 |
| |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
111 | 122 |
| |
112 | 123 |
| |
113 | 124 |
| |
| |||
139 | 150 |
| |
140 | 151 |
| |
141 | 152 |
| |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
142 | 159 |
| |
143 | 160 |
| |
144 | 161 |
| |
145 |
| - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
146 | 230 |
| |
147 | 231 |
| |
148 | 232 |
| |
| |||
194 | 278 |
| |
195 | 279 |
| |
196 | 280 |
| |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
197 | 286 |
| |
198 | 287 |
| |
199 | 288 |
| |
|
Lines changed: 41 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
507 | 507 |
| |
508 | 508 |
| |
509 | 509 |
| |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + |
Lines changed: 39 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
460 | 460 |
| |
461 | 461 |
| |
462 | 462 |
| |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + |
0 commit comments
Comments
(0)