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

« back to all changes in this revision

Viewing changes to src/backend/access/hash/hash.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-07-01 17:41:41 UTC
  • mfrom: (1.1.4 upstream)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20090701174141-jfmn9tt8e69m950x
Tags: 8.4.0-1
* Final 8.4.0 release. Major enhancements:
  - Windowing Functions
  - Common Table Expressions and Recursive Queries
  - Default and variadic parameters for functions
  - Parallel Restore
  - Column Permissions
  - Per-database locale settings
  - Improved hash indexes
  - Improved join performance for EXISTS and NOT EXISTS queries
  - Easier-to-use Warm Standby
  - Automatic sizing of the Free Space Map
  - Visibility Map (greatly reduces vacuum overhead for slowly-changing
    tables)
  - Version-aware psql (backslash commands work against older servers)
  - Support SSL certificates for user authentication
  - Per-function runtime statistics
  - Easy editing of functions in psql
  - New contrib modules: pg_stat_statements, auto_explain, citext,
    btree_gin 
  Upload to unstable, 8.4 is the new default. 
* debian/control: Build the versionless metapackages and have them point to
  8.4.

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/hash.c,v 1.110 2009/05/05 19:36:32 tgl Exp $
 
11
 *        $PostgreSQL: pgsql/src/backend/access/hash/hash.c,v 1.112 2009/06/11 14:48:53 momjian Exp $
12
12
 *
13
13
 * NOTES
14
14
 *        This file contains only the public interface routines.
52
52
        Relation        index = (Relation) PG_GETARG_POINTER(1);
53
53
        IndexInfo  *indexInfo = (IndexInfo *) PG_GETARG_POINTER(2);
54
54
        IndexBuildResult *result;
55
 
        BlockNumber     relpages;
 
55
        BlockNumber relpages;
56
56
        double          reltuples;
57
57
        uint32          num_buckets;
58
58
        HashBuildState buildstate;
76
76
         * (assuming their hash codes are pretty random) there will be no locality
77
77
         * of access to the index, and if the index is bigger than available RAM
78
78
         * then we'll thrash horribly.  To prevent that scenario, we can sort the
79
 
         * tuples by (expected) bucket number.  However, such a sort is useless
 
79
         * tuples by (expected) bucket number.  However, such a sort is useless
80
80
         * overhead when the index does fit in RAM.  We choose to sort if the
81
81
         * initial index size exceeds NBuffers.
82
82
         *
83
 
         * NOTE: this test will need adjustment if a bucket is ever different
84
 
         * from one page.
 
83
         * NOTE: this test will need adjustment if a bucket is ever different from
 
84
         * one page.
85
85
         */
86
86
        if (num_buckets >= (uint32) NBuffers)
87
87
                buildstate.spool = _h_spoolinit(index, num_buckets);
285
285
hashgetbitmap(PG_FUNCTION_ARGS)
286
286
{
287
287
        IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
288
 
        TIDBitmap *tbm = (TIDBitmap *) PG_GETARG_POINTER(1);
 
288
        TIDBitmap  *tbm = (TIDBitmap *) PG_GETARG_POINTER(1);
289
289
        HashScanOpaque so = (HashScanOpaque) scan->opaque;
290
290
        bool            res;
291
291
        int64           ntids = 0;
294
294
 
295
295
        while (res)
296
296
        {
297
 
                bool    add_tuple;
 
297
                bool            add_tuple;
298
298
 
299
299
                /*
300
300
                 * Skip killed tuples if asked to.
312
312
                        add_tuple = true;
313
313
 
314
314
                /* Save tuple ID, and continue scanning */
315
 
                if (add_tuple) 
 
315
                if (add_tuple)
316
316
                {
317
317
                        /* Note we mark the tuple ID as requiring recheck */
318
318
                        tbm_add_tuples(tbm, &scan->xs_ctup.t_self, 1, true);
481
481
         * each bucket.
482
482
         */
483
483
        metabuf = _hash_getbuf(rel, HASH_METAPAGE, HASH_READ, LH_META_PAGE);
484
 
        metap =  HashPageGetMeta(BufferGetPage(metabuf));
 
484
        metap = HashPageGetMeta(BufferGetPage(metabuf));
485
485
        orig_maxbucket = metap->hashm_maxbucket;
486
486
        orig_ntuples = metap->hashm_ntuples;
487
487
        memcpy(&local_metapage, metap, sizeof(local_metapage));
610
610
                /*
611
611
                 * Otherwise, our count is untrustworthy since we may have
612
612
                 * double-scanned tuples in split buckets.      Proceed by dead-reckoning.
 
613
                 * (Note: we still return estimated_count = false, because using this
 
614
                 * count is better than not updating reltuples at all.)
613
615
                 */
614
616
                if (metap->hashm_ntuples > tuples_removed)
615
617
                        metap->hashm_ntuples -= tuples_removed;
623
625
        /* return statistics */
624
626
        if (stats == NULL)
625
627
                stats = (IndexBulkDeleteResult *) palloc0(sizeof(IndexBulkDeleteResult));
 
628
        stats->estimated_count = false;
626
629
        stats->num_index_tuples = num_index_tuples;
627
630
        stats->tuples_removed += tuples_removed;
628
631
        /* hashvacuumcleanup will fill in num_pages */