forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit390d581
committed
Fix plpgsql to reinitialize record variables at block re-entry.
If one exits and re-enters a DECLARE ... BEGIN ... END block within asingle execution of a plpgsql function, perhaps due to a surrounding loop,the declared variables are supposed to get re-initialized to null (orwhatever their initializer is). But this failed to happen for variablesof type "record", because while exec_stmt_block() expected such variablesto be included in the block's initvarnos list, plpgsql_add_initdatums()only adds DTYPE_VAR variables to that list. This bug appears to havebeen there since the aboriginal addition of plpgsql to our tree.Fix by teaching plpgsql_add_initdatums() to include DTYPE_REC variablesas well. (We don't need to consider other DTYPEs because they don'trepresent separately-stored values.) I failed to resist the temptationto make some nearby cosmetic adjustments, too.No back-patch, because there have not been field complaints, and itseems possible that somewhere out there someone has code dependingon the incorrect behavior. In any case this change would have noimpact on correctly-written code.Discussion:https://postgr.es/m/22994.1512800671@sss.pgh.pa.us1 parentce1468d commit390d581
File tree
5 files changed
+68
-16
lines changed- src
- pl/plpgsql/src
- test/regress
- expected
- sql
5 files changed
+68
-16
lines changedLines changed: 9 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2384 | 2384 |
| |
2385 | 2385 |
| |
2386 | 2386 |
| |
2387 |
| - | |
| 2387 | + | |
2388 | 2388 |
| |
2389 | 2389 |
| |
2390 | 2390 |
| |
2391 | 2391 |
| |
2392 | 2392 |
| |
2393 |
| - | |
2394 |
| - | |
| 2393 | + | |
| 2394 | + | |
2395 | 2395 |
| |
2396 | 2396 |
| |
2397 | 2397 |
| |
| |||
2402 | 2402 |
| |
2403 | 2403 |
| |
2404 | 2404 |
| |
| 2405 | + | |
| 2406 | + | |
| 2407 | + | |
| 2408 | + | |
2405 | 2409 |
| |
2406 | 2410 |
| |
2407 | 2411 |
| |
2408 | 2412 |
| |
2409 | 2413 |
| |
| 2414 | + | |
2410 | 2415 |
| |
2411 | 2416 |
| |
2412 | 2417 |
| |
| |||
2427 | 2432 |
| |
2428 | 2433 |
| |
2429 | 2434 |
| |
| 2435 | + | |
2430 | 2436 |
| |
2431 | 2437 |
| |
2432 | 2438 |
| |
|
Lines changed: 9 additions & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1184 | 1184 |
| |
1185 | 1185 |
| |
1186 | 1186 |
| |
1187 |
| - | |
1188 | 1187 |
| |
1189 | 1188 |
| |
1190 | 1189 |
| |
| |||
1193 | 1192 |
| |
1194 | 1193 |
| |
1195 | 1194 |
| |
1196 |
| - | |
| 1195 | + | |
| 1196 | + | |
1197 | 1197 |
| |
1198 |
| - | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
1199 | 1202 |
| |
1200 | 1203 |
| |
1201 | 1204 |
| |
1202 |
| - | |
| 1205 | + | |
1203 | 1206 |
| |
1204 | 1207 |
| |
1205 | 1208 |
| |
| |||
1241 | 1244 |
| |
1242 | 1245 |
| |
1243 | 1246 |
| |
1244 |
| - | |
| 1247 | + | |
1245 | 1248 |
| |
1246 | 1249 |
| |
1247 | 1250 |
| |
| |||
1258 | 1261 |
| |
1259 | 1262 |
| |
1260 | 1263 |
| |
1261 |
| - | |
1262 |
| - | |
1263 |
| - | |
1264 |
| - | |
1265 | 1264 |
| |
1266 |
| - | |
1267 |
| - | |
| 1265 | + | |
1268 | 1266 |
| |
1269 | 1267 |
| |
1270 | 1268 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
407 | 407 |
| |
408 | 408 |
| |
409 | 409 |
| |
410 |
| - | |
411 |
| - | |
| 410 | + | |
| 411 | + | |
412 | 412 |
| |
413 | 413 |
| |
414 | 414 |
| |
|
Lines changed: 27 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
5025 | 5025 |
| |
5026 | 5026 |
| |
5027 | 5027 |
| |
| 5028 | + | |
| 5029 | + | |
| 5030 | + | |
| 5031 | + | |
| 5032 | + | |
| 5033 | + | |
| 5034 | + | |
| 5035 | + | |
| 5036 | + | |
| 5037 | + | |
| 5038 | + | |
| 5039 | + | |
| 5040 | + | |
| 5041 | + | |
| 5042 | + | |
| 5043 | + | |
| 5044 | + | |
| 5045 | + | |
| 5046 | + | |
| 5047 | + | |
| 5048 | + | |
| 5049 | + | |
| 5050 | + | |
| 5051 | + | |
| 5052 | + | |
| 5053 | + | |
| 5054 | + | |
5028 | 5055 |
| |
5029 | 5056 |
| |
5030 | 5057 |
| |
|
Lines changed: 21 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4014 | 4014 |
| |
4015 | 4015 |
| |
4016 | 4016 |
| |
| 4017 | + | |
| 4018 | + | |
| 4019 | + | |
| 4020 | + | |
| 4021 | + | |
| 4022 | + | |
| 4023 | + | |
| 4024 | + | |
| 4025 | + | |
| 4026 | + | |
| 4027 | + | |
| 4028 | + | |
| 4029 | + | |
| 4030 | + | |
| 4031 | + | |
| 4032 | + | |
| 4033 | + | |
| 4034 | + | |
| 4035 | + | |
| 4036 | + | |
| 4037 | + | |
4017 | 4038 |
| |
4018 | 4039 |
| |
4019 | 4040 |
| |
|
0 commit comments
Comments
(0)