- Notifications
You must be signed in to change notification settings - Fork5
Commitfa2fa99
committed
Permit dump/reload of not-too-large >1GB tuples
Our documentation states that our maximum field size is 1 GB, and thatour maximum row size of 1.6 TB. However, while this might be attainablein theory with enough contortions, it is not workable in practice; forstarters, pg_dump fails to dump tables containing rows larger than 1 GB,even if individual columns are well below the limit; and even if onedoes manage to manufacture a dump file containing a row that large, theserver refuses to load it anyway.This commit enables dumping and reloading of such tuples, provided twoconditions are met:1. no single column is larger than 1 GB (in output size -- for bytea this includes the formatting overhead)2. the whole row is not larger than 2 GBThere are three related changes to enable this:a. StringInfo's API now has two additional functions that allow creatinga string that grows beyond the typical 1GB limit (and "long" string).ABI compatibility is maintained. We still limit these strings to 2 GB,though, for reasons explained below.b. COPY now uses long StringInfos, so that pg_dump doesn't choketrying to emit rows longer than 1GB.c. heap_form_tuple now uses the MCXT_ALLOW_HUGE flag in its allocationfor the input tuple, which means that large tuples are accepted oninput. Note that at this point we do not apply any further limit to theinput tuple size.The main reason to limit to 2 GB is that the FE/BE protocol uses 32 bitlength words to describe each row; and because the documentation isambiguous on its signedness and libpq does consider it signed, we cannotuse the highest-order bit. Additionally, the StringInfo API uses "int"(which is 4 bytes wide in most platforms) in many places, so we'd needto change that API too in order to improve, which has lots of fallout.Backpatch to 9.5, which is the oldest that hasMemoryContextAllocExtended, a necessary piece of infrastructure. Wecould apply to 9.4 with very minimal additional effort, but any furtherthan that would require backpatching "huge" allocations too.This is the largest set of changes we could find that can beback-patched without breaking compatibility with existing systems.Fixing a bigger set of problems (for example, dumping tuples bigger than2GB, or dumping fields bigger than 1GB) would require changing the FE/BEprotocol and/or changing the StringInfo API in an ABI-incompatible way,neither of which would be back-patchable.Authors: Daniel Vérité, Álvaro HerreraReviewed by: Tomas VondraDiscussion:https://postgr.es/m/20160229183023.GA286012@alvherre.pgsql1 parent78c8c81 commitfa2fa99
File tree
4 files changed
+74
-22
lines changed- src
- backend
- access/common
- commands
- lib
- include/lib
4 files changed
+74
-22
lines changedLines changed: 3 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
741 | 741 |
| |
742 | 742 |
| |
743 | 743 |
| |
744 |
| - | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
745 | 747 |
| |
746 | 748 |
| |
747 | 749 |
| |
|
Lines changed: 4 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
385 | 385 |
| |
386 | 386 |
| |
387 | 387 |
| |
388 |
| - | |
| 388 | + | |
389 | 389 |
| |
390 | 390 |
| |
391 | 391 |
| |
| |||
1907 | 1907 |
| |
1908 | 1908 |
| |
1909 | 1909 |
| |
1910 |
| - | |
| 1910 | + | |
1911 | 1911 |
| |
1912 | 1912 |
| |
1913 | 1913 |
| |
| |||
2742 | 2742 |
| |
2743 | 2743 |
| |
2744 | 2744 |
| |
2745 |
| - | |
2746 |
| - | |
| 2745 | + | |
| 2746 | + | |
2747 | 2747 |
| |
2748 | 2748 |
| |
2749 | 2749 |
| |
|
Lines changed: 54 additions & 12 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4 | 4 |
| |
5 | 5 |
| |
6 | 6 |
| |
7 |
| - | |
| 7 | + | |
| 8 | + | |
8 | 9 |
| |
9 | 10 |
| |
10 | 11 |
| |
| |||
36 | 37 |
| |
37 | 38 |
| |
38 | 39 |
| |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
39 | 58 |
| |
40 | 59 |
| |
41 | 60 |
| |
42 | 61 |
| |
43 |
| - | |
| 62 | + | |
44 | 63 |
| |
45 | 64 |
| |
46 | 65 |
| |
| |||
49 | 68 |
| |
50 | 69 |
| |
51 | 70 |
| |
| 71 | + | |
52 | 72 |
| |
53 | 73 |
| |
54 | 74 |
| |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
55 | 87 |
| |
56 | 88 |
| |
57 | 89 |
| |
| |||
142 | 174 |
| |
143 | 175 |
| |
144 | 176 |
| |
145 |
| - | |
| 177 | + | |
146 | 178 |
| |
147 | 179 |
| |
148 | 180 |
| |
| |||
244 | 276 |
| |
245 | 277 |
| |
246 | 278 |
| |
247 |
| - | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
248 | 290 |
| |
249 | 291 |
| |
250 | 292 |
| |
251 | 293 |
| |
252 | 294 |
| |
253 | 295 |
| |
254 | 296 |
| |
255 |
| - | |
| 297 | + | |
256 | 298 |
| |
257 | 299 |
| |
258 | 300 |
| |
| |||
261 | 303 |
| |
262 | 304 |
| |
263 | 305 |
| |
264 |
| - | |
| 306 | + | |
265 | 307 |
| |
266 | 308 |
| |
267 | 309 |
| |
| |||
276 | 318 |
| |
277 | 319 |
| |
278 | 320 |
| |
279 |
| - | |
280 |
| - | |
281 |
| - | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
282 | 324 |
| |
283 |
| - | |
284 |
| - | |
| 325 | + | |
| 326 | + | |
285 | 327 |
| |
286 |
| - | |
| 328 | + | |
287 | 329 |
| |
288 | 330 |
| |
289 | 331 |
|
Lines changed: 13 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
30 | 30 |
| |
31 | 31 |
| |
32 | 32 |
| |
| 33 | + | |
| 34 | + | |
33 | 35 |
| |
34 | 36 |
| |
35 | 37 |
| |
| |||
38 | 40 |
| |
39 | 41 |
| |
40 | 42 |
| |
| 43 | + | |
41 | 44 |
| |
42 | 45 |
| |
43 | 46 |
| |
| |||
46 | 49 |
| |
47 | 50 |
| |
48 | 51 |
| |
49 |
| - | |
| 52 | + | |
50 | 53 |
| |
51 | 54 |
| |
52 | 55 |
| |
53 |
| - | |
| 56 | + | |
54 | 57 |
| |
55 | 58 |
| |
56 | 59 |
| |
| |||
67 | 70 |
| |
68 | 71 |
| |
69 | 72 |
| |
70 |
| - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
71 | 76 |
| |
72 | 77 |
| |
| 78 | + | |
73 | 79 |
| |
74 | 80 |
| |
75 | 81 |
| |
| 82 | + | |
76 | 83 |
| |
77 |
| - | |
| 84 | + | |
78 | 85 |
| |
79 | 86 |
| |
| 87 | + | |
80 | 88 |
| |
81 | 89 |
| |
82 | 90 |
| |
83 | 91 |
| |
84 |
| - | |
| 92 | + | |
85 | 93 |
| |
86 | 94 |
| |
87 | 95 |
| |
|
0 commit comments
Comments
(0)