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

Commit1d334ab

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 parent6bf9f4e commit1d334ab

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
@@ -518,7 +518,7 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
518518
}
519519
#ifdefHAVE__CONFIGTHREADLOCALE
520520
if (stmt.oldthreadlocale!=-1)
521-
_configthreadlocale(stmt.oldthreadlocale);
521+
(void)_configthreadlocale(stmt.oldthreadlocale);
522522
#endif
523523
#endif
524524
}

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

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

20362038
free_statement(stmt);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp