[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pgsql-bugs
Subject:    Re: BUG #17450: SUBSTRING function extracting lesser characters than specified
From:       "David G. Johnston" <david.g.johnston () gmail ! com>
Date:       2022-03-28 14:09:23
Message-ID: CAKFQuwZ9=nQojnCdk3nVqaPUH1CQGvg2+w_H+U_xp+1vzMoPJQ () mail ! gmail ! com
[Download RAW message or body]

On Mon, Mar 28, 2022 at 5:35 AM Pavel Borisov <pashkin.elfe@gmail.com>
wrote:

> =D0=BF=D0=BD, 28 =D0=BC=D0=B0=D1=80. 2022 =D0=B3. =D0=B2 15:01, hubert de=
pesz lubaczewski <depesz@depesz.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.04@gmail.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
>>
>
You should reference the documentation you are basing your conclusion off
of for this kind of report.

This example in the documentation clearly demonstrates the 1-based nature
of the numbering:

substring('Thomas' from 2 for 3) =E2=86=92 hom

as does this one:

substr('alphabet', 3, 2) =E2=86=92 ph

https://www.postgresql.org/docs/current/functions-string.html

Oddly, I don't actually see a non-standard form of substring spelled that
way though indeed the example works.


Probably it should be backpatched into all versions having 4bd3fad80e5c
> i.e. since v11.
>

The behavior of the example command is identical both before and since v11
so I don't see how that commit has anything to do with this.  Nor, as shown
above, does this contradict the documentation.  The bug report is simply
wrong and you seem to have attempted to supply a fix without confirming it.

David J.

[Attachment #3 (text/html)]

<div dir="ltr"><div dir="ltr"><div class="gmail_default" \
style="font-family:arial,helvetica,sans-serif"><span \
style="font-family:Arial,Helvetica,sans-serif">On Mon, Mar 28, 2022 at 5:35 AM Pavel \
Borisov &lt;<a href="mailto:pashkin.elfe@gmail.com">pashkin.elfe@gmail.com</a>&gt; \
wrote:</span><br></div></div><div class="gmail_quote"><blockquote class="gmail_quote" \
style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">пн, 28 мар. \
2022 г. в 15:01, hubert depesz lubaczewski &lt;<a href="mailto:depesz@depesz.com" \
target="_blank">depesz@depesz.com</a>&gt;:<br></div><div \
class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Mon, Mar 28, 2022 \
at 10:30:07AM +0000, PG Bug reporting form wrote:<br> &gt; The following bug has been \
logged on the website:<br> &gt; <br>
&gt; Bug reference:         17450<br>
&gt; Logged by:               Suman Ganguly<br>
&gt; Email address:         <a href="mailto:ganguly.04@gmail.com" \
target="_blank">ganguly.04@gmail.com</a><br> &gt; PostgreSQL version: 10.17<br>
&gt; Operating system:     x86_64-pc-linux-gnu<br>
&gt; Description:            <br>
&gt; <br>
&gt; select substring(&#39;123456&#39;, 0 , 5)<br>
&gt; On running this, Postgres returns &#39;1234&#39;<br>
&gt; Expecting &#39;12345&#39; to be returned as per the \
documentation<br></blockquote></div></div></blockquote><div><br></div><div \
class="gmail_default" style="font-family:arial,helvetica,sans-serif">You should \
reference the documentation you are basing your conclusion off of for this kind of \
report.</div><div><br></div><div class="gmail_default" \
style="font-family:arial,helvetica,sans-serif">This example in the documentation \
clearly demonstrates the 1-based nature of the numbering:</div><div \
class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div \
class="gmail_default" \
style="font-family:arial,helvetica,sans-serif">substring(&#39;Thomas&#39; from 2 for \
3) → hom</div><div class="gmail_default" \
style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" \
style="font-family:arial,helvetica,sans-serif">as does this one:</div><div \
class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div \
class="gmail_default" \
style="font-family:arial,helvetica,sans-serif">substr(&#39;alphabet&#39;, 3, 2) → \
ph<br></div><div class="gmail_default" \
style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" \
style="font-family:arial,helvetica,sans-serif"><a \
href="https://www.postgresql.org/docs/current/functions-string.html">https://www.postgresql.org/docs/current/functions-string.html</a><br></div><div \
class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div \
class="gmail_default" style="font-family:arial,helvetica,sans-serif">Oddly, I \
don&#39;t actually see a non-standard form of substring spelled that way though \
indeed the example works.</div><div class="gmail_default" \
style="font-family:arial,helvetica,sans-serif"><br></div><div><br></div><blockquote \
class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div \
class="gmail_quote"><div>Probably it should be backpatched into all versions having \
4bd3fad80e5c i.e. since v11.</div></div></div></blockquote><div><br></div><div \
class="gmail_default" style="font-family:arial,helvetica,sans-serif">The behavior of \
the example command is identical both before and since v11 so I don&#39;t see how \
that commit has anything to do with this.   Nor, as shown above, does this contradict \
the documentation.   The bug report is simply wrong and you seem to have attempted to \
supply a fix  without confirming it.</div><div class="gmail_default" \
style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" \
style="font-family:arial,helvetica,sans-serif">David J.</div><div \
class="gmail_default" \
style="font-family:arial,helvetica,sans-serif"><br></div></div></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic