]> 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:38 +0000 (22:30 +0300)
commite7bab081a9f726fa8cd910bd7e2567423383b44b
tree2f454f7d3aa017e7e7dcff8317e01a489de71b57
parent623e49c0c03a1ff1b0992a20c0e2fdaaa6d13f34
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