Transactions and constraints

From: Emil Eifrem <emil(dot)eifrem(at)windh(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Transactions and constraints
Date: 2002-05-30 23:54:05
Message-ID: 1022802847.16198.20.camel@palpatine
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

We have a problem related to transactions and constraints. Our tables
look like this:

---
CREATE TABLE table_a
(
id INT NOT NULL PRIMARY KEY
);

CREATE TABLE table_b
(
a_id INT NOT NULL CONSTRAINT my_ref
REFERENCES table_a(id)
DEFERRABLE INITIALLY DEFERRED,
value INT NOT NULL
);
---

In psql we run the following SQL statements:

---
BEGIN;

INSERT INTO table_a (id) VALUES (1);
INSERT INTO table_b (a_id,value) VALUES (1,1);
DELETE FROM table_b WHERE a_id=1;
DELETE FROM table_a WHERE id=1;

COMMIT;
---

Upon commit, we get the following error message:

"ERROR: my_ref referential integrity violation - key referenced from
table_b not found in table_a"

We believe this to be valid SQL. We have successfully executed the
equivalent statements on an Informix Dynamic Server 9.20.

Our environment:

Linux palpatine 2.4.9-31 #1 Tue Feb 26 07:11:02 EST 2002 i686
unknown
PostgreSQL 7.2.1 built from yesterday's source RPMS on
www.postgresql.org

Does anyone know if the error is on ours or on PostgreSQL's side?

TIA,

--
Emil Eifrem [emil(at)windh(dot)net] /'\ ASCII Ribbon Campaign
Kernel Developer, .windh AB \ / No HTML/RTF in email
× No Word docs in email
/ \ Respect for open standards

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-05-31 00:23:47 Re: Transactions and constraints
Previous Message Francisco Reyes 2002-05-30 23:35:03 Re: Moving data from FreeBSD to Red Hat