From Andrew.Clark@fnf.com Mon Sep 19 18:01:18 2005 X-Original-To: pgsql-ports-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B7BB9D93D4 for ; Mon, 19 Sep 2005 15:01:18 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 38032-07 for ; Mon, 19 Sep 2005 18:01:10 +0000 (GMT) Received: from lmxfislrext.fnfis.com (lmxfislrext.fnfis.com [162.39.178.131]) by svr1.postgresql.org (Postfix) with ESMTP id 2509CD9345 for ; Mon, 19 Sep 2005 15:01:09 -0300 (ADT) Received: from sbhfislrgw02.FNFIS.COM ([10.132.201.42]) by lmxfislrext.fnfis.com (8.12.11/8.12.11) with ESMTP id j8JI194u032162 for ; Mon, 19 Sep 2005 13:01:09 -0500 Received: from CMBFISLR01.FNFIS.COM ([10.132.201.13]) by sbhfislrgw02.FNFIS.COM with Microsoft SMTPSVC(5.0.2195.6713); Mon, 19 Sep 2005 13:01:09 -0500 Received: from smbfisyyz01.FNFIS.COM ([10.66.0.28]) by CMBFISLR01.FNFIS.COM with Microsoft SMTPSVC(5.0.2195.6713); Mon, 19 Sep 2005 13:01:09 -0500 X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 content-class: urn:content-classes:message Subject: Solaris - psql returns 0 instead of 1 for file not found. MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C5BD44.19649C08" Date: Mon, 19 Sep 2005 13:01:03 -0500 Message-ID: <74825F195D477C4995425A1313D646B114A923@smbfisyyz01.FNFIS.COM> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Solaris - psql returns 0 instead of 1 for file not found. Thread-Index: AcW9RB0XgEsLbj1eRwSSXAuLIe0hmg== From: "Clark, Andrew" To: X-OriginalArrivalTime: 19 Sep 2005 18:01:09.0599 (UTC) FILETIME=[1D3E86F0:01C5BD44] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.181 required=5 tests=[AWL=-0.597, DNS_FROM_RFC_ABUSE=0.374, DNS_FROM_RFC_POST=1.376, HTML_60_70=0.027, HTML_MESSAGE=0.001] X-Spam-Level: * X-Archive-Number: 200509/13 X-Sequence-Number: 2207 This is a multi-part message in MIME format. ------_=_NextPart_001_01C5BD44.19649C08 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi all, I've found the when psql is used with the -f flag and the specified file doesn't exist the rc value is 0. $ uname -a SunOS bld 5.8 Generic_108528-29 sun4u sparc SUNW,Sun-Fire-V440 $ psql -V psql (PostgreSQL) 8.0.2 $ ls foo foo: No such file or directory $ psql -f foo foo: No such file or directory =20 $ echo $? 0 However, in the man page for psql it says: EXIT STATUS psql returns 0 to the shell if it finished normally, 1 if a fatal error of its own (out of memory, file not found) occurs, ... I'm assuming this is the same with other platforms, but I only use PostgreSQL on Solaris. Has this been fix in 8.0.3? Cheers, Andrew ------_=_NextPart_001_01C5BD44.19649C08 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Solaris - psql returns 0 instead of 1 for file not found.

Hi all,

I've found the when psql is used with = the -f flag and the specified file doesn't exist the rc value is = 0.

$ uname -a
SunOS bld 5.8 Generic_108528-29 = sun4u sparc SUNW,Sun-Fire-V440

$ psql -V
psql (PostgreSQL) 8.0.2

$ ls foo
foo: No such file or = directory

$ psql -f foo
foo: No such file or = directory
 
$ echo $?
0

However, in the = man page for psql it says:

EXIT = STATUS
     psql returns 0 to the shell if it finished = normally, 1 if  a
     fatal  error  of  its  = own  (out  of memory, file not found)
     occurs, ...

I'm assuming this = is the same with other platforms, but I only use PostgreSQL on = Solaris.

Has this been fix = in 8.0.3?

Cheers,
Andrew

------_=_NextPart_001_01C5BD44.19649C08-- From pgman@candle.pha.pa.us Tue Sep 20 19:01:03 2005 X-Original-To: pgsql-patches-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6D09DD93EA; Tue, 20 Sep 2005 16:01:03 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 28286-07; Tue, 20 Sep 2005 19:00:58 +0000 (GMT) Received: from candle.pha.pa.us (candle.pha.pa.us [64.139.89.126]) by svr1.postgresql.org (Postfix) with ESMTP id BA6EFD9390; Tue, 20 Sep 2005 16:00:56 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id j8KJ0uh11335; Tue, 20 Sep 2005 15:00:56 -0400 (EDT) From: Bruce Momjian Message-Id: <200509201900.j8KJ0uh11335@candle.pha.pa.us> Subject: Re: [PORTS] Solaris - psql returns 0 instead of 1 for file not found. In-Reply-To: <74825F195D477C4995425A1313D646B114A923@smbfisyyz01.FNFIS.COM> To: "Clark, Andrew" Date: Tue, 20 Sep 2005 15:00:56 -0400 (EDT) Cc: pgsql-ports@postgresql.org, PostgreSQL-patches X-Mailer: ELM [version 2.4ME+ PL121 (25)] MIME-Version: 1.0 Content-Type: multipart/mixed; boundary=ELM1127242856-9434-0_ Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.01 required=5 tests=[AWL=0.010] X-Spam-Level: X-Archive-Number: 200509/89 X-Sequence-Number: 17434 --ELM1127242856-9434-0_ Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII I have applied the following patch to 8.1beta and 8.0.X to return the proper failure value for a psql -f filename open failure. The bug was that process_file() was returning false for failure, while the call site expected MainLoop() return values, meaning false/0 was success. --------------------------------------------------------------------------- Clark, Andrew wrote: > Hi all, > > I've found the when psql is used with the -f flag and the specified file > doesn't exist the rc value is 0. > > $ uname -a > SunOS bld 5.8 Generic_108528-29 sun4u sparc SUNW,Sun-Fire-V440 > > $ psql -V > psql (PostgreSQL) 8.0.2 > > $ ls foo > foo: No such file or directory > > $ psql -f foo > foo: No such file or directory > > $ echo $? > 0 > > However, in the man page for psql it says: > > EXIT STATUS > psql returns 0 to the shell if it finished normally, 1 if a > fatal error of its own (out of memory, file not found) > occurs, ... > > I'm assuming this is the same with other platforms, but I only use > PostgreSQL on Solaris. > > Has this been fix in 8.0.3? > > Cheers, > Andrew -- 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 --ELM1127242856-9434-0_ Content-Transfer-Encoding: 7bit Content-Type: text/plain Content-Disposition: inline; filename="/bjm/diff" Index: src/bin/psql/command.c =================================================================== RCS file: /cvsroot/pgsql/src/bin/psql/command.c,v retrieving revision 1.152 diff -c -c -r1.152 command.c *** src/bin/psql/command.c 14 Aug 2005 18:49:30 -0000 1.152 --- src/bin/psql/command.c 20 Sep 2005 18:43:41 -0000 *************** *** 1314,1320 **** * process_file * * Read commands from filename and then them to the main processing loop ! * Handler for \i, but can be used for other things as well. */ int process_file(char *filename) --- 1314,1321 ---- * process_file * * Read commands from filename and then them to the main processing loop ! * Handler for \i, but can be used for other things as well. Returns ! * MainLoop() error code. */ int process_file(char *filename) *************** *** 1324,1330 **** char *oldfilename; if (!filename) ! return false; canonicalize_path(filename); fd = fopen(filename, PG_BINARY_R); --- 1325,1331 ---- char *oldfilename; if (!filename) ! return EXIT_FAILURE; canonicalize_path(filename); fd = fopen(filename, PG_BINARY_R); *************** *** 1332,1338 **** if (!fd) { psql_error("%s: %s\n", filename, strerror(errno)); ! return false; } oldfilename = pset.inputfile; --- 1333,1339 ---- if (!fd) { psql_error("%s: %s\n", filename, strerror(errno)); ! return EXIT_FAILURE; } oldfilename = pset.inputfile; Index: src/bin/psql/startup.c =================================================================== RCS file: /cvsroot/pgsql/src/bin/psql/startup.c,v retrieving revision 1.122 diff -c -c -r1.122 startup.c *** src/bin/psql/startup.c 5 Sep 2005 18:05:13 -0000 1.122 --- src/bin/psql/startup.c 20 Sep 2005 18:43:41 -0000 *************** *** 690,698 **** sprintf(psqlrc, "%s-%s", filename, PG_VERSION); if (access(psqlrc, R_OK) == 0) ! process_file(psqlrc); else if (access(filename, R_OK) == 0) ! process_file(filename); free(psqlrc); } --- 690,698 ---- sprintf(psqlrc, "%s-%s", filename, PG_VERSION); if (access(psqlrc, R_OK) == 0) ! (void)process_file(psqlrc); else if (access(filename, R_OK) == 0) ! (void)process_file(filename); free(psqlrc); } --ELM1127242856-9434-0_-- From xzilla@users.sourceforge.net Thu Sep 22 16:00:24 2005 X-Original-To: pgsql-bugs-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B44B1DA951; Thu, 22 Sep 2005 13:00:24 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 08509-04; Thu, 22 Sep 2005 16:00:22 +0000 (GMT) Received: from eastrmmtao05.cox.net (eastrmmtao05.cox.net [68.230.240.34]) by svr1.postgresql.org (Postfix) with ESMTP id 08544DA946; Thu, 22 Sep 2005 13:00:19 -0300 (ADT) Received: from [192.168.0.17] (really [68.105.164.251]) by eastrmmtao05.cox.net (InterMail vM.6.01.05.02 201-2131-123-102-20050715) with ESMTP id <20050922160009.VPRH24048.eastrmmtao05.cox.net@[192.168.0.17]>; Thu, 22 Sep 2005 12:00:09 -0400 From: Robert Treat Reply-To: pgsql-bugs@postgresql.org To: pgsql-ports@postgresql.org, pgsql-bugs@postgresql.org Subject: Re: [PORTS] Solaris - psql returns 0 instead of 1 for file not found. Date: Thu, 22 Sep 2005 12:00:08 -0400 User-Agent: KMail/1.6.2 Cc: "Clark, Andrew" References: <74825F195D477C4995425A1313D646B114A923@smbfisyyz01.FNFIS.COM> In-Reply-To: <74825F195D477C4995425A1313D646B114A923@smbfisyyz01.FNFIS.COM> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <200509221200.08227.xzilla@users.sourceforge.net> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.039 required=5 tests=[AWL=0.039] X-Spam-Level: X-Archive-Number: 200509/148 X-Sequence-Number: 12888 On Monday 19 September 2005 14:01, Clark, Andrew wrote: > Hi all, > > I've found the when psql is used with the -f flag and the specified file > doesn't exist the rc value is 0. > > $ uname -a > SunOS bld 5.8 Generic_108528-29 sun4u sparc SUNW,Sun-Fire-V440 > > $ psql -V > psql (PostgreSQL) 8.0.2 > > $ ls foo > foo: No such file or directory > > $ psql -f foo > foo: No such file or directory > > $ echo $? > 0 > > However, in the man page for psql it says: > > EXIT STATUS > psql returns 0 to the shell if it finished normally, 1 if a > fatal error of its own (out of memory, file not found) > occurs, ... > > I'm assuming this is the same with other platforms, but I only use > PostgreSQL on Solaris. > > Has this been fix in 8.0.3? > Redirecting to -bugs since I've confirmed this behavior on Slackware Linux 10 with psql version 8.1beta1 and there does seem to be something wrong with the above situation (perhaps the man page needs to be reworded?) -- Robert Treat Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL From pgman@candle.pha.pa.us Thu Sep 22 16:04:00 2005 X-Original-To: pgsql-bugs-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D50D6DA962; Thu, 22 Sep 2005 13:04:00 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 08509-10; Thu, 22 Sep 2005 16:03:52 +0000 (GMT) Received: from candle.pha.pa.us (candle.pha.pa.us [64.139.89.126]) by svr1.postgresql.org (Postfix) with ESMTP id 9596ADA946; Thu, 22 Sep 2005 13:03:50 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id j8MG3pr22924; Thu, 22 Sep 2005 12:03:51 -0400 (EDT) From: Bruce Momjian Message-Id: <200509221603.j8MG3pr22924@candle.pha.pa.us> Subject: Re: [PORTS] Solaris - psql returns 0 instead of 1 for file not found. In-Reply-To: <200509221200.08227.xzilla@users.sourceforge.net> To: pgsql-bugs@postgresql.org Date: Thu, 22 Sep 2005 12:03:51 -0400 (EDT) Cc: pgsql-ports@postgresql.org, "Clark, Andrew" X-Mailer: ELM [version 2.4ME+ PL121 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.01 required=5 tests=[AWL=0.010] X-Spam-Level: X-Archive-Number: 200509/149 X-Sequence-Number: 12889 A patch has been applied and this will be fixed in 8.0.4 and 8.1beta3. --------------------------------------------------------------------------- Robert Treat wrote: > On Monday 19 September 2005 14:01, Clark, Andrew wrote: > > Hi all, > > > > I've found the when psql is used with the -f flag and the specified file > > doesn't exist the rc value is 0. > > > > $ uname -a > > SunOS bld 5.8 Generic_108528-29 sun4u sparc SUNW,Sun-Fire-V440 > > > > $ psql -V > > psql (PostgreSQL) 8.0.2 > > > > $ ls foo > > foo: No such file or directory > > > > $ psql -f foo > > foo: No such file or directory > > > > $ echo $? > > 0 > > > > However, in the man page for psql it says: > > > > EXIT STATUS > > psql returns 0 to the shell if it finished normally, 1 if a > > fatal error of its own (out of memory, file not found) > > occurs, ... > > > > I'm assuming this is the same with other platforms, but I only use > > PostgreSQL on Solaris. > > > > Has this been fix in 8.0.3? > > > > Redirecting to -bugs since I've confirmed this behavior on Slackware Linux 10 > with psql version 8.1beta1 and there does seem to be something wrong with the > above situation (perhaps the man page needs to be reworded?) > > -- > Robert Treat > Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL > > ---------------------------(end of broadcast)--------------------------- > TIP 6: explain analyze is your friend > -- 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