X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 19468D980C for ; Mon, 26 Sep 2005 18:34:36 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 05409-09 for ; Mon, 26 Sep 2005 21:34:32 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id D6443D980E for ; Mon, 26 Sep 2005 18:34:30 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j8QLXBgO062943 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 26 Sep 2005 15:33:13 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j8QLXAjB051557; Mon, 26 Sep 2005 15:33:11 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j8QLXA6s051556; Mon, 26 Sep 2005 15:33:10 -0600 (MDT) (envelope-from mfuhr) Date: Mon, 26 Sep 2005 15:33:09 -0600 From: Michael Fuhr To: Axel Rau Cc: pgsql-sql@postgresql.org, daryl@brandywine.com Subject: Re: Updating cidr column with network operator Message-ID: <20050926213309.GA37147@winnie.fuhr.org> References: <4332C38E.5040807@brandywine.com> <72c14f47f1dca0ae99e559cef56416a3@Chaos1.DE> <43331359.1020703@brandywine.com> <20050923173204.GA80995@winnie.fuhr.org> <4a95b442a12d5b4f3cc508868a13aba5@Chaos1.DE> <20050926000541.GA11071@winnie.fuhr.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] X-Spam-Level: X-Archive-Number: 200509/254 X-Sequence-Number: 22801 On Mon, Sep 26, 2005 at 12:34:59PM +0200, Axel Rau wrote: > Am 26.09.2005 um 02:05 schrieb Michael Fuhr: > > On Fri, Sep 23, 2005 at 09:19:25PM +0200, Axel Rau wrote: > > > I'm sure this would be the cleanest solution but remember networks > > > change. > > > > Yes, which is why it's a good idea to automatically propogate those > > changes to tables that maintain redundant data. > > I would not call it redundant but normalized, because network has some > attributes, common to all addresses in the net, 1st of all the netmask. An attribute is redundant if it repeats a fact that can be learned without it. If one table contains IP addresses and another contains networks, then you can associate IP addresses and networks with a join of the two tables; indeed, this is how the "fix the network column" update works. Having a network column in the address table simply repeats what could be learned through the join. > > > > This update also might not give the results you want if more than > > > > one network matches. > > > > > > This is not possible, because the pk of network is the net cidr. > > > > Yes, it is possible, because the update's join condition isn't > > equality but rather containment. If the network table contains > > 10.1.0.0/16 and 10.1.0.0/24, then the IP address 10.1.0.1 would > > match both. > > You mean, unique does not imply none-overlapping for data-type > network? Oh, I didn't know that. > > Who is responsible for this func spec? This is completly contra- > real-world-experience. Can this be re-considered for a future release? This isn't "completely contra-real-world-experience" -- it's just contrary to your particular use case. The networks 10.1.0.0/16 and 10.1.0.0/24 are in fact different, and in some applications having both in a table's primary key column would be perfectly legitimate. For example, a table might store network administration information, where the administrator for 10.1.0.0/16 as a whole is Group X, and the administrator for 10.1.0.0/24 in particular is Group Y. -- Michael Fuhr