@@ -580,15 +580,12 @@ _bt_buildadd(BTWriteState *wstate, BTPageState *state, IndexTuple itup)
580
580
* Save a copy of the minimum key for the new page. We have to copy
581
581
* it off the old page, not the new one, in case we are not at leaf
582
582
* level.
583
- * If tuple contains non-key attributes, truncate them.
584
- * We perform truncation only for leaf pages,
585
- * beacuse all tuples at inner pages will be already
586
- * truncated by the time we handle them.
583
+ * Despite oitup is already initialized, it's important to get high
584
+ * key from the page, since we could have replaced it with truncated
585
+ * copy. See comment above.
587
586
*/
588
- if (indnkeyatts != indnatts && P_ISLEAF (opageop ))
589
- state -> btps_minkey = index_truncate_tuple (wstate -> index ,oitup );
590
- else
591
- state -> btps_minkey = CopyIndexTuple (oitup );
587
+ oitup = (IndexTuple )PageGetItem (opage ,PageGetItemId (opage ,P_HIKEY ));
588
+ state -> btps_minkey = CopyIndexTuple (oitup );
592
589
593
590
/*
594
591
* Set the sibling links for both pages.