|
|
|
|
@ -63,12 +63,11 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e |
|
|
|
|
DefElem *providerEl = NULL; |
|
|
|
|
DefElem *deterministicEl = NULL; |
|
|
|
|
DefElem *versionEl = NULL; |
|
|
|
|
char *collcollate = NULL; |
|
|
|
|
char *collctype = NULL; |
|
|
|
|
char *collproviderstr = NULL; |
|
|
|
|
bool collisdeterministic = true; |
|
|
|
|
int collencoding = 0; |
|
|
|
|
char collprovider = 0; |
|
|
|
|
char *collcollate; |
|
|
|
|
char *collctype; |
|
|
|
|
bool collisdeterministic; |
|
|
|
|
int collencoding; |
|
|
|
|
char collprovider; |
|
|
|
|
char *collversion = NULL; |
|
|
|
|
Oid newoid; |
|
|
|
|
ObjectAddress address; |
|
|
|
|
@ -167,65 +166,71 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e |
|
|
|
|
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION), |
|
|
|
|
errmsg("collation \"default\" cannot be copied"))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (localeEl) |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
collcollate = defGetString(localeEl); |
|
|
|
|
collctype = defGetString(localeEl); |
|
|
|
|
} |
|
|
|
|
char *collproviderstr = NULL; |
|
|
|
|
|
|
|
|
|
if (lccollateEl) |
|
|
|
|
collcollate = defGetString(lccollateEl); |
|
|
|
|
collcollate = NULL; |
|
|
|
|
collctype = NULL; |
|
|
|
|
|
|
|
|
|
if (lcctypeEl) |
|
|
|
|
collctype = defGetString(lcctypeEl); |
|
|
|
|
if (localeEl) |
|
|
|
|
{ |
|
|
|
|
collcollate = defGetString(localeEl); |
|
|
|
|
collctype = defGetString(localeEl); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (providerEl) |
|
|
|
|
collproviderstr = defGetString(providerEl); |
|
|
|
|
if (lccollateEl) |
|
|
|
|
collcollate = defGetString(lccollateEl); |
|
|
|
|
|
|
|
|
|
if (deterministicEl) |
|
|
|
|
collisdeterministic = defGetBoolean(deterministicEl); |
|
|
|
|
if (lcctypeEl) |
|
|
|
|
collctype = defGetString(lcctypeEl); |
|
|
|
|
|
|
|
|
|
if (versionEl) |
|
|
|
|
collversion = defGetString(versionEl); |
|
|
|
|
if (providerEl) |
|
|
|
|
collproviderstr = defGetString(providerEl); |
|
|
|
|
|
|
|
|
|
if (collproviderstr) |
|
|
|
|
{ |
|
|
|
|
if (pg_strcasecmp(collproviderstr, "icu") == 0) |
|
|
|
|
collprovider = COLLPROVIDER_ICU; |
|
|
|
|
else if (pg_strcasecmp(collproviderstr, "libc") == 0) |
|
|
|
|
collprovider = COLLPROVIDER_LIBC; |
|
|
|
|
if (deterministicEl) |
|
|
|
|
collisdeterministic = defGetBoolean(deterministicEl); |
|
|
|
|
else |
|
|
|
|
collisdeterministic = true; |
|
|
|
|
|
|
|
|
|
if (versionEl) |
|
|
|
|
collversion = defGetString(versionEl); |
|
|
|
|
|
|
|
|
|
if (collproviderstr) |
|
|
|
|
{ |
|
|
|
|
if (pg_strcasecmp(collproviderstr, "icu") == 0) |
|
|
|
|
collprovider = COLLPROVIDER_ICU; |
|
|
|
|
else if (pg_strcasecmp(collproviderstr, "libc") == 0) |
|
|
|
|
collprovider = COLLPROVIDER_LIBC; |
|
|
|
|
else |
|
|
|
|
ereport(ERROR, |
|
|
|
|
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION), |
|
|
|
|
errmsg("unrecognized collation provider: %s", |
|
|
|
|
collproviderstr))); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
collprovider = COLLPROVIDER_LIBC; |
|
|
|
|
|
|
|
|
|
if (!collcollate) |
|
|
|
|
ereport(ERROR, |
|
|
|
|
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION), |
|
|
|
|
errmsg("unrecognized collation provider: %s", |
|
|
|
|
collproviderstr))); |
|
|
|
|
} |
|
|
|
|
else if (!fromEl) |
|
|
|
|
collprovider = COLLPROVIDER_LIBC; |
|
|
|
|
|
|
|
|
|
if (!collcollate) |
|
|
|
|
ereport(ERROR, |
|
|
|
|
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION), |
|
|
|
|
errmsg("parameter \"lc_collate\" must be specified"))); |
|
|
|
|
errmsg("parameter \"lc_collate\" must be specified"))); |
|
|
|
|
|
|
|
|
|
if (!collctype) |
|
|
|
|
ereport(ERROR, |
|
|
|
|
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION), |
|
|
|
|
errmsg("parameter \"lc_ctype\" must be specified"))); |
|
|
|
|
if (!collctype) |
|
|
|
|
ereport(ERROR, |
|
|
|
|
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION), |
|
|
|
|
errmsg("parameter \"lc_ctype\" must be specified"))); |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Nondeterministic collations are currently only supported with ICU |
|
|
|
|
* because that's the only case where it can actually make a difference. |
|
|
|
|
* So we can save writing the code for the other providers. |
|
|
|
|
*/ |
|
|
|
|
if (!collisdeterministic && collprovider != COLLPROVIDER_ICU) |
|
|
|
|
ereport(ERROR, |
|
|
|
|
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), |
|
|
|
|
errmsg("nondeterministic collations not supported with this provider"))); |
|
|
|
|
/*
|
|
|
|
|
* Nondeterministic collations are currently only supported with ICU |
|
|
|
|
* because that's the only case where it can actually make a difference. |
|
|
|
|
* So we can save writing the code for the other providers. |
|
|
|
|
*/ |
|
|
|
|
if (!collisdeterministic && collprovider != COLLPROVIDER_ICU) |
|
|
|
|
ereport(ERROR, |
|
|
|
|
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), |
|
|
|
|
errmsg("nondeterministic collations not supported with this provider"))); |
|
|
|
|
|
|
|
|
|
if (!fromEl) |
|
|
|
|
{ |
|
|
|
|
if (collprovider == COLLPROVIDER_ICU) |
|
|
|
|
{ |
|
|
|
|
#ifdef USE_ICU |
|
|
|
|
|