pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jerry Sievert <jerry@legitimatesounding.com>
To: Pavel Stehule <pavel.stehule@gmail.com>
Cc: rafiss@gmail.com, PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Re: BUG #16804: substring() function returns "negative substring length" error when using a large length argument
Date: Mon, 4 Jan 2021 11:25:16 -0800
Message-ID: <018A6952-DDF4-4728-AA47-A819CC6DB2CB@legitimatesounding.com> (raw)
In-Reply-To: <CAFj8pRC8VwazNN9G=oOt7E=kxpCwjE9pu8Hx0ku6-FJxAJYRRA@mail.gmail.com>
References: <16804-f4eeeb6c11ba71d4@postgresql.org>
	<CAFj8pRC8VwazNN9G=oOt7E=kxpCwjE9pu8Hx0ku6-FJxAJYRRA@mail.gmail.com>

Hi,

> On Jan 4, 2021, at 11:21 AM, Pavel Stehule <pavel.stehule@gmail.com> wrote:
> 
> 
> 
> po 4. 1. 2021 v 19:44 odesílatel PG Bug reporting form <noreply@postgresql.org <mailto:noreply@postgresql.org>> napsal:
> > select substring('string' from 2 for 2147483646);
> 
> Actual result:
> 
> 2021-01-04 12:43:13.145 EST [85734] ERROR:  negative substring length not
> allowed
> 2021-01-04 12:43:13.145 EST [85734] STATEMENT:s
> negative substring length not allowed
> 
> Minimally this is a bug and it should raise an error "integer out of range". Probably in this case we can use MAX_INT as a special value of unlimited length, although it is a little bit scary, because length is an optional value. The attached patch should fix this issue. I do not have access to Oracle to check the behaviour of this case there.

Except according to the pg docs, it’s not out of range, it’s one less than MAX_INT.

The manual calls for it to be an integer, which is defined as:

integer	4 bytes	typical choice for integer	-2147483648 to +2147483647

The original bug report is one less than +2147483647, and thus should be a valid value, no?

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (7+ messages)  latest in thread

Message-ID: <018A6952-DDF4-4728-AA47-A819CC6DB2CB@legitimatesounding.com>
Permalink:  ../018A6952-DDF4-4728-AA47-A819CC6DB2CB@legitimatesounding.com/
Also on:    postgresql.org/message-id/018A6952-DDF4-4728-AA47-A819CC6DB2CB@legitimatesounding.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: jerry@legitimatesounding.com, pavel.stehule@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #16804: substring() function returns "negative substring length" error when using a large length argument
  In-Reply-To: <018A6952-DDF4-4728-AA47-A819CC6DB2CB@legitimatesounding.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