Unix Technical Forum

Re: [GENERAL] 'a' == 'a '

This is a discussion on Re: [GENERAL] 'a' == 'a ' within the pgsql Hackers forums, part of the PostgreSQL category; --> > -----Original Message----- > From: Tom Lane [mailto:tgl@sss.pgh.pa.us] > Sent: Thursday, October 20, 2005 2:54 PM > To: Dann ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-11-2008, 07:20 AM
Dann Corbit
 
Posts: n/a
Default Re: [GENERAL] 'a' == 'a '

> -----Original Message-----
> From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
> Sent: Thursday, October 20, 2005 2:54 PM
> To: Dann Corbit
> Cc: Richard_D_Levine@raytheon.com; general@postgresql.org; pgsql-
> hackers@postgresql.org
> Subject: Re: [GENERAL] [HACKERS] 'a' == 'a '
>
> "Dann Corbit" <DCorbit@connx.com> writes:
> > I guess that additional ambiguity arises if you add additional

spaces to
> > the end. Many database systems solve this by trimming the

characters
> > from the end of the string upon storage and the returned string will

not
> > have any trailing blanks.

>
> Can you document that? ISTM that that would effectively make char(n)
> and varchar(n) exactly equivalent, which is ... um ... a bit stupid.


This is SQL*Server:

drop table test_char
go
create table test_char(
fixed_30 char(30),
varch_30 varchar(30),
nchar_30 nchar(30),
nvarc_30 nvarchar(30)
)
go
insert into test_char values('Dann ', 'Dann ', 'Dann ', 'Dann ')
go
select len(fixed_30), len(varch_30), len(nchar_30), len(nvarc_30)
from test_char
go

Result set:
4 4 4 4


---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-11-2008, 07:20 AM
Andrew Dunstan
 
Posts: n/a
Default Re: [GENERAL] 'a' == 'a '



Dann Corbit wrote:

>>-----Original Message-----
>>From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
>>Sent: Thursday, October 20, 2005 2:54 PM
>>To: Dann Corbit
>>Cc: Richard_D_Levine@raytheon.com; general@postgresql.org; pgsql-
>>hackers@postgresql.org
>>Subject: Re: [GENERAL] [HACKERS] 'a' == 'a '
>>
>>"Dann Corbit" <DCorbit@connx.com> writes:
>>
>>
>>>I guess that additional ambiguity arises if you add additional
>>>
>>>

>spaces to
>
>
>>>the end. Many database systems solve this by trimming the
>>>
>>>

>characters
>
>
>>>from the end of the string upon storage and the returned string will
>>>
>>>

>not
>
>
>>>have any trailing blanks.
>>>
>>>

>>Can you document that? ISTM that that would effectively make char(n)
>>and varchar(n) exactly equivalent, which is ... um ... a bit stupid.
>>
>>

>
>This is SQL*Server:
>
>drop table test_char
>go
>create table test_char(
> fixed_30 char(30),
> varch_30 varchar(30),
> nchar_30 nchar(30),
> nvarc_30 nvarchar(30)
>)
>go
>insert into test_char values('Dann ', 'Dann ', 'Dann ', 'Dann ')
>go
>select len(fixed_30), len(varch_30), len(nchar_30), len(nvarc_30)
>from test_char
>go
>
>Result set:
>4 4 4 4
>
>
>
>


Yech.

What does one do in such a system if you want trailing blanks to be
significant, or even kept?

Anyway, the consensus seems to be that Postgresql's behavious is
consistent with a reasonable reading of the standard, so is there
anything really left to discuss, other than a possible addition to
documentation?

cheers

andrew



---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:17 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com