@@ -678,14 +678,30 @@ pg_import_system_collations(PG_FUNCTION_ARGS)
678
678
*/
679
679
for (i = -1 ; i < ucol_countAvailable (); i ++ )
680
680
{
681
+ /*
682
+ * In ICU 4.2, ucol_getKeywordsForLocale() sometimes returns
683
+ * values that will not be accepted by uloc_toLanguageTag(). Skip
684
+ * loading keyword variants in that version. (Both
685
+ * ucol_getKeywordValuesForLocale() and uloc_toLanguageTag() are
686
+ * new in ICU 4.2, so older versions are not supported at all.)
687
+ *
688
+ * XXX We have no information about ICU 4.3 through 4.7, but we
689
+ * know the code below works with 4.8.
690
+ */
691
+ #if U_ICU_VERSION_MAJOR_NUM > 4 || (U_ICU_VERSION_MAJOR_NUM == 4 && U_ICU_VERSION_MINOR_NUM > 2 )
692
+ #define LOAD_ICU_KEYWORD_VARIANTS
693
+ #endif
694
+
681
695
const char * name ;
682
696
char * langtag ;
683
697
char * icucomment ;
684
698
const char * collcollate ;
699
+ Oid collid ;
700
+ #ifdef LOAD_ICU_KEYWORD_VARIANTS
685
701
UEnumeration * en ;
686
702
UErrorCode status ;
687
703
const char * val ;
688
- Oid collid ;
704
+ #endif
689
705
690
706
if (i == -1 )
691
707
name = "" ; /* ICU root locale */
@@ -721,18 +737,9 @@ pg_import_system_collations(PG_FUNCTION_ARGS)
721
737
}
722
738
723
739
/*
724
- * Add keyword variants
725
- *
726
- * In ICU 4.2, ucol_getKeywordsForLocale() sometimes returns
727
- * values that will not be accepted by uloc_toLanguageTag(). Skip
728
- * loading keyword variants in that version. (Both
729
- * ucol_getKeywordValuesForLocale() and uloc_toLanguageTag() are
730
- * new in ICU 4.2, so older versions are not supported at all.)
731
- *
732
- * XXX We have no information about ICU 4.3 through 4.7, but we
733
- * know the below works with 4.8.
740
+ * Add keyword variants, if enabled.
734
741
*/
735
- #if U_ICU_VERSION_MAJOR_NUM > 4 || ( U_ICU_VERSION_MAJOR_NUM == 4 && U_ICU_VERSION_MINOR_NUM > 2 )
742
+ #ifdef LOAD_ICU_KEYWORD_VARIANTS
736
743
status = U_ZERO_ERROR ;
737
744
en = ucol_getKeywordValuesForLocale ("collation" , name , TRUE, & status );
738
745
if (U_FAILURE (status ))
@@ -779,7 +786,7 @@ pg_import_system_collations(PG_FUNCTION_ARGS)
779
786
(errmsg ("could not get keyword values for locale \"%s\": %s" ,
780
787
name , u_errorName (status ))));
781
788
uenum_close (en );
782
- #endif /* ICU >4.2 */
789
+ #endif /* LOAD_ICU_KEYWORD_VARIANTS */
783
790
}
784
791
}
785
792
#endif /* USE_ICU */
0 commit comments