From 52f0fc703f024555b58eac3dbf08c3a78de13263 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 5 Jun 2009 18:50:47 +0000 Subject: [PATCH] GIN's ItemPointerIsMin, ItemPointerIsMax, and ItemPointerIsLossyPage macros should use GinItemPointerGetBlockNumber/GinItemPointerGetOffsetNumber, not ItemPointerGetBlockNumber/ItemPointerGetOffsetNumber, because the latter will Assert() on ip_posid == 0, ie a "Min" pointer. (Thus, ItemPointerIsMin has never worked at all, but it seems unused at present.) I'm not certain that the case can occur in normal functioning, but it's blowing up on me while investigating Tatsuo-san's data corruption problem. In any case it seems like a problem waiting to bite someone. Back-patch just in case this really is a problem for somebody in the field. --- src/include/access/gin.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/include/access/gin.h b/src/include/access/gin.h index 4a4abc1cd2..49a14b6290 100644 --- a/src/include/access/gin.h +++ b/src/include/access/gin.h @@ -4,7 +4,7 @@ * * Copyright (c) 2006-2009, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/include/access/gin.h,v 1.31 2009/03/25 22:19:01 tgl Exp $ + * $PostgreSQL: pgsql/src/include/access/gin.h,v 1.32 2009/06/05 18:50:47 tgl Exp $ *-------------------------------------------------------------------------- */ #ifndef GIN_H @@ -124,18 +124,18 @@ typedef struct GinMetaPageData #define ItemPointerSetMin(p) \ ItemPointerSet((p), (BlockNumber)0, (OffsetNumber)0) #define ItemPointerIsMin(p) \ - (ItemPointerGetOffsetNumber(p) == (OffsetNumber)0 && \ - ItemPointerGetBlockNumber(p) == (BlockNumber)0) + (GinItemPointerGetOffsetNumber(p) == (OffsetNumber)0 && \ + GinItemPointerGetBlockNumber(p) == (BlockNumber)0) #define ItemPointerSetMax(p) \ ItemPointerSet((p), InvalidBlockNumber, (OffsetNumber)0xffff) #define ItemPointerIsMax(p) \ - (ItemPointerGetOffsetNumber(p) == (OffsetNumber)0xffff && \ - ItemPointerGetBlockNumber(p) == InvalidBlockNumber) + (GinItemPointerGetOffsetNumber(p) == (OffsetNumber)0xffff && \ + GinItemPointerGetBlockNumber(p) == InvalidBlockNumber) #define ItemPointerSetLossyPage(p, b) \ ItemPointerSet((p), (b), (OffsetNumber)0xffff) #define ItemPointerIsLossyPage(p) \ - (ItemPointerGetOffsetNumber(p) == (OffsetNumber)0xffff && \ - ItemPointerGetBlockNumber(p) != InvalidBlockNumber) + (GinItemPointerGetOffsetNumber(p) == (OffsetNumber)0xffff && \ + GinItemPointerGetBlockNumber(p) != InvalidBlockNumber) typedef struct {