Re: psql NUL record and field separator

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Abhijit Menon-Sen <ams(at)toroid(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: psql NUL record and field separator
Date: 2012-02-07 11:20:43
Message-ID: 1328613643.24489.4.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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?

Attachment Content-Type Size
psql-nul-sep.patch text/x-patch 14.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavan Deolasee 2012-02-07 11:21:07 Re: Assertion failure in AtCleanup_Portals
Previous Message Shigeru Hanada 2012-02-07 10:25:14 Re: Speed dblink using alternate libpq tuple storage