Re: More on inheritance and foreign keys
От | Andreas Pflug |
---|---|
Тема | Re: More on inheritance and foreign keys |
Дата | |
Msg-id | 44884886.5@pse-consulting.de обсуждение исходный текст |
Ответ на | Re: More on inheritance and foreign keys (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: More on inheritance and foreign keys
|
Список | pgsql-hackers |
Tom Lane wrote: > "Zeugswetter Andreas DCP SD" <ZeugswetterA@spardat.at> writes: > >>>The solution to the foreign key problem seems easy if I >>>modify PostgreSQL implementation and take off the ONLY word >>>from the SELECT query, but it's not an option for me, as I'm > > >>I think that the ONLY was wrong from day one :-( > > > Well, sure, but until we have an implementation that actually *works* > across multiple tables, it has to be there so that we can at least > consistently support the current single-table semantics. Until we > have some form of cross-table unique constraint (index or whatever) I managed uniqueness using normal indexes and ins/upd triggers on all child tables: CREATE OR REPLACE FUNCTION checkchildsunique RETURNS trigger AS $BODY$BEGIN IF EXISTS (SELECT 1 FROM foo Master WHERE Master.primaryKeyCol = NEW.primaryKeyCol) THEN RAISE EXCEPTION 'Primary Key violation in table % on %',TG_RELNAME, TG_OP; END IF; RETURN NEW; END;$BODY$ LANGUAGE 'plpgsql' Shouldn't be too complicated to implement it as internal function. Regards, Andreas
В списке pgsql-hackers по дате отправления: