~ubuntu-branches/ubuntu/oneiric/postgresql-9.1/oneiric-security

« back to all changes in this revision

Viewing changes to src/backend/commands/cluster.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2011-06-14 09:53:29 UTC
  • mto: (6.1.1 sid) (10.1.1 oneiric-proposed) (1.2.1)
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: james.westby@ubuntu.com-20110614095329-71gfhjywyp2c27au
Tags: upstream-9.1~beta2
ImportĀ upstreamĀ versionĀ 9.1~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
#include "miscadmin.h"
39
39
#include "optimizer/planner.h"
40
40
#include "storage/bufmgr.h"
 
41
#include "storage/lmgr.h"
 
42
#include "storage/predicate.h"
41
43
#include "storage/procarray.h"
42
44
#include "storage/smgr.h"
43
45
#include "utils/acl.h"
384
386
        if (OidIsValid(indexOid))
385
387
                check_index_is_clusterable(OldHeap, indexOid, recheck, AccessExclusiveLock);
386
388
 
 
389
        /*
 
390
         * All predicate locks on the tuples or pages are about to be made
 
391
         * invalid, because we move tuples around.      Promote them to relation
 
392
         * locks.  Predicate locks on indexes will be promoted when they are
 
393
         * reindexed.
 
394
         */
 
395
        TransferPredicateLocksToHeapRelation(OldHeap);
 
396
 
387
397
        /* rebuild_relation does all the dirty work */
388
398
        rebuild_relation(OldHeap, indexOid, freeze_min_age, freeze_table_age,
389
399
                                         verbose);
751
761
        isnull = (bool *) palloc(natts * sizeof(bool));
752
762
 
753
763
        /*
 
764
         * If the OldHeap has a toast table, get lock on the toast table to keep
 
765
         * it from being vacuumed.      This is needed because autovacuum processes
 
766
         * toast tables independently of their main tables, with no lock on the
 
767
         * latter.      If an autovacuum were to start on the toast table after we
 
768
         * compute our OldestXmin below, it would use a later OldestXmin, and then
 
769
         * possibly remove as DEAD toast tuples belonging to main tuples we think
 
770
         * are only RECENTLY_DEAD.      Then we'd fail while trying to copy those
 
771
         * tuples.
 
772
         *
 
773
         * We don't need to open the toast relation here, just lock it.  The lock
 
774
         * will be held till end of transaction.
 
775
         */
 
776
        if (OldHeap->rd_rel->reltoastrelid)
 
777
                LockRelationOid(OldHeap->rd_rel->reltoastrelid, AccessExclusiveLock);
 
778
 
 
779
        /*
754
780
         * We need to log the copied data in WAL iff WAL archiving/streaming is
755
 
         * enabled AND it's not a WAL-logged rel.
 
781
         * enabled AND it's a WAL-logged rel.
756
782
         */
757
783
        use_wal = XLogIsNeeded() && RelationNeedsWAL(NewHeap);
758
784