initdb-fallback-to-utf8-on-windows.patch
text/x-diff
Filename: initdb-fallback-to-utf8-on-windows.patch
Type: text/x-diff
Part: 0
Message:
Chinese initdb on Windows
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
| File | + | − |
|---|---|---|
| src/bin/initdb/initdb.c | 14 | 1 |
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index 98e864d..6999a42 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -2909,7 +2909,19 @@ main(int argc, char *argv[])
}
else if (!pg_valid_server_encoding_id(ctype_enc))
{
- /* We recognized it, but it's not a legal server encoding */
+ /*
+ * We recognized it, but it's not a legal server encoding.
+ * On Windows, UTF-8 works with any locale, so we can fall back
+ * to UTF-8.
+ */
+#ifdef WIN32
+ printf(_("Encoding %s implied by locale is not allowed as a server-side encoding.\n"
+ "The default database encoding has been set to %s instead.\n"),
+ pg_encoding_to_char(ctype_enc),
+ pg_encoding_to_char(PG_UTF8));
+ ctype_enc = PG_UTF8;
+ encodingid = encodingid_to_string(ctype_enc);
+#else
fprintf(stderr,
_("%s: locale %s requires unsupported encoding %s\n"),
progname, lc_ctype, pg_encoding_to_char(ctype_enc));
@@ -2918,6 +2930,7 @@ main(int argc, char *argv[])
"Rerun %s with a different locale selection.\n"),
pg_encoding_to_char(ctype_enc), progname);
exit(1);
+#endif
}
else
{