Commit 1b62d0f
committed
Allow psql to re-use connection parameters after a connection loss.
Instead of immediately PQfinish'ing a dead connection, save it aside
so that we can still extract its parameters for \connect attempts.
(This works because PQconninfo doesn't care whether the PGconn is in
CONNECTION_BAD state.) This allows developers to reconnect with
just \c after a database crash and restart.
It's tempting to use the same approach instead of closing the old
connection after a failed non-interactive \connect command. However,
that would not be very safe: consider a script containing
\c db1 user1 live_server
\c db2 user2 dead_server
\c db3
The script would be expecting to connect to db3 at dead_server, but
if we re-use parameters from the first connection then it might
successfully connect to db3 at live_server. This'd defeat the goal
of not letting a script accidentally execute commands against the
wrong database.
Discussion: https://postgr.es/m/38464.1603394584@sss.pgh.pa.us1 parent 860593e commit 1b62d0f
File tree
6 files changed
+73
-26
lines changed- doc/src/sgml/ref
- src/bin/psql
6 files changed
+73
-26
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
931 | 931 | | |
932 | 932 | | |
933 | 933 | | |
934 | | - | |
935 | | - | |
936 | | - | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
937 | 940 | | |
938 | 941 | | |
939 | 942 | | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
940 | 951 | | |
941 | 952 | | |
942 | 953 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3060 | 3060 | | |
3061 | 3061 | | |
3062 | 3062 | | |
3063 | | - | |
3064 | | - | |
3065 | | - | |
3066 | | - | |
3067 | | - | |
3068 | | - | |
3069 | | - | |
3070 | | - | |
3071 | | - | |
3072 | | - | |
3073 | 3063 | | |
3074 | 3064 | | |
3075 | | - | |
3076 | | - | |
3077 | | - | |
3078 | | - | |
3079 | | - | |
| 3065 | + | |
| 3066 | + | |
| 3067 | + | |
| 3068 | + | |
| 3069 | + | |
| 3070 | + | |
3080 | 3071 | | |
3081 | 3072 | | |
3082 | | - | |
| 3073 | + | |
| 3074 | + | |
| 3075 | + | |
| 3076 | + | |
| 3077 | + | |
| 3078 | + | |
| 3079 | + | |
| 3080 | + | |
| 3081 | + | |
| 3082 | + | |
| 3083 | + | |
| 3084 | + | |
3083 | 3085 | | |
3084 | 3086 | | |
3085 | 3087 | | |
| |||
3360 | 3362 | | |
3361 | 3363 | | |
3362 | 3364 | | |
3363 | | - | |
3364 | | - | |
| 3365 | + | |
| 3366 | + | |
| 3367 | + | |
| 3368 | + | |
| 3369 | + | |
| 3370 | + | |
| 3371 | + | |
3365 | 3372 | | |
3366 | 3373 | | |
3367 | 3374 | | |
3368 | 3375 | | |
3369 | 3376 | | |
3370 | 3377 | | |
| 3378 | + | |
| 3379 | + | |
| 3380 | + | |
| 3381 | + | |
| 3382 | + | |
| 3383 | + | |
| 3384 | + | |
3371 | 3385 | | |
3372 | 3386 | | |
3373 | 3387 | | |
| |||
3421 | 3435 | | |
3422 | 3436 | | |
3423 | 3437 | | |
| 3438 | + | |
3424 | 3439 | | |
3425 | 3440 | | |
| 3441 | + | |
| 3442 | + | |
| 3443 | + | |
| 3444 | + | |
| 3445 | + | |
| 3446 | + | |
3426 | 3447 | | |
3427 | 3448 | | |
3428 | 3449 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
313 | 313 | | |
314 | 314 | | |
315 | 315 | | |
316 | | - | |
317 | | - | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
318 | 320 | | |
319 | | - | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
320 | 324 | | |
321 | 325 | | |
322 | 326 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2744 | 2744 | | |
2745 | 2745 | | |
2746 | 2746 | | |
2747 | | - | |
| 2747 | + | |
2748 | 2748 | | |
2749 | 2749 | | |
2750 | 2750 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
120 | 127 | | |
121 | 128 | | |
122 | 129 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
| 148 | + | |
148 | 149 | | |
149 | 150 | | |
150 | 151 | | |
| |||
442 | 443 | | |
443 | 444 | | |
444 | 445 | | |
445 | | - | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
446 | 450 | | |
447 | 451 | | |
448 | 452 | | |
| |||
0 commit comments