Implement regexp_match(), a simplified alternative to regexp_matches().
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 17 Aug 2016 22:32:56 +0000 (18:32 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 17 Aug 2016 22:33:01 +0000 (18:33 -0400)
commitcf9b0fea5f6d1bcc9b2c66f5c30ecb04684a0919
tree37757fd2bb978cdd4837168e61340ddd7f33de04
parent2d7e591007a6f44e5e27e2b6c1098483105c0d10
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@mail.gmail.com>
doc/src/sgml/func.sgml
src/backend/catalog/information_schema.sql
src/backend/utils/adt/regexp.c
src/include/catalog/catversion.h
src/include/catalog/pg_proc.h
src/include/utils/builtins.h
src/test/regress/expected/regex.out
src/test/regress/expected/strings.out
src/test/regress/sql/regex.sql