пн, 28 мар. 2022 г. в 15:01, hubert depesz 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:
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.