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

« back to all changes in this revision

Viewing changes to src/backend/catalog/index.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/catalog/index.c,v 1.315 2009/03/31 22:12:46 tgl Exp $
 
11
 *        $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.318 2009/06/11 14:48:55 momjian Exp $
12
12
 *
13
13
 *
14
14
 * INTERFACE ROUTINES
745
745
                                                                                   NULL,                /* no check constraint */
746
746
                                                                                   NULL,
747
747
                                                                                   NULL,
748
 
                                                                                   true, /* islocal */
749
 
                                                                                   0); /* inhcount */
 
748
                                                                                   true,                /* islocal */
 
749
                                                                                   0);  /* inhcount */
750
750
 
751
751
                        referenced.classId = ConstraintRelationId;
752
752
                        referenced.objectId = conOid;
901
901
 
902
902
        /*
903
903
         * To drop an index safely, we must grab exclusive lock on its parent
904
 
         * table; otherwise there could be other backends using the index!
905
 
         * Exclusive lock on the index alone is insufficient because another
906
 
         * backend might be in the midst of devising a query plan that will use
907
 
         * the index.  The parser and planner take care to hold an appropriate
908
 
         * lock on the parent table while working, but having them hold locks on
909
 
         * all the indexes too seems overly expensive.  We do grab exclusive lock
910
 
         * on the index too, just to be safe. Both locks must be held till end of
911
 
         * transaction, else other backends will still see this index in pg_index.
 
904
         * table.  Exclusive lock on the index alone is insufficient because
 
905
         * another backend might be about to execute a query on the parent table.
 
906
         * If it relies on a previously cached list of index OIDs, then it could
 
907
         * attempt to access the just-dropped index.  We must therefore take a
 
908
         * table lock strong enough to prevent all queries on the table from
 
909
         * proceeding until we commit and send out a shared-cache-inval notice
 
910
         * that will make them update their index lists.
912
911
         */
913
912
        heapId = IndexGetRelation(indexId);
914
913
        userHeapRelation = heap_open(heapId, AccessExclusiveLock);
1384
1383
        Assert(RegProcedureIsValid(procedure));
1385
1384
 
1386
1385
        /*
1387
 
         * Switch to the table owner's userid, so that any index functions are
1388
 
         * run as that user.
 
1386
         * Switch to the table owner's userid, so that any index functions are run
 
1387
         * as that user.
1389
1388
         */
1390
1389
        GetUserIdAndContext(&save_userid, &save_secdefcxt);
1391
1390
        SetUserIdAndContext(heapRelation->rd_rel->relowner, true);
1545
1544
 
1546
1545
        scan = heap_beginscan_strat(heapRelation,       /* relation */
1547
1546
                                                                snapshot,               /* snapshot */
1548
 
                                                                0,                              /* number of keys */
1549
 
                                                                NULL,                   /* scan key */
1550
 
                                                                true,                   /* buffer access strategy OK */
 
1547
                                                                0,              /* number of keys */
 
1548
                                                                NULL,   /* scan key */
 
1549
                                                                true,   /* buffer access strategy OK */
1551
1550
                                                                allow_sync);    /* syncscan OK? */
1552
1551
 
1553
1552
        reltuples = 0;
1927
1926
        indexInfo->ii_Concurrent = true;
1928
1927
 
1929
1928
        /*
1930
 
         * Switch to the table owner's userid, so that any index functions are
1931
 
         * run as that user.
 
1929
         * Switch to the table owner's userid, so that any index functions are run
 
1930
         * as that user.
1932
1931
         */
1933
1932
        GetUserIdAndContext(&save_userid, &save_secdefcxt);
1934
1933
        SetUserIdAndContext(heapRelation->rd_rel->relowner, true);
1939
1938
        ivinfo.index = indexRelation;
1940
1939
        ivinfo.vacuum_full = false;
1941
1940
        ivinfo.analyze_only = false;
 
1941
        ivinfo.estimated_count = true;
1942
1942
        ivinfo.message_level = DEBUG2;
1943
 
        ivinfo.num_heap_tuples = -1;
 
1943
        ivinfo.num_heap_tuples = heapRelation->rd_rel->reltuples;
1944
1944
        ivinfo.strategy = NULL;
1945
1945
 
1946
1946
        state.tuplesort = tuplesort_begin_datum(TIDOID,
2050
2050
         */
2051
2051
        scan = heap_beginscan_strat(heapRelation,       /* relation */
2052
2052
                                                                snapshot,               /* snapshot */
2053
 
                                                                0,                              /* number of keys */
2054
 
                                                                NULL,                   /* scan key */
2055
 
                                                                true,                   /* buffer access strategy OK */
2056
 
                                                                false);                 /* syncscan not OK */
 
2053
                                                                0,              /* number of keys */
 
2054
                                                                NULL,   /* scan key */
 
2055
                                                                true,   /* buffer access strategy OK */
 
2056
                                                                false); /* syncscan not OK */
2057
2057
 
2058
2058
        /*
2059
2059
         * Scan all tuples matching the snapshot.
2267
2267
        if (RELATION_IS_OTHER_TEMP(iRel))
2268
2268
                ereport(ERROR,
2269
2269
                                (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2270
 
                                 errmsg("cannot reindex temporary tables of other sessions")));
 
2270
                           errmsg("cannot reindex temporary tables of other sessions")));
2271
2271
 
2272
2272
        /*
2273
 
         * Also check for active uses of the index in the current transaction;
2274
 
         * we don't want to reindex underneath an open indexscan.
 
2273
         * Also check for active uses of the index in the current transaction; we
 
2274
         * don't want to reindex underneath an open indexscan.
2275
2275
         */
2276
2276
        CheckTableNotInUse(iRel, "REINDEX INDEX");
2277
2277