@@ -63,12 +63,11 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
63
63
DefElem * providerEl = NULL ;
64
64
DefElem * deterministicEl = NULL ;
65
65
DefElem * versionEl = NULL ;
66
- char * collcollate = NULL ;
67
- char * collctype = NULL ;
68
- char * collproviderstr = NULL ;
69
- bool collisdeterministic = true;
70
- int collencoding = 0 ;
71
- char collprovider = 0 ;
66
+ char * collcollate ;
67
+ char * collctype ;
68
+ bool collisdeterministic ;
69
+ int collencoding ;
70
+ char collprovider ;
72
71
char * collversion = NULL ;
73
72
Oid newoid ;
74
73
ObjectAddress address ;
@@ -167,65 +166,71 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
167
166
(errcode (ERRCODE_INVALID_OBJECT_DEFINITION ),
168
167
errmsg ("collation \"default\" cannot be copied" )));
169
168
}
170
-
171
- if (localeEl )
169
+ else
172
170
{
173
- collcollate = defGetString (localeEl );
174
- collctype = defGetString (localeEl );
175
- }
171
+ char * collproviderstr = NULL ;
176
172
177
- if ( lccollateEl )
178
- collcollate = defGetString ( lccollateEl ) ;
173
+ collcollate = NULL ;
174
+ collctype = NULL ;
179
175
180
- if (lcctypeEl )
181
- collctype = defGetString (lcctypeEl );
176
+ if (localeEl )
177
+ {
178
+ collcollate = defGetString (localeEl );
179
+ collctype = defGetString (localeEl );
180
+ }
182
181
183
- if (providerEl )
184
- collproviderstr = defGetString (providerEl );
182
+ if (lccollateEl )
183
+ collcollate = defGetString (lccollateEl );
185
184
186
- if (deterministicEl )
187
- collisdeterministic = defGetBoolean ( deterministicEl );
185
+ if (lcctypeEl )
186
+ collctype = defGetString ( lcctypeEl );
188
187
189
- if (versionEl )
190
- collversion = defGetString (versionEl );
188
+ if (providerEl )
189
+ collproviderstr = defGetString (providerEl );
191
190
192
- if (collproviderstr )
193
- {
194
- if (pg_strcasecmp (collproviderstr , "icu" ) == 0 )
195
- collprovider = COLLPROVIDER_ICU ;
196
- else if (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
+ else if (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
+ }
198
211
else
212
+ collprovider = COLLPROVIDER_LIBC ;
213
+
214
+ if (!collcollate )
199
215
ereport (ERROR ,
200
216
(errcode (ERRCODE_INVALID_OBJECT_DEFINITION ),
201
- errmsg ("unrecognized collation provider: %s" ,
202
- collproviderstr )));
203
- }
204
- else if (!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" )));
211
218
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" )));
216
223
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" )));
226
233
227
- if (!fromEl )
228
- {
229
234
if (collprovider == COLLPROVIDER_ICU )
230
235
{
231
236
#ifdef USE_ICU
0 commit comments