Table/Column Constraints

From: "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: Table/Column Constraints
Date: 2000-11-20 07:07:06
Message-ID: NEBBIOAJBMEENKACLNPCCEHNCCAA.chriskl@familyhealth.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I was looking at the ALTER TABLE DROP CONSTRAINT bit of PostgreSQL, and I
started thinking about trying to implement it (as a bit of mental exercise).
(And because it's highly annoying not being able to remove the damn things!

Please comment on all of this, and tell me if it's going to be over my head!

I'm just trying to understand some stuff:

* I assume that the command is supposed to allow the dropping of unique,
primary, foreign key and check constraints? Should 'not null' constraints
also be included here?

* Unique constraints are implemented as indicies, so dropping a unique
constraint maps to dropping the relevant index.

* Primary keys are implemented...how?? I can't for the life of me find
where 'create table' occurs in the source code!

* Foreign keys are implemented as two triggers? It seems that all that is
required is the removal of these two triggers. I haven't checked carefully
to see _exactly_ what the triggers are doing. I see there is one associated
with the 'one' table and one with the 'many' table. It seems that dropping
a foreign key constraint should be a case of removing the two triggers?

* Check constraints. I seem to recall seeing code that implements check
constraints as triggers, but I wrote a query that retrieves all triggers
associated with a particular class and no check triggers were returned. How
are check constraints implemented? How would you drop a check constraint?

* Not null constraints. This seems to be a 'for completeness' constraint -
I presume it's implemented as part of the attribute definition? I guess it
would be relatively straightforward to drop a 'not null' constraint,
assuming they are actually named in there somewhere.

Would anyone be able to correct my understanding of these issues?

Also - is there some good reason why this hasn't been implemented yet? Is
there some subtle reason, or is it just that no-one's bothered?

Thanks,

Chris

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Philip Warner 2000-11-20 07:16:34 Re: Final proposal for resolving C-vs-newC issue
Previous Message Thomas Lockhart 2000-11-20 07:04:10 Re: [COMMITTERS] pgsql/src/backend/utils/adt (cash.c)