mirror of
https://github.com/postgres/postgres.git
synced 2025-07-31 22:04:40 +03:00
Call pg_newlocale_from_collation() also with default collation
Previously, callers of pg_newlocale_from_collation() did not call it if the collation was DEFAULT_COLLATION_OID and instead proceeded with a pg_locale_t of 0. Instead, now we call it anyway and have it return 0 if the default collation was passed. It already did this, so we just have to adjust the callers. This simplifies all the call sites and also makes future enhancements easier. After discussion and testing, the previous comment in pg_locale.c about avoiding this for performance reasons may have been mistaken since it was testing a very different patch version way back when. Reviewed-by: Julien Rouhaud <rjuju123@gmail.com> Discussion: https://www.postgresql.org/message-id/ed3baa81-7fac-7788-cc12-41e3f7917e34@enterprisedb.com
This commit is contained in:
@ -1454,8 +1454,6 @@ report_newlocale_failure(const char *localename)
|
||||
*
|
||||
* As a special optimization, the default/database collation returns 0.
|
||||
* Callers should then revert to the non-locale_t-enabled code path.
|
||||
* In fact, they shouldn't call this function at all when they are dealing
|
||||
* with the default locale. That can save quite a bit in hotspots.
|
||||
* Also, callers should avoid calling this before going down a C/POSIX
|
||||
* fastpath, because such a fastpath should work even on platforms without
|
||||
* locale_t support in the C library.
|
||||
@ -1472,7 +1470,6 @@ pg_newlocale_from_collation(Oid collid)
|
||||
/* Callers must pass a valid OID */
|
||||
Assert(OidIsValid(collid));
|
||||
|
||||
/* Return 0 for "default" collation, just in case caller forgets */
|
||||
if (collid == DEFAULT_COLLATION_OID)
|
||||
return (pg_locale_t) 0;
|
||||
|
||||
|
Reference in New Issue
Block a user