Re: Documentation of bt_page_items()'s ctid field - Mailing list pgsql-hackers

From Jeff Janes
Subject Re: Documentation of bt_page_items()'s ctid field
Date
Msg-id CAMkU=1w5YE8-n_QyLNPxnYuR7p-a-5+v_Y0p_CfDko+DTqs8bA@mail.gmail.com
Whole thread Raw
In response to Re: Documentation of bt_page_items()'s ctid field  (Peter Geoghegan <pg@heroku.com>)
Responses Re: Documentation of bt_page_items()'s ctid field
List pgsql-hackers

On Mon, Mar 9, 2015 at 4:06 PM, Peter Geoghegan <pg@heroku.com> wrote:
On Mon, Mar 9, 2015 at 3:51 PM, Jeff Janes <jeff.janes@gmail.com> wrote:
> How do I know if I am looking at a non-rightmost page?

It has a right-link (that's the easiest way to tell).

Meaning that btpo_next is not zero?  Should we say that in the patch in so many words?  I think it will be hard to explain the page_items more without also explaining the page_stats more.

 
It will (as the
docpatch points out) also necessarily have a ""high key" item.  We
know that we have to move right if the high key doesn't bound the
value we expected to find on the page (our scankey item - what the
index scan is searching for). So the high key goes with having a
rightlink, and in general we detect that we're looking at a
non-rightmost page based on the presence of a right-link.

So if I understand this correctly, if there is a high key it is itemoffset 1, but to know whether itemoffset 1 is a high key I first have to look at btpo_next.

And if there is a minus infinity, it will either be itemoffset 2 or 1, depending on whether there is a high key or not.

Thanks,

Jeff

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: BRIN page type identifier
Next
From: Peter Geoghegan
Date:
Subject: Re: Documentation of bt_page_items()'s ctid field