pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Support pg_read_[binary_]file (filename, missing_ok).
Date: Fri, 29 Jul 2022 19:38:58 +0000
Message-ID: <E1oHVp3-001p30-7G@gemulon.postgresql.org> (raw)

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



Message-ID: <E1oHVp3-001p30-7G@gemulon.postgresql.org>
Permalink:  ../E1oHVp3-001p30-7G@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1oHVp3-001p30-7G@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Support pg_read_[binary_]file (filename, missing_ok).
  In-Reply-To: <E1oHVp3-001p30-7G@gemulon.postgresql.org>
  References: <E1oHVp3-001p30-7G@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox