On 27.04.23 13:44, Daniel Verite wrote:
This collation has an empty pg_collation.collversion column, instead
of being set to the same value as "und-x-icu" to track its version.

The original patch implements this as an INSERT in which it would be easy to
fix I guess, but in current HEAD it comes as an entry in
include/catalog/pg_collation.dat:

{ oid => '963',
   descr => 'sorts using the Unicode Collation Algorithm with default
settings',
   collname => 'unicode', collprovider => 'i', collencoding => '-1',
   colliculocale => 'und' },

Should it be converted back into an INSERT or better left
in this file and collversion being updated afterwards?

How about we do it with an UPDATE command. We already do this for pg_database in a similar way. See attached patch.
From 91f2aff04f9bf137e4ac6e7df624dde770503bfd Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Mon, 8 May 2023 17:45:46 +0200
Subject: [PATCH] initdb: Set collversion for standard collation UNICODE

Discussion: 
https://www.postgresql.org/message-id/49417853-7bdd-4b23-a4e9-04c7aff33...@manitou-mail.org
---
 src/bin/initdb/initdb.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index 2c208ead01..632f6c9c72 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -1695,6 +1695,13 @@ setup_description(FILE *cmdfd)
 static void
 setup_collation(FILE *cmdfd)
 {
+       /*
+        * Set the collation version for collations defined in pg_collation.dat,
+        * except the ones where we know that the collation behavior will never
+        * change.
+        */
+       PG_CMD_PUTS("UPDATE pg_collation SET collversion = 
pg_collation_actual_version(oid) WHERE collname = 'unicode';\n\n");
+
        /* Import all collations we can find in the operating system */
        PG_CMD_PUTS("SELECT pg_import_system_collations('pg_catalog');\n\n");
 }
-- 
2.40.0

Reply via email to