pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedReferential Integrity Question (Delete/Insert during Transaction)
2+ messages / 2 participants
[nested] [flat]
* Referential Integrity Question (Delete/Insert during Transaction)
@ 2001-06-18 20:43 Stef Telford <stef@chronozon.artofdns.com>
2001-06-18 22:59 ` Re: Referential Integrity Question (Delete/Insert during Transaction) Stephan Szabo <sszabo@megazone23.bigpanda.com>
0 siblings, 1 reply; 2+ messages in thread
From: Stef Telford @ 2001-06-18 20:43 UTC (permalink / raw)
To: pgsql-sql
hello again everyone,
I seem to have hit what i -think- may be a bug (but i am not crying
wolf jst yet ;).
I have three tables. action, client and order_details. action has a primary
key 'order', client references action (along with adding the client_id as
part of its primary key), order_details references client (both parts of the
primary key there). all foreign keys (order in client and order+client_id in
order_details) are set to INITIALLY DEFERRED. so far so good i hope.
Now, i have a trigger that fires on insert, so i delete from the live
database and then insert the changes rather than doing an update. not
great, but shouldnt be a problem.
The problem comes when i do this:
mms_post=# BEGIN;
BEGIN
mms_post=# DELETE from client WHERE order_id = 22;
DELETE 1
mms_post=# INSERT INTO client
mms_post-#(cli_business_name,cli_chain_id,cli_business_type,cli_short_name,cl
i_sic,order_id,client_id,cli_agent_bank_id,cli_operating_name,creation_id,cli_
web_page,cli_tcc,creation_date)
mms_post-# VALUES ('STEFS','100-000000000333',1,'FHASDLKJH HFAKSDJ
HKALSDJ',2534,22,'100-00000000555',230,'FHASDLKJH HFAKSDJ
HKALSDJFH','jack','fgahsk@afsdhfkja.net','R','2001-06-18 13:46:45-04');
INSERT 24211 1
mms_post=# COMMIT;
ERROR: <unnamed> referential integrity violation - key in client still
referenced from order_details
Now. the way i understand it, shouldnt the integrity of any foreign keys
be checked at the -end- of the transaction, after all the commands have been
processed ? it seems that the DELETE is being processed and rejected, but
the foreign key would be 'okay' due to the following INSERT. I have tried
SET CONSTRAINTS as well with no difference :\
Does this make any sense or am i completely mad ? (more than likely)
regards,
Stefs.
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Referential Integrity Question (Delete/Insert during Transaction)
2001-06-18 20:43 Referential Integrity Question (Delete/Insert during Transaction) Stef Telford <stef@chronozon.artofdns.com>
@ 2001-06-18 22:59 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
0 siblings, 0 replies; 2+ messages in thread
From: Stephan Szabo @ 2001-06-18 22:59 UTC (permalink / raw)
To: Stef Telford <stef@chronozon.artofdns.com>; +Cc: pgsql-sql
On Mon, 18 Jun 2001, Stef Telford wrote:
>
> I seem to have hit what i -think- may be a bug (but i am not crying
> wolf jst yet ;).
>
> I have three tables. action, client and order_details. action has a primary
> key 'order', client references action (along with adding the client_id as
> part of its primary key), order_details references client (both parts of the
> primary key there). all foreign keys (order in client and order+client_id in
> order_details) are set to INITIALLY DEFERRED. so far so good i hope.
>
> Now. the way i understand it, shouldnt the integrity of any foreign keys
> be checked at the -end- of the transaction, after all the commands have been
> processed ? it seems that the DELETE is being processed and rejected, but
> the foreign key would be 'okay' due to the following INSERT. I have tried
> SET CONSTRAINTS as well with no difference :\
Yes. There's a problem where intermediate conditions are being checked in
certain sequences of deferred constraints. It should be fixed for 7.2.
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2001-06-18 22:59 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-06-18 20:43 Referential Integrity Question (Delete/Insert during Transaction) Stef Telford <stef@chronozon.artofdns.com>
2001-06-18 22:59 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox