Re: TEXT::CIDR/INET::CIDR output confusion

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: "Alexander M(dot) Pravking" <fduch(at)antar(dot)bryansk(dot)ru>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: TEXT::CIDR/INET::CIDR output confusion
Date: 2004-11-30 04:49:46
Message-ID: 200411300449.iAU4nkl07211@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


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(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Michael Fuhr 2004-11-30 04:56:23 Re: stored procedures in postgresql user plpgsql
Previous Message Christopher Browne 2004-11-30 04:09:14 Re: create stored procedure from temporary table