Re: BUG #13934: wrong result of split_part with char value

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Joe Conway <mail(at)joeconway(dot)com>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, "dominik(dot)kosiorek(at)infobright(dot)com" <dominik(dot)kosiorek(at)infobright(dot)com>, "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #13934: wrong result of split_part with char value
Date: 2016-02-09 15:55:40
Message-ID: 9241.1455033340@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Joe Conway <mail(at)joeconway(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2016-02-09 16:14:24 Re: BUG #13934: wrong result of split_part with char value
Previous Message Tom Lane 2016-02-09 15:46:37 Re: BUG #13937: 'src' -> jsonb_each() -> jsonb_object() -> 'dst' does not recreate 'src' as valid jsonb