]> granicus.if.org Git - postgresql/commit
Further tweaking of the readfile() function in pg_ctl.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 18 Oct 2012 19:26:26 +0000 (22:26 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 18 Oct 2012 19:30:46 +0000 (22:30 +0300)
commit95ff5b3599c3e88a70a45f3bb1e36f6c8762d450
tree88c6aeb17b63d069c661567ff30cf7918606f45a
parentafdc7515fdadf51ea459aab568b5b7687b552e75
Further tweaking of the readfile() function in pg_ctl.

Don't leak a file descriptor if the file is empty or we can't read its size.

Expect there to be a newline at the end of the last line, too. If there
isn't, ignore anything after the last newline. This makes it a tiny bit
more robust in case the file is appended to concurrently, so that we don't
return the last line if it hasn't been fully written yet. And this makes
the code a bit less obscure, anyway. Per Tom Lane's suggestion.

Backpatch to all supported branches.
src/bin/pg_ctl/pg_ctl.c