RE in where

Started by Patrick Nelsonabout 23 years ago4 messagesgeneral
Jump to latest
#1Patrick Nelson
pnelson@neatech.com

Ran a query that I run periodically and it no longer works. It looks like:

SELECT * FROM hosts WHERE host ~ '^61.216.';

However, now I get an error:

ERROR: Unable to identify an operator '~' for types 'inet' and '"unknown"'
You will have to retype this query using an explicit cast

Anyone know what I've got going that is wrong?

#2Patrick Nelson
pnelson@neatech.com
In reply to: Patrick Nelson (#1)
Re: RE in where

Patrick Nelson wrote:
----------------->>>>
Ran a query that I run periodically and it no longer works. It looks like:

SELECT * FROM hosts WHERE host ~ '^61.216.';

However, now I get an error:

ERROR: Unable to identify an operator '~' for types 'inet' and '"unknown"'
You will have to retype this query using an explicit cast

Anyone know what I've got going that is wrong?
----------------->>>>
More info:

Oh this is v7.3.1-1PGDG running on RH73 (server) and RH72 (clients)

This seems to be only with the inet data type. The other data types I try
with the ~ (or ~~) work fine.

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Patrick Nelson (#2)
Re: RE in where

Patrick Nelson <pnelson@neatech.com> writes:

Ran a query that I run periodically and it no longer works. It looks like:
SELECT * FROM hosts WHERE host ~ '^61.216.';
However, now I get an error:
ERROR: Unable to identify an operator '~' for types 'inet' and '"unknown"'
You will have to retype this query using an explicit cast

The inet-to-text cast isn't implicit anymore. You need an explicit
cast:
SELECT * FROM hosts WHERE host::text ~ '^61.216.';

regards, tom lane

#4Patrick Nelson
pnelson@neatech.com
In reply to: Tom Lane (#3)
Re: RE in where [SOLVED]

Tom Lane wrote:
----------------->>>>
The inet-to-text cast isn't implicit anymore. You need an explicit
cast:
SELECT * FROM hosts WHERE host::text ~ '^61.216.';
----------------->>>>

Worked like a charm...

Looked in the documentation but didn't see any ref to it. Any others
besides inet and unknown?