Re: Set readonly transaction per transaction

From: Kevin Grittner <kgrittn(at)ymail(dot)com>
To: Alexandor84 <oleksandr(dot)sukhotskyi(at)gmail(dot)com>, "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Set readonly transaction per transaction
Date: 2014-12-10 15:37:54
Message-ID: 155582596.4848118.1418225874525.JavaMail.yahoo@jws100188.mail.ne1.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Alexandor84 <oleksandr(dot)sukhotskyi(at)gmail(dot)com> wrote:

> AFAIK PgBouncer in transaction mode is not compatible with any
> SET statements.

It is compatible with any SET statements which don't leave a
persistent state beyond the end of the transaction. That includes
any SET LOCAL as well as a few SET options which only affect the
current transaction, like transaction_isolation,
transaction_read_only, and transaction_deferrable (note that these
three have a default_* setting which persists beyond transaction
boundaries -- those defaults are *not* safe to use).

For example, running through pgbouncer configured for transaction
mode:

test=# show transaction_read_only;
transaction_read_only
-----------------------
off
(1 row)

test=# begin;
BEGIN
test=# set transaction_read_only = on;
SET
test=# show transaction_read_only;
transaction_read_only
-----------------------
on
(1 row)

test=# select count(*) from pg_class;
count
-------
299
(1 row)

test=# commit;
COMMIT
test=# show transaction_read_only;
transaction_read_only
-----------------------
off
(1 row)

There's probably some room for improvements in the pgbouncer
documentation on this point.

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Devrim Gündüz 2014-12-16 23:19:18 9.4 driver
Previous Message Dave Cramer 2014-12-10 14:21:26 Re: Infinite waitOnLock