X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 041C83A535C for ; Tue, 30 Nov 2004 04:50:34 +0000 (GMT) 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 36872-05 for ; Tue, 30 Nov 2004 04:50:33 +0000 (GMT) Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 2AC923A5357 for ; Tue, 30 Nov 2004 04:50:29 +0000 (GMT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id iAU4nkl07211; Mon, 29 Nov 2004 23:49:46 -0500 (EST) From: Bruce Momjian Message-Id: <200411300449.iAU4nkl07211@candle.pha.pa.us> Subject: Re: TEXT::CIDR/INET::CIDR output confusion In-Reply-To: <20041112213158.GF12640@dyatel.antar.bryansk.ru> To: "Alexander M. Pravking" Date: Mon, 29 Nov 2004 23:49:46 -0500 (EST) Cc: pgsql-sql@postgresql.org X-Mailer: ELM [version 2.4ME+ PL108 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/294 X-Sequence-Number: 19612 Added to TODO list: * Prevent INET cast to CIDR from droping netmask, SELECT '1.1.1.1'::inet::cidr It is probably related to the TODO item above it: * Prevent INET cast to CIDR if the unmasked bits are not zero, or zero the bits I think the original code thought CIDR and INET where identical types that could be cast with no changes but we are finding that was incorrect. --------------------------------------------------------------------------- Alexander M. Pravking wrote: > It looks a bit strange that CIDR output depends on datatype it has been > casted from: > > fduch=# SELECT '1.1.1.1'::cidr; > cidr > ------------ > 1.1.1.1/32 > (1 row) > > fduch=# SELECT '1.1.1.1'::inet::cidr; > cidr > --------- > 1.1.1.1 > (1 row) > > > However these two seem to be 'equal' in terms of backend: > > fduch=# SELECT '1.1.1.1'::inet::cidr = '1.1.1.1'::inet; > ?column? > ---------- > t > (1 row) > > fduch=# SELECT '1.1.1.1'::inet::cidr = '1.1.1.1'::cidr; > ?column? > ---------- > t > (1 row) > > > I'm just curious how can it even be... > > fduch=# SELECT version(); > version > ------------------------------------------------------------------------------------------------ > PostgreSQL 7.4.5 on i386-portbld-freebsd5.3, compiled by GCC cc (GCC) 3.4.2 [FreeBSD] 20040728 > > > -- > Fduch M. Pravking > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073