~ubuntu-branches/ubuntu/natty/postgresql-8.4/natty-security

« back to all changes in this revision

Viewing changes to src/backend/access/gist/gistsplit.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/gistsplit.c,v 1.8 2009/04/06 14:27:27 teodor Exp $
 
11
 *        $PostgreSQL: pgsql/src/backend/access/gist/gistsplit.c,v 1.11 2009/06/24 15:16:22 petere Exp $
12
12
 *
13
13
 *-------------------------------------------------------------------------
14
14
 */
281
281
}
282
282
 
283
283
/*
284
 
 * Trivial picksplit implementaion. Function called only 
 
284
 * Trivial picksplit implementaion. Function called only
285
285
 * if user-defined picksplit puts all keys to the one page.
286
286
 * That is a bug of user-defined picksplit but we'd like
287
287
 * to "fix" that.
289
289
static void
290
290
genericPickSplit(GISTSTATE *giststate, GistEntryVector *entryvec, GIST_SPLITVEC *v, int attno)
291
291
{
292
 
        OffsetNumber     i,
293
 
                                         maxoff;
294
 
        int                              nbytes;
295
 
        GistEntryVector *evec;
 
292
        OffsetNumber i,
 
293
                                maxoff;
 
294
        int                     nbytes;
 
295
        GistEntryVector *evec;
296
296
 
297
297
        maxoff = entryvec->n - 1;
298
298
 
320
320
         * Form unions of each page
321
321
         */
322
322
 
323
 
        evec = palloc( sizeof(GISTENTRY) * entryvec->n + GEVHDRSZ );
 
323
        evec = palloc(sizeof(GISTENTRY) * entryvec->n + GEVHDRSZ);
324
324
 
325
325
        evec->n = v->spl_nleft;
326
 
        memcpy(evec->vector, entryvec->vector + FirstOffsetNumber, 
327
 
                                                 sizeof(GISTENTRY) * evec->n);
328
 
    v->spl_ldatum = FunctionCall2(&giststate->unionFn[attno],
329
 
                                                                        PointerGetDatum(evec),
330
 
                                                                        PointerGetDatum(&nbytes));
 
326
        memcpy(evec->vector, entryvec->vector + FirstOffsetNumber,
 
327
                   sizeof(GISTENTRY) * evec->n);
 
328
        v->spl_ldatum = FunctionCall2(&giststate->unionFn[attno],
 
329
                                                                  PointerGetDatum(evec),
 
330
                                                                  PointerGetDatum(&nbytes));
331
331
 
332
332
        evec->n = v->spl_nright;
333
 
        memcpy(evec->vector, entryvec->vector + FirstOffsetNumber + v->spl_nleft, 
334
 
                                                 sizeof(GISTENTRY) * evec->n);
335
 
    v->spl_rdatum = FunctionCall2(&giststate->unionFn[attno],
336
 
                                                                        PointerGetDatum(evec),
337
 
                                                                        PointerGetDatum(&nbytes));
 
333
        memcpy(evec->vector, entryvec->vector + FirstOffsetNumber + v->spl_nleft,
 
334
                   sizeof(GISTENTRY) * evec->n);
 
335
        v->spl_rdatum = FunctionCall2(&giststate->unionFn[attno],
 
336
                                                                  PointerGetDatum(evec),
 
337
                                                                  PointerGetDatum(&nbytes));
338
338
}
339
339
 
340
340
/*
365
365
                                  PointerGetDatum(entryvec),
366
366
                                  PointerGetDatum(sv));
367
367
 
368
 
        if ( sv->spl_nleft == 0 || sv->spl_nright == 0 )
 
368
        if (sv->spl_nleft == 0 || sv->spl_nright == 0)
369
369
        {
370
370
                ereport(DEBUG1,
371
371
                                (errcode(ERRCODE_INTERNAL_ERROR),
372
 
                                 errmsg("Picksplit method for %d column of index \"%s\" failed",
373
 
                                                                                        attno+1, RelationGetRelationName(r)),
374
 
                                 errhint("Index is not optimal, to optimize it contact developer or try to use the column as a second one in create index command")));
 
372
                          errmsg("picksplit method for column %d of index \"%s\" failed",
 
373
                                         attno + 1, RelationGetRelationName(r)),
 
374
                                 errhint("The index is not optimal. To optimize it, contact a developer, or try to use the column as the second one in the CREATE INDEX command.")));
375
375
 
376
376
                /*
377
 
                 * Reinit GIST_SPLITVEC. Although that fields are not used
378
 
                 * by genericPickSplit(), let us set up it for further processing 
 
377
                 * Reinit GIST_SPLITVEC. Although that fields are not used by
 
378
                 * genericPickSplit(), let us set up it for further processing
379
379
                 */
380
380
                sv->spl_ldatum_exists = (v->spl_lisnull[attno]) ? false : true;
381
381
                sv->spl_rdatum_exists = (v->spl_risnull[attno]) ? false : true;
397
397
 
398
398
                if (sv->spl_ldatum_exists || sv->spl_rdatum_exists)
399
399
                {
400
 
                        elog(LOG, "PickSplit method of %d columns of index '%s' doesn't support secondary split",
 
400
                        elog(LOG, "picksplit method for column %d of index \"%s\" doesn't support secondary split",
401
401
                                 attno + 1, RelationGetRelationName(r));
402
402
 
403
403
                        supportSecondarySplit(r, giststate, attno, sv, v->spl_lattr[attno], v->spl_rattr[attno]);