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

Commit1e165d0

Browse files
committed
Try to deliver a sane message for _create_locale() failure on Windows.
We were just printing errno, which is certainly not gonna work onWindows. Now, it's not entirely clear from Microsoft's documentationwhether _create_locale() adheres to standard Windows error reportingconventions, but let's assume it does and try to map the GetLastErrorresult to an errno. If this turns out not to work, probably the bestthing to do will be to assume the error is always ENOENT on Windows.This is a longstanding bug, but given the lack of previous fieldcomplaints, I'm not excited about back-patching it.Per report from Murtuza Zabuawala.Discussion:https://postgr.es/m/CAKKotZS-wcDcofXDCH=sidiuajE+nqHn2CGjLLX78anyDmi3gQ@mail.gmail.com
1 parentc1bb787 commit1e165d0

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

‎src/backend/utils/adt/pg_locale.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,13 +1227,18 @@ lc_ctype_is_c(Oid collation)
12271227
staticvoid
12281228
report_newlocale_failure(constchar*localename)
12291229
{
1230-
/* copy errno in case one of the ereport auxiliary functions changes it */
1231-
intsave_errno=errno;
1230+
intsave_errno;
1231+
1232+
/* On Windows, transform _create_locale() error to errno */
1233+
#ifdefWIN32
1234+
_dosmaperr(GetLastError());
1235+
#endif
12321236

12331237
/*
12341238
* ENOENT means "no such locale", not "no such file", so clarify that
12351239
* errno with an errdetail message.
12361240
*/
1241+
save_errno=errno;/* auxiliary funcs might change errno */
12371242
ereport(ERROR,
12381243
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
12391244
errmsg("could not create locale \"%s\": %m",

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,9 @@ CREATE COLLATION mycoll1 FROM "C";
627627
CREATE COLLATION mycoll2 ( LC_COLLATE = "POSIX", LC_CTYPE = "POSIX" );
628628
CREATE COLLATION mycoll3 FROM "default"; -- intentionally unsupported
629629
ERROR: collation "default" cannot be copied
630+
CREATE COLLATION mycoll4 ( LOCALE = "no_such_locale" ); -- fail
631+
ERROR: could not create locale "no_such_locale": No such file or directory
632+
DETAIL: The operating system could not find any locale data for the locale name "no_such_locale".
630633
DROP COLLATION mycoll1;
631634
CREATE TABLE collate_test23 (f1 text collate mycoll2);
632635
DROP COLLATION mycoll2; -- fail

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ EXPLAIN (COSTS OFF)
234234
CREATE COLLATION mycoll1FROM"C";
235235
CREATE COLLATION mycoll2 ( LC_COLLATE="POSIX", LC_CTYPE="POSIX" );
236236
CREATE COLLATION mycoll3FROM"default";-- intentionally unsupported
237+
CREATE COLLATION mycoll4 ( LOCALE="no_such_locale" );-- fail
237238

238239
DROP COLLATION mycoll1;
239240
CREATETABLEcollate_test23 (f1text collate mycoll2);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp