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

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: BUG #13934: wrong result of split_part with char value
Дата
Msg-id CAKFQuwaqOhZvK1rndtTzJyFjsGEGVXrpceYF49bwX3mC0ADuVQ@mail.gmail.com
обсуждение исходный текст
Ответ на BUG #13934: wrong result of split_part with char value  (dominik.kosiorek@infobright.com)
Ответы Re: BUG #13934: wrong result of split_part with char value
Список pgsql-bugs
On Monday, February 8, 2016, <dominik.kosiorek@infobright.com> wrote:

> The following bug has been logged on the website:
>
> Bug reference:      13934
> Logged by:          Dominik Kosiorek
> Email address:      dominik.kosiorek@infobright.com <javascript:;>
> PostgreSQL version: 9.2.2
> Operating system:   Ubuntu 14
> Description:
>
> create table string1postgres(
> a1 int,
> a2 char(65),
> a3pattern char(15),
> a4field int
> )
> insert into string1postgres values(72,'abcd defg poir abcde m ert g d c v=
 b
> gthb',' ',1);
>
> select split_part(a2,a3pattern,a4field) from string1postgres;
>
> -------------------
> the result of split part is:
> -------------------
> abcd defg poir abcde m ert g d c v b gthb
>
> -------------------
> instead of:
> -------------------
> abcd
>
> -------------------
> This defect is only with char type. On varchar result is correct.
>
>
This calls for another round of "don't use char=E2=80=9D 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.

You may read the documentation for details:

http://www.postgresql.org/docs/9.5/static/datatype-character.html

And search the Internet for numerous postings as to why you should avoid
char.

Use to text or varchar instead.

David J.

В списке pgsql-bugs по дате отправления:

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: BUG #13920: pg_try_advisory_xact_lock bigint trouble
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: BUG #13937: 'src' -> jsonb_each() -> jsonb_object() -> 'dst' does not recreate 'src' as valid jsonb