Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb8f44a4

Browse files
committed
Refactor error messages for unsupported providers in pg_locale.c
These code paths should not be reached normally, but if they are anerror with "(null)" as information for the collation provider would showup if no locale is set, while we can assume that we are referring tolibc.This refactors the code so as the provider is always reported even if nolocale is set. The name of the function where the error happens isadded, while on it, as it can be helpful for debugging.Issue introduced byd87d548, so backpatch down to 16.Author: Michael Paquier, Ranier VilelaReviewed-by: Jeff Davis, Kyotaro HoriguchiDiscussion:https://postgr.es/m/7073610042fcf97e1bea2ce08b7e0214b5e11094.camel@j-davis.comBackpatch-through: 16
1 parentee3a551 commitb8f44a4

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

‎src/backend/utils/adt/pg_locale.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@
8181
#include<shlwapi.h>
8282
#endif
8383

84+
/* Error triggered for locale-sensitive subroutines */
85+
#definePGLOCALE_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
20322036
else
20332037
/* shouldn't happen */
2034-
elog(ERROR,"unsupported collprovider: %c",locale->provider);
2038+
PGLOCALE_SUPPORT_ERROR(locale->provider);
20352039

20362040
returnresult;
20372041
}
@@ -2067,7 +2071,7 @@ pg_strncoll(const char *arg1, size_t len1, const char *arg2, size_t len2,
20672071
#endif
20682072
else
20692073
/* shouldn't happen */
2070-
elog(ERROR,"unsupported collprovider: %c",locale->provider);
2074+
PGLOCALE_SUPPORT_ERROR(locale->provider);
20712075

20722076
returnresult;
20732077
}
@@ -2086,7 +2090,7 @@ pg_strxfrm_libc(char *dest, const char *src, size_t destsize,
20862090
returnstrxfrm(dest,src,destsize);
20872091
#else
20882092
/* shouldn't happen */
2089-
elog(ERROR,"unsupported collprovider: %c",locale->provider);
2093+
PGLOCALE_SUPPORT_ERROR(locale->provider);
20902094
return0;/* keep compiler quiet */
20912095
#endif
20922096
}
@@ -2282,7 +2286,7 @@ pg_strxfrm_enabled(pg_locale_t locale)
22822286
returntrue;
22832287
else
22842288
/* shouldn't happen */
2285-
elog(ERROR,"unsupported collprovider: %c",locale->provider);
2289+
PGLOCALE_SUPPORT_ERROR(locale->provider);
22862290

22872291
return 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
23152319
else
23162320
/* shouldn't happen */
2317-
elog(ERROR,"unsupported collprovider: %c",locale->provider);
2321+
PGLOCALE_SUPPORT_ERROR(locale->provider);
23182322

23192323
returnresult;
23202324
}
@@ -2351,7 +2355,7 @@ pg_strnxfrm(char *dest, size_t destsize, const char *src, size_t srclen,
23512355
#endif
23522356
else
23532357
/* shouldn't happen */
2354-
elog(ERROR,"unsupported collprovider: %c",locale->provider);
2358+
PGLOCALE_SUPPORT_ERROR(locale->provider);
23552359

23562360
returnresult;
23572361
}
@@ -2369,7 +2373,7 @@ pg_strxfrm_prefix_enabled(pg_locale_t locale)
23692373
return true;
23702374
else
23712375
/* shouldn't happen */
2372-
elog(ERROR,"unsupported collprovider: %c",locale->provider);
2376+
PGLOCALE_SUPPORT_ERROR(locale->provider);
23732377

23742378
return false;/* keep compiler quiet */
23752379
}
@@ -2393,16 +2397,14 @@ pg_strxfrm_prefix(char *dest, const char *src, size_t destsize,
23932397
{
23942398
size_tresult=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
#ifdefUSE_ICU
24002403
elseif (locale->provider==COLLPROVIDER_ICU)
24012404
result=pg_strnxfrm_prefix_icu(dest,src,-1,destsize,locale);
24022405
#endif
24032406
else
2404-
/* shouldn't happen */
2405-
elog(ERROR,"unsupported collprovider: %c",locale->provider);
2407+
PGLOCALE_SUPPORT_ERROR(locale->provider);
24062408

24072409
returnresult;
24082410
}
@@ -2430,16 +2432,14 @@ pg_strnxfrm_prefix(char *dest, size_t destsize, const char *src,
24302432
{
24312433
size_tresult=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
#ifdefUSE_ICU
24372438
elseif (locale->provider==COLLPROVIDER_ICU)
24382439
result=pg_strnxfrm_prefix_icu(dest,src,-1,destsize,locale);
24392440
#endif
24402441
else
2441-
/* shouldn't happen */
2442-
elog(ERROR,"unsupported collprovider: %c",locale->provider);
2442+
PGLOCALE_SUPPORT_ERROR(locale->provider);
24432443

24442444
returnresult;
24452445
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp