unicode-norm-fix.patch
text/x-diff
Filename: unicode-norm-fix.patch
Type: text/x-diff
Part: 0
Patch
Format: unified
| File | + | − |
|---|---|---|
| src/common/unicode_norm.c | 4 | 0 |
| src/test/regress/expected/unicode.out | 12 | 0 |
| src/test/regress/sql/unicode.sql | 2 | 0 |
diff --git a/src/common/unicode_norm.c b/src/common/unicode_norm.c
index 36ff2aab21..06bf921e45 100644
--- a/src/common/unicode_norm.c
+++ b/src/common/unicode_norm.c
@@ -439,6 +439,10 @@ unicode_normalize(UnicodeNormalizationForm form, const pg_wchar *input)
decomp_chars[decomp_size] = '\0';
Assert(decomp_size == current_size);
+ /* Leave if there is nothing to decompose */
+ if (decomp_size == 0)
+ return decomp_chars;
+
/*
* Now apply canonical ordering.
*/
diff --git a/src/test/regress/expected/unicode.out b/src/test/regress/expected/unicode.out
index 2a1e903696..88aef0fe08 100644
--- a/src/test/regress/expected/unicode.out
+++ b/src/test/regress/expected/unicode.out
@@ -8,6 +8,18 @@ SELECT U&'\0061\0308bc' <> U&'\00E4bc' COLLATE "C" AS sanity_check;
t
(1 row)
+SELECT normalize('');
+ normalize
+-----------
+
+(1 row)
+
+SELECT is_normalized('');
+ is_normalized
+---------------
+ t
+(1 row)
+
SELECT normalize(U&'\0061\0308\24D1c') = U&'\00E4\24D1c' COLLATE "C" AS test_default;
test_default
--------------
diff --git a/src/test/regress/sql/unicode.sql b/src/test/regress/sql/unicode.sql
index ccfc6fa77a..07cd2851fc 100644
--- a/src/test/regress/sql/unicode.sql
+++ b/src/test/regress/sql/unicode.sql
@@ -5,6 +5,8 @@ SELECT getdatabaseencoding() <> 'UTF8' AS skip_test \gset
SELECT U&'\0061\0308bc' <> U&'\00E4bc' COLLATE "C" AS sanity_check;
+SELECT normalize('');
+SELECT is_normalized('');
SELECT normalize(U&'\0061\0308\24D1c') = U&'\00E4\24D1c' COLLATE "C" AS test_default;
SELECT normalize(U&'\0061\0308\24D1c', NFC) = U&'\00E4\24D1c' COLLATE "C" AS test_nfc;
SELECT normalize(U&'\00E4bc', NFC) = U&'\00E4bc' COLLATE "C" AS test_nfc_idem;