git.postgresql.org Git - postgresql.git/commit

git projects / postgresql.git / commit
? search:
summary | shortlog | log | commit | commitdiff | tree
(parent: f80049f) | patch
Make locale-dependent regex character classes work for large char codes.
Mon, 5 Sep 2016 21:06:29 +0000 (17:06 -0400)
Mon, 5 Sep 2016 21:06:29 +0000 (17:06 -0400)
commit c54159d44ceaba26ceda9fea1804f0de122a8f30
Make locale-dependent regex character classes work for large char codes.

Previously, we failed to recognize Unicode characters above U+7FF as
being members of locale-dependent character classes such as [[:alpha:]].
(Actually, the same problem occurs for large pg_wchar values in any
multibyte encoding, but UTF8 is the only case people have actually
complained about.) It's impractical to get Spencer's original code to
handle character classes or ranges containing many thousands of characters,
because it insists on considering each member character individually at
regex compile time, whether or not the character will ever be of interest
at run time. To fix, choose a cutoff point MAX_SIMPLE_CHR below which
we process characters individually as before, and deal with entire ranges
or classes as single entities above that. We can actually make things
cheaper than before for chars below the cutoff, because the color map can
now be a simple linear array for those chars, rather than the multilevel
tree structure Spencer designed. It's more expensive than before for
chars above the cutoff, because we must do a binary search in a list of
high chars and char ranges used in the regex pattern, plus call iswalpha()
and friends for each locale-dependent character class used in the pattern.
However, multibyte encodings are normally designed to give smaller codes
to popular characters, so that we can expect that the slow path will be
taken relatively infrequently. In any case, the speed penalty appears
minor except when we have to apply iswalpha() etc. to high character codes
at runtime --- and the previous coding gave wrong answers for those cases,
so whether it was faster is moot.

Tom Lane, reviewed by Heikki Linnakangas

Discussion: <15563.1471913698@sss.pgh.pa.us>
13 files changed:
src/backend/regex/README diff | blob | blame | history
src/backend/regex/regc_color.c diff | blob | blame | history
src/backend/regex/regc_cvec.c diff | blob | blame | history
src/backend/regex/regc_locale.c diff | blob | blame | history
src/backend/regex/regc_pg_locale.c diff | blob | blame | history
src/backend/regex/regcomp.c diff | blob | blame | history
src/backend/regex/regexport.c diff | blob | blame | history
src/backend/regex/regprefix.c diff | blob | blame | history
src/include/regex/regcustom.h diff | blob | blame | history
src/include/regex/regex.h diff | blob | blame | history
src/include/regex/regguts.h diff | blob | blame | history
src/test/regress/expected/regex.linux.utf8.out [new file with mode: 0644] blob
src/test/regress/sql/regex.linux.utf8.sql [new file with mode: 0644] blob
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /