Обсуждение: enforcing transaction mode for read-write queries.

Поиск
Список
Период
Сортировка

enforcing transaction mode for read-write queries.

От
Rajesh Kumar Mallah
Дата:
Hi ,

We are a PerlDBI shop and  and are  doing a code migration from
implicit transaction mode (ie, AutoCommit=>0)  to an explicit mode (ie, AutoCommit=>1) .

While the code migration is ongoing (or even permanently)  We wish that postgresql reject
any UPDATE , DELETE , INSERT , nextval ,  setval etc unless the session is in a transaction
mode . ie they should be preceded by an explicit "BEGIN work;". This shall immensely help
us to prevent many bugs in the migration.

Is there any way to accomplish that ? Any help shall be greatly appreciated.

regds
Rajesh Kumar Mallah.

Re: enforcing transaction mode for read-write queries.

От
David Johnston
Дата:
On Sep 30, 2012, at 22:22, Rajesh Kumar Mallah <mallah.rajesh@gmail.com> wrote:

> Hi ,
>
> We are a PerlDBI shop and  and are  doing a code migration from
> implicit transaction mode (ie, AutoCommit=>0)  to an explicit mode (ie, AutoCommit=>1) .
>
> While the code migration is ongoing (or even permanently)  We wish that postgresql reject
> any UPDATE , DELETE , INSERT , nextval ,  setval etc unless the session is in a transaction
> mode . ie they should be preceded by an explicit "BEGIN work;". This shall immensely help
> us to prevent many bugs in the migration.
>
> Is there any way to accomplish that ? Any help shall be greatly appreciated.
>
> regds
> Rajesh Kumar

http://www.postgresql.org/docs/9.0/static/runtime-config-client.html

default_transaction_read_only

Set this to true for the database then whenever you actually want to allow modification you override it on a
per-transactionbasis. 

David J.




Re: enforcing transaction mode for read-write queries.

От
Rajesh Kumar Mallah
Дата:
A gem it was i just needed that . Thanks! I tested and it serves my purpose.

On Mon, Oct 1, 2012 at 8:54 AM, David Johnston <polobo@yahoo.com> wrote:
On Sep 30, 2012, at 22:22, Rajesh Kumar Mallah <mallah.rajesh@gmail.com> wrote:

> Hi ,
>
> We are a PerlDBI shop and  and are  doing a code migration from
> implicit transaction mode (ie, AutoCommit=>0)  to an explicit mode (ie, AutoCommit=>1) .
>
> While the code migration is ongoing (or even permanently)  We wish that postgresql reject
> any UPDATE , DELETE , INSERT , nextval ,  setval etc unless the session is in a transaction
> mode . ie they should be preceded by an explicit "BEGIN work;". This shall immensely help
> us to prevent many bugs in the migration.
>
> Is there any way to accomplish that ? Any help shall be greatly appreciated.
>
> regds
> Rajesh Kumar

http://www.postgresql.org/docs/9.0/static/runtime-config-client.html

default_transaction_read_only

Set this to true for the database then whenever you actually want to allow modification you override it on a per-transaction basis.

David J.