Re: BUG #14800: substring produces different results with similar types

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Артём Костин <kostin(dot)artem(at)gmail(dot)com>
Cc: Francisco Olarte <folarte(at)peoplecall(dot)com>, "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: BUG #14800: substring produces different results with similar types
Date: 2017-09-06 18:07:32
Message-ID: CAKFQuwb75rbbifwgOqHSMxmgh2_OAr6179Y+OYtxfczuZ=roCQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, Sep 6, 2017 at 10:10 AM, Артём Костин <kostin(dot)artem(at)gmail(dot)com>
wrote:

> I'm sorry for this approach.
>
> The main point is that behaviour are not applied to all character types
> described in docs. You can see it in my example.
>

​There is only one "character type" in PostgreSQL, it is spelled
"character" (char is a valid alias).

>
>
> For the second point, please, check chapter 8.3 for this
> "Trailing spaces are removed when converting a character value to one of
> the other string types. Note that trailing spaces are semantically
> significant in character varying and text values, and when using pattern
> matching, that is LIKE and regular expressions."
>
>
IOW, ​The "character" data type is one of three "string-class" types in the
PostgreSQL system. "character" has no concept of "semantically significant
trailing whitespace". Therefore when converting from "character" to one of
the other two "string-class" types (varchar, text) you will never end up
with a resultant value with trailing whitespace.

​David J.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Patrick van Coeverden 2017-09-06 18:24:58 Line number in error message is incorrect when loading a CSV-file with multi-line records.
Previous Message Wood, Dan 2017-09-06 17:27:39 Re: Old row version in hot chain become visible after a freeze