Fix thinko in pg_read_file: testing for negative result is not the way
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 15 Oct 2005 19:47:09 +0000 (19:47 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 15 Oct 2005 19:47:09 +0000 (19:47 +0000)
to determine whether fread() failed.

src/backend/utils/adt/genfile.c

index 7f337ddc2e6b0828f8a63f93d35be4f1e6b71193..edb8a9fa2802c6e8d51553b4f8e6014a93671922 100644 (file)
@@ -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)));