From: | Pavel Borisov <pashkin(dot)elfe(at)gmail(dot)com> |
---|---|
To: | depesz(at)depesz(dot)com, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | ganguly(dot)04(at)gmail(dot)com, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org> |
Subject: | Re: BUG #17450: SUBSTRING function extracting lesser characters than specified |
Date: | 2022-03-28 12:35:30 |
Message-ID: | CALT9ZEE-kh8KufDLsohpvOw5rG9eMQXYfMTdE9dt-gawe1F+5g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
пн, 28 мар. 2022 г. в 15:01, hubert depesz lubaczewski <depesz(at)depesz(dot)com>:
> On Mon, Mar 28, 2022 at 10:30:07AM +0000, PG Bug reporting form wrote:
> > The following bug has been logged on the website:
> >
> > Bug reference: 17450
> > Logged by: Suman Ganguly
> > Email address: ganguly(dot)04(at)gmail(dot)com
> > PostgreSQL version: 10.17
> > Operating system: x86_64-pc-linux-gnu
> > Description:
> >
> > select substring('123456', 0 , 5)
> > On running this, Postgres returns '1234'
> > Expecting '12345' to be returned as per the documentation
>
> Well, the problem is that you're trying to provide character number 0,
> which is leading to bad results.
>
> substring works on base-1 numbering.
>
Yes, the behavior expected in a report seems to be right. I've attached a
very small fix for that issue. Probably it should be backpatched into all
versions having 4bd3fad80e5c i.e. since v11.
--
Best regards,
Pavel Borisov
Postgres Professional: http://postgrespro.com <http://www.postgrespro.com>
Attachment | Content-Type | Size |
---|---|---|
0001-Fix-text_substring-for-correct-processing-of-zero-or.patch | application/octet-stream | 2.1 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2022-03-28 13:55:21 | Re: BUG #17450: SUBSTRING function extracting lesser characters than specified |
Previous Message | hubert depesz lubaczewski | 2022-03-28 11:01:20 | Re: BUG #17450: SUBSTRING function extracting lesser characters than specified |