Re: HOT latest patch - version 8 - Mailing list pgsql-patches

From Heikki Linnakangas
Subject Re: HOT latest patch - version 8
Date
Msg-id 469937EA.8030604@enterprisedb.com
Whole thread Raw
In response to Re: HOT latest patch - version 8  (Stefan Kaltenbrunner <stefan@kaltenbrunner.cc>)
Responses Re: HOT latest patch - version 8
Re: HOT latest patch - version 8
List pgsql-patches
Stefan Kaltenbrunner wrote:
> tried to test a bit on my Solaris 10 install(sun studio , 64bit build)
> but I'm hitting the following while trying to initdb a new cluster:

I can't reproduce this error, but I found a bug that's likely causing
it. The patch uses InvalidOffsetNumber in lp_off to mark so called
"redirect dead" line pointers, but that special case is not checked in
PageGetRedirectingOffset-function, writing to a caller-supplied array
with -1 index instead, globbering over whatever is there. Actually
storing InvalidOffsetNumber in lp_off is a bit bogus in the first place
since lp_off is unsigned, and InvalidOffsetNumber is -1, so I fixed that
as well.

Patch attached.

--
  Heikki Linnakangas
  EnterpriseDB   http://www.enterprisedb.com
*** src/backend/storage/page/bufpage.c    2007-07-14 20:54:04.000000000 +0100
--- src/backend/storage/page/bufpage.c    2007-07-14 20:37:36.000000000 +0100
***************
*** 1180,1186 ****
              continue;

          /* interested in only redirected lps */
!         if (!ItemIdIsRedirected(lp))
              continue;

          offsets[ItemIdGetRedirect(lp) - 1] = offnum;
--- 1180,1186 ----
              continue;

          /* interested in only redirected lps */
!         if (!ItemIdIsRedirected(lp) || ItemIdIsRedirectDead(lp))
              continue;

          offsets[ItemIdGetRedirect(lp) - 1] = offnum;
*** src/include/storage/itemid.h    2007-07-14 20:54:04.000000000 +0100
--- src/include/storage/itemid.h    2007-07-14 20:46:09.000000000 +0100
***************
*** 27,32 ****
--- 27,37 ----
  typedef ItemIdData *ItemId;

  /*
+  * Magic lp_off value to mark "redirect dead" line pointers
+  */
+ #define DeadOffsetNumber        0x7FFF
+
+ /*
   * lp_flags contains these flags:
   */
  #define LP_USED            0x01    /* this line pointer is being used */
***************
*** 127,140 ****
  ( \
      AssertMacro(ItemIdIsValid(itemId)), \
      (bool) ((ItemIdIsRedirected(itemId)) && \
!             (ItemIdGetRedirect(itemId) == InvalidOffsetNumber)) \
  )

  /* Set itemId to redirect-dead i.e. redirected to itself */
  #define ItemIdSetRedirectDead(itemId) \
  ( \
      AssertMacro(ItemIdIsValid(itemId)), \
!     ItemIdSetRedirect((itemId), InvalidOffsetNumber) \
  )

  #endif   /* ITEMID_H */
--- 132,145 ----
  ( \
      AssertMacro(ItemIdIsValid(itemId)), \
      (bool) ((ItemIdIsRedirected(itemId)) && \
!             (ItemIdGetRedirect(itemId) == DeadOffsetNumber)) \
  )

  /* Set itemId to redirect-dead i.e. redirected to itself */
  #define ItemIdSetRedirectDead(itemId) \
  ( \
      AssertMacro(ItemIdIsValid(itemId)), \
!     ItemIdSetRedirect((itemId), DeadOffsetNumber) \
  )

  #endif   /* ITEMID_H */

pgsql-patches by date:

Previous
From: Magnus Hagander
Date:
Subject: Re: GSSAPI support on solaris
Next
From: Stefan Kaltenbrunner
Date:
Subject: Re: HOT latest patch - version 8