forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitb006f4d
committed
Prevent memory leaks from accumulating across printtup() calls.
Historically, printtup() has assumed that it could prevent memory leakageby pfree'ing the string result of each output function and manuallymanaging detoasting of toasted values. This amounts to assuming thatdatatype output functions never leak any memory internally; an assumptionwe've already decided to be bogus elsewhere, for example in COPY OUT.range_out in particular is known to leak multiple kilobytes per call, asnoted in bug #8573 from Godfried Vanluffelen. While we could go in and fixthat leak, it wouldn't be very notationally convenient, and in any casethere have been and undoubtedly will again be other leaks in other outputfunctions. So what seems like the best solution is to run the outputfunctions in a temporary memory context that can be reset after each row,as we're doing in COPY OUT. Some quick experimentation suggests this isactually a tad faster than the retail pfree's anyway.This patch fixes all the variants of printtup, except for debugtup()which is used in standalone mode. It doesn't seem worth worryingabout query-lifespan leaks in standalone mode, and fixing that casewould be a bit tedious since debugtup() doesn't currently have anystartup or shutdown functions.While at it, remove manual detoast management from several otheroutput-function call sites that had copied it from printtup(). Thisdoesn't make a lot of difference right now, but in view of recentdiscussions about supporting "non-flattened" Datums, we're going towant that code gone eventually anyway.Back-patch to 9.2 where range_out was introduced. We might eventuallydecide to back-patch this further, but in the absence of known majorleaks in older output functions, I'll refrain for now.1 parent84a05d4 commitb006f4d
File tree
4 files changed
+68
-137
lines changed- src/backend
- access/common
- bootstrap
- executor
- utils/adt
4 files changed
+68
-137
lines changedLines changed: 55 additions & 81 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
21 | 21 |
| |
22 | 22 |
| |
23 | 23 |
| |
| 24 | + | |
24 | 25 |
| |
25 | 26 |
| |
26 | 27 |
| |
| |||
61 | 62 |
| |
62 | 63 |
| |
63 | 64 |
| |
| 65 | + | |
64 | 66 |
| |
65 | 67 |
| |
66 | 68 |
| |
| |||
87 | 89 |
| |
88 | 90 |
| |
89 | 91 |
| |
| 92 | + | |
90 | 93 |
| |
91 | 94 |
| |
92 | 95 |
| |
| |||
124 | 127 |
| |
125 | 128 |
| |
126 | 129 |
| |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
127 | 142 |
| |
128 | 143 |
| |
129 | 144 |
| |
| |||
289 | 304 |
| |
290 | 305 |
| |
291 | 306 |
| |
| 307 | + | |
292 | 308 |
| |
293 | 309 |
| |
294 | 310 |
| |
| |||
300 | 316 |
| |
301 | 317 |
| |
302 | 318 |
| |
| 319 | + | |
| 320 | + | |
| 321 | + | |
303 | 322 |
| |
304 |
| - | |
| 323 | + | |
305 | 324 |
| |
306 | 325 |
| |
307 | 326 |
| |
| |||
313 | 332 |
| |
314 | 333 |
| |
315 | 334 |
| |
316 |
| - | |
317 |
| - | |
| 335 | + | |
318 | 336 |
| |
319 | 337 |
| |
320 | 338 |
| |
| |||
323 | 341 |
| |
324 | 342 |
| |
325 | 343 |
| |
326 |
| - | |
327 |
| - | |
328 |
| - | |
329 |
| - | |
| 344 | + | |
330 | 345 |
| |
331 |
| - | |
332 |
| - | |
333 |
| - | |
334 |
| - | |
335 |
| - | |
336 |
| - | |
337 |
| - | |
338 |
| - | |
339 |
| - | |
340 |
| - | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
341 | 349 |
| |
342 | 350 |
| |
343 |
| - | |
344 |
| - | |
345 |
| - | |
346 |
| - | |
347 |
| - | |
348 |
| - | |
349 |
| - | |
| 351 | + | |
| 352 | + | |
350 | 353 |
| |
351 | 354 |
| |
352 | 355 |
| |
| |||
355 | 358 |
| |
356 | 359 |
| |
357 | 360 |
| |
358 |
| - | |
359 | 361 |
| |
360 | 362 |
| |
361 | 363 |
| |
| |||
366 | 368 |
| |
367 | 369 |
| |
368 | 370 |
| |
369 |
| - | |
370 | 371 |
| |
371 |
| - | |
372 |
| - | |
373 |
| - | |
374 |
| - | |
375 | 372 |
| |
376 | 373 |
| |
377 | 374 |
| |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
378 | 379 |
| |
379 | 380 |
| |
380 | 381 |
| |
| |||
386 | 387 |
| |
387 | 388 |
| |
388 | 389 |
| |
| 390 | + | |
389 | 391 |
| |
390 | 392 |
| |
391 | 393 |
| |
| |||
399 | 401 |
| |
400 | 402 |
| |
401 | 403 |
| |
| 404 | + | |
| 405 | + | |
| 406 | + | |
402 | 407 |
| |
403 | 408 |
| |
404 | 409 |
| |
| |||
430 | 435 |
| |
431 | 436 |
| |
432 | 437 |
| |
433 |
| - | |
434 |
| - | |
| 438 | + | |
435 | 439 |
| |
436 | 440 |
| |
437 | 441 |
| |
438 | 442 |
| |
439 | 443 |
| |
440 | 444 |
| |
441 | 445 |
| |
442 |
| - | |
443 |
| - | |
444 |
| - | |
445 |
| - | |
446 |
| - | |
447 |
| - | |
448 |
| - | |
449 |
| - | |
450 |
| - | |
451 | 446 |
| |
452 | 447 |
| |
453 |
| - | |
454 |
| - | |
455 |
| - | |
456 |
| - | |
457 |
| - | |
458 | 448 |
| |
459 | 449 |
| |
460 | 450 |
| |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
461 | 455 |
| |
462 | 456 |
| |
463 | 457 |
| |
| |||
474 | 468 |
| |
475 | 469 |
| |
476 | 470 |
| |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
477 | 475 |
| |
478 | 476 |
| |
479 | 477 |
| |
| |||
536 | 534 |
| |
537 | 535 |
| |
538 | 536 |
| |
539 |
| - | |
540 |
| - | |
| 537 | + | |
541 | 538 |
| |
542 | 539 |
| |
543 | 540 |
| |
544 | 541 |
| |
545 | 542 |
| |
546 | 543 |
| |
547 | 544 |
| |
548 |
| - | |
| 545 | + | |
549 | 546 |
| |
550 | 547 |
| |
551 | 548 |
| |
552 | 549 |
| |
553 | 550 |
| |
554 |
| - | |
555 |
| - | |
556 |
| - | |
557 |
| - | |
558 |
| - | |
559 |
| - | |
560 |
| - | |
561 |
| - | |
562 |
| - | |
563 | 551 |
| |
564 | 552 |
| |
565 | 553 |
| |
566 |
| - | |
567 |
| - | |
568 |
| - | |
569 |
| - | |
570 |
| - | |
571 |
| - | |
572 | 554 |
| |
573 | 555 |
| |
574 | 556 |
| |
| |||
587 | 569 |
| |
588 | 570 |
| |
589 | 571 |
| |
| 572 | + | |
590 | 573 |
| |
591 | 574 |
| |
592 | 575 |
| |
| |||
600 | 583 |
| |
601 | 584 |
| |
602 | 585 |
| |
| 586 | + | |
| 587 | + | |
| 588 | + | |
603 | 589 |
| |
604 | 590 |
| |
605 | 591 |
| |
| |||
631 | 617 |
| |
632 | 618 |
| |
633 | 619 |
| |
634 |
| - | |
635 |
| - | |
| 620 | + | |
636 | 621 |
| |
637 | 622 |
| |
638 | 623 |
| |
639 | 624 |
| |
640 | 625 |
| |
641 | 626 |
| |
642 | 627 |
| |
643 |
| - | |
644 |
| - | |
645 |
| - | |
646 |
| - | |
647 |
| - | |
648 |
| - | |
649 |
| - | |
650 |
| - | |
651 |
| - | |
652 | 628 |
| |
653 |
| - | |
654 | 629 |
| |
655 | 630 |
| |
656 | 631 |
| |
657 |
| - | |
658 |
| - | |
659 |
| - | |
660 |
| - | |
661 |
| - | |
662 | 632 |
| |
663 | 633 |
| |
664 | 634 |
| |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
665 | 639 |
|
Lines changed: 8 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
835 | 835 |
| |
836 | 836 |
| |
837 | 837 |
| |
838 |
| - | |
839 | 838 |
| |
840 | 839 |
| |
841 | 840 |
| |
| |||
849 | 848 |
| |
850 | 849 |
| |
851 | 850 |
| |
852 |
| - | |
853 |
| - | |
854 |
| - | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
855 | 859 |
| |
856 | 860 |
| |
857 | 861 |
| |
|
Lines changed: 3 additions & 20 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
869 | 869 |
| |
870 | 870 |
| |
871 | 871 |
| |
872 |
| - | |
873 |
| - | |
874 |
| - | |
| 872 | + | |
875 | 873 |
| |
876 | 874 |
| |
877 | 875 |
| |
| |||
886 | 884 |
| |
887 | 885 |
| |
888 | 886 |
| |
889 |
| - | |
| 887 | + | |
890 | 888 |
| |
891 | 889 |
| |
892 | 890 |
| |
| |||
897 | 895 |
| |
898 | 896 |
| |
899 | 897 |
| |
900 |
| - | |
901 |
| - | |
902 |
| - | |
903 |
| - | |
904 |
| - | |
905 |
| - | |
906 |
| - | |
907 |
| - | |
908 |
| - | |
909 |
| - | |
910 |
| - | |
911 |
| - | |
912 |
| - | |
913 |
| - | |
914 |
| - | |
915 |
| - | |
| 898 | + | |
916 | 899 |
| |
917 | 900 |
| |
918 | 901 |
| |
|
0 commit comments
Comments
(0)