Skip site navigation (1) Skip section navigation (2)

Re: [HACKERS] lower() broken?

From: "jose' soares" <sferac(at)bo(dot)nettuno(dot)it>
To: Vince Vielhaber <vev(at)michvhf(dot)com>
Cc: hackers(at)postgresql(dot)org
Subject: Re: [HACKERS] lower() broken?
Date: 1999-02-22 13:44:34
Message-ID: 36D15F42.A75109C7@bo.nettuno.it (view raw or flat)
Thread:
Lists: pgsql-hackers

Vince Vielhaber ha scritto:

> I have a record in table cust with the username of  joblo  and it's
> already lower case.  This is from a cvsup a couple of weeks old.
>
> classifieds=> select count(*) from cust where username = lower('joblo');
> count
> -----
>     0
> (1 row)
>
> classifieds=> select count(*) from cust where username = 'joblo';
> count
> -----
>     1
> (1 row)
>
> Doesn't seem to matter if I use lower on username, 'joblo' or both.  And
> there's only the one record in the table.
>
> Did something break or did I forget how to use lower()?
>
> Vince.

I suppose you defined username as char() like...

prova=> create table test(username char(10));
CREATE
prova=> insert into test values ('joblo');
INSERT 207732 1
prova=> select count(*) from test where username = lower('joblo');
count
-----
    0
(1 row)


prova=> select count(*) from test where trim(username) = lower('joblo');
count
-----
    1
(1 row)

prova=> select count(*) from test where username = 'joblo';
count
-----
    1
(1 row)

prova=> select count(*) from test where username = lower('joblo     ');
count
-----
    1
(1 row)

The lower function "trims" the trailling spaces, this is why comparison fails.

because 'joblo     '  !=  'joblo'

I think this is a bug.

 - Jose' -



In response to

pgsql-hackers by date

Next:From: Andy SelleDate: 1999-02-22 13:46:09
Subject: Re: [HACKERS] SELECT COUNT(DISTINCT)
Previous:From: Oleg BroytmannDate: 1999-02-22 13:22:31
Subject: SELECT COUNT(DISTINCT)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group