Fix citext upgrade script for disallowance of oidvector element assignment.
In commit 45e02e3232ac7cc5ffe36f7986159b5e0b1f6fdc, we intentionally disallowed updates on individual elements of oidvector columns. While that still seems like a sane idea in the abstract, we (I) forgot that citext's "upgrade from unpackaged" script did in fact perform exactly such updates, in order to fix the problem that citext indexes should have a collation but would not in databases dumped or upgraded from pre-9.1 installations. Even if we wanted to add casts to allow such updates, there's no practical way to do so in the back branches, so the only real alternative is to make citext's kluge even klugier. In this patch, I cast the oidvector to text, fix its contents with regexp_replace, and cast back to oidvector. (Ugh!) Since the aforementioned commit went into all active branches, we have to fix this in all branches that contain the now-broken update script. Per report from Eric Malm.
This commit is contained in:
parent
9df492664a
commit
7f7eec89b6
@ -105,7 +105,12 @@ UPDATE pg_catalog.pg_attribute SET attcollation = 100
|
|||||||
FROM typeoids
|
FROM typeoids
|
||||||
WHERE atttypid = typeoids.typoid;
|
WHERE atttypid = typeoids.typoid;
|
||||||
|
|
||||||
UPDATE pg_catalog.pg_index SET indcollation[0] = 100
|
-- Updating the index indcollations is particularly tedious, but since we
|
||||||
|
-- don't currently allow SQL assignment to individual elements of oidvectors,
|
||||||
|
-- there's little choice.
|
||||||
|
|
||||||
|
UPDATE pg_catalog.pg_index SET indcollation =
|
||||||
|
pg_catalog.regexp_replace(indcollation::pg_catalog.text, '^0', '100')::pg_catalog.oidvector
|
||||||
WHERE indclass[0] IN (
|
WHERE indclass[0] IN (
|
||||||
WITH RECURSIVE typeoids(typoid) AS
|
WITH RECURSIVE typeoids(typoid) AS
|
||||||
( SELECT 'citext'::pg_catalog.regtype UNION
|
( SELECT 'citext'::pg_catalog.regtype UNION
|
||||||
@ -115,7 +120,8 @@ WHERE indclass[0] IN (
|
|||||||
WHERE opcintype = typeoids.typoid
|
WHERE opcintype = typeoids.typoid
|
||||||
);
|
);
|
||||||
|
|
||||||
UPDATE pg_catalog.pg_index SET indcollation[1] = 100
|
UPDATE pg_catalog.pg_index SET indcollation =
|
||||||
|
pg_catalog.regexp_replace(indcollation::pg_catalog.text, E'^(\\d+) 0', E'\\1 100')::pg_catalog.oidvector
|
||||||
WHERE indclass[1] IN (
|
WHERE indclass[1] IN (
|
||||||
WITH RECURSIVE typeoids(typoid) AS
|
WITH RECURSIVE typeoids(typoid) AS
|
||||||
( SELECT 'citext'::pg_catalog.regtype UNION
|
( SELECT 'citext'::pg_catalog.regtype UNION
|
||||||
@ -125,7 +131,8 @@ WHERE indclass[1] IN (
|
|||||||
WHERE opcintype = typeoids.typoid
|
WHERE opcintype = typeoids.typoid
|
||||||
);
|
);
|
||||||
|
|
||||||
UPDATE pg_catalog.pg_index SET indcollation[2] = 100
|
UPDATE pg_catalog.pg_index SET indcollation =
|
||||||
|
pg_catalog.regexp_replace(indcollation::pg_catalog.text, E'^(\\d+ \\d+) 0', E'\\1 100')::pg_catalog.oidvector
|
||||||
WHERE indclass[2] IN (
|
WHERE indclass[2] IN (
|
||||||
WITH RECURSIVE typeoids(typoid) AS
|
WITH RECURSIVE typeoids(typoid) AS
|
||||||
( SELECT 'citext'::pg_catalog.regtype UNION
|
( SELECT 'citext'::pg_catalog.regtype UNION
|
||||||
@ -135,7 +142,8 @@ WHERE indclass[2] IN (
|
|||||||
WHERE opcintype = typeoids.typoid
|
WHERE opcintype = typeoids.typoid
|
||||||
);
|
);
|
||||||
|
|
||||||
UPDATE pg_catalog.pg_index SET indcollation[3] = 100
|
UPDATE pg_catalog.pg_index SET indcollation =
|
||||||
|
pg_catalog.regexp_replace(indcollation::pg_catalog.text, E'^(\\d+ \\d+ \\d+) 0', E'\\1 100')::pg_catalog.oidvector
|
||||||
WHERE indclass[3] IN (
|
WHERE indclass[3] IN (
|
||||||
WITH RECURSIVE typeoids(typoid) AS
|
WITH RECURSIVE typeoids(typoid) AS
|
||||||
( SELECT 'citext'::pg_catalog.regtype UNION
|
( SELECT 'citext'::pg_catalog.regtype UNION
|
||||||
@ -145,7 +153,8 @@ WHERE indclass[3] IN (
|
|||||||
WHERE opcintype = typeoids.typoid
|
WHERE opcintype = typeoids.typoid
|
||||||
);
|
);
|
||||||
|
|
||||||
UPDATE pg_catalog.pg_index SET indcollation[4] = 100
|
UPDATE pg_catalog.pg_index SET indcollation =
|
||||||
|
pg_catalog.regexp_replace(indcollation::pg_catalog.text, E'^(\\d+ \\d+ \\d+ \\d+) 0', E'\\1 100')::pg_catalog.oidvector
|
||||||
WHERE indclass[4] IN (
|
WHERE indclass[4] IN (
|
||||||
WITH RECURSIVE typeoids(typoid) AS
|
WITH RECURSIVE typeoids(typoid) AS
|
||||||
( SELECT 'citext'::pg_catalog.regtype UNION
|
( SELECT 'citext'::pg_catalog.regtype UNION
|
||||||
@ -155,7 +164,8 @@ WHERE indclass[4] IN (
|
|||||||
WHERE opcintype = typeoids.typoid
|
WHERE opcintype = typeoids.typoid
|
||||||
);
|
);
|
||||||
|
|
||||||
UPDATE pg_catalog.pg_index SET indcollation[5] = 100
|
UPDATE pg_catalog.pg_index SET indcollation =
|
||||||
|
pg_catalog.regexp_replace(indcollation::pg_catalog.text, E'^(\\d+ \\d+ \\d+ \\d+ \\d+) 0', E'\\1 100')::pg_catalog.oidvector
|
||||||
WHERE indclass[5] IN (
|
WHERE indclass[5] IN (
|
||||||
WITH RECURSIVE typeoids(typoid) AS
|
WITH RECURSIVE typeoids(typoid) AS
|
||||||
( SELECT 'citext'::pg_catalog.regtype UNION
|
( SELECT 'citext'::pg_catalog.regtype UNION
|
||||||
@ -165,7 +175,8 @@ WHERE indclass[5] IN (
|
|||||||
WHERE opcintype = typeoids.typoid
|
WHERE opcintype = typeoids.typoid
|
||||||
);
|
);
|
||||||
|
|
||||||
UPDATE pg_catalog.pg_index SET indcollation[6] = 100
|
UPDATE pg_catalog.pg_index SET indcollation =
|
||||||
|
pg_catalog.regexp_replace(indcollation::pg_catalog.text, E'^(\\d+ \\d+ \\d+ \\d+ \\d+ \\d+) 0', E'\\1 100')::pg_catalog.oidvector
|
||||||
WHERE indclass[6] IN (
|
WHERE indclass[6] IN (
|
||||||
WITH RECURSIVE typeoids(typoid) AS
|
WITH RECURSIVE typeoids(typoid) AS
|
||||||
( SELECT 'citext'::pg_catalog.regtype UNION
|
( SELECT 'citext'::pg_catalog.regtype UNION
|
||||||
@ -175,7 +186,8 @@ WHERE indclass[6] IN (
|
|||||||
WHERE opcintype = typeoids.typoid
|
WHERE opcintype = typeoids.typoid
|
||||||
);
|
);
|
||||||
|
|
||||||
UPDATE pg_catalog.pg_index SET indcollation[7] = 100
|
UPDATE pg_catalog.pg_index SET indcollation =
|
||||||
|
pg_catalog.regexp_replace(indcollation::pg_catalog.text, E'^(\\d+ \\d+ \\d+ \\d+ \\d+ \\d+ \\d+) 0', E'\\1 100')::pg_catalog.oidvector
|
||||||
WHERE indclass[7] IN (
|
WHERE indclass[7] IN (
|
||||||
WITH RECURSIVE typeoids(typoid) AS
|
WITH RECURSIVE typeoids(typoid) AS
|
||||||
( SELECT 'citext'::pg_catalog.regtype UNION
|
( SELECT 'citext'::pg_catalog.regtype UNION
|
||||||
|
Loading…
x
Reference in New Issue
Block a user