Skip to content

Commit 382a821

Browse files
committed
Allow NULL version for individual collations.
Remove the documented restriction that collation providers must either return NULL for all collations or non-NULL for all collations. Use NULL for glibc collations like "C.UTF-8", which might otherwise lead future proposed commits to force unnecessary index rebuilds. Reviewed-by: Peter Eisentraut <peter.eisentraut@2ndquadrant.com> Discussion: https://postgr.es/m/CA%2BhUKGJvqup3s%2BJowVTcacZADO6dOhfdBmvOPHLS3KXUJu41Jw%40mail.gmail.com
1 parent dd8e191 commit 382a821

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/backend/utils/adt/pg_locale.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,10 +1505,6 @@ pg_newlocale_from_collation(Oid collid)
15051505
/*
15061506
* Get provider-specific collation version string for the given collation from
15071507
* the operating system/library.
1508-
*
1509-
* A particular provider must always either return a non-NULL string or return
1510-
* NULL (if it doesn't support versions). It must not return NULL for some
1511-
* collcollate and not NULL for others.
15121508
*/
15131509
char *
15141510
get_collation_actual_version(char collprovider, const char *collcollate)
@@ -1540,6 +1536,23 @@ get_collation_actual_version(char collprovider, const char *collcollate)
15401536
if (collprovider == COLLPROVIDER_LIBC)
15411537
{
15421538
#if defined(__GLIBC__)
1539+
char *copy = pstrdup(collcollate);
1540+
char *copy_suffix = strstr(copy, ".");
1541+
bool need_version = true;
1542+
1543+
/*
1544+
* Check for names like C.UTF-8 by chopping off the encoding suffix on
1545+
* our temporary copy, so we can skip the version.
1546+
*/
1547+
if (copy_suffix)
1548+
*copy_suffix = '\0';
1549+
if (pg_strcasecmp("c", copy) == 0 ||
1550+
pg_strcasecmp("posix", copy) == 0)
1551+
need_version = false;
1552+
pfree(copy);
1553+
if (!need_version)
1554+
return NULL;
1555+
15431556
/* Use the glibc version because we don't have anything better. */
15441557
collversion = pstrdup(gnu_get_libc_version());
15451558
#endif

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy