Table/Column Constraints
От | Christopher Kings-Lynne |
---|---|
Тема | Table/Column Constraints |
Дата | |
Msg-id | NEBBIOAJBMEENKACLNPCCEHNCCAA.chriskl@familyhealth.com.au обсуждение исходный текст |
Ответы |
Re: Table/Column Constraints
|
Список | 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
В списке pgsql-hackers по дате отправления: