In case Tom isn't sick of me yet...

users=# select '10.1.2.3/24'::inet::cidr;
  ?column?   
-------------
 10.1.2.3/24

while:

users=# select '10.1.2.3/24'::cidr;
ERROR:  invalid CIDR value '10.1.2.3/24': has bits set to right of mask

Apparently, since there's no explicit function to cast from inet to cidr,
postgresql assumes its always safe to do so, as they are
binary-compatible. Anyone mind if I create explicit function for this so
this could be flagged as error?

-alex


Tue, 12 Jun 2001 09:58:21 -0400 (EDT)
Alex Pilosov <alex@pilosoft.com>
inet/cidr wierdness (casting)
Alex Pilosov <alex@pilosoft.com> writes:
> Apparently, since there's no explicit function to cast from inet to cidr,
> postgresql assumes its always safe to do so, as they are
> binary-compatible.

Yes.  I've thought for awhile that it was a mistake to treat them as
binary-compatible.  However, you'd need a lot more operator/function
declarations if they're not so marked.

> Anyone mind if I create explicit function for this so
> this could be flagged as error?

Won't help if they are binary compatible...

			regards, tom lane

Tue, 12 Jun 2001 11:19:36 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: inet/cidr wierdness (casting) 