]> granicus.if.org Git - postgresql/commitdiff
Damage control for yesterday's CheckIndexCompatible changes.
authorRobert Haas <rhaas@postgresql.org>
Thu, 26 Jan 2012 13:21:31 +0000 (08:21 -0500)
committerRobert Haas <rhaas@postgresql.org>
Thu, 26 Jan 2012 13:21:31 +0000 (08:21 -0500)
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.

src/backend/commands/indexcmds.c
src/test/regress/expected/alter_table.out
src/test/regress/sql/alter_table.sql

index 1bf1de56f315c40aa0901d4af49c30e1aa25e783..6c909298b7d72fdfb08dcdbf2516b71a10a5ccbe 100644 (file)
@@ -214,11 +214,20 @@ CheckIndexCompatible(Oid oldId,
 
        ReleaseSysCache(tuple);
 
+       if (!ret)
+               return false;
+
        /* For polymorphic opcintype, column type changes break compatibility. */
        irel = index_open(oldId, AccessShareLock); /* caller probably has a lock */
-       for (i = 0; i < old_natts && ret; i++)
-               ret = (!IsPolymorphicType(get_opclass_input_type(classObjectId[i])) ||
-                          irel->rd_att->attrs[i]->atttypid == typeObjectId[i]);
+       for (i = 0; i < old_natts; i++)
+       {
+               if (IsPolymorphicType(get_opclass_input_type(classObjectId[i])) &&
+                   irel->rd_att->attrs[i]->atttypid != typeObjectId[i])
+               {
+                       ret = false;
+                       break;
+               }
+       }
 
        /* Any change in exclusion operator selections breaks compatibility. */
        if (ret && indexInfo->ii_ExclusionOps != NULL)
@@ -231,14 +240,21 @@ CheckIndexCompatible(Oid oldId,
                                         old_natts * sizeof(Oid)) == 0;
 
                /* Require an exact input type match for polymorphic operators. */
-               for (i = 0; i < old_natts && ret; i++)
+               if (ret)
                {
-                       Oid                     left,
-                                               right;
+                       for (i = 0; i < old_natts && ret; i++)
+                       {
+                               Oid                     left,
+                                                       right;
 
-                       op_input_types(indexInfo->ii_ExclusionOps[i], &left, &right);
-                       ret = (!(IsPolymorphicType(left) || IsPolymorphicType(right)) ||
-                                  irel->rd_att->attrs[i]->atttypid == typeObjectId[i]);
+                               op_input_types(indexInfo->ii_ExclusionOps[i], &left, &right);
+                               if ((IsPolymorphicType(left) || IsPolymorphicType(right)) &&
+                                          irel->rd_att->attrs[i]->atttypid != typeObjectId[i])
+                               {
+                                       ret = false;
+                                       break;
+                               }
+                       }
                }
        }
 
index 41bfa857ddd84e24017b1e682a8108e2384f882d..e99254950426b6edea30ae125b1f5ba8e538b79e 100644 (file)
@@ -1665,15 +1665,6 @@ where oid = 'test_storage'::regclass;
  t
 (1 row)
 
--- SET DATA TYPE without a rewrite
-CREATE DOMAIN other_textarr AS text[];
-CREATE TABLE norewrite_array(c text[] PRIMARY KEY);
-NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "norewrite_array_pkey" for table "norewrite_array"
-SET client_min_messages = debug1;
-ALTER TABLE norewrite_array ALTER c TYPE text[]; -- no work
-ALTER TABLE norewrite_array ALTER c TYPE other_textarr; -- rebuild index
-DEBUG:  building index "norewrite_array_pkey" on table "norewrite_array"
-RESET client_min_messages;
 --
 -- lock levels
 --
index 494c1504d7883329c7e4752636ec9f51dff6a507..d9bf08d6d5067ae2fd1321c103f52214a23e082f 100644 (file)
@@ -1197,14 +1197,6 @@ select reltoastrelid <> 0 as has_toast_table
 from pg_class
 where oid = 'test_storage'::regclass;
 
--- SET DATA TYPE without a rewrite
-CREATE DOMAIN other_textarr AS text[];
-CREATE TABLE norewrite_array(c text[] PRIMARY KEY);
-SET client_min_messages = debug1;
-ALTER TABLE norewrite_array ALTER c TYPE text[]; -- no work
-ALTER TABLE norewrite_array ALTER c TYPE other_textarr; -- rebuild index
-RESET client_min_messages;
-
 --
 -- lock levels
 --