pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
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
Date: Thu, 30 Nov 2023 17:34:25 -0500
Message-ID: <526193.1701383665@sss.pgh.pa.us> (raw)
In-Reply-To: <CANzqJaA5Az_2z8X3_T3ieypvqQkFDuEbbtF7Uu0L0tXEKiyXjw@mail.gmail.com>
References: <f7b61d30-3b95-463a-9627-fed806e5e2db@quadratum-braccas.com>
	<CAJ=80GV3NaKeRi9GDXa+bA-Zck0YYHwGa90v70GBwoyi1EQftQ@mail.gmail.com>
	<507459.1701374156@sss.pgh.pa.us>
	<CANzqJaA5Az_2z8X3_T3ieypvqQkFDuEbbtF7Uu0L0tXEKiyXjw@mail.gmail.com>

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





view thread (8+ messages)  latest in thread

Message-ID: <526193.1701383665@sss.pgh.pa.us>
Permalink:  ../526193.1701383665@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/526193.1701383665@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: tgl@sss.pgh.pa.us, ronljohnsonjr@gmail.com, pgsql-admin@lists.postgresql.org
  Subject: Re: char column with a single space as the default not working
  In-Reply-To: <526193.1701383665@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox