char column with a single space as the default not working

From: Sbob <sbob(at)quadratum-braccas(dot)com>
To: Pgsql-admin <pgsql-admin(at)lists(dot)postgresql(dot)org>
Subject: char column with a single space as the default not working
Date: 2023-11-30 15:34:12
Message-ID: f7b61d30-3b95-463a-9627-fed806e5e2db@quadratum-braccas.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

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

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message ROHIT SACHDEVA 2023-11-30 15:45:08 Re: Related to Foreign Table Accessing
Previous Message John Scalia 2023-11-30 14:59:59 Logical replication issue, pg 13.9