forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit041e8b9
committed
Get rid of our dependency on type "long" for memory size calculations.
Consistently use "Size" (or size_t, or in some places int64 or double)as the type for variables holding memory allocation sizes. In mostplaces variables' data types were fine already, but we had an ancienthabit of computing bytes from kilobytes-units GUCs with code like"work_mem * 1024L". That risks overflow on Win64 where they did notmake "long" as wide as "size_t". We worked around that by restrictingsuch GUCs' ranges, so you couldn't set work_mem et al higher than 2GBon Win64. This patch removes that restriction, after replacing suchcalculations with "work_mem * (Size) 1024" or variants of that.It should be noted that this patch was constructed by searchingoutwards from the GUCs that have MAX_KILOBYTES as upper limit.So I can't positively guarantee there are no other places doingmemory-size arithmetic in int or long variables. I do however feelpretty confident that increasing MAX_KILOBYTES on Win64 is safe now.Also, nothing in our code should be dealing in multiple-gigabyteallocations without authorization from a relevant GUC, so it seemspretty likely that this search caught everything that could be atrisk of overflow.Author: Vladlen Popolitov <v.popolitov@postgrespro.ru>Co-authored-by: Tom Lane <tgl@sss.pgh.pa.us>Discussion:https://postgr.es/m/1a01f0-66ec2d80-3b-68487680@275952171 parentf8d8581 commit041e8b9
File tree
20 files changed
+50
-46
lines changed- src
- backend
- access
- gin
- hash
- heap
- nbtree
- commands
- executor
- nodes
- optimizer
- path
- plan
- replication/logical
- utils/sort
- include
- executor
- nodes
- utils
- test/modules/test_bloomfilter
20 files changed
+50
-46
lines changedLines changed: 4 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
39 | 39 |
| |
40 | 40 |
| |
41 | 41 |
| |
42 |
| - | |
| 42 | + | |
43 | 43 |
| |
44 | 44 |
| |
45 | 45 |
| |
| |||
456 | 456 |
| |
457 | 457 |
| |
458 | 458 |
| |
459 |
| - | |
| 459 | + | |
460 | 460 |
| |
461 | 461 |
| |
462 | 462 |
| |
| |||
795 | 795 |
| |
796 | 796 |
| |
797 | 797 |
| |
798 |
| - | |
| 798 | + | |
799 | 799 |
| |
800 | 800 |
| |
801 | 801 |
| |
| |||
901 | 901 |
| |
902 | 902 |
| |
903 | 903 |
| |
904 |
| - | |
| 904 | + | |
905 | 905 |
| |
906 | 906 |
| |
907 | 907 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
125 | 125 |
| |
126 | 126 |
| |
127 | 127 |
| |
128 |
| - | |
| 128 | + | |
129 | 129 |
| |
130 | 130 |
| |
131 | 131 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
288 | 288 |
| |
289 | 289 |
| |
290 | 290 |
| |
291 |
| - | |
| 291 | + | |
292 | 292 |
| |
293 | 293 |
| |
294 | 294 |
| |
|
Lines changed: 3 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
120 | 120 |
| |
121 | 121 |
| |
122 | 122 |
| |
123 |
| - | |
| 123 | + | |
124 | 124 |
| |
125 | 125 |
| |
126 | 126 |
| |
| |||
155 | 155 |
| |
156 | 156 |
| |
157 | 157 |
| |
158 |
| - | |
| 158 | + | |
159 | 159 |
| |
160 | 160 |
| |
161 | 161 |
| |
162 | 162 |
| |
163 | 163 |
| |
164 |
| - | |
| 164 | + | |
165 | 165 |
| |
166 | 166 |
| |
167 | 167 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2070 | 2070 |
| |
2071 | 2071 |
| |
2072 | 2072 |
| |
2073 |
| - | |
| 2073 | + | |
2074 | 2074 |
| |
2075 | 2075 |
| |
2076 | 2076 |
| |
| |||
3037 | 3037 |
| |
3038 | 3038 |
| |
3039 | 3039 |
| |
3040 |
| - | |
| 3040 | + | |
3041 | 3041 |
| |
3042 | 3042 |
| |
3043 | 3043 |
| |
|
Lines changed: 5 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2953 | 2953 |
| |
2954 | 2954 |
| |
2955 | 2955 |
| |
2956 |
| - | |
| 2956 | + | |
2957 | 2957 |
| |
2958 | 2958 |
| |
2959 | 2959 |
| |
| |||
2969 | 2969 |
| |
2970 | 2970 |
| |
2971 | 2971 |
| |
2972 |
| - | |
2973 |
| - | |
| 2972 | + | |
2974 | 2973 |
| |
| 2974 | + | |
| 2975 | + | |
2975 | 2976 |
| |
2976 | 2977 |
| |
2977 |
| - | |
| 2978 | + | |
2978 | 2979 |
| |
2979 | 2980 |
| |
2980 | 2981 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
375 | 375 |
| |
376 | 376 |
| |
377 | 377 |
| |
378 |
| - | |
| 378 | + | |
379 | 379 |
| |
380 | 380 |
| |
381 | 381 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
326 | 326 |
| |
327 | 327 |
| |
328 | 328 |
| |
329 |
| - | |
| 329 | + | |
330 | 330 |
| |
331 | 331 |
| |
332 | 332 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
91 | 91 |
| |
92 | 92 |
| |
93 | 93 |
| |
94 |
| - | |
| 94 | + | |
95 | 95 |
| |
96 | 96 |
| |
97 | 97 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
143 | 143 |
| |
144 | 144 |
| |
145 | 145 |
| |
146 |
| - | |
| 146 | + | |
147 | 147 |
| |
148 | 148 |
| |
149 | 149 |
| |
|
Lines changed: 6 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
263 | 263 |
| |
264 | 264 |
| |
265 | 265 |
| |
266 |
| - | |
| 266 | + | |
267 | 267 |
| |
268 | 268 |
| |
269 | 269 |
| |
| |||
273 | 273 |
| |
274 | 274 |
| |
275 | 275 |
| |
276 |
| - | |
| 276 | + | |
277 | 277 |
| |
278 | 278 |
| |
279 | 279 |
| |
| |||
1539 | 1539 |
| |
1540 | 1540 |
| |
1541 | 1541 |
| |
1542 |
| - | |
1543 |
| - | |
| 1542 | + | |
| 1543 | + | |
1544 | 1544 |
| |
1545 |
| - | |
| 1545 | + | |
1546 | 1546 |
| |
1547 | 1547 |
| |
1548 | 1548 |
| |
| |||
1555 | 1555 |
| |
1556 | 1556 |
| |
1557 | 1557 |
| |
1558 |
| - | |
| 1558 | + | |
1559 | 1559 |
| |
1560 | 1560 |
| |
1561 | 1561 |
| |
|
Lines changed: 7 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1903 | 1903 |
| |
1904 | 1904 |
| |
1905 | 1905 |
| |
1906 |
| - | |
| 1906 | + | |
1907 | 1907 |
| |
1908 | 1908 |
| |
1909 | 1909 |
| |
| |||
2488 | 2488 |
| |
2489 | 2489 |
| |
2490 | 2490 |
| |
2491 |
| - | |
| 2491 | + | |
2492 | 2492 |
| |
2493 | 2493 |
| |
2494 | 2494 |
| |
| |||
4028 | 4028 |
| |
4029 | 4029 |
| |
4030 | 4030 |
| |
4031 |
| - | |
| 4031 | + | |
4032 | 4032 |
| |
4033 | 4033 |
| |
4034 | 4034 |
| |
| |||
4663 | 4663 |
| |
4664 | 4664 |
| |
4665 | 4665 |
| |
4666 |
| - | |
| 4666 | + | |
4667 | 4667 |
| |
4668 | 4668 |
| |
4669 | 4669 |
| |
| |||
4690 | 4690 |
| |
4691 | 4691 |
| |
4692 | 4692 |
| |
4693 |
| - | |
| 4693 | + | |
4694 | 4694 |
| |
4695 | 4695 |
| |
4696 | 4696 |
| |
| |||
6496 | 6496 |
| |
6497 | 6497 |
| |
6498 | 6498 |
| |
6499 |
| - | |
| 6499 | + | |
6500 | 6500 |
| |
6501 | 6501 |
| |
6502 | 6502 |
| |
| |||
6527 | 6527 |
| |
6528 | 6528 |
| |
6529 | 6529 |
| |
6530 |
| - | |
| 6530 | + | |
6531 | 6531 |
| |
6532 | 6532 |
| |
6533 | 6533 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
6887 | 6887 |
| |
6888 | 6888 |
| |
6889 | 6889 |
| |
6890 |
| - | |
| 6890 | + | |
6891 | 6891 |
| |
6892 | 6892 |
| |
6893 | 6893 |
| |
|
Lines changed: 3 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3643 | 3643 |
| |
3644 | 3644 |
| |
3645 | 3645 |
| |
3646 |
| - | |
| 3646 | + | |
3647 | 3647 |
| |
3648 | 3648 |
| |
3649 | 3649 |
| |
| |||
3656 | 3656 |
| |
3657 | 3657 |
| |
3658 | 3658 |
| |
3659 |
| - | |
| 3659 | + | |
3660 | 3660 |
| |
3661 | 3661 |
| |
3662 | 3662 |
| |
| |||
3699 | 3699 |
| |
3700 | 3700 |
| |
3701 | 3701 |
| |
3702 |
| - | |
3703 |
| - | |
| 3702 | + | |
3704 | 3703 |
| |
3705 | 3704 |
| |
3706 | 3705 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
265 | 265 |
| |
266 | 266 |
| |
267 | 267 |
| |
268 |
| - | |
| 268 | + | |
269 | 269 |
| |
270 | 270 |
| |
271 | 271 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
147 | 147 |
| |
148 | 148 |
| |
149 | 149 |
| |
150 |
| - | |
| 150 | + | |
151 | 151 |
| |
152 | 152 |
| |
153 | 153 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
62 | 62 |
| |
63 | 63 |
| |
64 | 64 |
| |
65 |
| - | |
| 65 | + | |
66 | 66 |
| |
67 | 67 |
| |
68 | 68 |
| |
| |||
84 | 84 |
| |
85 | 85 |
| |
86 | 86 |
| |
87 |
| - | |
| 87 | + | |
88 | 88 |
| |
89 | 89 |
| |
90 | 90 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
97 | 97 |
| |
98 | 98 |
| |
99 | 99 |
| |
100 |
| - | |
| 100 | + | |
101 | 101 |
| |
102 | 102 |
| |
103 | 103 |
| |
|
Lines changed: 7 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
17 | 17 |
| |
18 | 18 |
| |
19 | 19 |
| |
20 |
| - | |
21 |
| - | |
22 |
| - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
23 | 27 |
| |
24 | 28 |
| |
25 | 29 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
76 | 76 |
| |
77 | 77 |
| |
78 | 78 |
| |
79 |
| - | |
| 79 | + | |
80 | 80 |
| |
81 | 81 |
| |
82 | 82 |
| |
|
0 commit comments
Comments
(0)