v1-0001-docs-Include-database-collation-check-on-SQL-from.patch

text/plain

Filename: v1-0001-docs-Include-database-collation-check-on-SQL-from.patch
Type: text/plain
Part: 0
Message: docs: Include database collation check on SQL from alter_collation.sgml

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch v1-0001
Subject: docs: Include database collation check on SQL from ALTER COLLATION
File+
doc/src/sgml/ref/alter_collation.sgml 7 1
From e44674dfaee27bc449e0f3de65a0925851a598a3 Mon Sep 17 00:00:00 2001
From: Matheus Alcantara <mths.dev@pm.me>
Date: Thu, 9 Apr 2026 14:09:05 -0300
Subject: [PATCH v1 1/2] docs: Include database collation check on SQL from
 ALTER COLLATION

Previously the alter_collation.sgml documentation section include a SQL
that can be used to identity all collations in the current database that
need to be refreshed due to a collation version miss match and the
objects that depend on them. However if there is objects that use the
database collation these objects are not returned by the query.

This commit improve the query on alter_collation.sgml to include the
database collation version check too to report such cases.
---
 doc/src/sgml/ref/alter_collation.sgml | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/doc/src/sgml/ref/alter_collation.sgml b/doc/src/sgml/ref/alter_collation.sgml
index a40a31442a8..f0c3af20b95 100644
--- a/doc/src/sgml/ref/alter_collation.sgml
+++ b/doc/src/sgml/ref/alter_collation.sgml
@@ -164,7 +164,13 @@ SELECT pg_describe_object(refclassid, refobjid, refobjsubid) AS "Collation",
        pg_describe_object(classid, objid, objsubid) AS "Object"
   FROM pg_depend d JOIN pg_collation c
        ON refclassid = 'pg_collation'::regclass AND refobjid = c.oid
-  WHERE c.collversion <> pg_collation_actual_version(c.oid)
+       JOIN pg_database db ON db.datname = current_database()
+  WHERE c.collprovider IN ('d', 'c')
+    AND (
+        (c.collprovider = 'd' AND db.datcollversion <> pg_database_collation_actual_version(db.oid))
+        OR
+        (c.collprovider = 'c' AND c.collversion <> pg_collation_actual_version(c.oid))
+    )
   ORDER BY 1, 2;
 ]]></programlisting></para>
  </refsect1>
-- 
2.53.0