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

Commitb620cf2

Browse files
committed
Blind attempt to fix _configthreadlocale() failures on MinGW.
Apparently, some builds of MinGW contain a version of_configthreadlocale() that always returns -1, indicating failure.Rather than treating that as a curl-up-and-die condition, soldier onas though the function didn't exist. This leaves us without threadsafety on such MinGW versions, but we didn't have it anyway.Discussion:https://postgr.es/m/d06a16bc-52d6-9f0d-2379-21242d7dbe81@2ndQuadrant.com
1 parent00376ea commitb620cf2

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

‎src/interfaces/ecpg/ecpglib/descriptor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
519519
}
520520
#ifdefHAVE__CONFIGTHREADLOCALE
521521
if (stmt.oldthreadlocale!=-1)
522-
_configthreadlocale(stmt.oldthreadlocale);
522+
(void)_configthreadlocale(stmt.oldthreadlocale);
523523
#endif
524524
#endif
525525
}

‎src/interfaces/ecpg/ecpglib/execute.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1785,7 +1785,9 @@ ecpg_do_prologue(int lineno, const int compat, const int force_indicator,
17851785
* Make sure we do NOT honor the locale for numeric input/output since the
17861786
* database wants the standard decimal point. If available, use
17871787
* uselocale() for this because it's thread-safe. Windows doesn't have
1788-
* that, but it usually does have _configthreadlocale().
1788+
* that, but it usually does have _configthreadlocale(). In some versions
1789+
* of MinGW, _configthreadlocale() exists but always returns -1 --- so
1790+
* treat that situation as if the function doesn't exist.
17891791
*/
17901792
#ifdefHAVE_USELOCALE
17911793
stmt->clocale=newlocale(LC_NUMERIC_MASK,"C", (locale_t)0);
@@ -1803,11 +1805,6 @@ ecpg_do_prologue(int lineno, const int compat, const int force_indicator,
18031805
#else
18041806
#ifdefHAVE__CONFIGTHREADLOCALE
18051807
stmt->oldthreadlocale=_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
1806-
if (stmt->oldthreadlocale==-1)
1807-
{
1808-
ecpg_do_epilogue(stmt);
1809-
return false;
1810-
}
18111808
#endif
18121809
stmt->oldlocale=ecpg_strdup(setlocale(LC_NUMERIC,NULL),lineno);
18131810
if (stmt->oldlocale==NULL)
@@ -2024,12 +2021,17 @@ ecpg_do_epilogue(struct statement *stmt)
20242021
uselocale(stmt->oldlocale);
20252022
#else
20262023
if (stmt->oldlocale)
2027-
{
20282024
setlocale(LC_NUMERIC,stmt->oldlocale);
20292025
#ifdefHAVE__CONFIGTHREADLOCALE
2030-
_configthreadlocale(stmt->oldthreadlocale);
2026+
2027+
/*
2028+
* This is a bit trickier than it looks: if we failed partway through
2029+
* statement initialization, oldthreadlocale could still be 0. But that's
2030+
* okay because a call with 0 is defined to be a no-op.
2031+
*/
2032+
if (stmt->oldthreadlocale!=-1)
2033+
(void)_configthreadlocale(stmt->oldthreadlocale);
20312034
#endif
2032-
}
20332035
#endif
20342036

20352037
free_statement(stmt);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp