Re: I'm puzzled by a foreign key constraint problem

From: Richard Huxton <dev(at)archonet(dot)com>
To: Jonathan Guthrie <jguthrie(at)brokersys(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: I'm puzzled by a foreign key constraint problem
Date: 2008-11-04 07:49:33
Message-ID: 490FFE8D.9020606@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Jonathan Guthrie wrote:
> When I create a project, entries in the project table and the resource
> table are created in a single function. Then, separate functions are
> called to set the owner's access to the new project. These other
> functions are failing because of the resourceid foreign key constraint.

Have you turned statement logging on? Your message suggests that's the
case, but didn't say so explicitly.

Are the two steps:
1. Create project, resource
2. Set access-rights
done in separate connections by any chance? If so it's possible (due to
MVCC) that #2 is still seeing the database as it was before #1 committed.

> Anyway, I need for these operations to succeed because the lack of
> permissions causes odd problems in other parts of the system.

If you want both steps to succeed or fail together though, they need to
be in the same transaction.

--
Richard Huxton
Archonet Ltd

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thom Brown 2008-11-04 09:45:12 Best memory/planner settings for Postgres
Previous Message Tom Lane 2008-11-04 05:38:23 Re: INSERT with RETURNING clause inside SQL function