pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Vincent Van Driessche <vincent@dabble.be>
To: pgsql-bugs@lists.postgresql.org
Subject: Default collation changes leave indexes in invalid state
Date: Wed, 11 Sep 2019 10:05:18 +0200
Message-ID: <etPan.5d78aabe.5e660da.ad70@dabble.be> (raw)

Hi all

When making changes to the database collation types in PostgreSQL, indexes that already exist that point to the “default” collation type, remain pointed at “default”, even though the collation type that the “default” entry is referring to, no longer is valid.

```
SELECT pg_class.relname AS Index, pg_attribute.attname AS Column, CASE WHEN pg_attribute.attcollation = 0 THEN '<none>' ELSE pg_collation.collname END AS Collation 
FROM pg_class LEFT JOIN pg_attribute ON pg_class.oid = pg_attribute.attrelid LEFT JOIN pg_collation ON pg_attribute.attcollation = pg_collation.oid WHERE pg_class.relam != 0 AND  pg_collation.collname = 'default’;
```

I’ve used the above query to validate this behaviour. By running it before and after changing the `C` collation into `en_US.UTF-8`:

```
UPDATE pg_database SET datcollate='en_US.UTF-8', datctype='en_US.UTF-8'
```

I’m aware that the most accepted way to alter collation types right now is to remember to recreate indexes based on the new collation (before or after, whatever takes preference), but I feel like triggering an update of the relevant collations (referring to “default”) when changes to the collation type are detected makes a lot of sense. (A form of cascading update) as this would allow the old indexes to be queried without issues. (I’d think)

Please let me know if this makes sense or not, I got referred here from the slack channel (https://postgresteam.slack.com/archives/C0FS3UTAP/p1568186700106500)


Kind Regards
Vincent Van Driessche



Sent via Migadu.com, world's easiest email hosting

Attachments:

  dabble.ico (application/octet-stream, 31.3K) download

view thread (4+ messages)  latest in thread

Message-ID: <etPan.5d78aabe.5e660da.ad70@dabble.be>
Permalink:  ../etPan.5d78aabe.5e660da.ad70@dabble.be/
Also on:    postgresql.org/message-id/etPan.5d78aabe.5e660da.ad70@dabble.be

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: vincent@dabble.be
  Subject: Re: Default collation changes leave indexes in invalid state
  In-Reply-To: <etPan.5d78aabe.5e660da.ad70@dabble.be>
  References: <etPan.5d78aabe.5e660da.ad70@dabble.be>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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