@@ -3443,7 +3443,11 @@ comparetup_cluster(const SortTuple *a, const SortTuple *b,
34433443 int32 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
34463449 if (state -> indexInfo -> ii_KeyAttrNumbers [0 ] != 0 )
3450+ #endif
34473451 {
34483452 compare = inlineApplySortFunction (& scanKey -> sk_func , scanKey -> sk_flags ,
34493453 scanKey -> sk_collation ,
@@ -3472,7 +3476,11 @@ comparetup_cluster(const SortTuple *a, const SortTuple *b,
34723476
34733477 for (; nkey < state -> nKeys ; nkey ++ , scanKey ++ )
34743478 {
3479+ #if PG_VERSION_NUM >= 110000
3480+ AttrNumber attno = state -> indexInfo -> ii_IndexAttrNumbers [nkey ];
3481+ #else
34753482 AttrNumber attno = state -> indexInfo -> ii_KeyAttrNumbers [nkey ];
3483+ #endif
34763484 Datum datum1 ,
34773485 datum2 ;
34783486 bool isnull1 ,
@@ -3538,15 +3546,20 @@ static void
35383546copytup_cluster (RumTuplesortstate * state , SortTuple * stup , void * tup )
35393547{
35403548 HeapTuple 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 */
35433556 tuple = heap_copytuple (tuple );
35443557 stup -> tuple = (void * ) tuple ;
35453558 USEMEM (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 )
35483561 stup -> datum1 = heap_getattr (tuple ,
3549- state -> indexInfo -> ii_KeyAttrNumbers [ 0 ] ,
3562+ attno ,
35503563 state -> tupDesc ,
35513564 & stup -> isnull1 );
35523565}
@@ -3578,6 +3591,11 @@ readtup_cluster(RumTuplesortstate *state, SortTuple *stup,
35783591{
35793592 unsigned int t_len = tuplen - sizeof (ItemPointerData ) - sizeof (int );
35803593 HeapTuple 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
35823600 USEMEM (state , GetMemoryChunkSpace (tuple ));
35833601 /* Reconstruct the HeapTupleData header */
@@ -3595,9 +3613,9 @@ readtup_cluster(RumTuplesortstate *state, SortTuple *stup,
35953613 & tuplen , sizeof (tuplen ));
35963614 stup -> 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 )
35993617 stup -> datum1 = heap_getattr (tuple ,
3600- state -> indexInfo -> ii_KeyAttrNumbers [ 0 ] ,
3618+ attno ,
36013619 state -> tupDesc ,
36023620 & stup -> isnull1 );
36033621}
0 commit comments