Foreign key type checking patch

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Foreign key type checking patch
Date: 2004-03-01 15:35:58
Message-ID: Pine.LNX.4.58.0403011634110.28778@sablons.cri.ensmp.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches


Hello again patchers,

Here is a proposed patch against 7.4.1 to check exact match
of foreign key types wrt the referenced keys, and to show
a warning if this is not the case.

This is an attempt to prevent stupid bugs such as :

CREATE TABLE foo(id INT4 NOT NULL PRIMARY KEY);
CREATE TABLE bla(id INT2 REFERENCES foo);

which may work at the beginning, and then fails later on.

I'm not at ease with postgresql internals, however this
implementation seems reasonnable to me, and in the spirit
of how the surrounding code works.

I could not find any simple way to tell the user about
what is being processed, as there is not real context information
and tell 'while processing this constraint'... However this
situation seems to be the normal case with any postgresql
messages, as far as I can tell from my use.

Have a nice day,

--
Fabien Coelho - coelho(at)cri(dot)ensmp(dot)fr

Attachment Content-Type Size
fk_type_check.diff.gz application/octet-stream 3.8 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message scott.marlowe 2004-03-01 16:30:53 Re: BTrees with record numbers
Previous Message Andrew Sullivan 2004-03-01 15:09:04 Re: [HACKERS] Collaboration Tool Proposal

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2004-03-01 16:54:07 Re: Foreign key type checking patch
Previous Message Fabien COELHO 2004-03-01 08:10:54 "ALSO" keyword to "CREATE RULE" patch