Re: psql NUL record and field separator

Peter Eisentraut <peter_e@gmx.net>

From: Peter Eisentraut <peter_e@gmx.net>
To: Abhijit Menon-Sen <ams@toroid.org>
Cc: pgsql-hackers@postgresql.org
Date: 2012-02-07T11:20:43Z
Lists: pgsql-hackers

Attachments

On tor, 2012-01-26 at 19:00 +0530, Abhijit Menon-Sen wrote:
> At issue are (at least) these three lines from print_unaligned_text in
> src/bin/psql/print.c:
> 
>  358         /* the last record needs to be concluded with a newline
> */
>  359         if (need_recordsep)
>  360             fputc('\n', fout);
> 
> Perhaps the right thing to do would be to change this to output \0 if
> --record-separator-zero was used (but leave it at \n otherwise)? That
> is what my second attached patch does:
> 
> $ bin/psql --record-separator-zero --field-separator-zero -At -c
> 'select 1,2 union select 3,4'|xargs -0 echo
> 1 2 3 4
> 
> Thoughts?
> 
> > I think the most common use of this would be to set the record
> > separator from the command line, so we could use a short option
> > such as -0 or -z for that.
> 
> I agree. The current option names are very unwieldy to type.
> 
I have incorporated your two patches and added short options.  Updated
patch attached.

This made me wonder, however.  The existing -F and -R options set the
record *separator*.  The new options, however, set the record
*terminator*.  This is the small distinction that you had discovered.

Should we rename the options and/or add that to the documentation, or is
the new behavior obvious and any new terminology would be too confusing?