diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2022-07-29 15:38:49 -0400 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2022-07-29 15:38:49 -0400 |
| commit | 283129e325b721a5a62227f20d7e3d149b379c73 (patch) | |
| tree | a77377711f7fa536929419cead77d7dcc18f1485 /doc/src | |
| parent | fd96d14d950f2b1d19b5cb3b8e5a7d4d2b3fa161 (diff) | |
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
Diffstat (limited to 'doc/src')
| -rw-r--r-- | doc/src/sgml/func.sgml | 18 |
1 files changed, 14 insertions, 4 deletions
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 @@ -28412,12 +28412,22 @@ SELECT pg_size_pretty(sum(pg_relation_size(relid))) AS total_size </para> <para> + 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. <application>psql</application>'s <command>\df</command> command + can be useful to check what the actual function signatures are. + </para> + + <para> Some of these functions take an optional <parameter>missing_ok</parameter> parameter, which specifies the behavior when the file or directory does not exist. If <literal>true</literal>, the function returns <literal>NULL</literal> or an empty result set, as appropriate. - If <literal>false</literal>, an error is raised. The default - is <literal>false</literal>. + If <literal>false</literal>, an error is raised. (Failure conditions + other than <quote>file not found</quote> are reported as errors in any + case.) The default is <literal>false</literal>. </para> <table id="functions-admin-genfile-table"> @@ -28636,7 +28646,7 @@ SELECT pg_size_pretty(sum(pg_relation_size(relid))) AS total_size <indexterm> <primary>pg_read_file</primary> </indexterm> - <function>pg_read_file</function> ( <parameter>filename</parameter> <type>text</type> <optional>, <parameter>offset</parameter> <type>bigint</type>, <parameter>length</parameter> <type>bigint</type> <optional>, <parameter>missing_ok</parameter> <type>boolean</type> </optional></optional> ) + <function>pg_read_file</function> ( <parameter>filename</parameter> <type>text</type> <optional>, <parameter>offset</parameter> <type>bigint</type>, <parameter>length</parameter> <type>bigint</type> </optional> <optional>, <parameter>missing_ok</parameter> <type>boolean</type> </optional> ) <returnvalue>text</returnvalue> </para> <para> @@ -28661,7 +28671,7 @@ SELECT pg_size_pretty(sum(pg_relation_size(relid))) AS total_size <indexterm> <primary>pg_read_binary_file</primary> </indexterm> - <function>pg_read_binary_file</function> ( <parameter>filename</parameter> <type>text</type> <optional>, <parameter>offset</parameter> <type>bigint</type>, <parameter>length</parameter> <type>bigint</type> <optional>, <parameter>missing_ok</parameter> <type>boolean</type> </optional></optional> ) + <function>pg_read_binary_file</function> ( <parameter>filename</parameter> <type>text</type> <optional>, <parameter>offset</parameter> <type>bigint</type>, <parameter>length</parameter> <type>bigint</type> </optional> <optional>, <parameter>missing_ok</parameter> <type>boolean</type> </optional> ) <returnvalue>bytea</returnvalue> </para> <para> |
