Error message for FK referencing deferrable unique/PK

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)googlemail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Error message for FK referencing deferrable unique/PK
Date: 2009-08-12 09:20:00
Message-ID: 8e2dbb700908120220q348b64e0h780fac38f1206ed9@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

While looking at this report

http://archives.postgresql.org/pgsql-bugs/2009-08/msg00083.php

I spotted another error message which could use improvement:

CREATE TABLE foo(a int PRIMARY KEY DEFERRABLE);
CREATE TABLE bar(a int REFERENCES foo(a));

ERROR: there is no unique constraint matching given keys for
referenced table "foo"

Whereas if you define the FK slightly differently so that it goes
through transformFkeyGetPrimaryKey() instead, you get a much better
error message:

CREATE TABLE bar(a int REFERENCES foo);

ERROR: cannot use a deferrable primary key for referenced table "foo"

The attached patch to transformFkeyCheckAttrs() makes the former case
generate a similar error to the latter.

- Dean

Attachment Content-Type Size
fk-deferrable-error.patch text/x-patch 2.3 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2009-08-12 12:17:05 Re: "Hot standby"?
Previous Message Magnus Hagander 2009-08-12 09:14:13 Re: [HACKERS] BUG #4961: pg_standby.exe crashes with no args