From: | john snow <ofbizfanster(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-novice <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: why do i get 2 as answer for select length('aa '::char(6)); |
Date: | 2018-01-17 03:23:13 |
Message-ID: | CAE67tvWV2GpkGr6hUHfWVrHzn71HDqaxyiojxWyR6gCB2gWJ0g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
when you say char-type values, do you include varchar? if so, the other
results (see later post from first post) i get are inconsistent with the
assertion that length() disregards trailing spaces in char-type values, and
i don't understand why it's inconsistent. i hope i'm not becoming annoying
:-)
On Wed, Jan 17, 2018 at 11:09 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> john snow <ofbizfanster(at)gmail(dot)com> writes:
> > as well as select length('aa'::char(6));
> > i thought if the string to be stored is shorter than specified length ,
> it
> > will be padded with spaces?
>
> It *is* padded, as you can verify with other functions such as
> octet_length or pg_column_size. But length() disregards trailing
> spaces in char-type values, on the theory that they're semantically
> insignificant.
>
> regards, tom lane
>
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2018-01-17 03:32:05 | Re: why do i get 2 as answer for select length('aa '::char(6)); |
Previous Message | Tom Lane | 2018-01-17 03:09:16 | Re: why do i get 2 as answer for select length('aa '::char(6)); |