pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Handle empty-string edge cases correctly in strpos().
Date: Mon, 28 Oct 2019 16:21:21 +0000
Message-ID: <E1iP7lh-0002LR-7b@gemulon.postgresql.org> (raw)

Handle empty-string edge cases correctly in strpos().

Commit 9556aa01c rearranged the innards of text_position() in a way
that would make it not work for empty search strings.  Which is fine,
because all callers of that code special-case an empty pattern in
some way.  However, the primary use-case (text_position itself) got
special-cased incorrectly: historically it's returned 1 not 0 for
an empty search string.  Restore the historical behavior.

Per complaint from Austin Drenski (via Shay Rojansky).
Back-patch to v12 where it got broken.

Discussion: https://postgr.es/m/CADT4RqAz7oN4vkPir86Kg1_mQBmBxCp-L_=9vRpgSNPJf0KRkw@mail.gmail.com

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/43e43771bc4b03a9e33be7261cc84dc7f65ae9ef

Modified Files
--------------
src/backend/utils/adt/varlena.c       | 10 +++++++++-
src/test/regress/expected/strings.out | 18 ++++++++++++++++++
src/test/regress/sql/strings.sql      |  6 ++++++
3 files changed, 33 insertions(+), 1 deletion(-)



view thread (2+ messages)  latest in thread

Message-ID: <E1iP7lh-0002LR-7b@gemulon.postgresql.org>
Permalink:  ../E1iP7lh-0002LR-7b@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1iP7lh-0002LR-7b@gemulon.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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Handle empty-string edge cases correctly in strpos().
  In-Reply-To: <E1iP7lh-0002LR-7b@gemulon.postgresql.org>
  References: <E1iP7lh-0002LR-7b@gemulon.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