Re: Understanding autocommit

From: "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: "Chris Angelico *EXTERN*" <rosuav(at)gmail(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Understanding autocommit
Date: 2012-08-22 08:52:08
Message-ID: D960CB61B694CF459DCFB4B0128514C2084EF456@exadv11.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Chris Angelico wrote:
> I'm looking at these two pages:
>
> http://www.postgresql.org/docs/9.1/static/ecpg-sql-set-autocommit.html
> http://www.postgresql.org/docs/9.1/static/sql-start-transaction.html
>
> According to the first page, autocommit is off by default for
> "embedded SQL programs". Does this mean everything except the 'psql'
> command line interpreter, or is that some special case, and most
> programs default to autocommit on?
>
> Currently, I have explicit 'begin' statements in all our code. What
> I'd like to achieve is DB2-style semantics where a transaction is
> automatically and implicitly opened as soon as any query is performed,
> and that transaction remains until committed or rolled back (or until
> end of session implicit rollback).
>
> I'm sure there's something really obvious here, but... how do I find
> out whether my program's running in autocommit mode or not?

An "embedded SQL program" is a program written in C that makes use
of ecpg.

The server itself has autocommit, so every program that uses
PostgreSQL will be in autocommit mode by default.

The only way around that are explicit BEGIN or START TRANSACTION
commands (which is what ecpg uses).

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message hubert depesz lubaczewski 2012-08-22 09:00:36 Re: Problems with timestamp with time zone and old dates?
Previous Message Chris Angelico 2012-08-22 08:33:25 Understanding autocommit