character type value is not padded with spaces

From: Yoshiyuki Asaba <y-asaba(at)sra(dot)co(dot)jp>
To: pgsql-patches(at)postgresql(dot)org
Subject: character type value is not padded with spaces
Date: 2005-05-23 02:05:26
Message-ID: 20050523.110526.93017548.y-asaba@sra.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Character type value including multibyte characters is not padded
with spaces. It reproduces at 7.3.x, 7.4.x and 8.0.x.

create table t (a char(10));
insert into t values ('XXXXX'); -- X is 2byte character.

I expect that 'XXXXX ' is inserted. But 'XXXXX' is inserted.

select a, octed_length(a) from t;

a | octet_length
-------+--------------
XXXXX | 10

If padded with spaces, octet_length(a) is 15. This problem is caused
that string length is calculated by byte length(VARSIZE) in
exprTypmod().

I attache the patch for this problem.

Regards,

--
Yoshiyuki Asaba
y-asaba(at)sra(dot)co(dot)jp

Attachment Content-Type Size
unknown_filename text/plain 1.2 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Zeljko Vrba 2005-05-23 06:12:35 subquery returning array
Previous Message Tom Lane 2005-05-22 22:46:51 Re: PseudoPartitioning and agregates

Browse pgsql-patches by date

  From Date Subject
Next Message Neil Conway 2005-05-23 02:07:08 Re: bug fix - plperl %_SHARED misspelled
Previous Message Andrew Dunstan 2005-05-23 01:45:04 Re: bug fix - plperl %_SHARED misspelled