From: Bruce Momjian <pgman@candle.pha.pa.us>
To: Alexander M. Pravking <fduch@antar.bryansk.ru>
Cc: pgsql-sql@postgresql.org
Subject: Re: TEXT::CIDR/INET::CIDR output confusion
Date: Mon, 29 Nov 2004 23:49:46 -0500 (EST)
Message-ID: <200411300449.iAU4nkl07211@candle.pha.pa.us> (raw)
In-Reply-To: <20041112213158.GF12640@dyatel.antar.bryansk.ru>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: pgman@candle.pha.pa.us, fduch@antar.bryansk.ru
Subject: Re: TEXT::CIDR/INET::CIDR output confusion
In-Reply-To: <200411300449.iAU4nkl07211@candle.pha.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox