pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Sbob <sbob@quadratum-braccas.com>
To: Pgsql-admin <pgsql-admin@lists.postgresql.org>
Subject: char column with a single space as the default not working
Date: Thu, 30 Nov 2023 08:34:12 -0700
Message-ID: <f7b61d30-3b95-463a-9627-fed806e5e2db@quadratum-braccas.com> (raw)

All;


I created a table like this:

create table z (charcol char(1) default  ' ', intcol int);


Then I inserted a row with a single space in the charcol column and 
another insert letting the table use the default value:

insert into z values (' ', 1);

insert into z (intcol) values (2);


However neither of the inserted rows actually retained the single space 
in the charcol column:


select '[' || charcol || ']', intcol from z;
  ?column? | intcol
----------+--------
  []       |      1
  []       |      2
(2 rows)


Thoughts? Is it possible to add a single space to a char column without 
it getting truncated?


Thanks in advance






view thread (8+ messages)  latest in thread

Message-ID: <f7b61d30-3b95-463a-9627-fed806e5e2db@quadratum-braccas.com>
Permalink:  ../f7b61d30-3b95-463a-9627-fed806e5e2db@quadratum-braccas.com/
Also on:    postgresql.org/message-id/f7b61d30-3b95-463a-9627-fed806e5e2db@quadratum-braccas.com

 · 

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: sbob@quadratum-braccas.com, pgsql-admin@lists.postgresql.org
  Subject: Re: char column with a single space as the default not working
  In-Reply-To: <f7b61d30-3b95-463a-9627-fed806e5e2db@quadratum-braccas.com>

* 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