Re: char columns, space padding, and the "like" operator

From: "Haszlakiewicz, Eric" <EHASZLA(at)transunion(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <pgsql-interfaces(at)postgresql(dot)org>
Subject: Re: char columns, space padding, and the "like" operator
Date: 2009-02-02 22:07:43
Message-ID: 9D29FD18CBD74A478CBA86E6EF6DBAD403394E01@CHI4EVS04.corp.transunion.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

>-----Original Message-----
>From: Tom Lane [mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us]
>
>"Haszlakiewicz, Eric" <EHASZLA(at)transunion(dot)com> writes:
>> Once I realized that the value in the table actually got extended to
>> 'SOMEVALUE ', things started making sense, since the equivalent quick
>> select is actually:
>> select 'SOMEVALUE ' like 'SOME% %';
>
>> Unfortunately, my app has a whole bunch of places where it uses
>> constructs like this against char columns. Other databases (such as
>> Informix), automatically strip spaces off char column so queries like
>> the above behave in a more intuitive fashion.
>
>Cast the char(n) column to text or varchar, and it should work more
>like you're expecting.

Yeah, I figured that much. I was hoping for a connection-wide or
database-wide setting, so I wouldn't have to go change all my SQL
statements.

eric

In response to

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Tom Lane 2009-02-03 00:43:46 Re: char columns, space padding, and the "like" operator
Previous Message Tom Lane 2009-02-02 21:38:55 Re: char columns, space padding, and the "like" operator