Paul Vixie <paul@vix.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