Re: casting TEXT to CIDR (or to INET) has to be possible

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Paul Vixie <paul(at)vix(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: casting TEXT to CIDR (or to INET) has to be possible
Date: 2001-12-23 07:22:53
Message-ID: 21158.1009092173@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Paul Vixie <paul(at)vix(dot)com> writes:
> lartomatic=# select (host(relay)||'/18')::cidr from spam limit 5;
> ERROR: Cannot cast type 'text' to 'cidr'
> lartomatic=# select (host(relay)||'/18')::inet from spam limit 5;
> ERROR: Cannot cast type 'text' to 'inet'

Your wish is our command ;-). It seems to work okay in 7.2 beta:

regression=# create table spam(relay inet);
CREATE
regression=# insert into spam values ('127.0.0.1');
INSERT 287658 1
regression=# select (host(relay)||'/18')::cidr from spam limit 5;
ERROR: invalid CIDR value '127.0.0.1/18': has bits set to right of mask
regression=# select (host(relay)||'/18')::inet from spam limit 5;
inet
--------------
127.0.0.1/18
(1 row)

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2001-12-23 07:27:39 Re: Backend process termination + database corruption
Previous Message William Yu 2001-12-22 07:29:50 Backend process termination + database corruption