Re: Re: User-defined operator function: what parameter type to use for uncast character string? - Mailing list pgsql-general

From Adam Mackler
Subject Re: Re: User-defined operator function: what parameter type to use for uncast character string?
Date
Msg-id 20140801062356.GA20484@scruffle.mackler.org
Whole thread Raw
In response to Re: Re: User-defined operator function: what parameter type to use for uncast character string?  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: User-defined operator function: what parameter type to use for uncast character string?  (David G Johnston <david.g.johnston@gmail.com>)
Re: Re: User-defined operator function: what parameter type to use for uncast character string?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On Thu, Jul 31, 2014 at 10:03:00AM -0400, Tom Lane wrote:
> 2. text is the preferred type among the string class, so any case where
> you have text on one side and some other string type on the other is
> going to get resolved as text vs text.
> Because of #1, domain-specific functions and operators tend to be pretty
> useless; you find yourself always having to cast the other side to get
>
> If you're intent on having this behavior, the way to go at it is to make
> your own actual datatype (not a domain) and create all your own comparison
> operators for it.  You can add an implicit cast to text for cases where

Thanks to everyone who responded to my question.  Yes, the
case-insensitivity was an example contrivance.  My actual operator
function is using regular expressions to do text replacements, so
citext is not going to solve all my problems.  Looks like 'CREATE
TYPE' is the only way to get what I'm after here, and since there are
regular expressions involved, a C-language solution is not seeming
like it's going to be very convenient.  On top of that, the content of
my regular-expression replacement strings are constructed from data
in my database, so really my SQL-language operator function seemed
ideal except--of course--for the limitations you all have explained to
me.

One final question: the 'CREATE CAST' command got my interest.  I'm
assuming that when the docs say it 'performs a conversion between two
data types,' that the meaning of "data type" includes only those
created using 'CREATE TYPE' and excludes domains.  If I am mistaken on
that point I would be grateful to learn of that mistake.

Thanks again,
--
Adam Mackler


pgsql-general by date:

Previous
From: John R Pierce
Date:
Subject: Re: Upgrading from 9.0.11 to 9.3.5 on CentOS 6 (64 bit)
Next
From: Larry White
Date:
Subject: Re: Very Limited Toast Compression on JSONB (9.4 beta 2)