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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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

Browse pgsql-hackers by date

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