@@ -3443,7 +3443,11 @@ comparetup_cluster(const SortTuple *a, const SortTuple *b,
34433443int32 compare ;
34443444
34453445/* Compare the leading sort key, if it's simple */
3446+ #if PG_VERSION_NUM >=110000
3447+ if (state -> indexInfo -> ii_IndexAttrNumbers [0 ]!= 0 )
3448+ #else
34463449if (state -> indexInfo -> ii_KeyAttrNumbers [0 ]!= 0 )
3450+ #endif
34473451{
34483452compare = inlineApplySortFunction (& scanKey -> sk_func ,scanKey -> sk_flags ,
34493453scanKey -> sk_collation ,
@@ -3472,7 +3476,11 @@ comparetup_cluster(const SortTuple *a, const SortTuple *b,
34723476
34733477for (;nkey < state -> nKeys ;nkey ++ ,scanKey ++ )
34743478{
3479+ #if PG_VERSION_NUM >=110000
3480+ AttrNumber attno = state -> indexInfo -> ii_IndexAttrNumbers [nkey ];
3481+ #else
34753482AttrNumber attno = state -> indexInfo -> ii_KeyAttrNumbers [nkey ];
3483+ #endif
34763484Datum datum1 ,
34773485datum2 ;
34783486bool isnull1 ,
@@ -3538,15 +3546,20 @@ static void
35383546copytup_cluster (RumTuplesortstate * state ,SortTuple * stup ,void * tup )
35393547{
35403548HeapTuple tuple = (HeapTuple )tup ;
3549+ #if PG_VERSION_NUM >=110000
3550+ AttrNumber attno = state -> indexInfo -> ii_IndexAttrNumbers [0 ];
3551+ #else
3552+ AttrNumber attno = state -> indexInfo -> ii_KeyAttrNumbers [0 ];
3553+ #endif
35413554
35423555/* copy the tuple into sort storage */
35433556tuple = heap_copytuple (tuple );
35443557stup -> tuple = (void * )tuple ;
35453558USEMEM (state ,GetMemoryChunkSpace (tuple ));
35463559/* set up first-column key value, if it's a simple column */
3547- if (state -> indexInfo -> ii_KeyAttrNumbers [ 0 ] != 0 )
3560+ if (attno != 0 )
35483561stup -> datum1 = heap_getattr (tuple ,
3549- state -> indexInfo -> ii_KeyAttrNumbers [ 0 ] ,
3562+ attno ,
35503563state -> tupDesc ,
35513564& stup -> isnull1 );
35523565}
@@ -3578,6 +3591,11 @@ readtup_cluster(RumTuplesortstate *state, SortTuple *stup,
35783591{
35793592unsignedint t_len = tuplen - sizeof (ItemPointerData )- sizeof (int );
35803593HeapTuple tuple = (HeapTuple )palloc (t_len + HEAPTUPLESIZE );
3594+ #if PG_VERSION_NUM >=110000
3595+ AttrNumber attno = state -> indexInfo -> ii_IndexAttrNumbers [0 ];
3596+ #else
3597+ AttrNumber attno = state -> indexInfo -> ii_KeyAttrNumbers [0 ];
3598+ #endif
35813599
35823600USEMEM (state ,GetMemoryChunkSpace (tuple ));
35833601/* Reconstruct the HeapTupleData header */
@@ -3595,9 +3613,9 @@ readtup_cluster(RumTuplesortstate *state, SortTuple *stup,
35953613& tuplen ,sizeof (tuplen ));
35963614stup -> tuple = (void * )tuple ;
35973615/* set up first-column key value, if it's a simple column */
3598- if (state -> indexInfo -> ii_KeyAttrNumbers [ 0 ] != 0 )
3616+ if (attno != 0 )
35993617stup -> datum1 = heap_getattr (tuple ,
3600- state -> indexInfo -> ii_KeyAttrNumbers [ 0 ] ,
3618+ attno ,
36013619state -> tupDesc ,
36023620& stup -> isnull1 );
36033621}