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

Commitd5ac14f

Browse files
committed
Use libc version as a collation version on glibc systems.
Using glibc's version string to detect potential collation definitionchanges is not 100% reliable, but it's better than nothing. Currentlythis affects only collations explicitly provided by "libc". More workwill be needed to handle the default collation.Author: Thomas Munro, based on a suggestion from Christoph BergReviewed-by: Peter EisentrautDiscussion:https://postgr.es/m/4b76c6d4-ae5e-0dc6-7d0d-b5c796a07e34%402ndquadrant.com
1 parent4351142 commitd5ac14f

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

‎doc/src/sgml/ref/alter_collation.sgml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,16 @@ HINT: Rebuild all objects affected by this collation and run ALTER COLLATION pg
129129
does not actually check whether all affected objects have been rebuilt
130130
correctly.
131131
</para>
132+
<para>
133+
When using collations provided by <literal>libc</literal> and
134+
<productname>PostgreSQL</productname> was built with the GNU C library, the
135+
C library's version is used as a collation version. Since collation
136+
definitions typically change only with GNU C library releases, this provides
137+
some defense against corruption, but it is not completely reliable.
138+
</para>
139+
<para>
140+
Currently, there is no version tracking for the database default collation.
141+
</para>
132142

133143
<para>
134144
The following query can be used to identify all collations in the current

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@
7070
#include<unicode/ucnv.h>
7171
#endif
7272

73+
#ifdef__GLIBC__
74+
#include<gnu/libc-version.h>
75+
#endif
76+
7377
#ifdefWIN32
7478
/*
7579
* This Windows file defines StrNCpy. We don't need it here, so we undefine
@@ -1499,7 +1503,7 @@ pg_newlocale_from_collation(Oid collid)
14991503
char*
15001504
get_collation_actual_version(charcollprovider,constchar*collcollate)
15011505
{
1502-
char*collversion;
1506+
char*collversion=NULL;
15031507

15041508
#ifdefUSE_ICU
15051509
if (collprovider==COLLPROVIDER_ICU)
@@ -1523,7 +1527,13 @@ get_collation_actual_version(char collprovider, const char *collcollate)
15231527
}
15241528
else
15251529
#endif
1526-
collversion=NULL;
1530+
if (collprovider==COLLPROVIDER_LIBC)
1531+
{
1532+
#if defined(__GLIBC__)
1533+
/* Use the glibc version because we don't have anything better. */
1534+
collversion=pstrdup(gnu_get_libc_version());
1535+
#endif
1536+
}
15271537

15281538
returncollversion;
15291539
}

‎src/bin/pg_dump/t/002_pg_dump.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,8 +1376,8 @@
13761376
'CREATE COLLATION test0 FROM "C"'=> {
13771377
create_order=> 76,
13781378
create_sql=>'CREATE COLLATION test0 FROM "C";',
1379-
regexp=>qr/^
1380-
\QCREATE COLLATION public.test0 (provider = libc, locale = 'C');\E/xm,
1379+
regexp=>
1380+
qr/CREATE COLLATION public.test0\(provider = libc, locale = 'C'(, version = '[^']*')?\);/m,
13811381
collation=> 1,
13821382
like=> {%full_runs,section_pre_data=> 1, },
13831383
},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp