pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedpgsql: Introduce "builtin" collation provider.
4+ messages / 4 participants
[nested] [flat]
Commits from this thread:
2024-05-01 7562a9bd71 Fix locale options checking in CREATE DATABASE.
* pgsql: Introduce "builtin" collation provider.
@ 2024-03-14 06:39 Jeff Davis <jdavis@postgresql.org>
0 siblings, 2 replies; 4+ messages in thread
From: Jeff Davis @ 2024-03-14 06:39 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Introduce "builtin" collation provider.
New provider for collations, like "libc" or "icu", but without any
external dependency.
Initially, the only locale supported by the builtin provider is "C",
which is identical to the libc provider's "C" locale. The libc
provider's "C" locale has always been treated as a special case that
uses an internal implementation, without using libc at all -- so the
new builtin provider uses the same implementation.
The builtin provider's locale is independent of the server environment
variables LC_COLLATE and LC_CTYPE. Using the builtin provider, the
database collation locale can be "C" while LC_COLLATE and LC_CTYPE are
set to "en_US", which is impossible with the libc provider.
By offering a new builtin provider, it clarifies that the semantics of
a collation using this provider will never depend on libc, and makes
it easier to document the behavior.
Discussion: https://postgr.es/m/ab925f69-5f9d-f85e-b87c-bd2a44798659@joeconway.com
Discussion: https://postgr.es/m/dd9261f4-7a98-4565-93ec-336c1c110d90@manitou-mail.org
Discussion: https://postgr.es/m/ff4c2f2f9c8fc7ca27c1c24ae37ecaeaeaff6b53.camel%40j-davis.com
Reviewed-by: Daniel Vérité, Peter Eisentraut, Jeremy Schneider
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/2d819a08a1cbc11364e36f816b02e33e8dcc030b
Modified Files
--------------
doc/src/sgml/charset.sgml | 90 ++++++++++++++++++-----
doc/src/sgml/ref/create_collation.sgml | 11 ++-
doc/src/sgml/ref/create_database.sgml | 7 +-
doc/src/sgml/ref/createdb.sgml | 2 +-
doc/src/sgml/ref/initdb.sgml | 17 ++++-
src/backend/catalog/pg_collation.c | 5 +-
src/backend/commands/collationcmds.c | 74 +++++++++++++++----
src/backend/commands/dbcommands.c | 129 +++++++++++++++++++++++++--------
src/backend/utils/adt/formatting.c | 6 ++
src/backend/utils/adt/pg_locale.c | 123 ++++++++++++++++++++++++++-----
src/backend/utils/init/postinit.c | 20 ++++-
src/bin/initdb/initdb.c | 53 ++++++++++----
src/bin/initdb/t/001_initdb.pl | 40 +++++++++-
src/bin/pg_dump/pg_dump.c | 23 +++++-
src/bin/pg_upgrade/t/002_pg_upgrade.pl | 81 ++++++++++++++++-----
src/bin/psql/describe.c | 4 +-
src/bin/scripts/createdb.c | 19 ++++-
src/bin/scripts/t/020_createdb.pl | 60 +++++++++++++++
src/include/catalog/catversion.h | 2 +-
src/include/catalog/pg_collation.dat | 6 +-
src/include/catalog/pg_collation.h | 3 +
src/include/utils/pg_locale.h | 5 ++
src/test/icu/t/010_database.pl | 22 +++---
src/test/regress/expected/collate.out | 19 ++++-
src/test/regress/sql/collate.sql | 8 ++
25 files changed, 671 insertions(+), 158 deletions(-)
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: pgsql: Introduce "builtin" collation provider.
@ 2024-04-23 09:23 Peter Eisentraut <peter@eisentraut.org>
parent: Jeff Davis <jdavis@postgresql.org>
1 sibling, 1 reply; 4+ messages in thread
From: Peter Eisentraut @ 2024-04-23 09:23 UTC (permalink / raw)
To: Jeff Davis <jdavis@postgresql.org>; pgsql-committers@lists.postgresql.org
On 14.03.24 07:39, Jeff Davis wrote:
> Introduce "builtin" collation provider.
Jeff,
I think I found a small bug in this commit.
The new code in dbcommands.c createdb() reads like this:
+ /* validate provider-specific parameters */
+ if (dblocprovider != COLLPROVIDER_BUILTIN)
+ {
+ if (dbuiltinlocale)
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
+ errmsg("BUILTIN_LOCALE cannot be specified unless
locale provider is builtin")));
+ }
+ else if (dblocprovider != COLLPROVIDER_ICU)
+ {
+ if (diculocale)
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
+ errmsg("ICU locale cannot be specified unless
locale provider is ICU")));
+
+ if (dbicurules)
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
+ errmsg("ICU rules cannot be specified unless locale
provider is ICU")));
+ }
But if dblocprovider is COLLPROVIDER_LIBC, then the first "if" is true
and the second one won't be checked. I think the correct code structure
would be to make both of these checks separate if statements.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: pgsql: Introduce "builtin" collation provider.
@ 2024-04-23 15:33 Andrew Dunstan <andrew@dunslane.net>
parent: Jeff Davis <jdavis@postgresql.org>
1 sibling, 0 replies; 4+ messages in thread
From: Andrew Dunstan @ 2024-04-23 15:33 UTC (permalink / raw)
To: Jeff Davis <jdavis@postgresql.org>; PostgreSQL-development <pgsql-hackers@postgresql.org>
On 2024-03-14 Th 02:39, Jeff Davis wrote:
> Introduce "builtin" collation provider.
The new value "b" for pg_collation.collprovider doesn't seem to be
documented. Is that deliberate?
cheers
andrew
--
Andrew Dunstan
EDB: https://www.enterprisedb.com
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: pgsql: Introduce "builtin" collation provider.
@ 2024-05-01 02:55 Jeff Davis <pgsql@j-davis.com>
parent: Peter Eisentraut <peter@eisentraut.org>
0 siblings, 0 replies; 4+ messages in thread
From: Jeff Davis @ 2024-05-01 02:55 UTC (permalink / raw)
To: Peter Eisentraut <peter@eisentraut.org>; Jeff Davis <jdavis@postgresql.org>; pgsql-committers@lists.postgresql.org
On Tue, 2024-04-23 at 11:23 +0200, Peter Eisentraut wrote:
> I think I found a small bug in this commit.
Good catch, thank you.
Committed a fix.
Regards,
Jeff Davis
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2024-05-01 02:55 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-03-14 06:39 pgsql: Introduce "builtin" collation provider. Jeff Davis <jdavis@postgresql.org>
2024-04-23 09:23 ` Peter Eisentraut <peter@eisentraut.org>
2024-05-01 02:55 ` Jeff Davis <pgsql@j-davis.com>
2024-04-23 15:33 ` Andrew Dunstan <andrew@dunslane.net>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox