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

Поиск
Список
Период
Сортировка
От M Sarwar
Тема Re: char column with a single space as the default not working
Дата
Msg-id DM4PR19MB597873E9E96C6B64C4ADEE4CD382A@DM4PR19MB5978.namprd19.prod.outlook.com
обсуждение исходный текст
Ответ на Re: char column with a single space as the default not working  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-admin
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@sss.pgh.pa.us>
Sent: Thursday, November 30, 2023 5:34 PM
To: Ron Johnson <ronljohnsonjr@gmail.com>
Cc: Pgsql-admin <pgsql-admin@lists.postgresql.org>
Subject: Re: char column with a single space as the default not working
 
Ron Johnson <ronljohnsonjr@gmail.com> writes:
> On Thu, Nov 30, 2023 at 2:56 PM Tom Lane <tgl@sss.pgh.pa.us> 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


В списке pgsql-admin по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: char column with a single space as the default not working
Следующее
От: Laurenz Albe
Дата:
Сообщение: Re: char column with a single space as the default not working