Re: [HACKERS] psql -f doesn't complain about directories

2007-11-27 Thread Tom Lane
Peter Eisentraut <[EMAIL PROTECTED]> writes: > This should do better: Looks good to me, though I'd suggest updating gets_fromFile's header comment: - * The result is a malloc'd string. + * The result is a malloc'd string, or NULL on EOF or input error. regards, tom lane

Re: [HACKERS] psql -f doesn't complain about directories

2007-11-27 Thread Peter Eisentraut
Am Donnerstag, 15. November 2007 schrieb Tom Lane: > Peter Eisentraut <[EMAIL PROTECTED]> writes: > > Am Donnerstag, 15. November 2007 schrieb Tom Lane: > >> This seems too far removed from the scene of the crime > > > > Yeah, my zeroth attempt was to place this in gets_fromFile(), but there > > yo

Re: [HACKERS] psql -f doesn't complain about directories

2007-11-15 Thread Tom Lane
Peter Eisentraut <[EMAIL PROTECTED]> writes: > Am Donnerstag, 15. November 2007 schrieb Tom Lane: >> This seems too far removed from the scene of the crime > Yeah, my zeroth attempt was to place this in gets_fromFile(), but there you > don't have any opportunity to report failure to the main loop

Re: [HACKERS] psql -f doesn't complain about directories

2007-11-15 Thread Peter Eisentraut
Am Donnerstag, 15. November 2007 schrieb Tom Lane: > This seems too far removed from the scene of the crime Yeah, my zeroth attempt was to place this in gets_fromFile(), but there you don't have any opportunity to report failure to the main loop. We'd need to change the function signature to be

Re: [HACKERS] psql -f doesn't complain about directories

2007-11-15 Thread Tom Lane
Peter Eisentraut <[EMAIL PROTECTED]> writes: > Am Mittwoch, 14. November 2007 schrieb Martijn van Oosterhout: >> It's not the fopen that fails, it's the fgets that returns NULL. We >> don't subsequently check if that's due to an I/O error or EISDIR or if >> it's an end-of-file. > Here is a patch f

Re: [HACKERS] psql -f doesn't complain about directories

2007-11-15 Thread Peter Eisentraut
Am Mittwoch, 14. November 2007 schrieb Martijn van Oosterhout: > It's not the fopen that fails, it's the fgets that returns NULL. We > don't subsequently check if that's due to an I/O error or EISDIR or if > it's an end-of-file. Here is a patch for this. -- Peter Eisentraut http://developer.post

Re: [HACKERS] psql -f doesn't complain about directories

2007-11-15 Thread Zdenek Kotala
Martijn van Oosterhout napsal(a): On Wed, Nov 14, 2007 at 09:33:17PM +0100, Zdenek Kotala wrote: Sure, why not. To be honest I think that psql shouldn't be ignoring the EISDIR error the kernel is returning. But it works when you open directory in read-only mode. See posix definition: [EISDIR]

Re: [HACKERS] psql -f doesn't complain about directories

2007-11-14 Thread Alvaro Herrera
David Fetter wrote: > On Wed, Nov 14, 2007 at 05:15:20PM -0300, Alvaro Herrera wrote: > > Peter Eisentraut wrote: > > > Letting psql execute a script file that is really a directory > > > doesn't complain at all: > > > > > > $ psql -f /tmp > > > > > > Should we do some kind of stat() before openi

Re: [HACKERS] psql -f doesn't complain about directories

2007-11-14 Thread David Fetter
On Wed, Nov 14, 2007 at 05:15:20PM -0300, Alvaro Herrera wrote: > Peter Eisentraut wrote: > > Letting psql execute a script file that is really a directory > > doesn't complain at all: > > > > $ psql -f /tmp > > > > Should we do some kind of stat() before opening the file and abort > > if it's a

Re: [HACKERS] psql -f doesn't complain about directories

2007-11-14 Thread Martijn van Oosterhout
On Wed, Nov 14, 2007 at 10:25:23PM +0100, Peter Eisentraut wrote: > Martijn van Oosterhout wrote: > > To be honest I think that psql shouldn't be ignoring the > > EISDIR error the kernel is returning. > > We use fopen(), which doesn't appear to pass that on. It's not the fopen that fails, it's th

Re: [HACKERS] psql -f doesn't complain about directories

2007-11-14 Thread Peter Eisentraut
Martijn van Oosterhout wrote: > To be honest I think that psql shouldn't be ignoring the > EISDIR error the kernel is returning. We use fopen(), which doesn't appear to pass that on. -- Peter Eisentraut http://developer.postgresql.org/~petere/ ---(end of broadcast)--

Re: [HACKERS] psql -f doesn't complain about directories

2007-11-14 Thread Andrew Dunstan
Alvaro Herrera wrote: Peter Eisentraut wrote: Letting psql execute a script file that is really a directory doesn't complain at all: $ psql -f /tmp Should we do some kind of stat() before opening the file and abort if it's a directory? Actually anything other than a plain file, r

[HACKERS] psql -f doesn't complain about directories

2007-11-14 Thread Peter Eisentraut
Letting psql execute a script file that is really a directory doesn't complain at all: $ psql -f /tmp Should we do some kind of stat() before opening the file and abort if it's a directory? -- Peter Eisentraut http://developer.postgresql.org/~petere/ ---(end of broadc

Re: [HACKERS] psql -f doesn't complain about directories

2007-11-14 Thread Martijn van Oosterhout
On Wed, Nov 14, 2007 at 09:33:17PM +0100, Zdenek Kotala wrote: > >Sure, why not. To be honest I think that psql shouldn't be ignoring the > >EISDIR error the kernel is returning. > > But it works when you open directory in read-only mode. See posix > definition: > > [EISDIR] > The named file

Re: [HACKERS] psql -f doesn't complain about directories

2007-11-14 Thread Zdenek Kotala
Alvaro Herrera wrote: Peter Eisentraut wrote: Letting psql execute a script file that is really a directory doesn't complain at all: $ psql -f /tmp Should we do some kind of stat() before opening the file and abort if it's a directory? Actually anything other than a plain file, right? (Do

Re: [HACKERS] psql -f doesn't complain about directories

2007-11-14 Thread Zdenek Kotala
Martijn van Oosterhout wrote: On Wed, Nov 14, 2007 at 05:15:20PM -0300, Alvaro Herrera wrote: Should we do some kind of stat() before opening the file and abort if it's a directory? Actually anything other than a plain file, right? (Do we really want to be able to psql -f a_pipe?) Sure, why

Re: [HACKERS] psql -f doesn't complain about directories

2007-11-14 Thread Martijn van Oosterhout
On Wed, Nov 14, 2007 at 05:15:20PM -0300, Alvaro Herrera wrote: > > Should we do some kind of stat() before opening the file and abort if it's > > a > > directory? > > Actually anything other than a plain file, right? (Do we really want to > be able to psql -f a_pipe?) Sure, why not. To be hon

Re: [HACKERS] psql -f doesn't complain about directories

2007-11-14 Thread Alvaro Herrera
Peter Eisentraut wrote: > Letting psql execute a script file that is really a directory doesn't > complain > at all: > > $ psql -f /tmp > > Should we do some kind of stat() before opening the file and abort if it's a > directory? Actually anything other than a plain file, right? (Do we reall