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

Commite94bb14

Browse files
committed
DefineCollation() code cleanup
Reorganize the code in DefineCollation() so that the parts using theFROM clause and the parts not doing so are more cleanly separated. Nofunctionality change intended.Reviewed-by: Julien Rouhaud <rjuju123@gmail.com>Discussion:https://www.postgresql.org/message-id/29ae752f-80e9-8d31-601c-62cf01cc93d8@enterprisedb.com
1 parent9198e63 commite94bb14

File tree

1 file changed

+57
-52
lines changed

1 file changed

+57
-52
lines changed

‎src/backend/commands/collationcmds.c

Lines changed: 57 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,11 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
6363
DefElem*providerEl=NULL;
6464
DefElem*deterministicEl=NULL;
6565
DefElem*versionEl=NULL;
66-
char*collcollate=NULL;
67-
char*collctype=NULL;
68-
char*collproviderstr=NULL;
69-
boolcollisdeterministic= true;
70-
intcollencoding=0;
71-
charcollprovider=0;
66+
char*collcollate;
67+
char*collctype;
68+
boolcollisdeterministic;
69+
intcollencoding;
70+
charcollprovider;
7271
char*collversion=NULL;
7372
Oidnewoid;
7473
ObjectAddressaddress;
@@ -167,65 +166,71 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
167166
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
168167
errmsg("collation \"default\" cannot be copied")));
169168
}
170-
171-
if (localeEl)
169+
else
172170
{
173-
collcollate=defGetString(localeEl);
174-
collctype=defGetString(localeEl);
175-
}
171+
char*collproviderstr=NULL;
176172

177-
if (lccollateEl)
178-
collcollate=defGetString(lccollateEl);
173+
collcollate=NULL;
174+
collctype=NULL;
179175

180-
if (lcctypeEl)
181-
collctype=defGetString(lcctypeEl);
176+
if (localeEl)
177+
{
178+
collcollate=defGetString(localeEl);
179+
collctype=defGetString(localeEl);
180+
}
182181

183-
if (providerEl)
184-
collproviderstr=defGetString(providerEl);
182+
if (lccollateEl)
183+
collcollate=defGetString(lccollateEl);
185184

186-
if (deterministicEl)
187-
collisdeterministic=defGetBoolean(deterministicEl);
185+
if (lcctypeEl)
186+
collctype=defGetString(lcctypeEl);
188187

189-
if (versionEl)
190-
collversion=defGetString(versionEl);
188+
if (providerEl)
189+
collproviderstr=defGetString(providerEl);
191190

192-
if (collproviderstr)
193-
{
194-
if (pg_strcasecmp(collproviderstr,"icu")==0)
195-
collprovider=COLLPROVIDER_ICU;
196-
elseif (pg_strcasecmp(collproviderstr,"libc")==0)
197-
collprovider=COLLPROVIDER_LIBC;
191+
if (deterministicEl)
192+
collisdeterministic=defGetBoolean(deterministicEl);
193+
else
194+
collisdeterministic= true;
195+
196+
if (versionEl)
197+
collversion=defGetString(versionEl);
198+
199+
if (collproviderstr)
200+
{
201+
if (pg_strcasecmp(collproviderstr,"icu")==0)
202+
collprovider=COLLPROVIDER_ICU;
203+
elseif (pg_strcasecmp(collproviderstr,"libc")==0)
204+
collprovider=COLLPROVIDER_LIBC;
205+
else
206+
ereport(ERROR,
207+
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
208+
errmsg("unrecognized collation provider: %s",
209+
collproviderstr)));
210+
}
198211
else
212+
collprovider=COLLPROVIDER_LIBC;
213+
214+
if (!collcollate)
199215
ereport(ERROR,
200216
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
201-
errmsg("unrecognized collation provider: %s",
202-
collproviderstr)));
203-
}
204-
elseif (!fromEl)
205-
collprovider=COLLPROVIDER_LIBC;
206-
207-
if (!collcollate)
208-
ereport(ERROR,
209-
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
210-
errmsg("parameter \"lc_collate\" must be specified")));
217+
errmsg("parameter \"lc_collate\" must be specified")));
211218

212-
if (!collctype)
213-
ereport(ERROR,
214-
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
215-
errmsg("parameter \"lc_ctype\" must be specified")));
219+
if (!collctype)
220+
ereport(ERROR,
221+
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
222+
errmsg("parameter \"lc_ctype\" must be specified")));
216223

217-
/*
218-
* Nondeterministic collations are currently only supported with ICU
219-
* because that's the only case where it can actually make a difference.
220-
* So we can save writing the code for the other providers.
221-
*/
222-
if (!collisdeterministic&&collprovider!=COLLPROVIDER_ICU)
223-
ereport(ERROR,
224-
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
225-
errmsg("nondeterministic collations not supported with this provider")));
224+
/*
225+
* Nondeterministic collations are currently only supported with ICU
226+
* because that's the only case where it can actually make a difference.
227+
* So we can save writing the code for the other providers.
228+
*/
229+
if (!collisdeterministic&&collprovider!=COLLPROVIDER_ICU)
230+
ereport(ERROR,
231+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
232+
errmsg("nondeterministic collations not supported with this provider")));
226233

227-
if (!fromEl)
228-
{
229234
if (collprovider==COLLPROVIDER_ICU)
230235
{
231236
#ifdefUSE_ICU

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp