Re: [HACKERS] char(8) vs char8 - Mailing list pgsql-hackers

From Byron Nikolaidis
Subject Re: [HACKERS] char(8) vs char8
Date
Msg-id 355B05CC.350843F1@insightdist.com
Whole thread Raw
In response to char(8) vs char8  (darcy@druid.net (D'Arcy J.M. Cain))
Responses Re: [HACKERS] char(8) vs char8
List pgsql-hackers

D'Arcy J.M. Cain wrote:

> This was an unexpected difference between these two types and I wonder
> if it was meant to be this way.  Previously, a char8 field with the
> string 'abc' would return 'abc' as expected.  Now, with char(8), I get
> back 'abc     ' instead.  You can see this with my PygreSQL module
> or the C interface (which my module uses, of course.)  This causes a
> lot of my programs to break.
>

char(x) is the datatype 'bpchar' (blank padded char).  Thus it is padded
with spaces to the field width.

Couldn't you use something like "select rtrim(column) from table".  This
will trim the spaces off.

Byron


pgsql-hackers by date:

Previous
From: Andreas Zeugswetter
Date:
Subject: AW: [HACKERS] char(8) vs char8
Next
From: "Thomas G. Lockhart"
Date:
Subject: Re: [HACKERS] char(8) vs char8