Re: Apparent Problem With NULL in Restoring pg_dump [SOLVED]

From: Rich Shepard <rshepard(at)appl-ecosys(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Apparent Problem With NULL in Restoring pg_dump [SOLVED]
Date: 2011-09-16 23:05:37
Message-ID: alpine.LNX.2.00.1109161553570.26931@salmo.appl-ecosys.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 16 Sep 2011, Rich Shepard wrote:

> Scrolling through the table with rows ordered by date and chemical I find
> no duplicates ... so far. However, what I do find is that the above did not
> work:

Turns out there was 1 duplicate. Reading the psql man page and making an
error in the \copy command syntax taught me the (E' ') escape syntax. Kool!

To close this thread, here's what I did to remove the table rows with
embedded newlines:

1) Made a copy of the chemistry table named 'junk'.
2) insert into junk select * from chemistry where site_id = 'GW-22';
3) insert into junk select * from chemistry where site_id = (E'GW-22\n');
4) \copy from junk to '</full/path/to/foo.sql>'
5) In emacs, use global search and replace to remove unwanted '\n'.
6) delete from junk where site_id = 'GW-22';
7) delete from junk where site_id = (E'GW-22\n');
8) \copy junk from '<full/path/to/foo.sql'>
9) delete from chemistry where site_id = 'GW-22';
10) delete from chemistry where site_id = (E'GW-22\n');
11) insert into chemistry select * from junk;

The latter found the one duplicate so I fixed that in emacs, then dropped
junk and repeated steps 8-11.

This message is as much for my future reference as it is for others who
might face the same problem.

Rich

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Craig Ringer 2011-09-17 00:28:00 Re: Indexes not allowed on (read-only) views: Why?
Previous Message Edson Carlos Ericksson Richter 2011-09-16 23:03:03 RES: Foreign PostgreSQL server