Re: COPY seems to work, but no data in the table

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: missive(at)hotmail(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: COPY seems to work, but no data in the table
Date: 2002-07-17 03:50:12
Message-ID: 10829.1026877812@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Lee Harr <missive(at)frontiernet(dot)net> writes:
> oh. Here is is:
> http://archives.postgresql.org/pgsql-bugs/2002-02/msg00173.php

> What I found was that if a foreign key constraint was not satisfied
> while COPYing data in to a table, the whole COPY would fail, but
> there was never any error message.

> As I recall it, Tom Lane looked at this problem at the time and said
> that it would be less than simple to fix.

The example I cited in my followup works in CVS tip ... or at least
it reports a failure message:

regression=# create table foo(f1 int primary key);
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'foo_pkey' for table 'foo'
CREATE TABLE
regression=# create table bar(f2 int references foo);
NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
CREATE TABLE
regression=# copy bar from stdin;
Enter data to be copied followed by a newline.
End with a backslash and a period on a line by itself.
>> 1
>> \.
ERROR: $1 referential integrity violation - key referenced from bar not found in foo
lost synchronization with server, resetting connection
regression=#

I believe it works the same way in 7.2.1, but don't have an
exactly-7.2.1-release code tree handy to check. (This is a post-7.2
bug fix though, 7.2 will fail :-()

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ben Liblit 2002-07-17 04:06:30 dropping anonymous constraints
Previous Message Steve Lane 2002-07-17 03:40:14 Logging SQL queries?