aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2011-11-21 11:24:39 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2011-11-21 11:25:05 -0500
commit94bdb198813b079467d7ed07c6f72ac896da7161 (patch)
tree7154f82406e1ecd5a3f1e050c00caa67c3fe3713
parent590ceed6f21fd243a6caf7233d3b2ce01350ecb6 (diff)
downloadpostgresql-94bdb198813b079467d7ed07c6f72ac896da7161.tar.gz
postgresql-94bdb198813b079467d7ed07c6f72ac896da7161.zip
Fix citext upgrade script to update derived copies of pg_type.typcollation.
If the existing citext type has not merely been created, but used in any tables, then the upgrade script wasn't doing enough. We have to update attcollation for each citext table column, and indcollation for each citext index column, as well. Per report from Rudolf van der Leeden.
-rw-r--r--contrib/citext/citext--unpackaged--1.0.sql42
1 files changed, 40 insertions, 2 deletions
diff --git a/contrib/citext/citext--unpackaged--1.0.sql b/contrib/citext/citext--unpackaged--1.0.sql
index 42d7aeeb7ff..9b0f200aac7 100644
--- a/contrib/citext/citext--unpackaged--1.0.sql
+++ b/contrib/citext/citext--unpackaged--1.0.sql
@@ -81,11 +81,49 @@ ALTER EXTENSION citext ADD function translate(citext,citext,text);
--
-- As of 9.1, type citext should be marked collatable. There is no ALTER TYPE
-- command for this, so we have to do it by poking the pg_type entry directly.
+-- We have to poke any derived copies in pg_attribute or pg_index as well.
-- Notes: 100 is the OID of the "pg_catalog.default" collation --- it seems
-- easier and more reliable to hard-wire that here than to pull it out of
--- pg_collation. Also, we don't need a pg_depend entry since the default
--- collation is pinned.
+-- pg_collation. Also, we don't need to make pg_depend entries since the
+-- default collation is pinned.
--
UPDATE pg_catalog.pg_type SET typcollation = 100
WHERE oid = 'citext'::pg_catalog.regtype;
+
+UPDATE pg_catalog.pg_attribute SET attcollation = 100
+WHERE atttypid = 'citext'::pg_catalog.regtype;
+
+UPDATE pg_catalog.pg_index SET indcollation[0] = 100
+WHERE indclass[0] IN (SELECT oid FROM pg_catalog.pg_opclass
+ WHERE opcintype = 'citext'::pg_catalog.regtype);
+
+UPDATE pg_catalog.pg_index SET indcollation[1] = 100
+WHERE indclass[1] IN (SELECT oid FROM pg_catalog.pg_opclass
+ WHERE opcintype = 'citext'::pg_catalog.regtype);
+
+UPDATE pg_catalog.pg_index SET indcollation[2] = 100
+WHERE indclass[2] IN (SELECT oid FROM pg_catalog.pg_opclass
+ WHERE opcintype = 'citext'::pg_catalog.regtype);
+
+UPDATE pg_catalog.pg_index SET indcollation[3] = 100
+WHERE indclass[3] IN (SELECT oid FROM pg_catalog.pg_opclass
+ WHERE opcintype = 'citext'::pg_catalog.regtype);
+
+UPDATE pg_catalog.pg_index SET indcollation[4] = 100
+WHERE indclass[4] IN (SELECT oid FROM pg_catalog.pg_opclass
+ WHERE opcintype = 'citext'::pg_catalog.regtype);
+
+UPDATE pg_catalog.pg_index SET indcollation[5] = 100
+WHERE indclass[5] IN (SELECT oid FROM pg_catalog.pg_opclass
+ WHERE opcintype = 'citext'::pg_catalog.regtype);
+
+UPDATE pg_catalog.pg_index SET indcollation[6] = 100
+WHERE indclass[6] IN (SELECT oid FROM pg_catalog.pg_opclass
+ WHERE opcintype = 'citext'::pg_catalog.regtype);
+
+UPDATE pg_catalog.pg_index SET indcollation[7] = 100
+WHERE indclass[7] IN (SELECT oid FROM pg_catalog.pg_opclass
+ WHERE opcintype = 'citext'::pg_catalog.regtype);
+
+-- somewhat arbitrarily, we assume no citext indexes have more than 8 columns