Re: Re: I think I know what I'm doing wrong, but.... - Mailing list pgsql-novice

From Tom Lane
Subject Re: Re: I think I know what I'm doing wrong, but....
Date
Msg-id 17336.978800658@sss.pgh.pa.us
Whole thread Raw
In response to Re: I think I know what I'm doing wrong, but....  ("Eric Nielsen" <ericnielsen@earthlink.net>)
Responses Re: Re: I think I know what I'm doing wrong, but....
List pgsql-novice
"Eric Nielsen" <ericnielsen@earthlink.net> writes:
>> However the insert fails, with a referential integrity problem.  I _think_
>> this is because it tries to do the rule's trigger before actually doing
>> the original select, so the key does not exist.

I think you are right.  Non-INSTEAD rule actions are executed before the
original query is carried out.  I have argued in the past that this is
stupid for ON INSERT rules, which would be better done after the
original query, but I haven't had any luck getting agreement to change
it.

>> Is there a solution using rules,

Only if you can use a delayed referential integrity check that isn't
checked till end of transaction.  I don't know offhand if we even
implement such a feature, let alone whether it'd be OK for your
application logic.

            regards, tom lane

pgsql-novice by date:

Previous
From: "Eric Nielsen"
Date:
Subject: Re: I think I know what I'm doing wrong, but....
Next
From: "Fernando M. Maresca"
Date:
Subject: Re: well, this is a newbie list...