mirror of
https://github.com/postgres/postgres.git
synced 2025-07-15 19:21:59 +03:00
Copy collencoding in CREATE COLLATION / FROM
This command used to compute the collencoding entry like when a completely new collation is created. But for example when copying the "C" collation, this would then result in a collation that has a collencoding entry for the current database encoding rather than -1, thus not making an exact copy. This has probably no practical impact, but making this change keeps the catalog contents neat. Reported-by: Tom Lane <tgl@sss.pgh.pa.us>
This commit is contained in:
@ -64,7 +64,7 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
|
|||||||
char *collcollate = NULL;
|
char *collcollate = NULL;
|
||||||
char *collctype = NULL;
|
char *collctype = NULL;
|
||||||
char *collproviderstr = NULL;
|
char *collproviderstr = NULL;
|
||||||
int collencoding;
|
int collencoding = 0;
|
||||||
char collprovider = 0;
|
char collprovider = 0;
|
||||||
char *collversion = NULL;
|
char *collversion = NULL;
|
||||||
Oid newoid;
|
Oid newoid;
|
||||||
@ -126,6 +126,7 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
|
|||||||
collcollate = pstrdup(NameStr(((Form_pg_collation) GETSTRUCT(tp))->collcollate));
|
collcollate = pstrdup(NameStr(((Form_pg_collation) GETSTRUCT(tp))->collcollate));
|
||||||
collctype = pstrdup(NameStr(((Form_pg_collation) GETSTRUCT(tp))->collctype));
|
collctype = pstrdup(NameStr(((Form_pg_collation) GETSTRUCT(tp))->collctype));
|
||||||
collprovider = ((Form_pg_collation) GETSTRUCT(tp))->collprovider;
|
collprovider = ((Form_pg_collation) GETSTRUCT(tp))->collprovider;
|
||||||
|
collencoding = ((Form_pg_collation) GETSTRUCT(tp))->collencoding;
|
||||||
|
|
||||||
ReleaseSysCache(tp);
|
ReleaseSysCache(tp);
|
||||||
|
|
||||||
@ -185,6 +186,8 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
|
|||||||
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
|
||||||
errmsg("parameter \"lc_ctype\" must be specified")));
|
errmsg("parameter \"lc_ctype\" must be specified")));
|
||||||
|
|
||||||
|
if (!fromEl)
|
||||||
|
{
|
||||||
if (collprovider == COLLPROVIDER_ICU)
|
if (collprovider == COLLPROVIDER_ICU)
|
||||||
collencoding = -1;
|
collencoding = -1;
|
||||||
else
|
else
|
||||||
@ -192,6 +195,7 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
|
|||||||
collencoding = GetDatabaseEncoding();
|
collencoding = GetDatabaseEncoding();
|
||||||
check_encoding_locale_matches(collencoding, collcollate, collctype);
|
check_encoding_locale_matches(collencoding, collcollate, collctype);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!collversion)
|
if (!collversion)
|
||||||
collversion = get_collation_actual_version(collprovider, collcollate);
|
collversion = get_collation_actual_version(collprovider, collcollate);
|
||||||
|
Reference in New Issue
Block a user