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@postgresql.org
Subject: pgsql: Remove new coupling between NAMEDATALEN and MAX_LEVENSHTEIN_STRL
Date: Fri, 22 Jan 2016 16:53:18 +0000
Message-ID: <E1aMexa-0003X8-5J@gemulon.postgresql.org> (raw)
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>

Remove new coupling between NAMEDATALEN and MAX_LEVENSHTEIN_STRLEN.

Commit e529cd4ffa605c6f introduced an Assert requiring NAMEDATALEN to be
less than MAX_LEVENSHTEIN_STRLEN, which has been 255 for a long time.
Since up to that instant we had always allowed NAMEDATALEN to be
substantially more than that, this was ill-advised.

It's debatable whether we need MAX_LEVENSHTEIN_STRLEN at all (versus
putting a CHECK_FOR_INTERRUPTS into the loop), or whether it has to be
so tight; but this patch takes the narrower approach of just not applying
the MAX_LEVENSHTEIN_STRLEN limit to calls from the parser.

Trusting the parser for this seems reasonable, first because the strings
are limited to NAMEDATALEN which is unlikely to be hugely more than 256,
and second because the maximum distance is tightly constrained by
MAX_FUZZY_DISTANCE (though we'd forgotten to make use of that limit in one
place).  That means the cost is not really O(mn) but more like O(max(m,n)).

Relaxing the limit for user-supplied calls is left for future research;
given the lack of complaints to date, it doesn't seem very high priority.

In passing, fix confusion between lengths-in-bytes and lengths-in-chars
in comments and error messages.

Per gripe from Kevin Day; solution suggested by Robert Haas.  Back-patch
to 9.5 where the unwanted restriction was introduced.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/a396144ac03b0cf337f80201df7e4663cc5a8131

Modified Files
--------------
contrib/fuzzystrmatch/fuzzystrmatch.c |   29 +++++++++---------
src/backend/parser/parse_relation.c   |   13 +++++----
src/backend/utils/adt/levenshtein.c   |   52 ++++++++++++++++++---------------
src/include/utils/builtins.h          |   11 ++++---
4 files changed, 60 insertions(+), 45 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


view thread (2+ messages)  latest in thread

Message-ID: <E1aMexa-0003X8-5J@gemulon.postgresql.org>
Permalink:  ../E1aMexa-0003X8-5J@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1aMexa-0003X8-5J@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: Remove new coupling between NAMEDATALEN and MAX_LEVENSHTEIN_STRL
  In-Reply-To: <E1aMexa-0003X8-5J@gemulon.postgresql.org>
  References: <E1aMexa-0003X8-5J@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