From: | Kyle <kyle(at)actarg(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org |
Subject: | New operators |
Date: | 2000-09-15 15:55:57 |
Message-ID: | 39C2468D.5A2DDBEF@actarg.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
I have a front end that builds queries based on a user selection of:
Match type (=, <, >, ~, ~~, etc)
Ignore/honor upper/lower case
Negate the comparison
I ended up putting the following operators in the backend so the
operators all
had parallel types of case/no-case options. This made the front end
code much simpler.
Would it be helpful to others to make these built-in operators?
-- Case insensitive operators (for consistency with like operators)
create function likenocase(text,text) returns boolean as '
begin return upper($1) like upper($2); end;' language 'plpgsql' with
(iscachable);
create operator ~~* (leftarg = text,rightarg = text,procedure =
likenocase, negator = !~~*);
create function nlikenocase(text,text) returns boolean as '
begin return upper($1) not like upper($2); end;' language 'plpgsql'
with (iscachable);
create operator !~~* (leftarg = text,rightarg = text,procedure =
nlikenocase, negator = ~~*);
create function eqnocase(text,text) returns boolean as '
begin return upper($1) = upper($2); end;' language 'plpgsql' with
(iscachable);
create operator =* (leftarg = text,rightarg = text,procedure =
eqnocase, negator = !=*);
create function neqnocase(text,text) returns boolean as '
begin return upper($1) != upper($2); end;' language 'plpgsql' with
(iscachable);
create operator !=* (leftarg = text,rightarg = text,procedure =
neqnocase, negator = =*);
Attachment | Content-Type | Size |
---|---|---|
kyle.vcf | text/x-vcard | 185 bytes |
From | Date | Subject | |
---|---|---|---|
Next Message | Jie Liang | 2000-09-15 21:29:26 | Re: get table schema in psql? |
Previous Message | Stuart Foster | 2000-09-15 15:24:45 | Where to get benchmark testing |