From 283129e325b721a5a62227f20d7e3d149b379c73 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 29 Jul 2022 15:38:49 -0400 Subject: Support pg_read_[binary_]file (filename, missing_ok). There wasn't an especially nice way to read all of a file while passing missing_ok = true. Add an additional overloaded variant to support that use-case. While here, refactor the C code to avoid a rats-nest of PG_NARGS checks, instead handling the argument collection in the outer wrapper functions. It's a bit longer this way, but far more straightforward. (Upon looking at the code coverage report for genfile.c, I was impelled to also add a test case for pg_stat_file() -- tgl) Kyotaro Horiguchi Discussion: https://postgr.es/m/20220607.160520.1984541900138970018.horikyota.ntt@gmail.com --- doc/src/sgml/func.sgml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 21f8ab73e28..053d4dc650b 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -28411,13 +28411,23 @@ SELECT pg_size_pretty(sum(pg_relation_size(relid))) AS total_size considered. + + When granting privilege on these functions, note that the table entries + showing optional parameters are mostly implemented as several physical + functions with different parameter lists. Privilege must be granted + separately on each such function, if it is to be + used. psql's \df command + can be useful to check what the actual function signatures are. + + Some of these functions take an optional missing_ok parameter, which specifies the behavior when the file or directory does not exist. If true, the function returns NULL or an empty result set, as appropriate. - If false, an error is raised. The default - is false. + If false, an error is raised. (Failure conditions + other than file not found are reported as errors in any + case.) The default is false. @@ -28636,7 +28646,7 @@ SELECT pg_size_pretty(sum(pg_relation_size(relid))) AS total_size pg_read_file - pg_read_file ( filenametext, offset bigint, length bigint , missing_ok boolean ) + pg_read_file ( filenametext, offset bigint, length bigint , missing_ok boolean ) text @@ -28661,7 +28671,7 @@ SELECT pg_size_pretty(sum(pg_relation_size(relid))) AS total_size pg_read_binary_file - pg_read_binary_file ( filename text , offset bigint, length bigint , missing_ok boolean ) + pg_read_binary_file ( filename text , offset bigint, length bigint , missing_ok boolean ) bytea -- cgit v1.2.3