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

Commit4442e19

Browse files
committed
When creating a collation, check that the locales can be loaded
This is the same check that would happen later when the collation isused, but it's friendlier to check the collation already when it iscreated.
1 parentbd58d9d commit4442e19

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

‎src/backend/commands/collationcmds.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include"postgres.h"
1616

1717
#include"access/heapam.h"
18+
#include"access/xact.h"
1819
#include"catalog/dependency.h"
1920
#include"catalog/indexing.h"
2021
#include"catalog/namespace.h"
@@ -30,6 +31,7 @@
3031
#include"utils/acl.h"
3132
#include"utils/builtins.h"
3233
#include"utils/lsyscache.h"
34+
#include"utils/pg_locale.h"
3335
#include"utils/syscache.h"
3436

3537
staticvoidAlterCollationOwner_internal(Relationrel,OidcollationOid,
@@ -51,6 +53,7 @@ DefineCollation(List *names, List *parameters)
5153
DefElem*lcctypeEl=NULL;
5254
char*collcollate=NULL;
5355
char*collctype=NULL;
56+
Oidnewoid;
5457

5558
collNamespace=QualifiedNameGetCreationNamespace(names,&collName);
5659

@@ -130,12 +133,16 @@ DefineCollation(List *names, List *parameters)
130133

131134
check_encoding_locale_matches(GetDatabaseEncoding(),collcollate,collctype);
132135

133-
CollationCreate(collName,
136+
newoid=CollationCreate(collName,
134137
collNamespace,
135138
GetUserId(),
136139
GetDatabaseEncoding(),
137140
collcollate,
138141
collctype);
142+
143+
/* check that the locales can be loaded */
144+
CommandCounterIncrement();
145+
pg_newlocale_from_collation(newoid);
139146
}
140147

141148
/*

‎src/test/regress/expected/collate.linux.utf8.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,8 @@ ERROR: encoding UTF8 does not match locale en_US
744744
DETAIL: The chosen LC_CTYPE setting requires encoding LATIN1.
745745
CREATE COLLATION test3 (lc_collate = 'en_US.utf8'); -- fail
746746
ERROR: parameter "lc_ctype" must be specified
747+
CREATE COLLATION testx (locale = 'nonsense'); -- fail
748+
ERROR: could not create locale "nonsense": No such file or directory
747749
CREATE COLLATION test4 FROM nonsense;
748750
ERROR: collation "nonsense" for current database encoding "UTF8" does not exist
749751
CREATE COLLATION test5 FROM test0;

‎src/test/regress/sql/collate.linux.utf8.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ CREATE COLLATION test0 (locale = 'en_US.utf8'); -- fail
234234
CREATE COLLATION test1 (lc_collate='en_US.utf8', lc_ctype='de_DE.utf8');
235235
CREATE COLLATION test2 (locale='en_US');-- fail
236236
CREATE COLLATION test3 (lc_collate='en_US.utf8');-- fail
237+
CREATE COLLATION testx (locale='nonsense');-- fail
237238

238239
CREATE COLLATION test4FROM nonsense;
239240
CREATE COLLATION test5FROM test0;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp