Skip site navigation (1) Skip section navigation (2)

Re: [HACKERS] backslash in psql output

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
Cc: hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] backslash in psql output
Date: 1998-10-10 15:19:44
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us> writes:
> I realize the double-backslash is confusing, but I don't think we can
> make such a user-visible change at this time.  I think we need to open
> discussion on this issue on the general list, and to include discussion
> of NULL displays, and any other issues, as well as how to properly
> output the column separation character if that appears in the data.
> So, I think we have to put it back to the old way, and open discussion
> about this after 6.4.

Well, actually there *was* public discussion of this issue, on the
pgsql-interfaces list around 12/13 August.  The consensus was that
unnecessary backslashing was a bad idea --- in fact, I didn't see
*anyone* arguing in favor of the old behavior, and the people who
actually had backslashes in their data definitely didn't want it.
Admittedly it was a pretty small sample (Tom Lockhart and I were
two of the primary complainers) but there wasn't any sentiment
for keeping the old behavior.

Keep in mind that what we are discussing here is the behavior of
PQprint(), not the behavior of FE/BE transport protocol or anything
else that affects data received by applications.  PQprint's goal in
life is to present data in a reasonably human-friendly way, *not*
to produce a completely unambiguous machine-readable syntax.  Its
output format is in fact very ambiguous.  Here's an example:

play=> create table test(id int4, val text);
play=> insert into test values (1, NULL);
play=> insert into test values (2, '    ');
play=> insert into test values (3, 'foobar');
play=> insert into test values (4, 'oneback\\slash');
play=> insert into test values (5, 'onevert|bar');
play=> select * from test;
(5 rows)

You can't tell the difference between a NULL field and an all-blanks
value in this format; nor can you really be sure how many trailing
blanks there are in tuples 3 and 5.  So the goal is readability,
not lack of ambiguity.  Given that goal, I don't see the value of
printing backslash escapes.  Are you really having difficulty telling
the data vertical bar from the ones used as column separators?
Physical alignment is the cue the eye relies on, I think.

The only cases that PQprint inserted backslashes for were the column
separator char (unnecessary per above example), newlines (also not
exactly hard to recognize), and backslash itself.  All of these
seem unnecessary and confusing to me.

I'm sorry that this change sat in my to-do queue for so long, but
I don't see it as a last-minute thing.  The consensus to do it was
established two months ago.

			regards, tom lane


pgsql-hackers by date

Next:From: Cary B. O'BrienDate: 1998-10-10 15:31:35
Subject: Bug and Patch for dump/restore of varchars
Previous:From: Bruce MomjianDate: 1998-10-10 15:02:41
Subject: Re: [HACKERS] backslash in psql output

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group