On 21.07.25 21:12, Greg Sabino Mullane wrote: > Seems good enough for me. I think as long as we document it well, it's > only going to be a net positive, even with some edge cases.
I just moved the patch from PG19-Drafts to PG19-2 commitfest.[1]
+1 for the patch,i have reviewed and tested this patch, except these below cosmetic changes it LGTM.
cosmetic changes: 1) add comment about %i in get_prompt api. 2) maybe we can use read-write instead of read/write to be consistent with the naming such as options of target_session_attrs uses read-write.
testing:
=> in primary node:
psql (19devel) Type "help" for help.
postgres=# \set PROMPT1 '[%i] # ' [read/write] # set default_transaction_read_only=on; SET [read-only] # set default_transaction_read_only=off; SET [read/write] # show in_hot_standby ; in_hot_standby ---------------- off (1 row)
[read/write] # set default_transaction_read_only=on; SET [read-only] # show in_hot_standby ; in_hot_standby ---------------- off (1 row)
[read-only] # \q
=> in replica node
psql (19devel) Type "help" for help.
postgres=# \set PROMPT1 '[%i] # ' [read-only] # show in_hot_standby ; in_hot_standby ---------------- on (1 row)
[read-only] # show default_transaction_read_only; default_transaction_read_only ------------------------------- off (1 row)
[read-only] # set default_transaction_read_only=on; SET [read-only] # set transaction_read_only=on; SET [read-only] # set transaction_read_only=off; ERROR: cannot set transaction read-write mode during recovery [read-only] # select pg_promote(); pg_promote ------------ t (1 row)
[read-only] # show in_hot_standby ; in_hot_standby ---------------- off (1 row)
[read-only] # show default_transaction_read_only; default_transaction_read_only ------------------------------- on (1 row)
[read-only] # set default_transaction_read_only=off; SET [read/write] #