Re: BUG #13934: wrong result of split_part with char value - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #13934: wrong result of split_part with char value
Date
Msg-id 9241.1455033340@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #13934: wrong result of split_part with char value  (Joe Conway <mail@joeconway.com>)
Responses Re: BUG #13934: wrong result of split_part with char value
List pgsql-bugs
Joe Conway <mail@joeconway.com> writes:
> In other words, when you insert ' ' into string1postgres.a3pattern,
> which is defined as char(15), the single space is trimmed leaving an
> empty string:

> test=# select '***' || a3pattern || '!!!' from string1postgres;
>  ?column?
> ----------
>  ***!!!
> (1 row)

Actually, I believe the space-trimming happens when the char(n) value
is coerced to type text in preparation for passing it to the || operator
(which takes text).  Since trailing spaces are considered insignificant
in char(n), whereas they definitely are significant in text, this is a
reasonable thing to do, at least in some contexts.

            regards, tom lane

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #13937: 'src' -> jsonb_each() -> jsonb_object() -> 'dst' does not recreate 'src' as valid jsonb
Next
From: "David G. Johnston"
Date:
Subject: Re: BUG #13934: wrong result of split_part with char value