0

I've set up a database on PostgreSQL 14, and now when I try to insert data, I'm getting the following error:

ERROR: collation "cs_CZ.utf8" for encoding "UTF8" does not exist

Currently, I see the following settings: Encoding | UTF8 Collate | en_US.UTF-8 Ctype | en_US.UTF-8

I didn't encounter this issue on another project, and I managed to insert Czech data into it.

Do you know if I'll need to create new databases with cs_CZ.utf8 or just change the encoding?

Thank you.

2
  • Is that Debian/Ubuntu? Commented Mar 1 at 10:53
  • It is centos9..
    – Jan Kůst
    Commented Mar 1 at 12:07

1 Answer 1

2

Since this is CentOS:

  • install the glibc-all-langpacks package

  • restart PostgreSQL

  • import the new collations with

    SELECT pg_import_system_collations('pg_catalog');
    

Not that collations are not shared between databases, so you have to import the collations in all databases of the cluster where you need them.

6
  • When I performed the steps you described, new collations were loaded; however, I still encounter the same error. Additionally, when I execute the command select collname from pg_collation;, the collations are displayed incorrectly, in my opinion. However, in the output of select collname from pg_collation, I still don't have cs_CZ.UTF8.
    – Jan Kůst
    Commented Mar 4 at 10:50
  • Describe "displayed incorrectly". What do you get for SELECT collname FROM pg_collation WHERE collname LIKE 'cs_CZ%';? Commented Mar 4 at 10:58
  • You're right, I see there: cs-CZ-x-icu cs_CZ cs_CZ cs_CZ.iso88592 cs_CZ.utf8 Now it doesn't make sense to me that I'm still encountering the same error, even though I restarted the PostgreSQL server.
    – Jan Kůst
    Commented Mar 4 at 11:00
  • Perhaps you should edit your question and show the exact command you are trying that gives you the error. Note that you have to import the system collations in every database where you want to use them. Commented Mar 4 at 11:13
  • This might be the issue... I executed your command for import only under the postgres database.
    – Jan Kůst
    Commented Mar 4 at 12:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.