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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Support pg_read_[binary_]file (filename, missing_ok).
Date: 2022-07-29 19:38:58
Message-ID: E1oHVp3-001p30-7G@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: 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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Robert Haas 2022-07-29 21:13:10 pgsql: Fix brown paper bag bug in bbe08b8869bd29d587f24ef18eb45c7d4d14a
Previous Message Tom Lane 2022-07-29 17:31:31 pgsql: In transformRowExpr(), check for too many columns in the row.