Re: Inconvenience of pg_read_binary_file()

2022-08-01 Thread Kyotaro Horiguchi
At Sat, 30 Jul 2022 10:24:39 -0400, Tom Lane wrote in > Alvaro Herrera writes: > > On 2022-Jul-30, Michael Paquier wrote: > >> PG_VERSION would be simpler. Looking at postmaster.pid would require > >> a lookup at external_pid_file, and as it is not set by default you > >> would need to add some

Re: Inconvenience of pg_read_binary_file()

2022-07-30 Thread Tom Lane
Alvaro Herrera writes: > On 2022-Jul-30, Michael Paquier wrote: >> PG_VERSION would be simpler. Looking at postmaster.pid would require >> a lookup at external_pid_file, and as it is not set by default you >> would need to add some extra logic in the tests where >> external_pid_file = NULL <=> PG

Re: Inconvenience of pg_read_binary_file()

2022-07-30 Thread Alvaro Herrera
On 2022-Jul-30, Michael Paquier wrote: > PG_VERSION would be simpler. Looking at postmaster.pid would require > a lookup at external_pid_file, and as it is not set by default you > would need to add some extra logic in the tests where > external_pid_file = NULL <=> PGDATA/postmaster.pid. Hmm, no

Re: Inconvenience of pg_read_binary_file()

2022-07-29 Thread Michael Paquier
On Fri, Jul 29, 2022 at 11:35:36PM -0400, Tom Lane wrote: > Hm. I considered reading PG_VERSION instead, or postmaster.pid. > PG_VERSION would be a very boring test case, but it should certainly > be present in $PGDATA. PG_VERSION would be simpler. Looking at postmaster.pid would require a looku

Re: Inconvenience of pg_read_binary_file()

2022-07-29 Thread Tom Lane
Michael Paquier writes: > On Fri, Jul 29, 2022 at 03:44:25PM -0400, Tom Lane wrote: >> Pushed after some fooling with the docs and test cases. (Notably, >> I do not think we can assume that pg_hba.conf exists in $PGDATA; some >> installations keep it elsewhere. I used postgresql.auto.conf instea

Re: Inconvenience of pg_read_binary_file()

2022-07-29 Thread Michael Paquier
On Fri, Jul 29, 2022 at 03:44:25PM -0400, Tom Lane wrote: > Pushed after some fooling with the docs and test cases. (Notably, > I do not think we can assume that pg_hba.conf exists in $PGDATA; some > installations keep it elsewhere. I used postgresql.auto.conf instead.) Are you sure that this la

Re: Inconvenience of pg_read_binary_file()

2022-07-29 Thread Tom Lane
Kyotaro Horiguchi writes: > Please find the attached. I added some regression tests for both > pg_read_file() and pg_read_binary_file(). Yeah, I definitely find this way cleaner even if it's a bit more verbose. I think that the PG_RETURN_NULL code paths are not reachable in the wrappers that do

Re: Inconvenience of pg_read_binary_file()

2022-07-29 Thread Kyotaro Horiguchi
Thanks for taking a look! At Thu, 28 Jul 2022 16:22:17 -0400, Tom Lane wrote in > Kyotaro Horiguchi writes: > > - Simplified the implementation (by complexifying argument handling..). > > - REVOKEd EXECUTE from the new functions. > > - Edited the signature of the two functions. > > >> - pg_rea

Re: Inconvenience of pg_read_binary_file()

2022-07-28 Thread Tom Lane
Kyotaro Horiguchi writes: > - Simplified the implementation (by complexifying argument handling..). > - REVOKEd EXECUTE from the new functions. > - Edited the signature of the two functions. >> - pg_read_file ( filename text [, offset bigint, length bigint [, missing_ok >> boolean ]] ) →

Re: Inconvenience of pg_read_binary_file()

2022-06-29 Thread Kyotaro Horiguchi
At Tue, 07 Jun 2022 17:29:31 +0900 (JST), Kyotaro Horiguchi wrote in > pg_read_file(text, bool) makes sense to me, but it doesn't seem like > to be able to share C function with other variations. > pg_read_binary_file() need to accept some out-of-range value for > offset or length to signal that

Re: Inconvenience of pg_read_binary_file()

2022-06-07 Thread Kyotaro Horiguchi
At Tue, 7 Jun 2022 16:33:53 +0900, Michael Paquier wrote in > On Tue, Jun 07, 2022 at 04:05:20PM +0900, Kyotaro Horiguchi wrote: > > 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, tr

Re: Inconvenience of pg_read_binary_file()

2022-06-07 Thread Michael Paquier
On Tue, Jun 07, 2022 at 04:05:20PM +0900, Kyotaro Horiguchi wrote: > 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. Yeah, the "normal" cases th