Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gYDqN-00033T-4Z for pgsql-hackers@arkaria.postgresql.org; Sat, 15 Dec 2018 17:35:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gYDqK-0002zJ-Gl for pgsql-hackers@arkaria.postgresql.org; Sat, 15 Dec 2018 17:35:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gYDqK-0002zC-9X for pgsql-hackers@lists.postgresql.org; Sat, 15 Dec 2018 17:35:12 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gYDqI-000522-Vm for pgsql-hackers@lists.postgresql.org; Sat, 15 Dec 2018 17:35:11 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id wBFHZ96R019347 for ; Sat, 15 Dec 2018 12:35:09 -0500 From: Tom Lane To: pgsql-hackers@lists.postgresql.org Subject: Improving collation-dependent indexes in system catalogs MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <19345.1544895308.1@sss.pgh.pa.us> Date: Sat, 15 Dec 2018 12:35:09 -0500 Message-ID: <19346.1544895309@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Awhile back we noticed that a couple of system catalogs had acquired indexes on "text" columns, which were unsafe because their sort order was collation-dependent, so that cloning template0 with a different database collation could yield broken indexes. We fixed this in commit 0b28ea79 with a bit of a hack: we said it's okay to have such indexes as long as they use the text_pattern_ops opclass, making them collation insensitive. While fooling with the idea of making type "name" collation aware, it occurred to me that there's a better, more general answer, which is to insist that collation-aware system catalog columns must be marked with C collation. This rule would apply without modification to both "text" and "name" columns. In the wake of commit 5e0928005, it also means that pg_statistic data for such a column would port safely across a database collation change, which up to now it does not. And I think we could have the bootstrap code apply the rule automatically, making for one less way to screw up when changing catalog definitions. Thoughts, objections? regards, tom lane