Skip site navigation (1) Skip section navigation (2)

pgsql: Improve similar_escape() in two different ways: * Stop escaping

From: tgl(at)postgresql(dot)org (Tom Lane)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Improve similar_escape() in two different ways: * Stop escaping
Date: 2009-10-10 03:50:15
Message-ID: 20091010035015.72E0C753FB7@cvs.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-committers
Log Message:
-----------
Improve similar_escape() in two different ways:

* Stop escaping ? and {.  As of SQL:2008, SIMILAR TO is defined to have
POSIX-compatible interpretation of ? as well as {m,n} and related constructs,
so we should allow these things through to our regex engine.

* Escape ^ and $.  It appears that our regex engine will treat ^^ at the
beginning of the string the same as ^, and similarly for $$ at the end of
the string, which meant that SIMILAR TO was effectively ignoring ^ at the
start of the pattern and $ at the end.  Since these are not supposed to be
metacharacters, this is a bug.

The second part of this is arguably a back-patchable bug fix, but I'm
hesitant to do that because it might break applications that are expecting
something like "col SIMILAR TO '^foo$'" to work like a POSIX pattern.
Seems safer to only change it at a major version boundary.

Per discussion of an example from Doug Gorley.

Modified Files:
--------------
    pgsql/doc/src/sgml:
        func.sgml (r1.488 -> r1.489)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/doc/src/sgml/func.sgml?r1=1.488&r2=1.489)
    pgsql/src/backend/utils/adt:
        regexp.c (r1.82 -> r1.83)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/adt/regexp.c?r1=1.82&r2=1.83)

pgsql-committers by date

Next:From: Tom LaneDate: 2009-10-12 18:10:53
Subject: pgsql: Move the handling of SELECT FOR UPDATE locking and rechecking out
Previous:From: Tom LaneDate: 2009-10-10 01:43:50
Subject: pgsql: Split the processing of INSERT/UPDATE/DELETE operations out of

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group