Re: Foreign key not working in some cases when using triggers

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Martin Edlman <edlman(at)fortech(dot)cz>
Cc: PostgreSQL Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: Foreign key not working in some cases when using triggers
Date: 2003-09-04 15:58:33
Message-ID: 20030904085359.W37906-100000@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


> I have problem with foreign keys on postgresql-7.3.2-1PGDG.
>
> I have two tables, sorry for the lenght, but I want to give you complete
> information.
>
> Table qmail_account has FK on zone(name). On some occasions when I want
> to insert data to qmail_account I get the RI error that the value of
> qmail_account.domain was not found in zone.name. I'm sure it is there.
> Maybe there is some problem with index zone_name_key.
> Originaly I had this problem with zone.name and qmail_account.domain
> defined as varchar(100), so I changed it to char(100), but it didn't help.
> This problem occurs on some domains only - but on these domains it gives
> the error every time.
> I realized that when I insert the data with the "on-insert-working" domain
> and then update it to the "on-insert-not-working" domain, the update
> works.
> As I have a trigger on qmail_account which checks some values and sets
> them if they are empty. "home" is filled different ways for public and
> private domains, so I use select query to the "zone".
> When I specify "home" at insert, it works even with domains it failed with
> empty and then auto-filled "home".
>
> The trigger is run before insert/update on qmail_account. The trigger
> doesn't change the value of NEW.domain in any way.
>
> So I'd like to know if there is something I can do to make the insert
> working with the trigger.

If possible, can you give a complete example script that shows the
problem?

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Bertrand Petit 2003-09-04 20:28:53 Re: [HACKERS] [BUGS] 7.4 beta 1: SET log_statement=false
Previous Message Ben Grimm 2003-09-04 12:59:37 pg_dump/all doesn't output schemas correctly (v7.3.4)