Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 43D30475CA9 for ; Sun, 25 Aug 2002 08:48:19 -0400 (EDT) Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by postgresql.org (Postfix) with SMTP id 22C3147582E for ; Sun, 25 Aug 2002 08:48:17 -0400 (EDT) Received: (qmail 32236 invoked by uid 0); 25 Aug 2002 12:48:20 -0000 Received: from chello062178186201.1.15.tuwien.teleweb.at (HELO beeblebrox) (62.178.186.201) by mail.gmx.net (mp006-rz3) with SMTP; 25 Aug 2002 12:48:20 -0000 Message-ID: <002201c24c35$d5bd0ef0$0100a8c0@beeblebrox> From: "Michael Paesold" To: "Ross J. Reedstrom" , "Jiaqing Wang" Cc: References: <20020825042730.GA6376@rice.edu> Subject: Re: weird situation, BUG or I'm not doing it right Date: Sun, 25 Aug 2002 14:49:21 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/338 X-Sequence-Number: 9184 Ross J. Reedstrom wrote: > 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 Then, why is 'PR' blank padded to char(?) and upper('pr') not? It seems that when comparing char with text, the comparision is done as text, not as bpchar. billing=# select 'A'::char(2) = upper('a'); ?column? ---------- f billing=# select 'A'::char(2) = upper('a')::bpchar; ?column? ---------- t Regards, Michael Paesold