Inconvenience of pg_read_binary_file()

Kyotaro Horiguchi <horikyota.ntt@gmail.com>

From: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
To: pgsql-hackers@postgresql.org
Date: 2022-06-07T07:05:20Z
Lists: pgsql-hackers

Attachments

If I want to read a file that I'm not sure of the existence but I want
to read the whole file if exists, I would call
pg_read_binary_file('path', 0, -1, true) but unfortunately this
doesn't work.

Does it make sense to change the function so as to accept the
parameter specification above? Or the arguments could be ('path',
null, null, true) but (0,-1) is simpler considering the
characteristics of the function.

(We could also rearrange the the parameter order as "filename,
missing_ok, offset, length" but that is simply confusing..)

If it is, pg_read_file() is worth receive the same modification and
I'll post the version containing doc part.

regards.

-- 
Kyotaro Horiguchi
NTT Open Source Software Center

Commits

  1. Adjust new pg_read_file() test cases for more portability.

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