From: Joe Conway <mail@joeconway.com>
To: David G. Johnston <david.g.johnston@gmail.com>
To: dominik.kosiorek@infobright.com <dominik.kosiorek@infobright.com>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: BUG #13934: wrong result of split_part with char value
Date: Tue, 9 Feb 2016 07:29:08 -0800
Message-ID: <56BA05C4.7010004@joeconway.com> (raw)
In-Reply-To: <CAKFQuwaqOhZvK1rndtTzJyFjsGEGVXrpceYF49bwX3mC0ADuVQ@mail.gmail.com>
References: <20160208151107.2662.82302@wrigleys.postgresql.org>
<CAKFQuwaqOhZvK1rndtTzJyFjsGEGVXrpceYF49bwX3mC0ADuVQ@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
On 02/08/2016 06:00 PM, David G. Johnston wrote:
> On Monday, February 8, 2016, <dominik.kosiorek@infobright.com
> This calls for another round of "don't use char” advice...
>
> It is not a bug but a result of the fact that trailing white space in
> char values is able to be trimmed away thus leaving you the empty string
> and no splitting.
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)
And if you feed an actual space to split_part(), it works as expected.
test=# select split_part(a2,' ',a4field) from string1postgres;
split_part
------------
abcd
(1 row)
HTH,
Joe
--
Crunchy Data - http://crunchydata.com
PostgreSQL Support for Secure Enterprises
Consulting, Training, & Open Source Development
Attachments:
signature.asc (application/pgp-signature, 835B) download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: mail@joeconway.com, david.g.johnston@gmail.com, dominik.kosiorek@infobright.com
Subject: Re: BUG #13934: wrong result of split_part with char value
In-Reply-To: <56BA05C4.7010004@joeconway.com>
References: <20160208151107.2662.82302@wrigleys.postgresql.org> <CAKFQuwaqOhZvK1rndtTzJyFjsGEGVXrpceYF49bwX3mC0ADuVQ@mail.gmail.com> <56BA05C4.7010004@joeconway.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox