Thread: Autocomit off in psql don't work

Autocomit off in psql don't work

From
Olleg
Date:
SuSE Linux 8.2 (i586)
PostgreSQL REL7_4_STABLE (cvs), 7.4
compiled with:
gcc (GCC) 3.3 20030226 (prerelease) (SuSE Linux)
flex version 2.5.4
bison (GNU Bison) 1.875
PostgreSQL config.status 7.4
configured by ./configure, generated by GNU Autoconf 2.53,
   with options "'--prefix=/opt/pgsql' '--enable-integer-datetimes'
'--enable-thread-safety' '--disable-largefile' '--with-java'
'--with-pam' '--with-openss' '--with-gnu-ld'"

To repeat:

$ /opt/pgsql/bin/psql
Welcome to psql 7.4, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
        \h for help with SQL commands
        \? for help on internal slash commands
        \g or terminate with semicolon to execute query
        \q to quit

olleg=# \set
VERSION = 'PostgreSQL 7.4 on i686-pc-linux-gnu, compiled by GCC gcc
(GCC) 3.3 20030226 (prerelease) (SuSE Linux)'
AUTOCOMMIT = 'on'
VERBOSITY = 'default'
DBNAME = 'olleg'
USER = 'olleg'
PORT = '5432'
ENCODING = 'KOI8'
PROMPT1 = '%/%R%# '
PROMPT2 = '%/%R%# '
PROMPT3 = '>> '
HISTSIZE = '500'
olleg=# \set AUTOCOMMIT OFF
olleg=# \set
VERSION = 'PostgreSQL 7.4 on i686-pc-linux-gnu, compiled by GCC gcc
(GCC) 3.3 20030226 (prerelease) (SuSE Linux)'
AUTOCOMMIT = 'OFF'
VERBOSITY = 'default'
DBNAME = 'olleg'
USER = 'olleg'
PORT = '5432'
ENCODING = 'KOI8'
PROMPT1 = '%/%R%# '
PROMPT2 = '%/%R%# '
PROMPT3 = '>> '
HISTSIZE = '500'
olleg=# begin;
BEGIN
olleg=# select now();
               now
-------------------------------
  2003-11-28 18:15:59.063438+03
(1 row)

olleg=# select now();
               now
-------------------------------
  2003-11-28 18:15:59.063438+03
(1 row)
olleg=# commit;
COMMIT
olleg=# select now();
               now
-------------------------------
  2003-11-28 18:16:42.484651+03
(1 row)

olleg=# select now();
               now
-------------------------------
  2003-11-28 18:16:43.085406+03
(1 row)
olleg=# commit;
WARNING:  there is no transaction in progress
COMMIT

--
Olleg

Re: Autocomit off in psql don't work

From
Tom Lane
Date:
Olleg <olleg@jane.telecom.mipt.ru> writes:
> olleg=# \set AUTOCOMMIT OFF

It has to be

    \set AUTOCOMMIT off

Not sure if we should be more flexible about this or not.  The code says

    /*
     * for backwards compatibility, anything except "off" is taken as
     * "true"
     */


            regards, tom lane

Re: Autocomit off in psql don't work

From
Bruce Momjian
Date:
Tom Lane wrote:
> Olleg <olleg@jane.telecom.mipt.ru> writes:
> > olleg=# \set AUTOCOMMIT OFF
>
> It has to be
>
>     \set AUTOCOMMIT off
>
> Not sure if we should be more flexible about this or not.  The code says
>
>     /*
>      * for backwards compatibility, anything except "off" is taken as
>      * "true"
>      */

That seems pretty strange to me.  Is this a TODO?

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073