Skip site navigation (1) Skip section navigation (2)

Re: [PORTS] Solaris - psql returns 0 instead of 1 for file not found.

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: "Clark, Andrew" <Andrew(dot)Clark(at)fnf(dot)com>
Cc: pgsql-ports(at)postgresql(dot)org,PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [PORTS] Solaris - psql returns 0 instead of 1 for file not found.
Date: 2005-09-20 19:00:56
Message-ID: 200509201900.j8KJ0uh11335@candle.pha.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-patchespgsql-ports
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(at)candle(dot)pha(dot)pa(dot)us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

In response to

pgsql-ports by date

Next:From: Robert TreatDate: 2005-09-22 16:00:08
Subject: Re: [PORTS] Solaris - psql returns 0 instead of 1 for file not found.
Previous:From: Clark, AndrewDate: 2005-09-19 18:01:03
Subject: Solaris - psql returns 0 instead of 1 for file not found.

pgsql-bugs by date

Next:From: Eder de OliveiraDate: 2005-09-20 21:15:11
Subject: BUG #1902: Error connect
Previous:From: Jim.GrayDate: 2005-09-20 18:16:04
Subject: Re: Fw: BUG #1862: ECPG Connect, host variable trailing blanks

pgsql-patches by date

Next:From: Alvaro HerreraDate: 2005-09-20 19:07:19
Subject: Re: Multiple -t options for pg_dump
Previous:From: Neil ConwayDate: 2005-09-20 18:49:26
Subject: Re: Multiple -t options for pg_dump

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group