pgsql: Support pg_read_[binary_]file (filename, missing_ok). - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Support pg_read_[binary_]file (filename, missing_ok).
Date
Msg-id E1oHVp3-001p30-7G@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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

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(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: In transformRowExpr(), check for too many columns in the row.
Next
From: Robert Haas
Date:
Subject: pgsql: Fix brown paper bag bug in bbe08b8869bd29d587f24ef18eb45c7d4d14a