This is a discussion on psql -f doesn't complain about directories within the pgsql Hackers forums, part of the PostgreSQL category; --> Letting psql execute a script file that is really a directory doesn't complain at all: $ psql -f /tmp ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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 broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster |
| |||
| 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 really want to be able to psql -f a_pipe?) -- Alvaro Herrera Developer, http://www.PostgreSQL.org/ Essentially, you're proposing Kevlar shoes as a solution for the problem that you want to walk around carrying a loaded gun aimed at your foot. (Tom Lane) ---------------------------(end of broadcast)--------------------------- TIP 5: don't forget to increase your free space map settings |
| |||
| 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 we really want to > be able to psql -f a_pipe?) > I don't see why not. cheers andrew ---------------------------(end of broadcast)--------------------------- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq |
| |||
| 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 honest I think that psql shouldn't be ignoring the EISDIR error the kernel is returning. Have a nice day, -- Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/ > Those who make peaceful revolution impossible will make violent revolution inevitable. > -- John F Kennedy -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFHO1hdIB7bNG8LQkwRAmvHAKCBuRblr2cj4gP5mURmgv W7SzbdIgCeOzSV zA2KmSf8nkkGwvSSrfzM+L0= =zeV7 -----END PGP SIGNATURE----- |
| |||
| 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 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 is a directory and oflag includes O_WRONLY or O_RDWR. Zdenek ---------------------------(end of broadcast)--------------------------- TIP 5: don't forget to increase your free space map settings |
| |||
| 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 we really want to > be able to psql -f a_pipe?) > What's about symlink to regular file/pipe? Zdenek ---------------------------(end of broadcast)--------------------------- TIP 7: You can help support the PostgreSQL project by donating at http://www.postgresql.org/about/donate |
| |||
| 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 is a directory and oflag includes O_WRONLY or O_RDWR. $ strace psql -f /tmp <snip> open("/tmp", O_RDONLY|O_LARGEFILE) = 4 <snip> read(4, 0xb7f1b000, 4096) = -1 EISDIR (Is a directory) Which is subsequently ignored. I'm hoping it doesn't ignore other errors, like EIO or EPIPE, Have a nice day, -- Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/ > Those who make peaceful revolution impossible will make violent revolution inevitable. > -- John F Kennedy -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFHO2TcIB7bNG8LQkwRAhSnAJ9BPrysgeDs9HvQjE7q1G ZE1avHVACfQ+hf QtHlAYy8xbtTE7UMJshruaI= =zaGL -----END PGP SIGNATURE----- |
| |||
| 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)--------------------------- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to majordomo@postgresql.org so that your message can get through to the mailing list cleanly |
| |||
| 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 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. Have a nice day, -- Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/ > Those who make peaceful revolution impossible will make violent revolution inevitable. > -- John F Kennedy -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFHO2u8IB7bNG8LQkwRApXJAJ0ZNrJ1ObBaAv6z55IsNY yozuDHugCfVTSG kIxyuHYwromenEYrKLRQ9eE= =B1We -----END PGP SIGNATURE----- |
| ||||
| 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 directory? > > Actually anything other than a plain file, right? (Do we really > want to be able to psql -f a_pipe?) Yes, I have seen people use just this technique. Cheers, David. -- David Fetter <david@fetter.org> http://fetter.org/ Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter Skype: davidfetter XMPP: david.fetter@gmail.com Remember to vote! Consider donating to Postgres: http://www.postgresql.org/about/donate ---------------------------(end of broadcast)--------------------------- TIP 4: Have you searched our list archives? http://archives.postgresql.org |