Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb989662

Browse files
committed
Return proper exit code (3) from psql when ON_ERROR_STOP=on and
--single-transaction are both used and the failure happens in commit,e.g. failed deferred trigger. Also properly free BEGIN/COMMIT resultstructures from --single-transaction.Per report from Dominic Bevacqua
1 parentaa8eed3 commitb989662

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

‎src/bin/psql/command.c

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2010, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.216 2010/02/26 02:01:17 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.217 2010/03/08 23:03:00 momjian Exp $
77
*/
88
#include"postgres_fe.h"
99
#include"command.h"
@@ -1731,10 +1731,28 @@ process_file(char *filename, bool single_txn)
17311731
pset.inputfile=filename;
17321732

17331733
if (single_txn)
1734-
res=PSQLexec("BEGIN", false);
1734+
{
1735+
if ((res=PSQLexec("BEGIN", false))==NULL)
1736+
{
1737+
if (pset.on_error_stop)
1738+
returnEXIT_USER;
1739+
}
1740+
else
1741+
PQclear(res);
1742+
}
1743+
17351744
result=MainLoop(fd);
1745+
17361746
if (single_txn)
1737-
res=PSQLexec("COMMIT", false);
1747+
{
1748+
if ((res=PSQLexec("COMMIT", false))==NULL)
1749+
{
1750+
if (pset.on_error_stop)
1751+
returnEXIT_USER;
1752+
}
1753+
else
1754+
PQclear(res);
1755+
}
17381756

17391757
fclose(fd);
17401758
pset.inputfile=oldfilename;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp