Created
May 31, 2016 01:04
-
-
Save Azerothian/1752ce8d4123e4025b8270e11cede003 to your computer and use it in GitHub Desktop.
macaddr, inet ilike operators for postgresql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION ilikemac(macaddr, text) | |
RETURNS boolean AS | |
$$ | |
BEGIN | |
RETURN ($1::text) ilike ($2) ; | |
END; | |
$$ LANGUAGE 'plpgsql' IMMUTABLE; | |
CREATE OPERATOR ~~* ( | |
LEFTARG = macaddr, | |
RIGHTARG = text, | |
PROCEDURE = ilikemac | |
); | |
CREATE OR REPLACE FUNCTION ilikeinet(inet, text) | |
RETURNS boolean AS | |
$$ | |
BEGIN | |
RETURN $1::text ilike $2; | |
END; | |
$$ LANGUAGE 'plpgsql' IMMUTABLE; | |
CREATE OPERATOR ~~* ( | |
LEFTARG = inet, | |
RIGHTARG = text, | |
PROCEDURE = ilikeinet | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment