pg_read_binary_file_modify.patch

text/x-patch

Filename: pg_read_binary_file_modify.patch
Type: text/x-patch
Part: 0
Message: Inconvenience of pg_read_binary_file()

Patch

Format: unified
File+
src/backend/utils/adt/genfile.c 2 2
diff --git a/src/backend/utils/adt/genfile.c b/src/backend/utils/adt/genfile.c
index 2bf5219256..219203be1c 100644
--- a/src/backend/utils/adt/genfile.c
+++ b/src/backend/utils/adt/genfile.c
@@ -331,10 +331,10 @@ pg_read_binary_file(PG_FUNCTION_ARGS)
 		seek_offset = PG_GETARG_INT64(1);
 		bytes_to_read = PG_GETARG_INT64(2);
 
-		if (bytes_to_read < 0)
+		if (bytes_to_read < -1)
 			ereport(ERROR,
 					(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
-					 errmsg("requested length cannot be negative")));
+					 errmsg("invalid requested length")));
 	}
 	if (PG_NARGS() >= 4)
 		missing_ok = PG_GETARG_BOOL(3);