RE: set autocommit only for select statements

Поиск
Список
Период
Сортировка
От Michel SALAIS
Тема RE: set autocommit only for select statements
Дата
Msg-id 005201d84e4b$dce0e6b0$96a2b410$@msym.fr
обсуждение исходный текст
Ответ на Re: set autocommit only for select statements  (Holger Jakobs <holger@jakobs.com>)
Ответы Re: set autocommit only for select statements  (Mladen Gogala <gogala.mladen@gmail.com>)
Список pgsql-admin

-----Message d'origine-----
De : Holger Jakobs <holger@jakobs.com>
Envoyé : mardi 12 avril 2022 08:31
À : pgsql-admin@lists.postgresql.org
Objet : Re: set autocommit only for select statements

Am 12.04.22 um 03:53 schrieb Mladen Gogala:
>
> The "autocommit" is a tool option which tells the tool whether to add
> "COMMIT" statement after each and every SQL. The RDBMS server only
> knows about transactions, as mandated by the ACID compliance. What the
> "autocommit" option of tools like psql actually does is to turn each
> of your SQL statements into a separate transaction.
>
What you write about psql sending a COMMIT statement after each statement is wrong. It may be true for other database
systems.

PostgreSQL as a server commits each statement automatically unless the client has started a transaction with BEGIN or
STARTTRANSACTION statements. 

This can be proved easily by not using psql as a client, but some programming language.

Regards,

Holger


-- Holger Jakobs, Bergisch Gladbach, Tel. +49-178-9759012
-----------------------------------------------------------------------------------


Hi,
It is a little more "complex" :-)
A session can be put in AUTOCOMMIT mode or transaction mode. Tool "psql" is by default in AUTOCOMMIT mode and can be
putin transaction mode using  
\set AUTOCOMMIT off

Pay attention to the variable case. It should be in capital letters. When this is done, You don't need to start
transactionsexplicitly and the server behaves like Oracle but it is not an identical behavior. Other points matter like
thereaction to errors when in a transaction...  

Other programming environments could choose another default operating mode and however can offer to choose the
operatingmode at connection. 


Michel SALAIS





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

Предыдущее
От: Holger Jakobs
Дата:
Сообщение: Re: set autocommit only for select statements
Следующее
От: Mladen Gogala
Дата:
Сообщение: Re: set autocommit only for select statements