@@ -530,7 +530,6 @@ extern void ginEntryFillRoot(GinBtree btree, Buffer root, Buffer lbuf, Buffer rb
530530extern IndexTuple ginPageGetLinkItup (Buffer buf );
531531
532532/* gindatapage.c */
533- extern int ginCompareItemPointers (ItemPointer a , ItemPointer b );
534533extern uint32 ginMergeItemPointers (ItemPointerData * dst ,
535534 ItemPointerData * a , uint32 na ,
536535 ItemPointerData * b , uint32 nb );
@@ -724,4 +723,28 @@ extern void ginHeapTupleFastCollect(GinState *ginstate,
724723extern void ginInsertCleanup (GinState * ginstate ,
725724 bool vac_delay , IndexBulkDeleteResult * stats );
726725
726+ /*
727+ * Merging the results of several gin scans compares item pointers a lot,
728+ * so we want this to be inlined. But if the compiler doesn't support that,
729+ * fall back on the non-inline version from itemptr.c. See STATIC_IF_INLINE in
730+ * c.h.
731+ */
732+ #ifdef PG_USE_INLINE
733+ static inline int
734+ ginCompareItemPointers (ItemPointer a , ItemPointer b )
735+ {
736+ uint64 ia = (uint64 ) a -> ip_blkid .bi_hi << 32 | (uint64 ) a -> ip_blkid .bi_lo << 16 | a -> ip_posid ;
737+ uint64 ib = (uint64 ) b -> ip_blkid .bi_hi << 32 | (uint64 ) b -> ip_blkid .bi_lo << 16 | b -> ip_posid ;
738+
739+ if (ia == ib )
740+ return 0 ;
741+ else if (ia > ib )
742+ return 1 ;
743+ else
744+ return -1 ;
745+ }
746+ #else
747+ #define ginCompareItemPointers (a , b ) ItemPointerCompare(a, b)
748+ #endif /* PG_USE_INLINE */
749+
727750#endif /* GIN_PRIVATE_H */
0 commit comments