Re: Re: incorrect exit code from psql with single transaction + violation of deferred FK constraint

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: Re: incorrect exit code from psql with single transaction + violation of deferred FK constraint
Дата
Msg-id 201003080030.o280UIY26032@momjian.us
обсуждение исходный текст
Ответ на Re: Re: incorrect exit code from psql with single transaction + violation of deferred FK constraint  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Re: incorrect exit code from psql with single transaction + violation of deferred FK constraint  (Bruce Momjian <bruce@momjian.us>)
Список pgsql-hackers
Tom Lane wrote:
> Bruce Momjian <bruce@momjian.us> writes:
> > The attached patch checks for the proper return from BEGIN/COMMIT, and
> > properly frees the libpq structures.  In testing, this does return 3 as
> > you expected.
>
> Really?  It looks to me like you'd get exit(1).  Maybe that's the right
> thing, but MainLoop itself seems to return EXIT_USER not EXIT_FAILURE
> when it gets an error.

Sorry, you are right.  I must have mis-read my tests.  Updated patch
attached.

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  PG East:  http://www.enterprisedb.com/community/nav-pg-east-2010.do
Index: src/bin/psql/command.c
===================================================================
RCS file: /cvsroot/pgsql/src/bin/psql/command.c,v
retrieving revision 1.216
diff -c -c -r1.216 command.c
*** src/bin/psql/command.c    26 Feb 2010 02:01:17 -0000    1.216
--- src/bin/psql/command.c    8 Mar 2010 00:29:26 -0000
***************
*** 1731,1740 ****
--- 1731,1752 ----
      pset.inputfile = filename;

      if (single_txn)
+     {
          res = PSQLexec("BEGIN", false);
+         if (!res)
+             return EXIT_USER;
+         PQclear(res);
+     }
+
      result = MainLoop(fd);
+
      if (single_txn)
+     {
          res = PSQLexec("COMMIT", false);
+         if (!res)
+             return EXIT_USER;
+         PQclear(res);
+     }

      fclose(fd);
      pset.inputfile = oldfilename;

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Re: incorrect exit code from psql with single transaction + violation of deferred FK constraint
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: Re: incorrect exit code from psql with single transaction + violation of deferred FK constraint