Tabbed data in tab-separated output

From: felix(at)crowfix(dot)com
To: pgsql-general(at)postgresql(dot)org
Subject: Tabbed data in tab-separated output
Date: 2007-01-04 01:59:24
Message-ID: 20070104015924.GA30532@crowfix.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have a table which has a few VARCHAR columns whose first character
is a tab. If I run pg_dump on this table, it outputs data like this:

43158 \t555-1212 3

where the two embedded white spaces are actually tabs.

If I use psql to execute SQL to dump parts of the table, like this:

psql -qtA -f '\t' -U xyzzy xyzzy -c 'select ... >/tmp/xxx

I get this:

43158 310-319-1333, x1070 3

where that initial embeded white space represents two tabs. When I
use psql to restore this data, it thinks the 2nd column is empty and
complains that the third column is the wrong type.

pg_dump apparently is smart enough to print embedded tabs as escaped
chars, but not psql. Is there a fix for this? I thought of reverting
to standard output, without the -t option, and analyzing the first two
lines to tell exactly how many spaces are assigned to each column, but
that gives me the shudders.

--
... _._. ._ ._. . _._. ._. ___ .__ ._. . .__. ._ .. ._.
Felix Finch: scarecrow repairman & rocket surgeon / felix(at)crowfix(dot)com
GPG = E987 4493 C860 246C 3B1E 6477 7838 76E9 182E 8151 ITAR license #4933
I've found a solution to Fermat's Last Theorem but I see I've run out of room o

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tomas Lanczos 2007-01-04 02:28:47 could not open file xxxx for writing: Permission denied
Previous Message Adrian Klaver 2007-01-04 00:15:30 Re: Generic timestamp function for updates where field