Skip to content

Commit 9d35116

Browse files
committed
Damage control for yesterday's CheckIndexCompatible changes.
Rip out a regression test that doesn't play well with settings put in place by the build farm, and rewrite the code in CheckIndexCompatible in a hopefully more transparent style.
1 parent 9f9135d commit 9d35116

File tree

3 files changed

+25
-26
lines changed

3 files changed

+25
-26
lines changed

src/backend/commands/indexcmds.c

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,20 @@ CheckIndexCompatible(Oid oldId,
214214

215215
ReleaseSysCache(tuple);
216216

217+
if (!ret)
218+
return false;
219+
217220
/* For polymorphic opcintype, column type changes break compatibility. */
218221
irel = index_open(oldId, AccessShareLock); /* caller probably has a lock */
219-
for (i = 0; i < old_natts && ret; i++)
220-
ret = (!IsPolymorphicType(get_opclass_input_type(classObjectId[i])) ||
221-
irel->rd_att->attrs[i]->atttypid == typeObjectId[i]);
222+
for (i = 0; i < old_natts; i++)
223+
{
224+
if (IsPolymorphicType(get_opclass_input_type(classObjectId[i])) &&
225+
irel->rd_att->attrs[i]->atttypid != typeObjectId[i])
226+
{
227+
ret = false;
228+
break;
229+
}
230+
}
222231

223232
/* Any change in exclusion operator selections breaks compatibility. */
224233
if (ret && indexInfo->ii_ExclusionOps != NULL)
@@ -231,14 +240,21 @@ CheckIndexCompatible(Oid oldId,
231240
old_natts * sizeof(Oid)) == 0;
232241

233242
/* Require an exact input type match for polymorphic operators. */
234-
for (i = 0; i < old_natts && ret; i++)
243+
if (ret)
235244
{
236-
Oid left,
237-
right;
245+
for (i = 0; i < old_natts && ret; i++)
246+
{
247+
Oid left,
248+
right;
238249

239-
op_input_types(indexInfo->ii_ExclusionOps[i], &left, &right);
240-
ret = (!(IsPolymorphicType(left) || IsPolymorphicType(right)) ||
241-
irel->rd_att->attrs[i]->atttypid == typeObjectId[i]);
250+
op_input_types(indexInfo->ii_ExclusionOps[i], &left, &right);
251+
if ((IsPolymorphicType(left) || IsPolymorphicType(right)) &&
252+
irel->rd_att->attrs[i]->atttypid != typeObjectId[i])
253+
{
254+
ret = false;
255+
break;
256+
}
257+
}
242258
}
243259
}
244260

src/test/regress/expected/alter_table.out

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,15 +1665,6 @@ where oid = 'test_storage'::regclass;
16651665
t
16661666
(1 row)
16671667

1668-
-- SET DATA TYPE without a rewrite
1669-
CREATE DOMAIN other_textarr AS text[];
1670-
CREATE TABLE norewrite_array(c text[] PRIMARY KEY);
1671-
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "norewrite_array_pkey" for table "norewrite_array"
1672-
SET client_min_messages = debug1;
1673-
ALTER TABLE norewrite_array ALTER c TYPE text[]; -- no work
1674-
ALTER TABLE norewrite_array ALTER c TYPE other_textarr; -- rebuild index
1675-
DEBUG: building index "norewrite_array_pkey" on table "norewrite_array"
1676-
RESET client_min_messages;
16771668
--
16781669
-- lock levels
16791670
--

src/test/regress/sql/alter_table.sql

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,14 +1197,6 @@ select reltoastrelid <> 0 as has_toast_table
11971197
from pg_class
11981198
where oid = 'test_storage'::regclass;
11991199

1200-
-- SET DATA TYPE without a rewrite
1201-
CREATE DOMAIN other_textarr AS text[];
1202-
CREATE TABLE norewrite_array(c text[] PRIMARY KEY);
1203-
SET client_min_messages = debug1;
1204-
ALTER TABLE norewrite_array ALTER c TYPE text[]; -- no work
1205-
ALTER TABLE norewrite_array ALTER c TYPE other_textarr; -- rebuild index
1206-
RESET client_min_messages;
1207-
12081200
--
12091201
-- lock levels
12101202
--

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy