pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Itai Zukerman <zukerman@math-hat.com>
To: pgsql-sql@postgresql.org
Subject: Re: OffsetNumber, picksplit, and GiST
Date: Wed, 26 Feb 2003 10:54:59 -0500
Message-ID: <87lm03ghpo.fsf@matt.w80.math-hat.com> (raw)
In-Reply-To: <87bs0z1zzs.fsf@matt.w80.math-hat.com>
References: <87bs0z1zzs.fsf@matt.w80.math-hat.com>

> Is the GiST examples I've looked through, in the picksplit functions,
> I see code that looks roughly like this:
>
>   bytea *entryvec = (bytea *) PG_GETARG_POINTER(0);
>   OffsetNumber i, maxoff;
>
>   maxoff = ((VARSIZE(entryvec) - VARHDRSZ) / sizeof(GISTENTRY)) - 1;
>
>   for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i))
>     {
>       ... DatumGetPointer((((GISTENTRY *) (VARDATA(entryvec)))[i].key)) ...
>     }
>
> I'm wondering, since FirstOffsetNumber is 1, what about the 0'th index
> in entryvec?  Is it just not set?

In backend/access/gist/gist.c I see how entryvec is built:

   storage = palloc(MAXALIGN(VARHDRSZ) + (*len + 1) * sizeof(GISTENTRY));
   entryvec = (bytea *) (storage + MAXALIGN(VARHDRSZ) - VARHDRSZ);
   decompvec = (bool *) palloc((*len + 1) * sizeof(bool));
   VARATT_SIZEP(entryvec) = (*len + 1) * sizeof(GISTENTRY) + VARHDRSZ;
   for (i = 1; i <= *len; i++)
   {
     [...] gistdentryinit(giststate, 0, &((GISTENTRY *) VARDATA(entryvec))[i], [...]
   }

So it looks like the 0'th entry indeed is empty.  Why?

Also, in gist.c the index "i" has type "int".  No mention of
OffsetNumber anywhere.  Any reason for that?

Finally, should I be asking this on pgsql-hackers?

-- 
Itai Zukerman  <http://www.math-hat.com/~zukerman/;



view thread (2+ messages)

Message-ID: <87lm03ghpo.fsf@matt.w80.math-hat.com>
Permalink:  ../87lm03ghpo.fsf@matt.w80.math-hat.com/
Also on:    postgresql.org/message-id/87lm03ghpo.fsf@matt.w80.math-hat.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: zukerman@math-hat.com
  Subject: Re: OffsetNumber, picksplit, and GiST
  In-Reply-To: <87lm03ghpo.fsf@matt.w80.math-hat.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox