Re: pipe_read_line for reading arbitrary strings
Daniel Gustafsson <daniel@yesql.se>
From: Daniel Gustafsson <daniel@yesql.se>
To: Heikki Linnakangas <hlinnaka@iki.fi>
Cc: Postgres hackers <pgsql-hackers@lists.postgresql.org>
Date: 2023-07-04T12:50:00Z
Lists: pgsql-hackers
> On 4 Jul 2023, at 13:59, Heikki Linnakangas <hlinnaka@iki.fi> wrote: > On 08/03/2023 00:05, Daniel Gustafsson wrote: >> If we are going to continue using this for reading $stuff from pipes, maybe we >> should think about presenting a nicer API which removes that risk? Returning >> an allocated buffer which contains all the output along the lines of the recent >> pg_get_line work seems a lot nicer and safer IMO. > > +1 Thanks for review! >> /* >> * Execute a command in a pipe and read the first line from it. The returned >> * string is allocated, the caller is responsible for freeing. >> */ >> char * >> pipe_read_line(char *cmd) > > I think it's worth being explicit here that it's palloc'd, or malloc'd in frontend programs, rather than just "allocated". Like in pg_get_line. Good point, I'll make that happen before committing this. -- Daniel Gustafsson
Commits
-
Fix errorhandling for reading from a pipe
- be41a9b03807 17.0 landed
-
Refactor pipe_read_line to return the full line
- 5c7038d70bb9 17.0 landed
-
Add -c/--restore-target-wal to pg_rewind
- a7e8ece41cf7 13.0 cited
-
Here is a patch that fixes the pipes used in find_other_exec() when
- 5b2f4afffe69 8.0.0 cited