From 330767ee9aa7081b9b4fc6ca82c337bb0c2a89fc Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Wed, 20 Nov 2024 15:56:46 +1300
Subject: [PATCH 2/3] Formally require ucrt on Windows.

Historically we tolerated the absence of various Windows features when
using the MinGW tool chain, because it used ancient msvcrt.dll for a
long period of time.  It now uses ucrt by default (like Windows 10,
Visual Studio 2015).

It was difficult or impossible to use MinGW with the various
msvcrXXX.dll versions that came between the original msvcrt.dll and
ucrt, so this represents a sudden jump in API from about 1996 to about
2015.  In fact we already effectively required ucrt in PostgreSQL 17:
commit 8d9a9f03 required _create_locale and friends, which arrived in
msvcr120.dll (Visual Studio 2013, the last of the pre-ucrt series of
runtimes), and for MinGW users that practically meant ucrt; meanwhile
for Visual Studio we currently require at least 2015, which uses ucrt.
That may not have been the first such case, but msvrt.dll and Visual
Studio 2013 builds had already dropped off our testing radar so we
weren't paying attention if so.

This commit formalizes the requirement.  It removes obsolete comments
that discussed msvcrt.dll limitations, and some tests of
!defined(_MSC_VER) to imply msvcrt.dll.  Later commits will remove more
anachronisms resulting from this policy decision.
---
 src/backend/utils/adt/pg_locale.c | 19 -------------------
 1 file changed, 19 deletions(-)

diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c
index d4e89663ec1..d1b392c248c 100644
--- a/src/backend/utils/adt/pg_locale.c
+++ b/src/backend/utils/adt/pg_locale.c
@@ -1017,13 +1017,6 @@ cache_locale_time(void)
  * get ISO Locale name directly by using GetLocaleInfoEx() with LCType as
  * LOCALE_SNAME.
  *
- * MinGW headers declare _create_locale(), but msvcrt.dll lacks that symbol in
- * releases before Windows 8. IsoLocaleName() always fails in a MinGW-built
- * postgres.exe, so only Unix-style values of the lc_messages GUC can elicit
- * localized messages. In particular, every lc_messages setting that initdb
- * can select automatically will yield only C-locale messages. XXX This could
- * be fixed by running the fully-qualified locale name through a lookup table.
- *
  * This function returns a pointer to a static buffer bearing the converted
  * name or NULL if conversion fails.
  *
@@ -1031,8 +1024,6 @@ cache_locale_time(void)
  * [2] https://docs.microsoft.com/en-us/windows/win32/intl/locale-names
  */
 
-#if defined(_MSC_VER)
-
 /*
  * Callback function for EnumSystemLocalesEx() in get_iso_localename().
  *
@@ -1201,16 +1192,6 @@ IsoLocaleName(const char *winlocname)
 		return get_iso_localename(winlocname);
 }
 
-#else							/* !defined(_MSC_VER) */
-
-static char *
-IsoLocaleName(const char *winlocname)
-{
-	return NULL;				/* Not supported on MinGW */
-}
-
-#endif							/* defined(_MSC_VER) */
-
 #endif							/* WIN32 && LC_MESSAGES */
 
 
-- 
2.39.5 (Apple Git-154)

