From: Tom Lane Date: Sat, 15 Oct 2005 19:47:09 +0000 (+0000) Subject: Fix thinko in pg_read_file: testing for negative result is not the way X-Git-Tag: REL9_0_0~9045 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=e4cd186608d15563e568f03bbe2919384fdc95c0;p=pg-rex%2Fsyncrep.git Fix thinko in pg_read_file: testing for negative result is not the way to determine whether fread() failed. --- diff --git a/src/backend/utils/adt/genfile.c b/src/backend/utils/adt/genfile.c index 06ff9afe03..2e0a247461 100644 --- a/src/backend/utils/adt/genfile.c +++ b/src/backend/utils/adt/genfile.c @@ -9,7 +9,7 @@ * Author: Andreas Pflug * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/genfile.c,v 1.7 2005/10/15 02:49:28 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/genfile.c,v 1.8 2005/10/15 19:47:09 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -134,7 +134,7 @@ pg_read_file(PG_FUNCTION_ARGS) nbytes = fread(VARDATA(buf), 1, (size_t) bytes_to_read, file); - if (nbytes < 0) + if (ferror(file)) ereport(ERROR, (errcode_for_file_access(), errmsg("could not read file \"%s\": %m", filename)));