Re: display hot standby state in psql prompt

Поиск
Список
Период
Сортировка
От Greg Sabino Mullane
Тема Re: display hot standby state in psql prompt
Дата
Msg-id CAKAnmmLf3Qpv54zM2u5N5XbbGDONtiz3F6yhM142O2mdQ3=f_A@mail.gmail.com
обсуждение исходный текст
Ответ на Re: display hot standby state in psql prompt  (Jim Jones <jim.jones@uni-muenster.de>)
Список pgsql-hackers
On Wed, Jun 25, 2025 at 11:50 AM Jim Jones <jim.jones@uni-muenster.de> wrote:
Since I cannot get the value of transaction_read_only via PQparameterStatus.

Hmmm... we can at least get default_transaction_read_only. As fe-connect.c points out:
                    /*
                     * "transaction_read_only = on" proves that at least one
                     * of default_transaction_read_only and in_hot_standby is
                     * on, but we don't actually know which.  We don't care
                     * though for the purpose of identifying a read-only
                     * session, so satisfy the CONNECTION_CHECK_TARGET code by
                     * claiming they are both on.  On the other hand, if it's
                     * a read-write session, they are certainly both off.
                     */
Maybe that's good enough? It won't detect people starting a new transaction and declaring it read-only, but it should be sufficient to warn people when a connection is starting out in a read-only state. And it will still toggle auto-magically on promotion.

Cheers,
Greg

--
Enterprise Postgres Software Products & Tech Support

В списке pgsql-hackers по дате отправления: