pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedlower/upper functions and strings in searches
3+ messages / 3 participants
[nested] [flat]
* lower/upper functions and strings in searches
@ 2003-08-14 23:46 Gregory S. Williamson <gsw@globexplorer.com>
2003-08-15 00:00 ` Re: lower/upper functions and strings in searches Stephan Szabo <sszabo@megazone.bigpanda.com>
2003-08-15 00:17 ` Re: lower/upper functions and strings in searches Josh Berkus <josh@agliodbs.com>
0 siblings, 2 replies; 3+ messages in thread
From: Gregory S. Williamson @ 2003-08-14 23:46 UTC (permalink / raw)
To: pgsql-sql
I am obviuously doing some newbie trick, and I ordinarily would spend time browing the archives, but the archives.postgresql.org site seems to be absurdly slow.
This is 7.3.3 on a linux box.
I have a bunch of data with state, city, county and country names. When our application does a search for an exact match:
select * from gx_geotowns where l_state = 'NM';
I get back a lot of rows of cities in New Mexico, as expected.
If I try:
select * from gx_geotowns where upper(l_state) = upper('nm');
I get back:
---------+-----------+----------+------------+------+------
(0 rows)
I've used other databases in which a similar statement worked as exepected:
select * from clients
where upper(client_name) = upper("Some client or otheR");
And it finds the row(s) in question ...
I just know I'm overlooking some real obvious thing but for some reason this eludes me. I could see if the search was very slow (the function returns type "text" and the indexed columns are of type CHAR().
If someone could offer help I would appreciate it,
Thanks,
Greg Williamson
DBA GlobeXplorer LLC
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: lower/upper functions and strings in searches
2003-08-14 23:46 lower/upper functions and strings in searches Gregory S. Williamson <gsw@globexplorer.com>
@ 2003-08-15 00:00 ` Stephan Szabo <sszabo@megazone.bigpanda.com>
1 sibling, 0 replies; 3+ messages in thread
From: Stephan Szabo @ 2003-08-15 00:00 UTC (permalink / raw)
To: Gregory S. Williamson <gsw@globexplorer.com>; +Cc: pgsql-sql
On Thu, 14 Aug 2003, Gregory S. Williamson wrote:
> I am obviuously doing some newbie trick, and I ordinarily would spend time browing the archives, but the archives.postgresql.org site seems to be absurdly slow.
>
> This is 7.3.3 on a linux box.
>
> I have a bunch of data with state, city, county and country names. When our application does a search for an exact match:
>
> select * from gx_geotowns where l_state = 'NM';
> I get back a lot of rows of cities in New Mexico, as expected.
>
> If I try:
>
> select * from gx_geotowns where upper(l_state) = upper('nm');
You say the column is of type CHAR(), but CHAR(2) or something else?
For 7.3 and earlier, you're going to get a text comparison which means
that trailing spaces are significant (it's effectively no pad in text vs
pad space in char).
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: lower/upper functions and strings in searches
2003-08-14 23:46 lower/upper functions and strings in searches Gregory S. Williamson <gsw@globexplorer.com>
@ 2003-08-15 00:17 ` Josh Berkus <josh@agliodbs.com>
1 sibling, 0 replies; 3+ messages in thread
From: Josh Berkus @ 2003-08-15 00:17 UTC (permalink / raw)
To: Gregory S. Williamson <gsw@globexplorer.com>; pgsql-sql
Gregory,
> I just know I'm overlooking some real obvious thing but for some reason this
eludes me. I could see if the search was very slow (the function returns type
"text" and the indexed columns are of type CHAR().
Char(what?) ?
if it's, say CHAR(4) that could be your problem;
'NM'::undefined == 'NM '::CHAR
but
'NM'::TEXT != 'NM '::CHAR
so casting everything to the desired type should fix the problem.
and why are you using CHAR, anyway?
--
-Josh Berkus
Aglio Database Solutions
San Francisco
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2003-08-15 00:17 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-08-14 23:46 lower/upper functions and strings in searches Gregory S. Williamson <gsw@globexplorer.com>
2003-08-15 00:00 ` Stephan Szabo <sszabo@megazone.bigpanda.com>
2003-08-15 00:17 ` Josh Berkus <josh@agliodbs.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox