Re: ERROR: null value in column "id" violates not-null constraint

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Paulsen <robert(at)paulsenonline(dot)net>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: ERROR: null value in column "id" violates not-null constraint
Date: 2009-10-10 18:46:45
Message-ID: 17323.1255200405@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Robert Paulsen <robert(at)paulsenonline(dot)net> writes:
> I have a database with a sequence field as a primary key in a table and can no
> longer insert data into it as it gets the subject error message.

Does the table actually have a default for id anymore? (Try looking
at it with psql's \d command.)

> POSSIBLE REASON FOR THE PROBLEM:
> I dumped the data, restored it into postgresql-8.2.13-0.1. dumped it from
> there and restored it back to postgresql-server-8.0.13-1.1. I now get the
> same failure from both 8.0 and 8.2.

pg_dump does not guarantee to produce backward-transportable dumps.
Did you pay attention to whether you got any errors while loading the
8.2 dump into 8.0? I don't have time to test it right now, but what
I'm thinking is that an ALTER TABLE ADD DEFAULT type of command failed
during the load because of some syntax issue or other.

Another possible foot-gun is to have tried to dump from the 8.2 server
using 8.0 pg_dump. This will generally not work; pg_dump cannot be
expected to understand system catalog layouts that are newer than it
is. You can force it to try with the -i switch, but usually that
doesn't result in anything better than a busted dump.

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Robert Paulsen 2009-10-10 19:00:46 Re: ERROR: null value in column "id" violates not-null constraint
Previous Message Robert Paulsen 2009-10-10 15:56:23 ERROR: null value in column "id" violates not-null constraint