Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9807c82

Browse files
committed
Fix citext upgrade script for disallowance of oidvector element assignment.
In commit45e02e3, we intentionallydisallowed updates on individual elements of oidvector columns. While thatstill 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 collationbut 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 practicalway to do so in the back branches, so the only real alternative is to makecitext'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 tofix this in all branches that contain the now-broken update script.Per report from Eric Malm.
1 parent0aa09c9 commit9807c82

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

‎contrib/citext/citext--unpackaged--1.0.sql

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,12 @@ UPDATE pg_catalog.pg_attribute SET attcollation = 100
105105
FROM typeoids
106106
WHERE atttypid=typeoids.typoid;
107107

108-
UPDATEpg_catalog.pg_indexSET indcollation[0]=100
108+
-- Updating the index indcollations is particularly tedious, but since we
109+
-- don't currently allow SQL assignment to individual elements of oidvectors,
110+
-- there's little choice.
111+
112+
UPDATEpg_catalog.pg_indexSET indcollation=
113+
pg_catalog.regexp_replace(indcollation::pg_catalog.text,'^0','100')::pg_catalog.oidvector
109114
WHERE indclass[0]IN (
110115
WITH RECURSIVE typeoids(typoid)AS
111116
(SELECT'citext'::pg_catalog.regtypeUNION
@@ -115,7 +120,8 @@ WHERE indclass[0] IN (
115120
WHERE opcintype=typeoids.typoid
116121
);
117122

118-
UPDATEpg_catalog.pg_indexSET indcollation[1]=100
123+
UPDATEpg_catalog.pg_indexSET indcollation=
124+
pg_catalog.regexp_replace(indcollation::pg_catalog.text, E'^(\\d+) 0', E'\\1 100')::pg_catalog.oidvector
119125
WHERE indclass[1]IN (
120126
WITH RECURSIVE typeoids(typoid)AS
121127
(SELECT'citext'::pg_catalog.regtypeUNION
@@ -125,7 +131,8 @@ WHERE indclass[1] IN (
125131
WHERE opcintype=typeoids.typoid
126132
);
127133

128-
UPDATEpg_catalog.pg_indexSET indcollation[2]=100
134+
UPDATEpg_catalog.pg_indexSET indcollation=
135+
pg_catalog.regexp_replace(indcollation::pg_catalog.text, E'^(\\d+\\d+) 0', E'\\1 100')::pg_catalog.oidvector
129136
WHERE indclass[2]IN (
130137
WITH RECURSIVE typeoids(typoid)AS
131138
(SELECT'citext'::pg_catalog.regtypeUNION
@@ -135,7 +142,8 @@ WHERE indclass[2] IN (
135142
WHERE opcintype=typeoids.typoid
136143
);
137144

138-
UPDATEpg_catalog.pg_indexSET indcollation[3]=100
145+
UPDATEpg_catalog.pg_indexSET indcollation=
146+
pg_catalog.regexp_replace(indcollation::pg_catalog.text, E'^(\\d+\\d+\\d+) 0', E'\\1 100')::pg_catalog.oidvector
139147
WHERE indclass[3]IN (
140148
WITH RECURSIVE typeoids(typoid)AS
141149
(SELECT'citext'::pg_catalog.regtypeUNION
@@ -145,7 +153,8 @@ WHERE indclass[3] IN (
145153
WHERE opcintype=typeoids.typoid
146154
);
147155

148-
UPDATEpg_catalog.pg_indexSET indcollation[4]=100
156+
UPDATEpg_catalog.pg_indexSET indcollation=
157+
pg_catalog.regexp_replace(indcollation::pg_catalog.text, E'^(\\d+\\d+\\d+\\d+) 0', E'\\1 100')::pg_catalog.oidvector
149158
WHERE indclass[4]IN (
150159
WITH RECURSIVE typeoids(typoid)AS
151160
(SELECT'citext'::pg_catalog.regtypeUNION
@@ -155,7 +164,8 @@ WHERE indclass[4] IN (
155164
WHERE opcintype=typeoids.typoid
156165
);
157166

158-
UPDATEpg_catalog.pg_indexSET indcollation[5]=100
167+
UPDATEpg_catalog.pg_indexSET indcollation=
168+
pg_catalog.regexp_replace(indcollation::pg_catalog.text, E'^(\\d+\\d+\\d+\\d+\\d+) 0', E'\\1 100')::pg_catalog.oidvector
159169
WHERE indclass[5]IN (
160170
WITH RECURSIVE typeoids(typoid)AS
161171
(SELECT'citext'::pg_catalog.regtypeUNION
@@ -165,7 +175,8 @@ WHERE indclass[5] IN (
165175
WHERE opcintype=typeoids.typoid
166176
);
167177

168-
UPDATEpg_catalog.pg_indexSET indcollation[6]=100
178+
UPDATEpg_catalog.pg_indexSET indcollation=
179+
pg_catalog.regexp_replace(indcollation::pg_catalog.text, E'^(\\d+\\d+\\d+\\d+\\d+\\d+) 0', E'\\1 100')::pg_catalog.oidvector
169180
WHERE indclass[6]IN (
170181
WITH RECURSIVE typeoids(typoid)AS
171182
(SELECT'citext'::pg_catalog.regtypeUNION
@@ -175,7 +186,8 @@ WHERE indclass[6] IN (
175186
WHERE opcintype=typeoids.typoid
176187
);
177188

178-
UPDATEpg_catalog.pg_indexSET indcollation[7]=100
189+
UPDATEpg_catalog.pg_indexSET indcollation=
190+
pg_catalog.regexp_replace(indcollation::pg_catalog.text, E'^(\\d+\\d+\\d+\\d+\\d+\\d+\\d+) 0', E'\\1 100')::pg_catalog.oidvector
179191
WHERE indclass[7]IN (
180192
WITH RECURSIVE typeoids(typoid)AS
181193
(SELECT'citext'::pg_catalog.regtypeUNION

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp