- Notifications
You must be signed in to change notification settings - Fork28
Commitf833c84
committed
Allow psql variable substitution to occur in backtick command strings.
Previously, text between backquotes in a psql metacommand's argumentswas always passed to the shell literally. That considerably hobblesthe usefulness of the feature for scripting, so we'd foreseen for a longtime that we'd someday want to allow substitution of psql variables intothe shell command. IMO the addition of \if metacommands has brought us tothat point, since \if can greatly benefit from some sort of client-sideexpression evaluation capability, and psql itself is not going to grow anysuch thing in time for v10. Hence, this patch. It allows :VARIABLE to bereplaced by the exact contents of the named variable, while :'VARIABLE'is replaced by the variable's contents suitably quoted to become a singleshell-command argument. (The quoting rules for that are different fromthose for SQL literals, so this is a bit of an abuse of the :'VARIABLE'notation, but I doubt anyone will be confused.)As with other situations in psql, no substitution occurs if the wordfollowing a colon is not a known variable name. That limits the risk ofcompatibility problems for existing psql scripts; but the risk isn't zero,so this needs to be called out in the v10 release notes.Discussion:https://postgr.es/m/9561.1490895211@sss.pgh.pa.us1 parent41bd155 commitf833c84
File tree
9 files changed
+180
-66
lines changed- doc/src/sgml/ref
- src
- bin/psql
- fe_utils
- include/fe_utils
9 files changed
+180
-66
lines changedLines changed: 22 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
769 | 769 |
| |
770 | 770 |
| |
771 | 771 |
| |
772 |
| - | |
773 |
| - | |
774 |
| - | |
775 |
| - | |
776 |
| - | |
777 |
| - | |
778 |
| - | |
779 | 772 |
| |
780 | 773 |
| |
781 | 774 |
| |
782 | 775 |
| |
783 | 776 |
| |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
784 | 799 |
| |
785 | 800 |
| |
786 | 801 |
| |
|
Lines changed: 66 additions & 32 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
116 | 116 |
| |
117 | 117 |
| |
118 | 118 |
| |
119 |
| - | |
120 |
| - | |
121 |
| - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
122 | 122 |
| |
123 | 123 |
| |
124 | 124 |
| |
125 | 125 |
| |
126 | 126 |
| |
127 | 127 |
| |
128 |
| - | |
| 128 | + | |
129 | 129 |
| |
130 | 130 |
| |
131 |
| - | |
| 131 | + | |
132 | 132 |
| |
133 | 133 |
| |
134 | 134 |
| |
| |||
139 | 139 |
| |
140 | 140 |
| |
141 | 141 |
| |
142 |
| - | |
| 142 | + | |
143 | 143 |
| |
144 |
| - | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
145 | 155 |
| |
146 |
| - | |
147 |
| - | |
148 |
| - | |
149 |
| - | |
150 |
| - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
151 | 161 |
| |
152 |
| - | |
153 |
| - | |
154 |
| - | |
155 |
| - | |
156 |
| - | |
157 |
| - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
158 | 168 |
| |
159 |
| - | |
160 |
| - | |
161 |
| - | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
162 | 172 |
| |
163 |
| - | |
164 |
| - | |
165 |
| - | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
166 | 176 |
| |
167 |
| - | |
168 |
| - | |
169 |
| - | |
170 |
| - | |
171 |
| - | |
172 |
| - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
173 | 209 |
| |
174 |
| - | |
175 |
| - | |
176 | 210 |
| |
177 | 211 |
| |
178 | 212 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
| 15 | + | |
15 | 16 |
| |
16 | 17 |
| |
17 | 18 |
| |
18 | 19 |
| |
19 |
| - | |
| 20 | + | |
20 | 21 |
| |
21 | 22 |
| |
22 | 23 |
| |
|
Lines changed: 45 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
242 | 242 |
| |
243 | 243 |
| |
244 | 244 |
| |
245 |
| - | |
246 |
| - | |
| 245 | + | |
247 | 246 |
| |
248 | 247 |
| |
249 | 248 |
| |
| |||
268 | 267 |
| |
269 | 268 |
| |
270 | 269 |
| |
271 |
| - | |
| 270 | + | |
| 271 | + | |
272 | 272 |
| |
273 | 273 |
| |
274 | 274 |
| |
275 | 275 |
| |
276 | 276 |
| |
277 | 277 |
| |
278 |
| - | |
| 278 | + | |
| 279 | + | |
279 | 280 |
| |
280 | 281 |
| |
281 | 282 |
| |
| |||
337 | 338 |
| |
338 | 339 |
| |
339 | 340 |
| |
340 |
| - | |
341 |
| - | |
342 |
| - | |
| 341 | + | |
| 342 | + | |
343 | 343 |
| |
344 | 344 |
| |
345 | 345 |
| |
| |||
350 | 350 |
| |
351 | 351 |
| |
352 | 352 |
| |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
353 | 391 |
| |
354 | 392 |
| |
355 | 393 |
| |
|
Lines changed: 7 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
699 | 699 |
| |
700 | 700 |
| |
701 | 701 |
| |
702 |
| - | |
703 |
| - | |
| 702 | + | |
704 | 703 |
| |
705 | 704 |
| |
706 | 705 |
| |
| |||
737 | 736 |
| |
738 | 737 |
| |
739 | 738 |
| |
740 |
| - | |
| 739 | + | |
| 740 | + | |
741 | 741 |
| |
742 | 742 |
| |
743 | 743 |
| |
744 |
| - | |
| 744 | + | |
| 745 | + | |
745 | 746 |
| |
746 | 747 |
| |
747 | 748 |
| |
| |||
1415 | 1416 |
| |
1416 | 1417 |
| |
1417 | 1418 |
| |
1418 |
| - | |
| 1419 | + | |
1419 | 1420 |
| |
1420 | 1421 |
| |
1421 | 1422 |
| |
1422 | 1423 |
| |
1423 | 1424 |
| |
1424 | 1425 |
| |
1425 | 1426 |
| |
1426 |
| - | |
| 1427 | + | |
1427 | 1428 |
| |
1428 | 1429 |
| |
1429 | 1430 |
| |
|
Lines changed: 24 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
425 | 425 |
| |
426 | 426 |
| |
427 | 427 |
| |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
428 | 432 |
| |
429 | 433 |
| |
430 | 434 |
| |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
431 | 447 |
| |
432 | 448 |
| |
433 | 449 |
| |
434 | 450 |
| |
| 451 | + | |
435 | 452 |
| |
436 | 453 |
| |
437 | 454 |
| |
| |||
442 | 459 |
| |
443 | 460 |
| |
444 | 461 |
| |
445 |
| - | |
| 462 | + | |
446 | 463 |
| |
447 | 464 |
| |
448 | 465 |
| |
| |||
451 | 468 |
| |
452 | 469 |
| |
453 | 470 |
| |
454 |
| - | |
455 |
| - | |
456 |
| - | |
457 |
| - | |
| 471 | + | |
| 472 | + | |
458 | 473 |
| |
459 | 474 |
| |
460 | 475 |
| |
| |||
481 | 496 |
| |
482 | 497 |
| |
483 | 498 |
| |
484 |
| - | |
485 |
| - | |
486 |
| - | |
487 |
| - | |
| 499 | + | |
| 500 | + | |
488 | 501 |
| |
489 | 502 |
| |
490 | 503 |
| |
| |||
524 | 537 |
| |
525 | 538 |
| |
526 | 539 |
| |
| 540 | + | |
| 541 | + | |
527 | 542 |
| |
528 | 543 |
| |
529 | 544 |
| |
|
0 commit comments
Comments
(0)