Re: bug/feature with upper function? - Mailing list pgsql-general

From Stephan Szabo
Subject Re: bug/feature with upper function?
Date
Msg-id 20020320104555.W47650-100000@megazone23.bigpanda.com
Whole thread Raw
In response to bug/feature with upper function?  (Vincent Stoessel <vincent@xaymaca.com>)
List pgsql-general
On Wed, 20 Mar 2002, Vincent Stoessel wrote:

> I am having a serious problem matching text using the upper() function
> in postgres 7.2 (from developer rpms) on  Redhat 7.2
>
> FEC=# SELECT * from upp_test where uname = 'KAT' ;
>          uname
> ----------------------
>   KAT
>   KAT
>   KAT
>   KAT
>   KAT
> (5 rows)
>
> db=# SELECT * from upp_test where upper(uname)  = 'KAT' ;
>   uname
> -------
> (0 rows)
>
> The reason I am worried about this is that I have a mix of upper and
> lower case words in the real world coumn and I have not been getting
> complete matches. Is this a bug?

You're getting a type conversion with upper (IIRC it's upper(text) returns
text) which is changing the behavior relating to the padding spaces.
It's going to think the upper is 'KAT               ' (I think I counted
out the right number of spaces).

In general it's often easiest to make the column varchar rather than char
unless you really are using the padding behavior, but you could possible
get away with an additional upper function:

create function upper(character) returns character as 'select upper(CAST(
$1 as text));' language 'sql';



pgsql-general by date:

Previous
From: Richard Huxton
Date:
Subject: Re: bug/feature with upper function?
Next
From: Bruno Wolff III
Date:
Subject: Re: zerofill: lost my leading zeroes