X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CAF11DA734 for ; Wed, 19 Oct 2005 18:07:24 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 31854-08 for ; Wed, 19 Oct 2005 21:07:21 +0000 (GMT) Received: from mtxexch01.add0.masergy.com (mail2.masergy.com [64.47.23.36]) by svr1.postgresql.org (Postfix) with ESMTP id 26A05DA6B0 for ; Wed, 19 Oct 2005 18:07:21 -0300 (ADT) X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: [pgsql-advocacy] Oracle buys Innobase Date: Wed, 19 Oct 2005 16:07:23 -0500 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [pgsql-advocacy] [GENERAL] Oracle buys Innobase Thread-Index: AcXU7Jp6ubZEvaSFSFa/mSI8mNGQNwAAUphg From: "Guy Rouillier" To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.195 required=5 tests=[AWL=-0.179, DNS_FROM_RFC_ABUSE=0.374] X-Spam-Level: X-Archive-Number: 200510/1207 X-Sequence-Number: 85436 Doug Quale wrote: > "Marc G. Fournier" writes: >=20 >> On Wed, 19 Oct 2005, Richard_D_Levine@raytheon.com wrote: >>=20 >>> I was referring to trailing blanks, but did not explicitly say it, >>> though showed it in the examples. I am pretty sure that the SQL >>> standard says that trailing whitespace is insignificant in string >>> comparison. >>=20 >> Then we are broken too :) >>=20 >> # select 'a ' =3D 'a '; >> ?column? >> ---------- >> f >> (1 row) >=20 > # select 'a'::char(8) =3D 'a '::char(8); > ?column? > ---------- > t > (1 row) >=20 > Trailing blanks aren't significant in fixed-length strings, so the > question is whether Postgresql treats comparison of varchars right.=20 This result is being misinterpreted. =20 select length('a'::char(8)) =3D=3D> 1 select length('a '::char(8)) =3D=3D> 1 So it isn't that the two different strings are comparing equal. The process of casting them to char(8) is trimming the blanks, so by the time they become fixed length strings, they are indeed equal. Addressing Dan's subsequent note here, I tried this in Oracle: select length(cast('a ' as varchar2(30))) from dual =3D=3D> 2 So Oracle does not trim when it casts. The subject of whether casting should trim trailing blanks is yet another tangential discussion. I would say that if the user hasn't specifically asked for a trim, it shouldn't happen, but I have not read the standard on this. We're all discussing these intricacies from a comp sci perspective. From a normal user's perspective, of course, they would prefer the DBMS to hide these types of nuances. --=20 Guy Rouillier