pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: rafiss@gmail.com
Subject: BUG #16804: substring() function returns "negative substring length" error when using a large length argument
Date: Mon, 04 Jan 2021 17:48:20 +0000
Message-ID: <16804-f4eeeb6c11ba71d4@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      16804
Logged by:          Rafi Shamim
Email address:      rafiss@gmail.com
PostgreSQL version: 13.1
Operating system:   MacOS 10.15.7
Description:        

Reproduction steps:

1. Connect to any PostgreSQL database.
2. Run this query:
> 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:  select substring('string'
from 2 for 2147483646)
negative substring length not allowed


Expected result:

I don't know if this is covered by these docs:
https://www.postgresql.org/docs/13/functions-string.html
But I would expect one of the following:
1. There should be no error message, and the result should be 'tring'.
(Meaning it just goes to the end of the string.)
2. An error message that says that the length argument is too long.

I don't know what the SQL standard says, but when I try similar queries with
SQLite and MSSQL, the result is 'tring'.



view thread (7+ messages)  latest in thread

Message-ID: <16804-f4eeeb6c11ba71d4@postgresql.org>
Permalink:  ../16804-f4eeeb6c11ba71d4@postgresql.org/
Also on:    postgresql.org/message-id/16804-f4eeeb6c11ba71d4@postgresql.org

 · 

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: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, rafiss@gmail.com
  Subject: Re: BUG #16804: substring() function returns "negative substring length" error when using a large length argument
  In-Reply-To: <16804-f4eeeb6c11ba71d4@postgresql.org>

* 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