Re: weird situation, BUG or I'm not doing it right - Mailing list pgsql-sql

From Ross J. Reedstrom
Subject Re: weird situation, BUG or I'm not doing it right
Date
Msg-id 20020825042730.GA6376@rice.edu
Whole thread Raw
In response to weird situation, BUG or I'm not doing it right  (Jiaqing Wang <jjw72@swbell.net>)
Responses Re: weird situation, BUG or I'm not doing it right  (Jiaqing Wang <jjw72@swbell.net>)
List pgsql-sql
On Sat, Aug 24, 2002 at 10:56:31PM -0700, Jiaqing Wang wrote:
> Hello,
> 
> I found below situation weird, it seems to me a bug.
> 
> backend=> select * from valid_addr where state_abrev=upper('pr');
>  zip_code | city_name | state_abrev
> ----------+-----------+-------------
> (0 rows)
> 
> while "select * from valid_addr where state_abrev='PR';" produces following
> output
> 
<20 lines of output>

You left out the critical piece: what's the schema for the table valid_addr?
I'll deduce that the column "state_abrev" is defined as something like
'char(4)'. It needs to be either char(2) (if _all_ state abbreviations are 
guarenteed to be only 2) or as text. fixed with char fields are padded with
blanks. Not a bug, but an feature of the SQL standard.

Ross


pgsql-sql by date:

Previous
From: Jiaqing Wang
Date:
Subject: weird situation, BUG or I'm not doing it right
Next
From: Manuel Sugawara
Date:
Subject: left join query does not perform well