forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit7b63528
committed
Fix array slicing of int2vector and oidvector values.
The previous coding labeled expressions such as pg_index.indkey[1:3] asbeing of int2vector type; which is not right because the subscript boundsof such a result don't, in general, satisfy the restrictions of int2vector.To fix, implicitly promote the result of slicing int2vector to int2[],or oidvector to oid[]. This is similar to what we've done with domainsover arrays, which is a good analogy because these types are very muchlike restricted domains of the corresponding regular-array types.A side-effect is that we now also forbid array-element updates on suchcolumns, eg while "update pg_index set indkey[4] = 42" would have workedbefore if you were superuser (and corrupted your catalogs irretrievably,no doubt) it's now disallowed. This seems like a good thing since, again,some choices of subscripting would've led to results not satisfying therestrictions of int2vector. The case of an array-slice update wasrejected before, though with a different error message than you get now.We could make these cases work in future if we added a cast from int2[]to int2vector (with a cast function checking the subscript restrictions)but it seems unlikely that there's any value in that.Per report from Ronan Dunklau. Back-patch to all supported branchesbecause of the crash risks involved.1 parentb2502ec commit7b63528
File tree
3 files changed
+20
-3
lines changed- src
- backend/parser
- include/catalog
3 files changed
+20
-3
lines changedLines changed: 13 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
225 | 225 |
| |
226 | 226 |
| |
227 | 227 |
| |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
228 | 240 |
| |
229 | 241 |
| |
230 | 242 |
| |
| |||
262 | 274 |
| |
263 | 275 |
| |
264 | 276 |
| |
| 277 | + | |
265 | 278 |
| |
266 | 279 |
| |
267 | 280 |
| |
|
Lines changed: 5 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
817 | 817 |
| |
818 | 818 |
| |
819 | 819 |
| |
| 820 | + | |
| 821 | + | |
820 | 822 |
| |
821 |
| - | |
| 823 | + | |
822 | 824 |
| |
823 | 825 |
| |
824 | 826 |
| |
825 | 827 |
| |
826 |
| - | |
| 828 | + | |
827 | 829 |
| |
828 | 830 |
| |
829 | 831 |
| |
830 | 832 |
| |
831 |
| - | |
| 833 | + | |
832 | 834 |
| |
833 | 835 |
| |
834 | 836 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
436 | 436 |
| |
437 | 437 |
| |
438 | 438 |
| |
| 439 | + | |
439 | 440 |
| |
440 | 441 |
| |
441 | 442 |
| |
442 | 443 |
| |
443 | 444 |
| |
444 | 445 |
| |
445 | 446 |
| |
| 447 | + | |
446 | 448 |
| |
447 | 449 |
| |
448 | 450 |
| |
|
0 commit comments
Comments
(0)