- Notifications
You must be signed in to change notification settings - Fork5
Commit3df9abd

Neil Conway
ALTER TABLE ADD COLUMN exhibits a significant memory leak when adding a
column with a default expression. In that situation, we need to rewritethe heap relation. To evaluate the new default expression, we useExecEvalExpr(); however, this can allocate memory in the current memorycontext, and ATRewriteTable() does not switch out of the active portal'sheap memory context. The end result is a rather large memory leak (onthe order of gigabytes for a reasonably sized table).This patch changes ATRewriteTable() to switch to the per-tuple memorycontext before beginning the per-tuple loop. It also removes an explicitheap_freetuple() in the loop, since that is no longer needed.In an unrelated change, I noticed the code was scanning through theattributes of the new tuple descriptor for each tuple of the old table.I changed this to use precomputation, which should slightly speed upthe loop.Thanks to steve@deefs.net for reporting the leak.1 parentd32b3ae commit3df9abd
1 file changed
+32
-16
lines changedLines changed: 32 additions & 16 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
8 | 8 |
| |
9 | 9 |
| |
10 | 10 |
| |
11 |
| - | |
| 11 | + | |
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
| |||
2460 | 2460 |
| |
2461 | 2461 |
| |
2462 | 2462 |
| |
| 2463 | + | |
| 2464 | + | |
| 2465 | + | |
2463 | 2466 |
| |
2464 | 2467 |
| |
2465 | 2468 |
| |
| |||
2480 | 2483 |
| |
2481 | 2484 |
| |
2482 | 2485 |
| |
| 2486 | + | |
| 2487 | + | |
| 2488 | + | |
| 2489 | + | |
| 2490 | + | |
| 2491 | + | |
| 2492 | + | |
| 2493 | + | |
| 2494 | + | |
| 2495 | + | |
| 2496 | + | |
| 2497 | + | |
2483 | 2498 |
| |
2484 | 2499 |
| |
2485 | 2500 |
| |
2486 | 2501 |
| |
2487 | 2502 |
| |
2488 | 2503 |
| |
| 2504 | + | |
| 2505 | + | |
| 2506 | + | |
| 2507 | + | |
| 2508 | + | |
| 2509 | + | |
2489 | 2510 |
| |
2490 | 2511 |
| |
2491 | 2512 |
| |
2492 | 2513 |
| |
2493 |
| - | |
2494 |
| - | |
2495 |
| - | |
2496 |
| - | |
2497 |
| - | |
2498 |
| - | |
| 2514 | + | |
2499 | 2515 |
| |
2500 | 2516 |
| |
2501 |
| - | |
2502 |
| - | |
2503 |
| - | |
2504 |
| - | |
2505 |
| - | |
| 2517 | + | |
| 2518 | + | |
| 2519 | + | |
2506 | 2520 |
| |
2507 | 2521 |
| |
2508 | 2522 |
| |
| |||
2526 | 2540 |
| |
2527 | 2541 |
| |
2528 | 2542 |
| |
| 2543 | + | |
| 2544 | + | |
| 2545 | + | |
| 2546 | + | |
| 2547 | + | |
2529 | 2548 |
| |
2530 | 2549 |
| |
2531 | 2550 |
| |
| |||
2572 | 2591 |
| |
2573 | 2592 |
| |
2574 | 2593 |
| |
2575 |
| - | |
2576 | 2594 |
| |
2577 | 2595 |
| |
2578 |
| - | |
2579 |
| - | |
2580 |
| - | |
2581 | 2596 |
| |
2582 | 2597 |
| |
2583 | 2598 |
| |
2584 | 2599 |
| |
2585 | 2600 |
| |
| 2601 | + | |
2586 | 2602 |
| |
2587 | 2603 |
| |
2588 | 2604 |
| |
|
0 commit comments
Comments
(0)