Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 46a44dc

Browse files
committed
Use version for builtin collations.
Given that the version field already exists, there's little reason not to use it. Suggestion from Peter Eisentraut. Discussion: https://postgr.es/m/613c120a-5413-4fa7-a501-6590eae558f8@eisentraut.org Reviewed-by: Peter Eisentraut
1 parent c2df2ed commit 46a44dc

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

src/backend/utils/adt/pg_locale.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1732,13 +1732,23 @@ get_collation_actual_version(char collprovider, const char *collcollate)
17321732

17331733
/*
17341734
* The only two supported locales (C and C.UTF-8) are both based on memcmp
1735-
* and are not expected to change.
1735+
* and are not expected to change, but track the version anyway.
17361736
*
17371737
* Note that the character semantics may change for some locales, but the
17381738
* collation version only tracks changes to sort order.
17391739
*/
17401740
if (collprovider == COLLPROVIDER_BUILTIN)
1741-
return NULL;
1741+
{
1742+
if (strcmp(collcollate, "C") == 0)
1743+
return "1";
1744+
else if (strcmp(collcollate, "C.UTF-8") == 0)
1745+
return "1";
1746+
else
1747+
ereport(ERROR,
1748+
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
1749+
errmsg("invalid locale name \"%s\" for builtin provider",
1750+
collcollate)));
1751+
}
17421752

17431753
#ifdef USE_ICU
17441754
if (collprovider == COLLPROVIDER_ICU)

src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@
5757
*/
5858

5959
/* yyyymmddN */
60-
#define CATALOG_VERSION_NO 202403272
60+
#define CATALOG_VERSION_NO 202403291
6161

6262
#endif

src/include/catalog/pg_collation.dat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@
2525
collcollate => 'POSIX', collctype => 'POSIX' },
2626
{ oid => '962', descr => 'sorts by Unicode code point, C character semantics',
2727
collname => 'ucs_basic', collprovider => 'b', collencoding => '6',
28-
colllocale => 'C' },
28+
colllocale => 'C', collversion => '1' },
2929
{ oid => '963',
3030
descr => 'sorts using the Unicode Collation Algorithm with default settings',
3131
collname => 'unicode', collprovider => 'i', collencoding => '-1',
3232
colllocale => 'und' },
3333
{ oid => '811', descr => 'sorts by Unicode code point; Unicode and POSIX character semantics',
3434
collname => 'pg_c_utf8', collprovider => 'b', collencoding => '6',
35-
colllocale => 'C.UTF-8' },
35+
colllocale => 'C.UTF-8', collversion => '1' },
3636

3737
]

0 commit comments

Comments
 (0)