pgsql: Implement regexp_match(), a simplified alternative to regexp_mat

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Implement regexp_match(), a simplified alternative to regexp_mat
Date: 2016-08-17 22:33:13
Message-ID: E1ba9Ob-0008F5-TP@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Implement regexp_match(), a simplified alternative to regexp_matches().

regexp_match() is like regexp_matches(), but it disallows the 'g' flag
and in consequence does not need to return a set. Instead, it returns
a simple text array value, or NULL if there's no match. Previously people
usually got that behavior with a sub-select, but this way is considerably
more efficient.

Documentation adjusted so that regexp_match() is presented first and then
regexp_matches() is introduced as a more complicated version. This is
a bit historically revisionist but seems pedagogically better.

Still TODO: extend contrib/citext to support this function.

Emre Hasegeli, reviewed by David Johnston

Discussion: <CAE2gYzy42sna2ME_e3y1KLQ-4UBrB-eVF0SWn8QG39sQSeVhEw(at)mail(dot)gmail(dot)com>

Branch
------
master

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

Modified Files
--------------
doc/src/sgml/func.sgml | 155 ++++++++++++++++++++---------
src/backend/catalog/information_schema.sql | 2 +-
src/backend/utils/adt/regexp.c | 137 +++++++++++++++++--------
src/include/catalog/catversion.h | 2 +-
src/include/catalog/pg_proc.h | 8 +-
src/include/utils/builtins.h | 2 +
src/test/regress/expected/regex.out | 28 ++++++
src/test/regress/expected/strings.out | 4 +-
src/test/regress/sql/regex.sql | 7 ++
9 files changed, 252 insertions(+), 93 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2016-08-18 00:06:33 pgsql: Fix deletion of speculatively inserted TOAST on conflict
Previous Message Andres Freund 2016-08-17 20:22:42 pgsql: Properly re-initialize replication slot shared memory upon creat