Re: Table inheritance, unique constraints and foreign key problem

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Jacob Rief" <jacob(dot)rief(at)gmx(dot)at>
Cc: <hackers(at)postgresql(dot)org>
Subject: Re: Table inheritance, unique constraints and foreign key problem
Date: 2007-11-27 00:42:56
Message-ID: 877ik4ecxb.fsf@oxford.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Jacob Rief" <jacob(dot)rief(at)gmx(dot)at> writes:

> this issue has been requested and its on the TODO-list. Since I really
> need foreign key constraints on inherited tables, I have two solutions:
> Adding some hackish RULES/TRIGGERS to my tables or implementing it
> myself. It think the latter is better. However, I have no experience in
> implementing such a feature in Postgres. I have written some triggers in
> C (actually C++) using the SPI_-functions, but that's it. I have a
> running 8.3beta, checked out from the repository, and I have read the
> Ottawa slides. Can someone tell me in a few lines, where to start with
> such a feature.

This is the tip of an iceberg. As you dig you find out it's caused by deeper
and deeper limitations until you're pretty much all of the executor.

The RI trigger code explicitly uses ONLY for the integrity checks. But if you
remove that you find it breaks because you get this message:

ERROR: SELECT FOR UPDATE/SHARE is not supported for inheritance queries

Look at src/backend/optimizer/path/allpaths.c:287 for a comment about this.

I'm a bit puzzled myself why this affects SELECT FOR UPDATE/SHARE but not
straight UPDATES and DELETES.

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Get trained by Bruce Momjian - ask me about EnterpriseDB's PostgreSQL training!

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message John Walker 2007-11-27 02:01:39 developing for psqlodbc
Previous Message Bruce Momjian 2007-11-27 00:39:17 Re: 8.3devel slower than 8.2 under read-only load