From 35eb0958be476d58dcc8ba462d57384e74a62d88 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Thu, 13 Jan 2011 09:13:12 +0200
Subject: [PATCH] Don't run regression tests in SQL_ASCII encoding by default

Instead, run them in the encoding that the locale selects, which is
more representative of real use.

Also document how locale and encoding for regression test runs can be
selected.
---
 doc/src/sgml/regress.sgml    | 42 ++++++++++++++++++++++++++++++++++++
 src/test/regress/GNUmakefile |  5 +----
 2 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/doc/src/sgml/regress.sgml b/doc/src/sgml/regress.sgml
index 6a3ac95558b..59083eca1a1 100644
--- a/doc/src/sgml/regress.sgml
+++ b/doc/src/sgml/regress.sgml
@@ -194,6 +194,48 @@ gmake standbycheck
    Additional automated testing may be available in later releases.
   </para>
   </sect2>
+
+  <sect2>
+   <title>Locale and encoding</title>
+
+   <para>
+    By default, the tests against a temporary installation use the
+    locale defined in the current environment and the corresponding
+    database encoding as determined by <command>initdb</command>.  It
+    can be useful to test different locales by setting the appropriate
+    environment variables, for example:
+<screen>
+gmake check LANG=C
+gmake check LC_COLLATE=en_US.utf8 LC_CTYPE=fr_CA.utf8
+</screen>
+    For implementation reasons, setting <envar>LC_ALL</envar> does not
+    work for this purpose; all the other locale-related environment
+    variables do work.
+   </para>
+
+   <para>
+    When testing against an existing installation, the locale is
+    determined by the existing database cluster and cannot be set
+    separately for the test run.
+   </para>
+
+   <para>
+    You can also choose the database encoding explicitly by setting
+    the variable <envar>MULTIBYTE</envar>, for example:
+<screen>
+gmake check LANG=C MULTIBYTE=EUC_JP
+</screen>
+    Setting the database encoding this way typically only makes sense
+    if the locale is C; otherwise the encoding is chosen automatically
+    from the locale, and specifying an encoding that does not match
+    the locale will result in an error.
+   </para>
+
+   <para>
+    The encoding can be set for tests against a temporary or an
+    existing installation.
+   </para>
+  </sect2>
   </sect1>
 
   <sect1 id="regress-evaluation">
diff --git a/src/test/regress/GNUmakefile b/src/test/regress/GNUmakefile
index cb67e5a12a8..15b9ec49f71 100644
--- a/src/test/regress/GNUmakefile
+++ b/src/test/regress/GNUmakefile
@@ -23,9 +23,6 @@ endif
 # where to find psql for testing an existing installation
 PSQLDIR = $(bindir)
 
-# default encoding
-MULTIBYTE = SQL_ASCII
-
 # maximum simultaneous connections for parallel tests
 MAXCONNOPT =
 ifdef MAX_CONNECTIONS
@@ -141,7 +138,7 @@ tablespace-setup:
 ## Run tests
 ##
 
-pg_regress_call = ./pg_regress --inputdir=$(srcdir) --dlpath=. --multibyte=$(MULTIBYTE) $(NOLOCALE)
+pg_regress_call = ./pg_regress --inputdir=$(srcdir) --dlpath=. $(if $(MULTIBYTE),--multibyte=$(MULTIBYTE)) $(NOLOCALE)
 
 check: all tablespace-setup
 	$(pg_regress_call) --temp-install=./tmp_check --top-builddir=$(top_builddir) --schedule=$(srcdir)/parallel_schedule $(MAXCONNOPT) $(TEMP_CONF)
-- 
GitLab