Lists: | pgsql-hackers |
---|
From: | Rafael Martinez <r(dot)m(dot)guerrero(at)usit(dot)uio(dot)no> |
---|---|
To: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | psql --single-transaction does not work as expected |
Date: | 2013-08-13 14:04:50 |
Message-ID: | 520A3D02.1050300@usit.uio.no |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello
I want to report that psql --single-transaction does not work as one
can expect after reading the help information for psql.
psql --help says:
- -1 ("one"), --single-transaction: execute command file as a single
transaction
If you run "psql -1 < sql_file.sql" insteed of "psql -1 -f
sql_file.sql" the single-transaction parameter will not work.
Test case:
==========
CREATE DATABASE test;
\c test
CREATE TABLE check_psql(id int, code text);
\q
# cat check_psql.sql
INSERT INTO check_psql (id,code) VALUES (1,'code1');
INSERT INTO check_psql (id,code) VALUES (2,code2);
# psql -1 test -f check_psql.sql
INSERT 0 1
psql:check_psql.sql:2: ERROR: column "code2" does not exist
LINE 1: INSERT INTO check_psql (id,code) VALUES (2,code2);
^
# psql -1 test -c "SELECT * FROM check_psql"
id | code
- ----+------
(0 rows)
# psql -1 test < /tmp/check_psql.sql
INSERT 0 1
ERROR: column "code2" does not exist
LINE 1: INSERT INTO check_psql (id,code) VALUES (2,code2);
^
#psql -1 test -c "SELECT * FROM check_psql"
id | code
- ----+-------
1 | code1
(1 row)
The docs for psql at
http://www.postgresql.org/docs/current/static/app-psql.html
have the right information, ".... -1 --single-transaction
When psql executes a script with the -f option ...."
I think we should either update the psql --help information for
- --single-transaction and say that this parameter only works together
with -f or update the psql code so psql -1 < file.sql also works.
regards,
- --
Rafael Martinez Guerrero
Center for Information Technology
University of Oslo, Norway
PGP Public Key: http://folk.uio.no/rafael/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
iEYEARECAAYFAlIKPQEACgkQBhuKQurGihQaGwCggvy+Fgiw1TlseZKM8oq4U/na
cgQAnRN4sw9NHBajG57wL0P+08p6Nb3y
=cNHB
-----END PGP SIGNATURE-----
From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | Rafael Martinez <r(dot)m(dot)guerrero(at)usit(dot)uio(dot)no> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: psql --single-transaction does not work as expected |
Date: | 2013-08-13 14:20:42 |
Message-ID: | 20130813142042.GA3613@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Tue, Aug 13, 2013 at 04:04:50PM +0200, Rafael Martinez wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hello
>
> I want to report that psql --single-transaction does not work as one
> can expect after reading the help information for psql.
>
> psql --help says:
>
> - -1 ("one"), --single-transaction: execute command file as a single
> transaction
>
> If you run "psql -1 < sql_file.sql" insteed of "psql -1 -f
> sql_file.sql" the single-transaction parameter will not work.
This will be fixed in PG 9.3; from the release notes:
Allow the psql --single-transaction mode to work when
reading from standard input (Fabien Coelho, Robert Haas)
Previously this option only worked when reading from a file.
--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +