Support pg_read_[binary_]file (filename, missing_ok).
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 29 Jul 2022 19:38:49 +0000 (15:38 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 29 Jul 2022 19:38:49 +0000 (15:38 -0400)
commit283129e325b721a5a62227f20d7e3d149b379c73
treea77377711f7fa536929419cead77d7dcc18f1485
parentfd96d14d950f2b1d19b5cb3b8e5a7d4d2b3fa161
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
src/backend/catalog/system_functions.sql
src/backend/utils/adt/genfile.c
src/include/catalog/catversion.h
src/include/catalog/pg_proc.dat
src/test/regress/expected/misc_functions.out
src/test/regress/sql/misc_functions.sql