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

Commit7d1297d

Browse files
committed
Remove pg_collation.collversion.
This model couldn't be extended to cover the default collation, anddidn't have any information about the affected database objects when theversion changed. Remove, in preparation for a follow-up commit thatwill add a new mechanism.Author: Thomas Munro <thomas.munro@gmail.com>Reviewed-by: Julien Rouhaud <rjuju123@gmail.com>Reviewed-by: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>Discussion:https://postgr.es/m/CAEepm%3D0uEQCpfq_%2BLYFBdArCe4Ot98t1aR4eYiYTe%3DyavQygiQ%40mail.gmail.com
1 parent8ef2a5a commit7d1297d

File tree

22 files changed

+8
-344
lines changed

22 files changed

+8
-344
lines changed

‎doc/src/sgml/catalogs.sgml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2361,17 +2361,6 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
23612361
<symbol>LC_CTYPE</symbol> for this collation object
23622362
</para></entry>
23632363
</row>
2364-
2365-
<row>
2366-
<entry role="catalog_table_entry"><para role="column_definition">
2367-
<structfield>collversion</structfield> <type>text</type>
2368-
</para>
2369-
<para>
2370-
Provider-specific version of the collation. This is recorded when the
2371-
collation is created and then checked when it is used, to detect
2372-
changes in the collation definition that could lead to data corruption.
2373-
</para></entry>
2374-
</row>
23752364
</tbody>
23762365
</tgroup>
23772366
</table>

‎doc/src/sgml/func.sgml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25444,11 +25444,7 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
2544425444
</para>
2544525445
<para>
2544625446
Returns the actual version of the collation object as it is currently
25447-
installed in the operating system. If this is different from the
25448-
value in
25449-
<structname>pg_collation</structname>.<structfield>collversion</structfield>,
25450-
then objects depending on the collation might need to be rebuilt. See
25451-
also <xref linkend="sql-altercollation"/>.
25447+
installed in the operating system.
2545225448
</para></entry>
2545325449
</row>
2545425450

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

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ PostgreSQL documentation
2121

2222
<refsynopsisdiv>
2323
<synopsis>
24-
ALTER COLLATION <replaceable>name</replaceable> REFRESH VERSION
25-
2624
ALTER COLLATION <replaceable>name</replaceable> RENAME TO <replaceable>new_name</replaceable>
2725
ALTER COLLATION <replaceable>name</replaceable> OWNER TO { <replaceable>new_owner</replaceable> | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
2826
ALTER COLLATION <replaceable>name</replaceable> SET SCHEMA <replaceable>new_schema</replaceable>
@@ -88,70 +86,9 @@ ALTER COLLATION <replaceable>name</replaceable> SET SCHEMA <replaceable>new_sche
8886
</listitem>
8987
</varlistentry>
9088

91-
<varlistentry>
92-
<term><literal>REFRESH VERSION</literal></term>
93-
<listitem>
94-
<para>
95-
Update the collation's version.
96-
See <xref linkend="sql-altercollation-notes"/> below.
97-
</para>
98-
</listitem>
99-
</varlistentry>
10089
</variablelist>
10190
</refsect1>
10291

103-
<refsect1 id="sql-altercollation-notes" xreflabel="Notes">
104-
<title>Notes</title>
105-
106-
<para>
107-
When using collations provided by the ICU library, the ICU-specific version
108-
of the collator is recorded in the system catalog when the collation object
109-
is created. When the collation is used, the current version is
110-
checked against the recorded version, and a warning is issued when there is
111-
a mismatch, for example:
112-
<screen>
113-
WARNING: collation "xx-x-icu" has version mismatch
114-
DETAIL: The collation in the database was created using version 1.2.3.4, but the operating system provides version 2.3.4.5.
115-
HINT: Rebuild all objects affected by this collation and run ALTER COLLATION pg_catalog."xx-x-icu" REFRESH VERSION, or build PostgreSQL with the right library version.
116-
</screen>
117-
A change in collation definitions can lead to corrupt indexes and other
118-
problems because the database system relies on stored objects having a
119-
certain sort order. Generally, this should be avoided, but it can happen
120-
in legitimate circumstances, such as when
121-
using <command>pg_upgrade</command> to upgrade to server binaries linked
122-
with a newer version of ICU. When this happens, all objects depending on
123-
the collation should be rebuilt, for example,
124-
using <command>REINDEX</command>. When that is done, the collation version
125-
can be refreshed using the command <literal>ALTER COLLATION ... REFRESH
126-
VERSION</literal>. This will update the system catalog to record the
127-
current collator version and will make the warning go away. Note that this
128-
does not actually check whether all affected objects have been rebuilt
129-
correctly.
130-
</para>
131-
<para>
132-
When using collations provided by <literal>libc</literal> and
133-
<productname>PostgreSQL</productname> was built with the GNU C library, the
134-
C library's version is used as a collation version. Since collation
135-
definitions typically change only with GNU C library releases, this provides
136-
some defense against corruption, but it is not completely reliable.
137-
</para>
138-
<para>
139-
Currently, there is no version tracking for the database default collation.
140-
</para>
141-
142-
<para>
143-
The following query can be used to identify all collations in the current
144-
database that need to be refreshed and the objects that depend on them:
145-
<programlisting><![CDATA[
146-
SELECT pg_describe_object(refclassid, refobjid, refobjsubid) AS "Collation",
147-
pg_describe_object(classid, objid, objsubid) AS "Object"
148-
FROM pg_depend d JOIN pg_collation c
149-
ON refclassid = 'pg_collation'::regclass AND refobjid = c.oid
150-
WHERE c.collversion <> pg_collation_actual_version(c.oid)
151-
ORDER BY 1, 2;
152-
]]></programlisting></para>
153-
</refsect1>
154-
15592
<refsect1>
15693
<title>Examples</title>
15794

‎doc/src/sgml/ref/create_collation.sgml

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ CREATE COLLATION [ IF NOT EXISTS ] <replaceable>name</replaceable> (
2727
[ LC_CTYPE = <replaceable>lc_ctype</replaceable>, ]
2828
[ PROVIDER = <replaceable>provider</replaceable>, ]
2929
[ DETERMINISTIC = <replaceable>boolean</replaceable>, ]
30-
[ VERSION = <replaceable>version</replaceable> ]
3130
)
3231
CREATE COLLATION [ IF NOT EXISTS ] <replaceable>name</replaceable> FROM <replaceable>existing_collation</replaceable>
3332
</synopsis>
@@ -149,26 +148,6 @@ CREATE COLLATION [ IF NOT EXISTS ] <replaceable>name</replaceable> FROM <replace
149148
</listitem>
150149
</varlistentry>
151150

152-
<varlistentry>
153-
<term><replaceable>version</replaceable></term>
154-
155-
<listitem>
156-
<para>
157-
Specifies the version string to store with the collation. Normally,
158-
this should be omitted, which will cause the version to be computed
159-
from the actual version of the collation as provided by the operating
160-
system. This option is intended to be used
161-
by <command>pg_upgrade</command> for copying the version from an
162-
existing installation.
163-
</para>
164-
165-
<para>
166-
See also <xref linkend="sql-altercollation"/> for how to handle
167-
collation version mismatches.
168-
</para>
169-
</listitem>
170-
</varlistentry>
171-
172151
<varlistentry>
173152
<term><replaceable>existing_collation</replaceable></term>
174153

‎src/backend/catalog/pg_collation.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ CollationCreate(const char *collname, Oid collnamespace,
4949
boolcollisdeterministic,
5050
int32collencoding,
5151
constchar*collcollate,constchar*collctype,
52-
constchar*collversion,
5352
boolif_not_exists,
5453
boolquiet)
5554
{
@@ -167,10 +166,6 @@ CollationCreate(const char *collname, Oid collnamespace,
167166
values[Anum_pg_collation_collcollate-1]=NameGetDatum(&name_collate);
168167
namestrcpy(&name_ctype,collctype);
169168
values[Anum_pg_collation_collctype-1]=NameGetDatum(&name_ctype);
170-
if (collversion)
171-
values[Anum_pg_collation_collversion-1]=CStringGetTextDatum(collversion);
172-
else
173-
nulls[Anum_pg_collation_collversion-1]= true;
174169

175170
tup=heap_form_tuple(tupDesc,values,nulls);
176171

‎src/backend/commands/collationcmds.c

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,12 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
6161
DefElem*lcctypeEl=NULL;
6262
DefElem*providerEl=NULL;
6363
DefElem*deterministicEl=NULL;
64-
DefElem*versionEl=NULL;
6564
char*collcollate=NULL;
6665
char*collctype=NULL;
6766
char*collproviderstr=NULL;
6867
boolcollisdeterministic= true;
6968
intcollencoding=0;
7069
charcollprovider=0;
71-
char*collversion=NULL;
7270
Oidnewoid;
7371
ObjectAddressaddress;
7472

@@ -96,8 +94,6 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
9694
defelp=&providerEl;
9795
elseif (strcmp(defel->defname,"deterministic")==0)
9896
defelp=&deterministicEl;
99-
elseif (strcmp(defel->defname,"version")==0)
100-
defelp=&versionEl;
10197
else
10298
{
10399
ereport(ERROR,
@@ -166,9 +162,6 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
166162
if (deterministicEl)
167163
collisdeterministic=defGetBoolean(deterministicEl);
168164

169-
if (versionEl)
170-
collversion=defGetString(versionEl);
171-
172165
if (collproviderstr)
173166
{
174167
if (pg_strcasecmp(collproviderstr,"icu")==0)
@@ -215,9 +208,6 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
215208
}
216209
}
217210

218-
if (!collversion)
219-
collversion=get_collation_actual_version(collprovider,collcollate);
220-
221211
newoid=CollationCreate(collName,
222212
collNamespace,
223213
GetUserId(),
@@ -226,7 +216,6 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
226216
collencoding,
227217
collcollate,
228218
collctype,
229-
collversion,
230219
if_not_exists,
231220
false);/* not quiet */
232221

@@ -277,80 +266,6 @@ IsThereCollationInNamespace(const char *collname, Oid nspOid)
277266
collname,get_namespace_name(nspOid))));
278267
}
279268

280-
/*
281-
* ALTER COLLATION
282-
*/
283-
ObjectAddress
284-
AlterCollation(AlterCollationStmt*stmt)
285-
{
286-
Relationrel;
287-
OidcollOid;
288-
HeapTupletup;
289-
Form_pg_collationcollForm;
290-
Datumcollversion;
291-
boolisnull;
292-
char*oldversion;
293-
char*newversion;
294-
ObjectAddressaddress;
295-
296-
rel=table_open(CollationRelationId,RowExclusiveLock);
297-
collOid=get_collation_oid(stmt->collname, false);
298-
299-
if (!pg_collation_ownercheck(collOid,GetUserId()))
300-
aclcheck_error(ACLCHECK_NOT_OWNER,OBJECT_COLLATION,
301-
NameListToString(stmt->collname));
302-
303-
tup=SearchSysCacheCopy1(COLLOID,ObjectIdGetDatum(collOid));
304-
if (!HeapTupleIsValid(tup))
305-
elog(ERROR,"cache lookup failed for collation %u",collOid);
306-
307-
collForm= (Form_pg_collation)GETSTRUCT(tup);
308-
collversion=SysCacheGetAttr(COLLOID,tup,Anum_pg_collation_collversion,
309-
&isnull);
310-
oldversion=isnull ?NULL :TextDatumGetCString(collversion);
311-
312-
newversion=get_collation_actual_version(collForm->collprovider,NameStr(collForm->collcollate));
313-
314-
/* cannot change from NULL to non-NULL or vice versa */
315-
if ((!oldversion&&newversion)|| (oldversion&& !newversion))
316-
elog(ERROR,"invalid collation version change");
317-
elseif (oldversion&&newversion&&strcmp(newversion,oldversion)!=0)
318-
{
319-
boolnulls[Natts_pg_collation];
320-
boolreplaces[Natts_pg_collation];
321-
Datumvalues[Natts_pg_collation];
322-
323-
ereport(NOTICE,
324-
(errmsg("changing version from %s to %s",
325-
oldversion,newversion)));
326-
327-
memset(values,0,sizeof(values));
328-
memset(nulls, false,sizeof(nulls));
329-
memset(replaces, false,sizeof(replaces));
330-
331-
values[Anum_pg_collation_collversion-1]=CStringGetTextDatum(newversion);
332-
replaces[Anum_pg_collation_collversion-1]= true;
333-
334-
tup=heap_modify_tuple(tup,RelationGetDescr(rel),
335-
values,nulls,replaces);
336-
}
337-
else
338-
ereport(NOTICE,
339-
(errmsg("version has not changed")));
340-
341-
CatalogTupleUpdate(rel,&tup->t_self,tup);
342-
343-
InvokeObjectPostAlterHook(CollationRelationId,collOid,0);
344-
345-
ObjectAddressSet(address,CollationRelationId,collOid);
346-
347-
heap_freetuple(tup);
348-
table_close(rel,NoLock);
349-
350-
returnaddress;
351-
}
352-
353-
354269
Datum
355270
pg_collation_actual_version(PG_FUNCTION_ARGS)
356271
{
@@ -608,7 +523,6 @@ pg_import_system_collations(PG_FUNCTION_ARGS)
608523
collid=CollationCreate(localebuf,nspid,GetUserId(),
609524
COLLPROVIDER_LIBC, true,enc,
610525
localebuf,localebuf,
611-
get_collation_actual_version(COLLPROVIDER_LIBC,localebuf),
612526
true, true);
613527
if (OidIsValid(collid))
614528
{
@@ -669,7 +583,6 @@ pg_import_system_collations(PG_FUNCTION_ARGS)
669583
collid=CollationCreate(alias,nspid,GetUserId(),
670584
COLLPROVIDER_LIBC, true,enc,
671585
locale,locale,
672-
get_collation_actual_version(COLLPROVIDER_LIBC,locale),
673586
true, true);
674587
if (OidIsValid(collid))
675588
{
@@ -731,7 +644,6 @@ pg_import_system_collations(PG_FUNCTION_ARGS)
731644
nspid,GetUserId(),
732645
COLLPROVIDER_ICU, true,-1,
733646
collcollate,collcollate,
734-
get_collation_actual_version(COLLPROVIDER_ICU,collcollate),
735647
true, true);
736648
if (OidIsValid(collid))
737649
{

‎src/backend/nodes/copyfuncs.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3224,16 +3224,6 @@ _copyAlterTableCmd(const AlterTableCmd *from)
32243224
returnnewnode;
32253225
}
32263226

3227-
staticAlterCollationStmt*
3228-
_copyAlterCollationStmt(constAlterCollationStmt*from)
3229-
{
3230-
AlterCollationStmt*newnode=makeNode(AlterCollationStmt);
3231-
3232-
COPY_NODE_FIELD(collname);
3233-
3234-
returnnewnode;
3235-
}
3236-
32373227
staticAlterDomainStmt*
32383228
_copyAlterDomainStmt(constAlterDomainStmt*from)
32393229
{
@@ -5229,9 +5219,6 @@ copyObjectImpl(const void *from)
52295219
caseT_AlterTableCmd:
52305220
retval=_copyAlterTableCmd(from);
52315221
break;
5232-
caseT_AlterCollationStmt:
5233-
retval=_copyAlterCollationStmt(from);
5234-
break;
52355222
caseT_AlterDomainStmt:
52365223
retval=_copyAlterDomainStmt(from);
52375224
break;

‎src/backend/nodes/equalfuncs.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,14 +1107,6 @@ _equalAlterTableCmd(const AlterTableCmd *a, const AlterTableCmd *b)
11071107
return true;
11081108
}
11091109

1110-
staticbool
1111-
_equalAlterCollationStmt(constAlterCollationStmt*a,constAlterCollationStmt*b)
1112-
{
1113-
COMPARE_NODE_FIELD(collname);
1114-
1115-
return true;
1116-
}
1117-
11181110
staticbool
11191111
_equalAlterDomainStmt(constAlterDomainStmt*a,constAlterDomainStmt*b)
11201112
{
@@ -3283,9 +3275,6 @@ equal(const void *a, const void *b)
32833275
caseT_AlterTableCmd:
32843276
retval=_equalAlterTableCmd(a,b);
32853277
break;
3286-
caseT_AlterCollationStmt:
3287-
retval=_equalAlterCollationStmt(a,b);
3288-
break;
32893278
caseT_AlterDomainStmt:
32903279
retval=_equalAlterDomainStmt(a,b);
32913280
break;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp