]> granicus.if.org Git - postgresql/commitdiff
Fix CompareIndexInfo's attnum comparisons
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Fri, 19 Jan 2018 19:34:44 +0000 (16:34 -0300)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Fri, 19 Jan 2018 19:56:42 +0000 (16:56 -0300)
When an index column is an expression, it makes no sense to compare its
attribute numbers.

This seems to account for remaining buildfarm fallout from 8b08f7d4820f.
At least, it solves the issue in my local 32bit VM -- let's see what the
rest thinks.

src/backend/catalog/index.c

index f0223416adf756e925fb9d893ba24007c81ca433..849a4691277450bdc15ed008a0ea8233804205ed 100644 (file)
@@ -1795,8 +1795,10 @@ CompareIndexInfo(IndexInfo *info1, IndexInfo *info2,
                if (maplen < info2->ii_KeyAttrNumbers[i])
                        elog(ERROR, "incorrect attribute map");
 
-               if (attmap[info2->ii_KeyAttrNumbers[i] - 1] !=
-                       info1->ii_KeyAttrNumbers[i])
+               /* ignore expressions at this stage */
+               if ((info1->ii_KeyAttrNumbers[i] != InvalidAttrNumber) &&
+                       (attmap[info2->ii_KeyAttrNumbers[i] - 1] !=
+                       info1->ii_KeyAttrNumbers[i]))
                        return false;
 
                if (collations1[i] != collations2[i])