From: Guy Rouillier <guyr@masergy.com>
To: pgsql-general@postgresql.org
Subject: Re: [pgsql-advocacy] Oracle buys Innobase
Date: Wed, 19 Oct 2005 16:07:23 -0500
Message-ID: <CC1CF380F4D70844B01D45982E671B239E8BEC@mtxexch01.add0.masergy.com> (raw)
Doug Quale wrote:
> "Marc G. Fournier" <scrappy@postgresql.org> writes:
>
>> On Wed, 19 Oct 2005, Richard_D_Levine@raytheon.com wrote:
>>
>>> 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.
>>
>> Then we are broken too :)
>>
>> # select 'a ' = 'a ';
>> ?column?
>> ----------
>> f
>> (1 row)
>
> # select 'a'::char(8) = 'a '::char(8);
> ?column?
> ----------
> t
> (1 row)
>
> Trailing blanks aren't significant in fixed-length strings, so the
> question is whether Postgresql treats comparison of varchars right.
This result is being misinterpreted.
select length('a'::char(8)) ==> 1
select length('a '::char(8)) ==> 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 ==> 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.
--
Guy Rouillier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: guyr@masergy.com, pgsql-general@postgresql.org
Subject: Re: [pgsql-advocacy] Oracle buys Innobase
In-Reply-To: <CC1CF380F4D70844B01D45982E671B239E8BEC@mtxexch01.add0.masergy.com>
References: <CC1CF380F4D70844B01D45982E671B239E8BEC@mtxexch01.add0.masergy.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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