X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D0B1F475B85 for ; Wed, 26 Feb 2003 10:59:02 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 80355-03 for ; Wed, 26 Feb 2003 10:58:47 -0500 (EST) Received: from nycsmtp2out.rdc-nyc.rr.com (nycsmtp2out.rdc-nyc.rr.com [24.29.99.223]) by postgresql.org (Postfix) with ESMTP id BD123475AF8 for ; Wed, 26 Feb 2003 10:54:58 -0500 (EST) Received: from math-hat.com (66-65-68-135.nyc.rr.com [66.65.68.135]) by nycsmtp2out.rdc-nyc.rr.com (8.12.1/Road Runner SMTP Server 1.0) with SMTP id h1QFnCBe002617 for ; Wed, 26 Feb 2003 10:49:12 -0500 (EST) Received: (nullmailer pid 22275 invoked by uid 1000); Wed, 26 Feb 2003 15:54:59 -0000 To: pgsql-sql@postgresql.org Subject: Re: OffsetNumber, picksplit, and GiST Mail-Copies-To: never From: Itai Zukerman Date: Wed, 26 Feb 2003 10:54:59 -0500 In-Reply-To: <87bs0z1zzs.fsf@matt.w80.math-hat.com> (Itai Zukerman's message of "Tue, 25 Feb 2003 22:29:11 -0500") Message-ID: <87lm03ghpo.fsf@matt.w80.math-hat.com> User-Agent: Gnus/5.090015 (Oort Gnus v0.15) Emacs/21.2 References: <87bs0z1zzs.fsf@matt.w80.math-hat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new X-Archive-Number: 200302/584 X-Sequence-Number: 11982 > 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