Skip to content

Commit a62d90f

Browse files
committed
Revert "Blind attempt to fix _configthreadlocale() failures on MinGW."
This reverts commit 2cf91cc. When using the old msvcrt.dll, MinGW would supply its own dummy version of _configthreadlocale() that just returns -1 if you try to use it. For a time we tolerated that to shut the build farm up. We would fall back to code that was enough for the tests to pass, but it would surely have risked crashing a real multithreaded program. We don't need that kludge anymore, because we can count on ucrt. We expect the real _configthreadlocale() to be present, and the ECPG tests will now fail if it isn't. The workaround was dead code and it's time to revert it. (A later patch still under review proposes to remove this use of _configthreadlocale() completely but we're unwinding this code in steps.) Reviewed-by: Peter Eisentraut <[email protected]> Discussion: https://postgr.es/m/d9e7731c-ca1b-477c-9298-fa51e135574a%40eisentraut.org
1 parent 1758d42 commit a62d90f

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

src/interfaces/ecpg/ecpglib/descriptor.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
512512
}
513513
#ifdef WIN32
514514
if (stmt.oldthreadlocale != -1)
515-
(void) _configthreadlocale(stmt.oldthreadlocale);
515+
_configthreadlocale(stmt.oldthreadlocale);
516516
#endif
517517
#endif
518518
}

src/interfaces/ecpg/ecpglib/execute.c

+9-11
Original file line numberDiff line numberDiff line change
@@ -1977,9 +1977,7 @@ ecpg_do_prologue(int lineno, const int compat, const int force_indicator,
19771977
* Make sure we do NOT honor the locale for numeric input/output since the
19781978
* database wants the standard decimal point. If available, use
19791979
* uselocale() for this because it's thread-safe. Windows doesn't have
1980-
* that, but it usually does have _configthreadlocale(). In some versions
1981-
* of MinGW, _configthreadlocale() exists but always returns -1 --- so
1982-
* treat that situation as if the function doesn't exist.
1980+
* that, but it does have _configthreadlocale().
19831981
*/
19841982
#ifdef HAVE_USELOCALE
19851983

@@ -1997,6 +1995,11 @@ ecpg_do_prologue(int lineno, const int compat, const int force_indicator,
19971995
#else
19981996
#ifdef WIN32
19991997
stmt->oldthreadlocale = _configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
1998+
if (stmt->oldthreadlocale == -1)
1999+
{
2000+
ecpg_do_epilogue(stmt);
2001+
return false;
2002+
}
20002003
#endif
20012004
stmt->oldlocale = ecpg_strdup(setlocale(LC_NUMERIC, NULL), lineno);
20022005
if (stmt->oldlocale == NULL)
@@ -2218,17 +2221,12 @@ ecpg_do_epilogue(struct statement *stmt)
22182221
uselocale(stmt->oldlocale);
22192222
#else
22202223
if (stmt->oldlocale)
2224+
{
22212225
setlocale(LC_NUMERIC, stmt->oldlocale);
22222226
#ifdef WIN32
2223-
2224-
/*
2225-
* This is a bit trickier than it looks: if we failed partway through
2226-
* statement initialization, oldthreadlocale could still be 0. But that's
2227-
* okay because a call with 0 is defined to be a no-op.
2228-
*/
2229-
if (stmt->oldthreadlocale != -1)
2230-
(void) _configthreadlocale(stmt->oldthreadlocale);
2227+
_configthreadlocale(stmt->oldthreadlocale);
22312228
#endif
2229+
}
22322230
#endif
22332231

22342232
free_statement(stmt);

0 commit comments

Comments
 (0)