forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commita8d8445
committed
Fix display of SQL-standard function's arguments in INSERT/SELECT.
If a SQL-standard function body contains an INSERT ... SELECT statement,any function parameters referenced within the SELECT were always printedin $N style, rather than using the parameter name if any. While notstrictly incorrect, this wasn't the intention, and it's inconsistentwith the way that such parameters would be printed in any other kindof statement.The cause is that the recursion to get_query_def fromget_insert_query_def neglected to pass down the context->namespaceslist, passing constant NIL instead. This is a very ancient oversight,but AFAICT it had no visible consequences before commite717a9aadded an outermost namespace with function parameters. We don't allowINSERT ... SELECT as a sub-query, except in a top-level WITH clause,where it couldn't contain any outer references that might need to accessupper namespaces. So although that's arguably a bug, I don't see anypoint in changing it before v14.In passing, harden the code added to get_parameter bye717a9a so thatit won't crash if a PARAM_EXTERN Param appears in an unexpected place.Per report from Erki Eessaar. Code fix by me, regression test caseby Masahiko Sawada.Discussion:https://postgr.es/m/AM9PR01MB8268347BED344848555167FAFE949@AM9PR01MB8268.eurprd01.prod.exchangelabs.com1 parentaa12781 commita8d8445
File tree
3 files changed
+38
-4
lines changed- src
- backend/utils/adt
- test/regress
- expected
- sql
3 files changed
+38
-4
lines changedLines changed: 6 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
6566 | 6566 |
| |
6567 | 6567 |
| |
6568 | 6568 |
| |
6569 |
| - | |
| 6569 | + | |
6570 | 6570 |
| |
6571 | 6571 |
| |
6572 | 6572 |
| |
| |||
7919 | 7919 |
| |
7920 | 7920 |
| |
7921 | 7921 |
| |
7922 |
| - | |
| 7922 | + | |
7923 | 7923 |
| |
7924 |
| - | |
7925 |
| - | |
| 7924 | + | |
| 7925 | + | |
| 7926 | + | |
| 7927 | + | |
7926 | 7928 |
| |
7927 | 7929 |
| |
7928 | 7930 |
| |
|
Lines changed: 21 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
279 | 279 |
| |
280 | 280 |
| |
281 | 281 |
| |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
282 | 289 |
| |
283 | 290 |
| |
284 | 291 |
| |
| |||
417 | 424 |
| |
418 | 425 |
| |
419 | 426 |
| |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
420 | 441 |
| |
421 | 442 |
| |
422 | 443 |
| |
|
Lines changed: 11 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
180 | 180 |
| |
181 | 181 |
| |
182 | 182 |
| |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
183 | 191 |
| |
184 | 192 |
| |
185 | 193 |
| |
| |||
217 | 225 |
| |
218 | 226 |
| |
219 | 227 |
| |
| 228 | + | |
| 229 | + | |
| 230 | + | |
220 | 231 |
| |
221 | 232 |
| |
222 | 233 |
| |
|
0 commit comments
Comments
(0)