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

« back to all changes in this revision

Viewing changes to src/backend/access/hash/hashpage.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
 *
9
9
 *
10
10
 * IDENTIFICATION
11
 
 *        $PostgreSQL: pgsql/src/backend/access/hash/hashpage.c,v 1.79 2009/01/01 17:23:35 momjian Exp $
 
11
 *        $PostgreSQL: pgsql/src/backend/access/hash/hashpage.c,v 1.80 2009/06/11 14:48:53 momjian Exp $
12
12
 *
13
13
 * NOTES
14
14
 *        Postgres hash pages look like ordinary relation pages.  The opaque
361
361
        /*
362
362
         * Choose the number of initial bucket pages to match the fill factor
363
363
         * given the estimated number of tuples.  We round up the result to the
364
 
         * next power of 2, however, and always force at least 2 bucket pages.
365
 
         * The upper limit is determined by considerations explained in
 
364
         * next power of 2, however, and always force at least 2 bucket pages. The
 
365
         * upper limit is determined by considerations explained in
366
366
         * _hash_expandtable().
367
367
         */
368
368
        dnumbuckets = num_tuples / ffactor;
421
421
 
422
422
        /*
423
423
         * We initialize the index with N buckets, 0 .. N-1, occupying physical
424
 
         * blocks 1 to N.  The first freespace bitmap page is in block N+1.
425
 
         * Since N is a power of 2, we can set the masks this way:
 
424
         * blocks 1 to N.  The first freespace bitmap page is in block N+1. Since
 
425
         * N is a power of 2, we can set the masks this way:
426
426
         */
427
427
        metap->hashm_maxbucket = metap->hashm_lowmask = num_buckets - 1;
428
428
        metap->hashm_highmask = (num_buckets << 1) - 1;
438
438
        /*
439
439
         * Release buffer lock on the metapage while we initialize buckets.
440
440
         * Otherwise, we'll be in interrupt holdoff and the CHECK_FOR_INTERRUPTS
441
 
         * won't accomplish anything.  It's a bad idea to hold buffer locks
442
 
         * for long intervals in any case, since that can block the bgwriter.
 
441
         * won't accomplish anything.  It's a bad idea to hold buffer locks for
 
442
         * long intervals in any case, since that can block the bgwriter.
443
443
         */
444
444
        _hash_chgbufaccess(rel, metabuf, HASH_WRITE, HASH_NOLOCK);
445
445
 
552
552
         * _hash_alloc_buckets() would fail, but if we supported buckets smaller
553
553
         * than a disk block then this would be an independent constraint.
554
554
         *
555
 
         * If you change this, see also the maximum initial number of buckets
556
 
         * in _hash_metapinit().
 
555
         * If you change this, see also the maximum initial number of buckets in
 
556
         * _hash_metapinit().
557
557
         */
558
558
        if (metap->hashm_maxbucket >= (uint32) 0x7FFFFFFE)
559
559
                goto fail;
839
839
                }
840
840
 
841
841
                /*
842
 
                 * Fetch the item's hash key (conveniently stored in the item)
843
 
                 * and determine which bucket it now belongs in.
 
842
                 * Fetch the item's hash key (conveniently stored in the item) and
 
843
                 * determine which bucket it now belongs in.
844
844
                 */
845
845
                itup = (IndexTuple) PageGetItem(opage, PageGetItemId(opage, ooffnum));
846
846
                bucket = _hash_hashkey2bucket(_hash_get_indextuple_hashkey(itup),