Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id B5ECA475892 for ; Thu, 28 Mar 2002 14:14:08 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 80068D60C; Thu, 28 Mar 2002 11:14:08 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 75BD55C02; Thu, 28 Mar 2002 11:14:08 -0800 (PST) Date: Thu, 28 Mar 2002 11:14:08 -0800 (PST) From: Stephan Szabo To: Oleg Lebedev Cc: Postgres SQL Mailing List Subject: Re: Table constraints In-Reply-To: <3CA3685F.47E2D497@waterford.org> Message-ID: <20020328110701.E25475-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200203/383 X-Sequence-Number: 7257 On Thu, 28 Mar 2002, Oleg Lebedev wrote: > Hi everybody, > I saw a couple of messages regarding rule/constraint/trigger standards > which Tom proposed to adopt in postgres. I've read through the current > specs, but still can't figure it out. I am using version 7.1.3 and this > is what I am trying to do: > I have 2 tables: > Set { type_id int, > set_desc varchar(128) } > Type { id int primary key } > > I want to update a row in Type table and cascade this update to update > Set table. I declare a constraint as follows: > ALTER TABLE Set > ADD CONSTRAINT fk_type > FOREIGN KEY (type_id) > REFERENCES Type (id) > ON UPDATE CASCADE; > Postgres gives me a NOTICE and creates the constraint. > > Here are some questions: > Why pg_relcheck table is still empty after the constraint is added? relcheck is only for CHECK constraints. > Why instead it created 5 triggers (I checked pg_class.reltriggers for > Set table): 3 called "fk_type" on Set and 2 unnamed on Type? Hmm, it should have only created 3 triggers, 1 on set and 2 on Type and they should have all had tgconstrname set to fk_type. What does select * from pg_trigger say? > Why when I try to update id in Type table I get RI violation error? > Shouldn't it cascade the update? It works for me in 7.2. I don't have 7.1.3 to test against right now but I'm pretty sure that's in the regression test. Can you give a short script that illustrates the problem?