Re: [HACKERS] backslash in psql output - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [HACKERS] backslash in psql output
Date
Msg-id 25962.908058970@sss.pgh.pa.us
Whole thread Raw
In response to Re: [HACKERS] backslash in psql output  (Bruce Momjian <maillist@candle.pha.pa.us>)
List pgsql-hackers
Bruce Momjian <maillist@candle.pha.pa.us> writes:
> If the user is reading psql output into a program, it is very unclear
> how to determine a valid column delimiter vs. a delimiter in the data.

Quite true, but the PQprint output format has never been
program-friendly, as I pointed out previously.

I think the appropriate response to this gripe is to add another
command-line switch to psql, which would change its display of SELECT
data to something more suitable for program consumption, rather than
trying to make a single output format that's a bad compromise between
human readability and machine readability.

Perhaps the COPY data syntax would work for a program-friendly output
format?  (Basically tabs and newlines are field and row delimiters,
with (IIRC) backslash-escaping of tabs, newlines, backslash itself,
and maybe nulls and suchlike.  Also \N stands for a null field.)

> And what about the COPY command.  Do you want to change the display of
> escape characters there too?  I hope not.

I wasn't proposing any such thing, unless it proves necessary to ensure
we can copy arbitrary-8-bit text data out and back in.  But that's a
task for a future release.

            regards, tom lane

pgsql-hackers by date:

Previous
From: "Oliver Elphick"
Date:
Subject: Re: [HACKERS] backslash in psql output
Next
From: "Gene Selkov, Jr."
Date:
Subject: yet another problem in recent builds, GIST this time