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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ron Johnson <ronljohnsonjr(at)gmail(dot)com>
Cc: Pgsql-admin <pgsql-admin(at)lists(dot)postgresql(dot)org>
Subject: Re: char column with a single space as the default not working
Date: 2023-11-30 22:34:25
Message-ID: 526193.1701383665@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Ron Johnson <ronljohnsonjr(at)gmail(dot)com> writes:
> On Thu, Nov 30, 2023 at 2:56 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message M Sarwar 2023-11-30 22:43:17 Re: char column with a single space as the default not working
Previous Message Ron Johnson 2023-11-30 22:00:24 Re: char column with a single space as the default not working