Hallo.

i just coded a new datatype named "cistring", that can be
used in every function that accepts text or varchar, and has
the great ability to be ordered case insensitive in ORDER BY-
Clauses and Indices. The problem is, that its coded like the 
text-type, so it is variable length completly.

I miss the possibility to code something like a userdifined
varchar(n). I don't know how to create an input function,
that accepts the size of the type, or a function, how to declare
such types at all. I think, somethink like a userdefined 
numeric(n,m) isn't possible, too, or am I wrong?

Thank you for all replies,
Daniel Migowski


Thu, 30 Oct 2003 09:42:47 +0100
Daniel Migowski <nur-gueltig-bis-2003-12-01@Mig-O.de>
CREATE TYPE for case insensitive text and varchar
Daniel Migowski <nur-gueltig-bis-2003-12-01@Mig-O.de> writes:
> I miss the possibility to code something like a userdifined
> varchar(n).

You're out of luck on that.  The data types that can have precision
parameters attached to them are hard-wired into the parser.

			regards, tom lane

Thu, 30 Oct 2003 17:34:14 -0500
Tom Lane <tgl@sss.pgh.pa.us>
Re: CREATE TYPE for case insensitive text and varchar 
Tom Lane wrote:

> Daniel Migowski <nur-gueltig-bis-2003-12-01@Mig-O.de> writes:
>> I miss the possibility to code something like a userdifined
>> varchar(n).
> 
> You're out of luck on that.  The data types that can have precision
> parameters attached to them are hard-wired into the parser.

Maybe you don't need to invent a whole new data type but the existing 
varchar can serve just fine?

The attached script for version 7.3.4 (does not work with 7.4) 
demonstrates how to add case insensitive operators *=, *> and so on 
including an operator class for btree to the existing varchar.

All one has to do is to use *= instead of = in queries. Indexes, even 
unique, based on case insensitive comparision are possible too and well 
supported. The only thing I think wouldn't work are IN and NOT IN 
constructs.


Jan

-- 
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#================================================== JanWieck@Yahoo.com #
Thu, 30 Oct 2003 22:38:19 -0500
Jan Wieck <JanWieck@Yahoo.com>
Re: CREATE TYPE for case insensitive text and varchar