Foreign Keys: check_primary_function

From: Anand Surelia <anand(at)bytekinc(dot)com>
To: "pgsql-general(at)postgreSQL(dot)org" <pgsql-general(at)postgreSQL(dot)org>, "pgsql-hackers(at)postgreSQL(dot)org" <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Foreign Keys: check_primary_function
Date: 1998-09-21 19:05:52
Message-ID: 3606A390.4C492BCF@bytekinc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Hi All,
I've changed the check_primary_key() function code to allow for either
the "automatic insert key rule" or "dependent insert key rule".
Previously it restricted the addtion of a child entry if the
corresponding parent entry was not there. Now if the option is
"automatic" it will add an entry in the parent too ( it will be
successful if there are no no-null fields in the parent apart from the
primary key).
The way to use it now is:
/*
* check_primary_key () -- check that key in tuple being
inserted/updated
* references existing tuple in "primary" table.
* Though it's called without args You have to specify referenced
* table/keys while creating trigger: key field names in triggered
table,
* referenced table name, referenced key field names,type of action
[automatic|dependent]:
* EXECUTE PROCEDURE
* check_primary_key ('Fkey1', 'Fkey2', 'Ptable', 'Pkey1', 'Pkey2',
'[automatic|dependent]').
*/
I am attaching the new ../contrib/spi/refint.c file which will do this.
I will be glad to help in case of any problems.

- Anand.

Attachment Content-Type Size
myrefint.c text/plain 17.0 KB

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Mr Richard Wang 1998-09-21 19:14:08 [Fwd: Redhat Postgres 6.3]
Previous Message Jackson, DeJuan 1998-09-21 18:32:05 RE: [GENERAL] Re:Foreign Keys

Browse pgsql-hackers by date

  From Date Subject
Next Message Brook Milligan 1998-09-21 20:37:33 Re: [HACKERS] union regression test
Previous Message Thomas G. Lockhart 1998-09-21 17:43:25 Re: [sferac@bo.nettuno.it: Re: [HACKERS] BUG: NOT boolfield kills backend]