forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit299298b
committed
Fix transient memory leak for SRFs in FROM.
Ina9c35cf I changed ExecMakeTableFunctionResult() to dynamicallyallocate the FunctionCallInfo used to call the SRF. Unfortunately Idid not account for the fact that the surrounding memory context hasquery lifetime, leading to a leak till the end of the query.In most cases the leak is fairly inconsequential, but if theFunctionScan is done many times in the query, the leak can addup. This happens e.g. if the function scan is on the inner side of anested loop, due to a lateral join.EXPLAIN SELECT sum(f) FROM generate_series(1, 100000000) g(i), generate_series(i, i+1) f;quickly shows the leak.Instead of explicitly freeing the FunctionCallInfo it seems better tomake sure all the per-set temporary state inExecMakeTableFunctionResult() is cleaned up wholesale. Currentlythat's probably just the FunctionCallInfo allocation, but sincethere's some initialization work, and since there's already anappropriate context, this seems like a more robust approach.Bug: #16112Reported-By: Ben CornettAuthor: Andres FreundReviewed-By: Tom LaneDiscussion:https://postgr.es/m/16112-4448bbf55a404189%40postgresql.orgBackpatch: 12,a9c35cf1 parent0a89e93 commit299298b
1 file changed
+29
-21
lines changedLines changed: 29 additions & 21 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
114 | 114 |
| |
115 | 115 |
| |
116 | 116 |
| |
117 |
| - | |
118 | 117 |
| |
119 | 118 |
| |
120 |
| - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
121 | 134 |
| |
122 | 135 |
| |
123 | 136 |
| |
| |||
163 | 176 |
| |
164 | 177 |
| |
165 | 178 |
| |
166 |
| - | |
167 |
| - | |
168 |
| - | |
169 |
| - | |
170 |
| - | |
171 |
| - | |
172 |
| - | |
173 |
| - | |
174 |
| - | |
175 |
| - | |
176 |
| - | |
177 |
| - | |
178 |
| - | |
| 179 | + | |
| 180 | + | |
179 | 181 |
| |
180 |
| - | |
181 | 182 |
| |
182 | 183 |
| |
183 | 184 |
| |
| |||
217 | 218 |
| |
218 | 219 |
| |
219 | 220 |
| |
220 |
| - | |
| 221 | + | |
221 | 222 |
| |
222 | 223 |
| |
223 | 224 |
| |
| |||
257 | 258 |
| |
258 | 259 |
| |
259 | 260 |
| |
260 |
| - | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
261 | 264 |
| |
262 | 265 |
| |
263 | 266 |
| |
| |||
285 | 288 |
| |
286 | 289 |
| |
287 | 290 |
| |
| 291 | + | |
| 292 | + | |
| 293 | + | |
288 | 294 |
| |
289 | 295 |
| |
290 | 296 |
| |
291 | 297 |
| |
292 | 298 |
| |
293 | 299 |
| |
294 |
| - | |
295 | 300 |
| |
296 | 301 |
| |
297 | 302 |
| |
| |||
378 | 383 |
| |
379 | 384 |
| |
380 | 385 |
| |
381 |
| - | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
382 | 389 |
| |
383 | 390 |
| |
| 391 | + | |
| 392 | + | |
384 | 393 |
| |
385 | 394 |
| |
386 | 395 |
| |
387 | 396 |
| |
388 | 397 |
| |
389 |
| - | |
390 | 398 |
| |
391 | 399 |
| |
392 | 400 |
| |
|
0 commit comments
Comments
(0)