pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: hubert depesz lubaczewski <depesz@depesz.com>
To: ganguly.04@gmail.com
To: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17450: SUBSTRING function extracting lesser characters than specified
Date: Mon, 28 Mar 2022 13:01:20 +0200
Message-ID: <20220328110119.GA28018@depesz.com> (raw)
In-Reply-To: <17450-69df48455c28fbea@postgresql.org>
References: <17450-69df48455c28fbea@postgresql.org>

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

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.

depesz





view thread (7+ messages)  latest in thread

Message-ID: <20220328110119.GA28018@depesz.com>
Permalink:  ../20220328110119.GA28018@depesz.com/
Also on:    postgresql.org/message-id/20220328110119.GA28018@depesz.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: depesz@depesz.com, ganguly.04@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #17450: SUBSTRING function extracting lesser characters than specified
  In-Reply-To: <20220328110119.GA28018@depesz.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox