psql -c does not honor ON_ERROR_STOP

Поиск
Список
Период
Сортировка
От Joe Conway
Тема psql -c does not honor ON_ERROR_STOP
Дата
Msg-id 54AC2960.6070605@credativ.com
обсуждение исходный текст
Ответы Re: psql -c does not honor ON_ERROR_STOP  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This seems like either a psql bug or maybe just a documentation bug. I
know the psql docs say that -c behavior can be surprising, but I find
the below surprising even after reading the docs a couple of times.
Given that ON_ERROR_STOP defaults to off, it seems like these two
cases should both result in two rows inserted.

8<----------------------
SQL="begin; insert into foo values(1); commit; begin; insert into foo
values(1); commit; begin; insert into foo values(2); commit;"

psql test -c "drop table if exists foo"
psql test -c "create table foo(id int primary key)"

psql test -c "${SQL}"
ERROR:  duplicate key value violates unique constraint "foo_pkey"
DETAIL:  Key (id)=(1) already exists.
psql test -c "select * from foo"id
- ---- 1
(1 row)

psql test -c "truncate foo"
echo "${SQL}" | psql test
BEGIN
INSERT 0 1
COMMIT
BEGIN
ERROR:  duplicate key value violates unique constraint "foo_pkey"
DETAIL:  Key (id)=(1) already exists.
ROLLBACK
BEGIN
INSERT 0 1
COMMIT
psql test -c "select * from foo"id
- ---- 1 2
(2 rows)
8<----------------------

Thoughts?

Joe

- -- 
Joseph E Conway
credativ LLC

270 E Douglas Ave
El Cajon, CA 92020

Office: +1 619 270 8787
Mobile: +1 619 843 8340

===================================
USA:         http://www.credativ.us
Canada:      http://www.credativ.ca
Germany:     http://www.credativ.de
Netherlands: http://www.credativ.nl
UK:          http://www.credativ.co.uk
India:       http://www.credativ.in
===================================
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBAgAGBQJUrClgAAoJEDfy90M199hld0IP/2mFzLZqN+wfK3gfBF6qe0W/
8Q1UYLC9n8uAPCBHWnhVuy+ypSjOqqmCrQCBwR4I1wpF0ni7gRwcTJ2pGYf3rh1o
HVCGqWfduDtRrdOjUaGVkSaNGdc73IjLQ+WFRAmfFAVpBpc3GkyWT3PG2I4+81IY
mDRxMgvf7n3NgzdKiCO7tci4dw4vvFOsmgCSA8opacYD/wPlx+IWGCr8uU6Ub9f7
S0ouKCTmfCGVzDjNs0HKkTtVrGmjqeS4c3dl56mFJf8Tuc0t9S2wSDUW2DmYWHu/
+zTLLo8XOzUnP6Uz1DXLzt4tBJSjNBgEgVx6OVe/MUdM/6+nrlI1VVHEC2EWZSEf
5OisX4kkIY1eqLj8ffTWUlCnyPFCb/5L3zVGFvxWL+FsenOxgTzrpGwEdPlOea1O
GYchUJlHT90CyTpqb/xHHpyhgy3u2raWTgD2lXgDJnzyUCrWSXXalgadrpyT6DnZ
JpIBW2vh00boOQOAy5yFwFFZ6r8XcUJzZEZbAdbsUY9f7BGq23mrrEW9QgEzj5VX
LEr8EKEK8VAa9VByBTl9Dch0MtcIP+8t9xYOhuF+winRujDpgrMIYiFjy0lhogWj
I885fWTU4sHWDOVOAxbVMILji+b6jALRuCQ6QcDq5Gx6ZIZeSZHfLGVNZO5LyxWR
gh8B3yMsshnNm3wCDrr/
=Te2e
-----END PGP SIGNATURE-----



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

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: Transactions involving multiple postgres foreign servers
Следующее
От: Tom Lane
Дата:
Сообщение: Re: psql -c does not honor ON_ERROR_STOP