Identify the version of a collation from ICU in Postgres Postgres 10 and later incorporates the International Components for Unicode (ICU) library for text-handling and other internationalization issues. 

Changes happen to human languages, such as sorting rules evolving. Therefore collation definitions are versioned in ICU. 

➥ How can I identify the version number of a collation? 

I know Postgres will report version number as part of a collation version mismatch error message. Is there a way to proactively query for the version rather than wait for an error message?
TL;DR

Check out the pg_collation_actual_version() function.

&nbsp;

DETAILS

The PostgreSQL documentation for ALTER COLLATION seems to discuss this issue in the "Notes" section:


  When using collations provided by the ICU library, the ICU-specific version of the collator is recorded in the system catalog when the collation object is created. When the collation is used, the current version is checked against the recorded version, and a warning is issued when there is a mismatch...  
  
  A change in collation definitions can lead to corrupt indexes and other problems because the database system relies on stored objects having a certain sort order. ...  
  
  The following query can be used to identify all collations in the current database that need to be refreshed and the objects that depend on them:  

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 &lt;&gt; pg_collation_actual_version(c.oid)  
  ORDER BY 1, 2;



You will notice that the given query makes use of the pg_collation_actual_version() function, which is defined as:


  pg_collation_actual_version returns the actual version of the collation object as it is currently installed in the operating system. If this is different from the value in pg_collation.collversion, then objects depending on the collation might need to be rebuilt.