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
@@ -2031,7 +2035,7 @@ pg_strcoll(const char *arg1, const char *arg2, pg_locale_t locale)
20312035#endif
20322036else
20332037/* shouldn't happen */
2034- elog ( ERROR , "unsupported collprovider: %c" , locale -> provider );
2038+ PGLOCALE_SUPPORT_ERROR ( locale -> provider );
20352039
20362040return result ;
20372041}
@@ -2067,7 +2071,7 @@ pg_strncoll(const char *arg1, size_t len1, const char *arg2, size_t len2,
20672071#endif
20682072else
20692073/* shouldn't happen */
2070- elog ( ERROR , "unsupported collprovider: %c" , locale -> provider );
2074+ PGLOCALE_SUPPORT_ERROR ( locale -> provider );
20712075
20722076return result ;
20732077}
@@ -2086,7 +2090,7 @@ pg_strxfrm_libc(char *dest, const char *src, size_t destsize,
20862090return strxfrm (dest ,src ,destsize );
20872091#else
20882092/* shouldn't happen */
2089- elog ( ERROR , "unsupported collprovider: %c" , locale -> provider );
2093+ PGLOCALE_SUPPORT_ERROR ( locale -> provider );
20902094return 0 ;/* keep compiler quiet */
20912095#endif
20922096}
@@ -2282,7 +2286,7 @@ pg_strxfrm_enabled(pg_locale_t locale)
22822286return true ;
22832287else
22842288/* shouldn't happen */
2285- elog ( ERROR , "unsupported collprovider: %c" , locale -> provider );
2289+ PGLOCALE_SUPPORT_ERROR ( locale -> provider );
22862290
22872291return false;/* keep compiler quiet */
22882292}
@@ -2314,7 +2318,7 @@ pg_strxfrm(char *dest, const char *src, size_t destsize, pg_locale_t locale)
23142318#endif
23152319else
23162320/* shouldn't happen */
2317- elog ( ERROR , "unsupported collprovider: %c" , locale -> provider );
2321+ PGLOCALE_SUPPORT_ERROR ( locale -> provider );
23182322
23192323return result ;
23202324}
@@ -2351,7 +2355,7 @@ pg_strnxfrm(char *dest, size_t destsize, const char *src, size_t srclen,
23512355#endif
23522356else
23532357/* shouldn't happen */
2354- elog ( ERROR , "unsupported collprovider: %c" , locale -> provider );
2358+ PGLOCALE_SUPPORT_ERROR ( locale -> provider );
23552359
23562360return result ;
23572361}
@@ -2369,7 +2373,7 @@ pg_strxfrm_prefix_enabled(pg_locale_t locale)
23692373return true;
23702374else
23712375/* shouldn't happen */
2372- elog ( ERROR , "unsupported collprovider: %c" , locale -> provider );
2376+ PGLOCALE_SUPPORT_ERROR ( locale -> provider );
23732377
23742378return false;/* keep compiler quiet */
23752379}
@@ -2393,16 +2397,14 @@ pg_strxfrm_prefix(char *dest, const char *src, size_t destsize,
23932397{
23942398size_t result = 0 ;/* keep compiler quiet */
23952399
2396- if (!locale || locale -> provider == COLLPROVIDER_LIBC )
2397- elog (ERROR ,"collprovider '%c' does not support pg_strxfrm_prefix()" ,
2398- locale -> provider );
2400+ if (!locale )
2401+ PGLOCALE_SUPPORT_ERROR (COLLPROVIDER_LIBC );
23992402#ifdef USE_ICU
24002403else if (locale -> provider == COLLPROVIDER_ICU )
24012404result = pg_strnxfrm_prefix_icu (dest ,src ,-1 ,destsize ,locale );
24022405#endif
24032406else
2404- /* shouldn't happen */
2405- elog (ERROR ,"unsupported collprovider: %c" ,locale -> provider );
2407+ PGLOCALE_SUPPORT_ERROR (locale -> provider );
24062408
24072409return result ;
24082410}
@@ -2430,16 +2432,14 @@ pg_strnxfrm_prefix(char *dest, size_t destsize, const char *src,
24302432{
24312433size_t result = 0 ;/* keep compiler quiet */
24322434
2433- if (!locale || locale -> provider == COLLPROVIDER_LIBC )
2434- elog (ERROR ,"collprovider '%c' does not support pg_strnxfrm_prefix()" ,
2435- locale -> provider );
2435+ if (!locale )
2436+ PGLOCALE_SUPPORT_ERROR (COLLPROVIDER_LIBC );
24362437#ifdef USE_ICU
24372438else if (locale -> provider == COLLPROVIDER_ICU )
24382439result = pg_strnxfrm_prefix_icu (dest ,src ,-1 ,destsize ,locale );
24392440#endif
24402441else
2441- /* shouldn't happen */
2442- elog (ERROR ,"unsupported collprovider: %c" ,locale -> provider );
2442+ PGLOCALE_SUPPORT_ERROR (locale -> provider );
24432443
24442444return result ;
24452445}