[PATCH] Add regression test for mismatched ENCODING and LOCALE in CREATE DATABASE

Started by Yushu Chen7 days ago2 messageshackers
Jump to latest
#1Yushu Chen
gentcys@gmail.com

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:

v1-0001-regress-test-create-database-with-locale-encoding.patchapplication/octet-stream; name=v1-0001-regress-test-create-database-with-locale-encoding.patchDownload+8-1
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Yushu Chen (#1)
Re: [PATCH] Add regression test for mismatched ENCODING and LOCALE in CREATE DATABASE

Yushu Chen <gentcys@gmail.com> writes:

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.

The reason there is no test for that is that the spelling of locale
names, and indeed the presence of any particular locale, is variable
across platforms. Your proposed test case might work fine on your
machine, but it will fail on a nontrivial fraction of our buildfarm
(where "fail" means "produce some other error message than what the
test is expecting").

As a recent example where I too was overoptimistic about this,
see the sad history of my attempts to install coverage of NLS
translation (8c498479d, 5b275a6e1, fe7ede45f, 7db6809ce,
84a3778c7, 462e24765).

We could perhaps install the test with multiple variant files to
accept the cases we see in practice. But that would be a pain
in the rear for maintenance, and you have to wonder what it'd
actually be proving.

regards, tom lane