8181#include <shlwapi.h>
8282#endif
8383
84+ /* Error triggered for locale-sensitive subroutines */
85+ #define PGLOCALE_SUPPORT_ERROR (provider ) \
86+ elog(ERROR, "unsupported collprovider for %s: %c", __func__, provider)
87+
8488/*
8589 * This should be large enough that most strings will fit, but small enough
8690 * that we feel comfortable putting it on the stack
@@ -2016,7 +2020,7 @@ pg_strcoll(const char *arg1, const char *arg2, pg_locale_t locale)
20162020#endif
20172021else
20182022/* shouldn't happen */
2019- elog ( ERROR , "unsupported collprovider: %c" , locale -> provider );
2023+ PGLOCALE_SUPPORT_ERROR ( locale -> provider );
20202024
20212025return result ;
20222026}
@@ -2052,7 +2056,7 @@ pg_strncoll(const char *arg1, size_t len1, const char *arg2, size_t len2,
20522056#endif
20532057else
20542058/* shouldn't happen */
2055- elog ( ERROR , "unsupported collprovider: %c" , locale -> provider );
2059+ PGLOCALE_SUPPORT_ERROR ( locale -> provider );
20562060
20572061return result ;
20582062}
@@ -2073,7 +2077,7 @@ pg_strxfrm_libc(char *dest, const char *src, size_t destsize,
20732077return strxfrm (dest ,src ,destsize );
20742078#else
20752079/* shouldn't happen */
2076- elog ( ERROR , "unsupported collprovider: %c" , locale -> provider );
2080+ PGLOCALE_SUPPORT_ERROR ( locale -> provider );
20772081return 0 ;/* keep compiler quiet */
20782082#endif
20792083}
@@ -2269,7 +2273,7 @@ pg_strxfrm_enabled(pg_locale_t locale)
22692273return true ;
22702274else
22712275/* shouldn't happen */
2272- elog ( ERROR , "unsupported collprovider: %c" , locale -> provider );
2276+ PGLOCALE_SUPPORT_ERROR ( locale -> provider );
22732277
22742278return false;/* keep compiler quiet */
22752279}
@@ -2301,7 +2305,7 @@ pg_strxfrm(char *dest, const char *src, size_t destsize, pg_locale_t locale)
23012305#endif
23022306else
23032307/* shouldn't happen */
2304- elog ( ERROR , "unsupported collprovider: %c" , locale -> provider );
2308+ PGLOCALE_SUPPORT_ERROR ( locale -> provider );
23052309
23062310return result ;
23072311}
@@ -2338,7 +2342,7 @@ pg_strnxfrm(char *dest, size_t destsize, const char *src, size_t srclen,
23382342#endif
23392343else
23402344/* shouldn't happen */
2341- elog ( ERROR , "unsupported collprovider: %c" , locale -> provider );
2345+ PGLOCALE_SUPPORT_ERROR ( locale -> provider );
23422346
23432347return result ;
23442348}
@@ -2356,7 +2360,7 @@ pg_strxfrm_prefix_enabled(pg_locale_t locale)
23562360return true;
23572361else
23582362/* shouldn't happen */
2359- elog ( ERROR , "unsupported collprovider: %c" , locale -> provider );
2363+ PGLOCALE_SUPPORT_ERROR ( locale -> provider );
23602364
23612365return false;/* keep compiler quiet */
23622366}
@@ -2380,16 +2384,14 @@ pg_strxfrm_prefix(char *dest, const char *src, size_t destsize,
23802384{
23812385size_t result = 0 ;/* keep compiler quiet */
23822386
2383- if (!locale || locale -> provider == COLLPROVIDER_LIBC )
2384- elog (ERROR ,"collprovider '%c' does not support pg_strxfrm_prefix()" ,
2385- locale -> provider );
2387+ if (!locale )
2388+ PGLOCALE_SUPPORT_ERROR (COLLPROVIDER_LIBC );
23862389#ifdef USE_ICU
23872390else if (locale -> provider == COLLPROVIDER_ICU )
23882391result = pg_strnxfrm_prefix_icu (dest ,src ,-1 ,destsize ,locale );
23892392#endif
23902393else
2391- /* shouldn't happen */
2392- elog (ERROR ,"unsupported collprovider: %c" ,locale -> provider );
2394+ PGLOCALE_SUPPORT_ERROR (locale -> provider );
23932395
23942396return result ;
23952397}
@@ -2417,16 +2419,14 @@ pg_strnxfrm_prefix(char *dest, size_t destsize, const char *src,
24172419{
24182420size_t result = 0 ;/* keep compiler quiet */
24192421
2420- if (!locale || locale -> provider == COLLPROVIDER_LIBC )
2421- elog (ERROR ,"collprovider '%c' does not support pg_strnxfrm_prefix()" ,
2422- locale -> provider );
2422+ if (!locale )
2423+ PGLOCALE_SUPPORT_ERROR (COLLPROVIDER_LIBC );
24232424#ifdef USE_ICU
24242425else if (locale -> provider == COLLPROVIDER_ICU )
24252426result = pg_strnxfrm_prefix_icu (dest ,src ,-1 ,destsize ,locale );
24262427#endif
24272428else
2428- /* shouldn't happen */
2429- elog (ERROR ,"unsupported collprovider: %c" ,locale -> provider );
2429+ PGLOCALE_SUPPORT_ERROR (locale -> provider );
24302430
24312431return result ;
24322432}