Re: char column with a single space as the default not working

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I had the similar issue few months ago when I was using CHAR. The issue is resolved when I started using VARYING CHARACTERS data types.
Thanks,
Sarwar


From: Tom Lane <tgl@xxxxxxxxxxxxx>
Sent: Thursday, November 30, 2023 5:34 PM
To: Ron Johnson <ronljohnsonjr@xxxxxxxxx>
Cc: Pgsql-admin <pgsql-admin@xxxxxxxxxxxxxxxxxxxx>
Subject: Re: char column with a single space as the default not working
 
Ron Johnson <ronljohnsonjr@xxxxxxxxx> writes:
> On Thu, Nov 30, 2023 at 2:56 PM Tom Lane <tgl@xxxxxxxxxxxxx> wrote:
>> Yeah, the space is stored.  What is probably surprising the OP
>> is that applying the || operator involves a coercion from "char"
>> to "text", which strips the defined-to-be-insignificant trailing
>> space(s) of the "char" value.

> How do you get a trailing space when trailing spaces are significant?

Use varchar or text.  If you want trailing spaces to be significant,
char is simply the wrong data type.

                        regards, tom lane



[Index of Archives]     [Postgresql Home]     [Postgresql General]     [Postgresql Performance]     [Postgresql PHP]     [Postgresql Jobs]     [PHP Users]     [PHP Databases]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Forum]

  Powered by Linux