Header And Logo

PostgreSQL
| The world's most advanced open source database.

Data Structures | Defines | Typedefs | Enumerations | Functions

predicate_internals.h File Reference

#include "storage/lock.h"
Include dependency graph for predicate_internals.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SERIALIZABLEXACT
struct  PredXactListElementData
struct  PredXactListData
struct  RWConflictData
struct  RWConflictPoolHeaderData
struct  SERIALIZABLEXIDTAG
struct  SERIALIZABLEXID
struct  PREDICATELOCKTARGETTAG
struct  PREDICATELOCKTARGET
struct  PREDICATELOCKTAG
struct  PREDICATELOCK
struct  LOCALPREDICATELOCK
struct  PredicateLockData
struct  TwoPhasePredicateXactRecord
struct  TwoPhasePredicateLockRecord
struct  TwoPhasePredicateRecord

Defines

#define InvalidSerCommitSeqNo   ((SerCommitSeqNo) UINT64CONST(0xFFFFFFFFFFFFFFFF))
#define RecoverySerCommitSeqNo   ((SerCommitSeqNo) 1)
#define FirstNormalSerCommitSeqNo   ((SerCommitSeqNo) 2)
#define SXACT_FLAG_COMMITTED   0x00000001
#define SXACT_FLAG_PREPARED   0x00000002
#define SXACT_FLAG_ROLLED_BACK   0x00000004
#define SXACT_FLAG_DOOMED   0x00000008
#define SXACT_FLAG_CONFLICT_OUT   0x00000010
#define SXACT_FLAG_READ_ONLY   0x00000020
#define SXACT_FLAG_DEFERRABLE_WAITING   0x00000040
#define SXACT_FLAG_RO_SAFE   0x00000080
#define SXACT_FLAG_RO_UNSAFE   0x00000100
#define SXACT_FLAG_SUMMARY_CONFLICT_IN   0x00000200
#define SXACT_FLAG_SUMMARY_CONFLICT_OUT   0x00000400
#define PredXactListElementDataSize   ((Size)MAXALIGN(sizeof(PredXactListElementData)))
#define PredXactListDataSize   ((Size)MAXALIGN(sizeof(PredXactListData)))
#define RWConflictDataSize   ((Size)MAXALIGN(sizeof(RWConflictData)))
#define RWConflictPoolHeaderDataSize   ((Size)MAXALIGN(sizeof(RWConflictPoolHeaderData)))
#define SET_PREDICATELOCKTARGETTAG_RELATION(locktag, dboid, reloid)
#define SET_PREDICATELOCKTARGETTAG_PAGE(locktag, dboid, reloid, blocknum)
#define SET_PREDICATELOCKTARGETTAG_TUPLE(locktag, dboid, reloid, blocknum, offnum, xmin)
#define GET_PREDICATELOCKTARGETTAG_DB(locktag)   ((Oid) (locktag).locktag_field1)
#define GET_PREDICATELOCKTARGETTAG_RELATION(locktag)   ((Oid) (locktag).locktag_field2)
#define GET_PREDICATELOCKTARGETTAG_PAGE(locktag)   ((BlockNumber) (locktag).locktag_field3)
#define GET_PREDICATELOCKTARGETTAG_OFFSET(locktag)   ((OffsetNumber) (locktag).locktag_field4)
#define GET_PREDICATELOCKTARGETTAG_XMIN(locktag)   ((TransactionId) (locktag).locktag_field5)
#define GET_PREDICATELOCKTARGETTAG_TYPE(locktag)
#define InvalidSerializableXact   ((SERIALIZABLEXACT *) NULL)

Typedefs

typedef uint64 SerCommitSeqNo
typedef struct SERIALIZABLEXACT SERIALIZABLEXACT
typedef struct
PredXactListElementData 
PredXactListElementData
typedef struct
PredXactListElementData
PredXactListElement
typedef struct PredXactListData PredXactListData
typedef struct PredXactListDataPredXactList
typedef struct RWConflictData RWConflictData
typedef struct RWConflictDataRWConflict
typedef struct
RWConflictPoolHeaderData 
RWConflictPoolHeaderData
typedef struct
RWConflictPoolHeaderData
RWConflictPoolHeader
typedef struct SERIALIZABLEXIDTAG SERIALIZABLEXIDTAG
typedef struct SERIALIZABLEXID SERIALIZABLEXID
typedef struct
PREDICATELOCKTARGETTAG 
PREDICATELOCKTARGETTAG
typedef struct PREDICATELOCKTARGET PREDICATELOCKTARGET
typedef struct PREDICATELOCKTAG PREDICATELOCKTAG
typedef struct PREDICATELOCK PREDICATELOCK
typedef struct LOCALPREDICATELOCK LOCALPREDICATELOCK
typedef enum
PredicateLockTargetType 
PredicateLockTargetType
typedef struct PredicateLockData PredicateLockData
typedef enum
TwoPhasePredicateRecordType 
TwoPhasePredicateRecordType
typedef struct
TwoPhasePredicateXactRecord 
TwoPhasePredicateXactRecord
typedef struct
TwoPhasePredicateLockRecord 
TwoPhasePredicateLockRecord
typedef struct
TwoPhasePredicateRecord 
TwoPhasePredicateRecord

Enumerations

enum  PredicateLockTargetType { PREDLOCKTAG_RELATION, PREDLOCKTAG_PAGE, PREDLOCKTAG_TUPLE }
enum  TwoPhasePredicateRecordType { TWOPHASEPREDICATERECORD_XACT, TWOPHASEPREDICATERECORD_LOCK }

Functions

PredicateLockDataGetPredicateLockStatusData (void)

Define Documentation

#define FirstNormalSerCommitSeqNo   ((SerCommitSeqNo) 2)

Definition at line 38 of file predicate_internals.h.

Referenced by InitPredicateLocks().

#define GET_PREDICATELOCKTARGETTAG_DB (   locktag  )     ((Oid) (locktag).locktag_field1)
#define GET_PREDICATELOCKTARGETTAG_OFFSET (   locktag  )     ((OffsetNumber) (locktag).locktag_field4)

Definition at line 424 of file predicate_internals.h.

Referenced by CheckTargetForConflictsIn(), and pg_lock_status().

#define GET_PREDICATELOCKTARGETTAG_PAGE (   locktag  )     ((BlockNumber) (locktag).locktag_field3)

Definition at line 422 of file predicate_internals.h.

Referenced by GetParentPredicateLockTag(), and pg_lock_status().

#define GET_PREDICATELOCKTARGETTAG_RELATION (   locktag  )     ((Oid) (locktag).locktag_field2)
#define GET_PREDICATELOCKTARGETTAG_TYPE (   locktag  ) 
Value:
(((locktag).locktag_field4 != InvalidOffsetNumber) ? PREDLOCKTAG_TUPLE : \
     (((locktag).locktag_field3 != InvalidBlockNumber) ? PREDLOCKTAG_PAGE :   \
      PREDLOCKTAG_RELATION))

Definition at line 428 of file predicate_internals.h.

Referenced by DropAllPredicateLocksFromTable(), GetParentPredicateLockTag(), pg_lock_status(), PredicateLockAcquire(), and PredicateLockPromotionThreshold().

#define GET_PREDICATELOCKTARGETTAG_XMIN (   locktag  )     ((TransactionId) (locktag).locktag_field5)

Definition at line 426 of file predicate_internals.h.

#define InvalidSerCommitSeqNo   ((SerCommitSeqNo) UINT64CONST(0xFFFFFFFFFFFFFFFF))
#define InvalidSerializableXact   ((SERIALIZABLEXACT *) NULL)
#define PredXactListDataSize   ((Size)MAXALIGN(sizeof(PredXactListData)))

Definition at line 181 of file predicate_internals.h.

Referenced by InitPredicateLocks(), and PredicateLockShmemSize().

#define PredXactListElementDataSize   ((Size)MAXALIGN(sizeof(PredXactListElementData)))

Definition at line 142 of file predicate_internals.h.

Referenced by InitPredicateLocks(), and PredicateLockShmemSize().

#define RecoverySerCommitSeqNo   ((SerCommitSeqNo) 1)

Definition at line 37 of file predicate_internals.h.

#define RWConflictDataSize   ((Size)MAXALIGN(sizeof(RWConflictData)))

Definition at line 205 of file predicate_internals.h.

Referenced by InitPredicateLocks(), and PredicateLockShmemSize().

#define RWConflictPoolHeaderDataSize   ((Size)MAXALIGN(sizeof(RWConflictPoolHeaderData)))

Definition at line 216 of file predicate_internals.h.

Referenced by InitPredicateLocks(), and PredicateLockShmemSize().

#define SET_PREDICATELOCKTARGETTAG_PAGE (   locktag,
  dboid,
  reloid,
  blocknum 
)
Value:
((locktag).locktag_field1 = (dboid), \
     (locktag).locktag_field2 = (reloid), \
     (locktag).locktag_field3 = (blocknum), \
     (locktag).locktag_field4 = InvalidOffsetNumber, \
     (locktag).locktag_field5 = InvalidTransactionId)

Definition at line 404 of file predicate_internals.h.

Referenced by CheckForSerializableConflictIn(), GetParentPredicateLockTag(), PageIsPredicateLocked(), PredicateLockPage(), and PredicateLockPageSplit().

#define SET_PREDICATELOCKTARGETTAG_RELATION (   locktag,
  dboid,
  reloid 
)
Value:
((locktag).locktag_field1 = (dboid), \
     (locktag).locktag_field2 = (reloid), \
     (locktag).locktag_field3 = InvalidBlockNumber, \
     (locktag).locktag_field4 = InvalidOffsetNumber, \
     (locktag).locktag_field5 = InvalidTransactionId)

Definition at line 397 of file predicate_internals.h.

Referenced by CheckForSerializableConflictIn(), DropAllPredicateLocksFromTable(), GetParentPredicateLockTag(), PredicateLockRelation(), and PredicateLockTuple().

#define SET_PREDICATELOCKTARGETTAG_TUPLE (   locktag,
  dboid,
  reloid,
  blocknum,
  offnum,
  xmin 
)
Value:
((locktag).locktag_field1 = (dboid), \
     (locktag).locktag_field2 = (reloid), \
     (locktag).locktag_field3 = (blocknum), \
     (locktag).locktag_field4 = (offnum), \
     (locktag).locktag_field5 = (xmin))

Definition at line 411 of file predicate_internals.h.

Referenced by CheckForSerializableConflictIn(), and PredicateLockTuple().

#define SXACT_FLAG_COMMITTED   0x00000001

Definition at line 110 of file predicate_internals.h.

#define SXACT_FLAG_CONFLICT_OUT   0x00000010

Definition at line 119 of file predicate_internals.h.

Referenced by ReleasePredicateLocks().

#define SXACT_FLAG_DEFERRABLE_WAITING   0x00000040

Definition at line 121 of file predicate_internals.h.

#define SXACT_FLAG_DOOMED   0x00000008

Definition at line 113 of file predicate_internals.h.

#define SXACT_FLAG_PREPARED   0x00000002

Definition at line 111 of file predicate_internals.h.

#define SXACT_FLAG_READ_ONLY   0x00000020

Definition at line 120 of file predicate_internals.h.

#define SXACT_FLAG_RO_SAFE   0x00000080

Definition at line 122 of file predicate_internals.h.

#define SXACT_FLAG_RO_UNSAFE   0x00000100

Definition at line 123 of file predicate_internals.h.

#define SXACT_FLAG_ROLLED_BACK   0x00000004

Definition at line 112 of file predicate_internals.h.

#define SXACT_FLAG_SUMMARY_CONFLICT_IN   0x00000200

Definition at line 124 of file predicate_internals.h.

#define SXACT_FLAG_SUMMARY_CONFLICT_OUT   0x00000400

Definition at line 125 of file predicate_internals.h.


Typedef Documentation

typedef struct PREDICATELOCK PREDICATELOCK
typedef struct PredXactListData* PredXactList

Definition at line 179 of file predicate_internals.h.

Definition at line 140 of file predicate_internals.h.

typedef struct RWConflictData* RWConflict

Definition at line 203 of file predicate_internals.h.

Definition at line 214 of file predicate_internals.h.

typedef uint64 SerCommitSeqNo

Definition at line 22 of file predicate_internals.h.


Enumeration Type Documentation

Enumerator:
PREDLOCKTAG_RELATION 
PREDLOCKTAG_PAGE 
PREDLOCKTAG_TUPLE 

Definition at line 370 of file predicate_internals.h.

{
    PREDLOCKTAG_RELATION,
    PREDLOCKTAG_PAGE,
    PREDLOCKTAG_TUPLE
    /* TODO SSI: Other types may be needed for index locking */
} PredicateLockTargetType;

Enumerator:
TWOPHASEPREDICATERECORD_XACT 
TWOPHASEPREDICATERECORD_LOCK 

Definition at line 438 of file predicate_internals.h.

{
    TWOPHASEPREDICATERECORD_XACT,
    TWOPHASEPREDICATERECORD_LOCK
} TwoPhasePredicateRecordType;


Function Documentation

PredicateLockData* GetPredicateLockStatusData ( void   ) 

Definition at line 1385 of file predicate.c.

References Assert, FirstPredicateLockMgrLock, hash_get_num_entries(), hash_seq_init(), hash_seq_search(), i, PredicateLockData::locktags, LW_SHARED, LWLockAcquire(), LWLockRelease(), PREDICATELOCKTAG::myTarget, PREDICATELOCKTAG::myXact, PredicateLockData::nelements, palloc(), SerializableXactHashLock, PREDICATELOCKTARGET::tag, PREDICATELOCK::tag, and PredicateLockData::xacts.

Referenced by pg_lock_status().

{
    PredicateLockData *data;
    int         i;
    int         els,
                el;
    HASH_SEQ_STATUS seqstat;
    PREDICATELOCK *predlock;

    data = (PredicateLockData *) palloc(sizeof(PredicateLockData));

    /*
     * To ensure consistency, take simultaneous locks on all partition locks
     * in ascending order, then SerializableXactHashLock.
     */
    for (i = 0; i < NUM_PREDICATELOCK_PARTITIONS; i++)
        LWLockAcquire(FirstPredicateLockMgrLock + i, LW_SHARED);
    LWLockAcquire(SerializableXactHashLock, LW_SHARED);

    /* Get number of locks and allocate appropriately-sized arrays. */
    els = hash_get_num_entries(PredicateLockHash);
    data->nelements = els;
    data->locktags = (PREDICATELOCKTARGETTAG *)
        palloc(sizeof(PREDICATELOCKTARGETTAG) * els);
    data->xacts = (SERIALIZABLEXACT *)
        palloc(sizeof(SERIALIZABLEXACT) * els);


    /* Scan through PredicateLockHash and copy contents */
    hash_seq_init(&seqstat, PredicateLockHash);

    el = 0;

    while ((predlock = (PREDICATELOCK *) hash_seq_search(&seqstat)))
    {
        data->locktags[el] = predlock->tag.myTarget->tag;
        data->xacts[el] = *predlock->tag.myXact;
        el++;
    }

    Assert(el == els);

    /* Release locks in reverse order */
    LWLockRelease(SerializableXactHashLock);
    for (i = NUM_PREDICATELOCK_PARTITIONS - 1; i >= 0; i--)
        LWLockRelease(FirstPredicateLockMgrLock + i);

    return data;
}