pgsql: Support pg_read_[binary_]file (filename, missing_ok).

Started by Tom Lanealmost 4 years ago1 messagescomitters
Jump to latest
#1Tom Lane
tgl@sss.pgh.pa.us

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: /messages/by-id/20220607.160520.1984541900138970018.horikyota.ntt@gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/283129e325b721a5a62227f20d7e3d149b379c73

Modified Files
--------------
doc/src/sgml/func.sgml | 18 ++-
src/backend/catalog/system_functions.sql | 4 +
src/backend/utils/adt/genfile.c | 200 ++++++++++++++++++---------
src/include/catalog/catversion.h | 2 +-
src/include/catalog/pg_proc.dat | 12 +-
src/test/regress/expected/misc_functions.out | 64 +++++++++
src/test/regress/sql/misc_functions.sql | 26 ++++
7 files changed, 254 insertions(+), 72 deletions(-)