forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitff428cd

Neil Conway
Fix several memory leaks when rescanning SRFs. Arrange for an SRF's
"multi_call_ctx" to be a distinct sub-context of the EState's per-querycontext, and delete the multi_call_ctx as soon as the SRF finishesexecution. This avoids leaking SRF memory until the end of the currentquery, which is particularly egregious when the SRF is scannedmultiple times. This change also fixes a leak of the fields of theAttInMetadata struct in shutdown_MultiFuncCall().Also fix a leak of the SRF result TupleDesc when rescanning aFunctionScan node. The TupleDesc is allocated in the per-query contextfor every call to ExecMakeTableFunctionResult(), so we should free itafter calling that function. Since the SRF might choose to returna non-expendable TupleDesc, we only free the TupleDesc if it isnot being reference-counted.Backpatch to 8.3 and 8.2 stable branches.1 parentb13635c commitff428cd
2 files changed
+30
-11
lines changedLines changed: 11 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
8 | 8 |
| |
9 | 9 |
| |
10 | 10 |
| |
11 |
| - | |
| 11 | + | |
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
| |||
77 | 77 |
| |
78 | 78 |
| |
79 | 79 |
| |
| 80 | + | |
80 | 81 |
| |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
81 | 91 |
| |
82 | 92 |
| |
83 | 93 |
| |
|
Lines changed: 19 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7 | 7 |
| |
8 | 8 |
| |
9 | 9 |
| |
10 |
| - | |
| 10 | + | |
11 | 11 |
| |
12 | 12 |
| |
13 | 13 |
| |
| |||
23 | 23 |
| |
24 | 24 |
| |
25 | 25 |
| |
| 26 | + | |
26 | 27 |
| |
27 | 28 |
| |
28 | 29 |
| |
| |||
63 | 64 |
| |
64 | 65 |
| |
65 | 66 |
| |
66 |
| - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
67 | 78 |
| |
68 | 79 |
| |
69 | 80 |
| |
70 | 81 |
| |
71 | 82 |
| |
72 |
| - | |
| 83 | + | |
73 | 84 |
| |
74 | 85 |
| |
75 | 86 |
| |
| |||
81 | 92 |
| |
82 | 93 |
| |
83 | 94 |
| |
84 |
| - | |
| 95 | + | |
85 | 96 |
| |
86 | 97 |
| |
87 | 98 |
| |
| |||
168 | 179 |
| |
169 | 180 |
| |
170 | 181 |
| |
171 |
| - | |
172 |
| - | |
| 182 | + | |
| 183 | + | |
173 | 184 |
| |
174 |
| - | |
175 |
| - | |
176 |
| - | |
177 |
| - | |
| 185 | + | |
| 186 | + | |
178 | 187 |
| |
179 | 188 |
| |
180 | 189 |
| |
|
0 commit comments
Comments
(0)