public inbox for [email protected]
help / color / mirror / Atom feedFrom: Yushu Chen <[email protected]>
To: [email protected]
Subject: [PATCH] Add regression test for mismatched ENCODING and LOCALE in CREATE DATABASE
Date: Sat, 23 May 2026 20:10:26 +0800
Message-ID: <CAP5x3pYD68_BpoDtfCxygAE8Dq9sWoFoimxP--LPL8hDcEufJA@mail.gmail.com> (raw)
Hi,
While reading the CREATE DATABASE documentation at
https://www.postgresql.org/docs/current/sql-createdatabase.html, I
noticed the following sentence:
"The specified locale and encoding settings must match, or an error
will be reported."
However, we do not currently have regression coverage for that failure case.
This patch adds a regression test covering incompatible ENCODING and
LOCALE combinations, for example:
CREATE DATABASE dbtest
LOCALE 'en_US.UTF-8'
ENCODING LATIN1
TEMPLATE template0;
Which is expected to fail due to the encoding/locale mismatch.
The patch only adds test coverage and does not change backend behavior.
Regards,
Yushu
Attachments:
[application/octet-stream] v1-0001-regress-test-create-database-with-locale-encoding.patch (2.2K, 2-v1-0001-regress-test-create-database-with-locale-encoding.patch)
download | inline diff:
From b454a1ab5867b308f9bd138c3db687f0014f849b Mon Sep 17 00:00:00 2001
From: Yushu Chen <[email protected]>
Date: Sat, 23 May 2026 20:02:03 +0800
Subject: [PATCH v1] regress test create database with locale encoding mismatch
src/test/regress/sql/database.sql does not have regression coverage
for the failure case described in the documentation
https://www.postgresql.org/docs/current/sql-createdatabase.html
"The specified locale and encoding settings must match,
or an error will be reported."
Author: Yushu Chen <[email protected]>
---
src/test/regress/expected/database.out | 5 +++++
src/test/regress/sql/database.sql | 3 +++
2 files changed, 8 insertions(+)
diff --git a/src/test/regress/expected/database.out b/src/test/regress/expected/database.out
index 6b879b0f62a..50089ff46e1 100644
--- a/src/test/regress/expected/database.out
+++ b/src/test/regress/expected/database.out
@@ -4,6 +4,11 @@ ALTER DATABASE regression_tbd RENAME TO regression_utf8;
ALTER DATABASE regression_utf8 SET TABLESPACE regress_tblspace;
ALTER DATABASE regression_utf8 SET TABLESPACE pg_default;
ALTER DATABASE regression_utf8 CONNECTION_LIMIT 123;
+-- Test raises an error when locale and encoding mismatch.
+CREATE DATABASE regression_locale_encoding_not_match
+ LOCALE "en_US.UTF-8" ENCODING LATIN9 TEMPLATE template0;
+ERROR: encoding "LATIN9" does not match locale "en_US.UTF-8"
+DETAIL: The chosen LC_CTYPE setting requires encoding "UTF8".
-- Test PgDatabaseToastTable. Doing this with GRANT would be slow.
BEGIN;
UPDATE pg_database
diff --git a/src/test/regress/sql/database.sql b/src/test/regress/sql/database.sql
index 4ef36127291..95063c851ac 100644
--- a/src/test/regress/sql/database.sql
+++ b/src/test/regress/sql/database.sql
@@ -4,6 +4,9 @@ ALTER DATABASE regression_tbd RENAME TO regression_utf8;
ALTER DATABASE regression_utf8 SET TABLESPACE regress_tblspace;
ALTER DATABASE regression_utf8 SET TABLESPACE pg_default;
ALTER DATABASE regression_utf8 CONNECTION_LIMIT 123;
+-- Test raises an error when locale and encoding mismatch.
+CREATE DATABASE regression_locale_encoding_not_match
+ LOCALE "en_US.UTF-8" ENCODING LATIN9 TEMPLATE template0;
-- Test PgDatabaseToastTable. Doing this with GRANT would be slow.
BEGIN;
--
2.50.1 (Apple Git-155)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: [PATCH] Add regression test for mismatched ENCODING and LOCALE in CREATE DATABASE
In-Reply-To: <CAP5x3pYD68_BpoDtfCxygAE8Dq9sWoFoimxP--LPL8hDcEufJA@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox