forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitde35207
committed
Fix edge case in plpgsql's make_callstmt_target().
If the plancache entry for the CALL statement is already stale,it's possible for us to fetch an old procedure OID out of it,and then fail with "cache lookup failed for function NNN".In ordinary usage this never happens because make_callstmt_targetis called just once immediately after building the plancacheentry. It can be forced however by setting up an erroneous CALL(that causes make_callstmt_target itself to report an error),then dropping/recreating the target procedure, then repeatingthe erroneous CALL.To fix, use SPI_plan_get_cached_plan() to fetch the plancache'splan, rather than assuming we can use SPI_plan_get_plan_sources().This shouldn't add any noticeable overhead in the normal case,and in the stale-plan case we'd have had to replan anyway a littlefurther down.The other callers of SPI_plan_get_plan_sources() seem OK, becauseeither they don't need up-to-date plans or they know that thequery was just (re) planned. But add some commentary in hopesof not falling into this trap again.Per bug #18574 from Song Hongyu. Back-patch to v14 where this codingwas introduced. (Older branches have comparable code, but it's runafter any required replanning, so there's no issue.)Discussion:https://postgr.es/m/18574-2ce7ba3249221389@postgresql.org1 parenta38f5f8 commitde35207
2 files changed
+16
-12
lines changedLines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2043 | 2043 |
| |
2044 | 2044 |
| |
2045 | 2045 |
| |
| 2046 | + | |
| 2047 | + | |
2046 | 2048 |
| |
2047 | 2049 |
| |
2048 | 2050 |
| |
|
Lines changed: 14 additions & 12 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2276 | 2276 |
| |
2277 | 2277 |
| |
2278 | 2278 |
| |
2279 |
| - | |
2280 |
| - | |
| 2279 | + | |
| 2280 | + | |
2281 | 2281 |
| |
2282 | 2282 |
| |
2283 | 2283 |
| |
| |||
2294 | 2294 |
| |
2295 | 2295 |
| |
2296 | 2296 |
| |
2297 |
| - | |
| 2297 | + | |
| 2298 | + | |
| 2299 | + | |
2298 | 2300 |
| |
2299 |
| - | |
2300 |
| - | |
2301 |
| - | |
2302 |
| - | |
2303 |
| - | |
| 2301 | + | |
| 2302 | + | |
2304 | 2303 |
| |
2305 |
| - | |
2306 |
| - | |
| 2304 | + | |
| 2305 | + | |
2307 | 2306 |
| |
2308 | 2307 |
| |
2309 | 2308 |
| |
| |||
2383 | 2382 |
| |
2384 | 2383 |
| |
2385 | 2384 |
| |
| 2385 | + | |
| 2386 | + | |
2386 | 2387 |
| |
2387 | 2388 |
| |
2388 | 2389 |
| |
| |||
4239 | 4240 |
| |
4240 | 4241 |
| |
4241 | 4242 |
| |
4242 |
| - | |
4243 |
| - | |
| 4243 | + | |
| 4244 | + | |
| 4245 | + | |
4244 | 4246 |
| |
4245 | 4247 |
| |
4246 | 4248 |
| |
|
0 commit comments
Comments
(0)