pgsql: CREATE DATABASE: make LOCALE apply to all collation providers.

Started by Jeff Davisabout 3 years ago4 messagescomitters
Jump to latest
#1Jeff Davis
pgsql@j-davis.com

CREATE DATABASE: make LOCALE apply to all collation providers.

For CREATE DATABASE, make LOCALE parameter apply regardless of the
provider used. Also affects initdb and createdb --locale arguments.

Previously, LOCALE (and --locale) only affected the database default
collation when using the libc provider.

Discussion: /messages/by-id/1a63084d-221e-4075-619e-6b3e590f673e@enterprisedb.com
Reviewed-by: Peter Eisentraut

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/a14e75eb0b6a73821e0d66c0d407372ec8376105

Modified Files
--------------
doc/src/sgml/ref/create_collation.sgml | 23 +++++++----
doc/src/sgml/ref/create_database.sgml | 57 ++++++++++++++++++++------
doc/src/sgml/ref/createdb.sgml | 5 ++-
doc/src/sgml/ref/initdb.sgml | 7 ++--
src/backend/commands/collationcmds.c | 2 +-
src/backend/commands/dbcommands.c | 17 +++++---
src/bin/initdb/initdb.c | 10 ++++-
src/bin/initdb/t/001_initdb.pl | 11 +++++
src/bin/scripts/createdb.c | 13 +++---
src/bin/scripts/t/020_createdb.pl | 15 +++++--
src/test/icu/t/010_database.pl | 33 +++++++++++----
src/test/regress/expected/collate.icu.utf8.out | 22 +++++-----
12 files changed, 155 insertions(+), 60 deletions(-)

#2Jeff Davis
pgsql@j-davis.com
In reply to: Jeff Davis (#1)
Re: pgsql: CREATE DATABASE: make LOCALE apply to all collation providers.

On Fri, 2023-06-16 at 17:41 +0000, Jeff Davis wrote:

CREATE DATABASE: make LOCALE apply to all collation providers.

This created a minor test diff for the test_extensions test for
cs_CZ.UTF-8:

https://buildfarm.postgresql.org/cgi-bin/show_stage_log.pl?nm=jay&dt=2023-06-16%2018%3A02%3A15&stg=testmodules-install-check-cs_CZ.UTF-8

https://buildfarm.postgresql.org/cgi-bin/show_stage_log.pl?nm=hippopotamus&dt=2023-06-16%2017%3A43%3A05&stg=testmodules-install-check-cs_CZ.UTF-8

I believe the new behavior is correct, and the test is being run
incorrectly.

The buildfarm members do an initdb with the cs_CZ locale, and then run
the test_extensions test in installcheck mode against that
installation. As expected that creates \dx+ output using the cs_CZ
locale, which sorts "sequence" before "schema", unlike with the C
locale.

The test_extensions Makefile specifies NO_LOCALE=1 to avoid this kind
of problem, but that doesn't help during an installcheck.

Regards,
Jeff Davis

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Jeff Davis (#2)
Re: pgsql: CREATE DATABASE: make LOCALE apply to all collation providers.

Jeff Davis <pgsql@j-davis.com> writes:

This created a minor test diff for the test_extensions test for
cs_CZ.UTF-8:
https://buildfarm.postgresql.org/cgi-bin/show_stage_log.pl?nm=jay&amp;dt=2023-06-16%2018%3A02%3A15&amp;stg=testmodules-install-check-cs_CZ.UTF-8
https://buildfarm.postgresql.org/cgi-bin/show_stage_log.pl?nm=hippopotamus&amp;dt=2023-06-16%2017%3A43%3A05&amp;stg=testmodules-install-check-cs_CZ.UTF-8

I believe the new behavior is correct, and the test is being run
incorrectly.

You do not get to define that. The reason we have buildfarm members
running tests this way is exactly to flush out tests that are unduly
collation-sensitive. They will break in the field too.

You might have to provide an alternative expected-file for that test.

regards, tom lane

#4Jeff Davis
pgsql@j-davis.com
In reply to: Tom Lane (#3)
Re: pgsql: CREATE DATABASE: make LOCALE apply to all collation providers.

On Fri, 2023-06-16 at 18:06 -0400, Tom Lane wrote:

You do not get to define that.  The reason we have buildfarm members
running tests this way is exactly to flush out tests that are unduly
collation-sensitive.  They will break in the field too.

It looks like the actual problem is that, when pg_regress creates the
database in --no-locale mode, it passes LC_COLLATE='C' and
LC_CTYPE='C', instead of just LOCALE='C'.

Before my commit, the two were equivalent so it didn't matter, but
afterwards it created an inconsistency that left daticulocale as cs-CZ.

Patch attached.

Regards,
Jeff Davis

Attachments:

v1-0001-pg_regress-for-no-locale-use-LOCALE-C.patchtext/x-patch; charset=UTF-8; name=v1-0001-pg_regress-for-no-locale-use-LOCALE-C.patchDownload+2-3