~ubuntu-branches/ubuntu/trusty/postgresql-8.4/trusty

« back to all changes in this revision

Viewing changes to src/backend/access/gist/gistget.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-07-11 16:59:35 UTC
  • mfrom: (5.1.1 karmic)
  • Revision ID: james.westby@ubuntu.com-20090711165935-jfwin6gfrxf0gfsi
Tags: 8.4.0-2
* debian/libpq-dev.install: Ship catalog/genbki.h. (Closes: #536139)
* debian/rules: Drop --enable-cassert for final release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 * Portions Copyright (c) 1994, Regents of the University of California
9
9
 *
10
10
 * IDENTIFICATION
11
 
 *        $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.80 2009/01/01 17:23:35 momjian Exp $
 
11
 *        $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.81 2009/06/11 14:48:53 momjian Exp $
12
12
 *
13
13
 *-------------------------------------------------------------------------
14
14
 */
79
79
 
80
80
        so = (GISTScanOpaque) scan->opaque;
81
81
 
82
 
    if (dir != ForwardScanDirection)
 
82
        if (dir != ForwardScanDirection)
83
83
                elog(ERROR, "GiST doesn't support other scan directions than forward");
84
84
 
85
85
        /*
101
101
gistgetbitmap(PG_FUNCTION_ARGS)
102
102
{
103
103
        IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
104
 
        TIDBitmap *tbm = (TIDBitmap *) PG_GETARG_POINTER(1);
105
 
        int64      ntids;
 
104
        TIDBitmap  *tbm = (TIDBitmap *) PG_GETARG_POINTER(1);
 
105
        int64           ntids;
106
106
 
107
107
        ntids = gistnext(scan, tbm);
108
108
 
136
136
 
137
137
        so = (GISTScanOpaque) scan->opaque;
138
138
 
139
 
        if ( so->qual_ok == false )
 
139
        if (so->qual_ok == false)
140
140
                return 0;
141
141
 
142
 
        if ( so->curbuf == InvalidBuffer ) 
 
142
        if (so->curbuf == InvalidBuffer)
143
143
        {
144
144
                if (ItemPointerIsValid(&so->curpos) == false)
145
145
                {
155
155
                        stk->block = GIST_ROOT_BLKNO;
156
156
 
157
157
                        pgstat_count_index_scan(scan->indexRelation);
158
 
                } 
 
158
                }
159
159
                else
160
160
                {
161
161
                        /* scan is finished */
164
164
        }
165
165
 
166
166
        /*
167
 
         * check stored pointers from last visit 
 
167
         * check stored pointers from last visit
168
168
         */
169
 
        if ( so->nPageData > 0 ) 
 
169
        if (so->nPageData > 0)
170
170
        {
171
171
                /*
172
172
                 * gistgetmulti never should go here
173
173
                 */
174
 
                Assert( tbm == NULL );
 
174
                Assert(tbm == NULL);
175
175
 
176
 
                if ( so->curPageData < so->nPageData )
 
176
                if (so->curPageData < so->nPageData)
177
177
                {
178
 
                        scan->xs_ctup.t_self = so->pageData[ so->curPageData ].heapPtr;
179
 
                        scan->xs_recheck = so->pageData[ so->curPageData ].recheck;
 
178
                        scan->xs_ctup.t_self = so->pageData[so->curPageData].heapPtr;
 
179
                        scan->xs_recheck = so->pageData[so->curPageData].recheck;
180
180
 
181
181
                        ItemPointerSet(&so->curpos,
182
 
                                                        BufferGetBlockNumber(so->curbuf),
183
 
                                                        so->pageData[ so->curPageData ].pageOffset);
 
182
                                                   BufferGetBlockNumber(so->curbuf),
 
183
                                                   so->pageData[so->curPageData].pageOffset);
184
184
 
185
 
                        so->curPageData ++;
 
185
                        so->curPageData++;
186
186
 
187
187
                        return 1;
188
188
                }
227
227
                if (!XLogRecPtrIsInvalid(so->stack->parentlsn) &&
228
228
                        XLByteLT(so->stack->parentlsn, opaque->nsn) &&
229
229
                        opaque->rightlink != InvalidBlockNumber /* sanity check */ &&
230
 
                        (so->stack->next == NULL || so->stack->next->block != opaque->rightlink)                /* check if already
 
230
                        (so->stack->next == NULL || so->stack->next->block != opaque->rightlink)        /* check if already
231
231
                                added */ )
232
232
                {
233
233
                        /* detect page split, follow right link to add pages */
272
272
                        if (!OffsetNumberIsValid(n))
273
273
                        {
274
274
                                /*
275
 
                                 * If we was called from gistgettuple and current buffer contains
276
 
                                 * something matched then make a recursive call - it will return
277
 
                                 * ItemPointer from so->pageData. But we save buffer pinned to 
278
 
                                 * support tuple's killing
 
275
                                 * If we was called from gistgettuple and current buffer
 
276
                                 * contains something matched then make a recursive call - it
 
277
                                 * will return ItemPointer from so->pageData. But we save
 
278
                                 * buffer pinned to support tuple's killing
279
279
                                 */
280
 
                                if ( !tbm && so->nPageData > 0 )
 
280
                                if (!tbm && so->nPageData > 0)
281
281
                                {
282
282
                                        LockBuffer(so->curbuf, GIST_UNLOCK);
283
283
                                        return gistnext(scan, NULL);
324
324
                                        ntids++;
325
325
                                        if (tbm != NULL)
326
326
                                                tbm_add_tuples(tbm, &it->t_tid, 1, scan->xs_recheck);
327
 
                                        else 
 
327
                                        else
328
328
                                        {
329
 
                                                so->pageData[ so->nPageData ].heapPtr = it->t_tid;
330
 
                                                so->pageData[ so->nPageData ].pageOffset = n;
331
 
                                                so->pageData[ so->nPageData ].recheck = scan->xs_recheck;
332
 
                                                so->nPageData ++;
 
329
                                                so->pageData[so->nPageData].heapPtr = it->t_tid;
 
330
                                                so->pageData[so->nPageData].pageOffset = n;
 
331
                                                so->pageData[so->nPageData].recheck = scan->xs_recheck;
 
332
                                                so->nPageData++;
333
333
                                        }
334
334
                                }
335
335
                        }
437
437
                        /*
438
438
                         * Call the Consistent function to evaluate the test.  The
439
439
                         * arguments are the index datum (as a GISTENTRY*), the comparison
440
 
                         * datum, the comparison operator's strategy number and
441
 
                         * subtype from pg_amop, and the recheck flag.
 
440
                         * datum, the comparison operator's strategy number and subtype
 
441
                         * from pg_amop, and the recheck flag.
442
442
                         *
443
443
                         * (Presently there's no need to pass the subtype since it'll
444
444
                         * always be zero, but might as well pass it for possible future