Skip site navigation (1) Skip section navigation (2)

Re: Re: postgres - development of inet/cidr

From: Sevo Stille <sevo(at)ip23(dot)net>
To: "D'Arcy J(dot)M(dot) Cain" <darcy(at)druid(dot)net>
Cc: Jakub Bartosz Bielecki <J(dot)B(dot)Bielecki(at)elka(dot)pw(dot)edu(dot)pl>, pgsql-hackers(at)PostgreSQL(dot)org
Subject: Re: Re: postgres - development of inet/cidr
Date: 2000-07-03 14:41:02
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
"D'Arcy J.M. Cain" wrote:
> Thus spake Jakub Bartosz Bielecki
> > 1. all functions which return text (host, network etc) should
> >       return pascal-like ASCII string not C-like ASCIIZ
> >    example:
> >       select host('')='';  -- this returns false!

Which it should not. In a text-to-text comparison, both have to be

> > 2. inet comparison routines (and thus operators) work in a strange way
> >    if I set netmask length to a non-default value (other than 32).
> >    example:
> >       select ''::inet=''::inet;  -- returns true
> >    I guess that this behaviour is different from described in manual.

This would be proper behaviour for the cidr datatype, which describes a
network. "select ''::cidr=''::cidr;" has to return
true, as both define the same network, the mask putting the 1 vs. 2
outside the comparison scope. 

On inet, I consider the above broken - going by the documentation,
having a netmask on a inet datatype does not define a network address
but rather supplies additional information on the cidr network the host
as specified by the address is in. Accordingly, it should only truncate
if the comparison casts to cidr. 

The big question is whether comparisons that only work on a cidr data
type (contains/contained) or have a cidr type on one side can safely
cast the inet type to cidr implicitly. For: 

"select ''::inet = ''::inet;"  FALSE  
"select ''::cidr = ''::cidr;"  TRUE
"select ''::cidr = ''::inet;"  FALSE  
"select ''::cidr >> ''::inet;" TRUE  
"select ''::cidr << ''::inet;" ERROR 

it looks sane, IMHO. But we need to reach an agreement on the proper
behaviour on greater/smaller comparisons. Should:

"select ''::inet > ''::cidr;"  

be true or false? Casting to cidr prior to comparison would make it
equivalent to "select ''::cidr > ''::cidr;", which
is false, both networks being equal. But we have at least three possible
comparisons of host to network - besides comparing net to net, the host
might be compared to the the base or top address of the network. That
situation can only be resolved doing explicit casts, so throwing an
error in these cases is IMHO indicated.



In response to


pgsql-hackers by date

Next:From: Tom LaneDate: 2000-07-03 14:47:07
Subject: Re: Backend Question
Previous:From: Chris BitmeadDate: 2000-07-03 14:38:38
Subject: Re: Backend Question

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group