PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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
 

Macros

#define InvalidSerCommitSeqNo   ((SerCommitSeqNo) PG_UINT64_MAX)
 
#define RecoverySerCommitSeqNo   ((SerCommitSeqNo) 1)
 
#define FirstNormalSerCommitSeqNo   ((SerCommitSeqNo) 2)
 
#define SXACT_FLAG_COMMITTED   0x00000001 /* already committed */
 
#define SXACT_FLAG_PREPARED   0x00000002 /* about to commit */
 
#define SXACT_FLAG_ROLLED_BACK   0x00000004 /* already rolled back */
 
#define SXACT_FLAG_DOOMED   0x00000008 /* will roll back */
 
#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)
 
#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_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)
 

Macro Definition Documentation

#define FirstNormalSerCommitSeqNo   ((SerCommitSeqNo) 2)

Definition at line 38 of file predicate_internals.h.

Referenced by InitPredicateLocks(), and ReleasePredicateLocks().

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

Definition at line 414 of file predicate_internals.h.

Referenced by CheckTargetForConflictsIn(), and pg_lock_status().

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

Definition at line 412 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)
#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.

Referenced by predicatelock_twophase_recover().

#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)
#define InvalidOffsetNumber
Definition: off.h:26

Definition at line 396 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)
#define InvalidOffsetNumber
Definition: off.h:26
#define InvalidBlockNumber
Definition: block.h:33

Definition at line 390 of file predicate_internals.h.

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

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

Definition at line 402 of file predicate_internals.h.

Referenced by CheckForSerializableConflictIn(), and PredicateLockTuple().

#define SXACT_FLAG_COMMITTED   0x00000001 /* already committed */

Definition at line 110 of file predicate_internals.h.

Referenced by InitPredicateLocks(), and ReleasePredicateLocks().

#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.

Referenced by GetSafeSnapshot().

#define SXACT_FLAG_DOOMED   0x00000008 /* will roll back */
#define SXACT_FLAG_PREPARED   0x00000002 /* about to commit */
#define SXACT_FLAG_READ_ONLY   0x00000020
#define SXACT_FLAG_RO_SAFE   0x00000080

Definition at line 122 of file predicate_internals.h.

Referenced by ReleasePredicateLocks().

#define SXACT_FLAG_RO_UNSAFE   0x00000100

Definition at line 123 of file predicate_internals.h.

Referenced by FlagSxactUnsafe().

#define SXACT_FLAG_ROLLED_BACK   0x00000004 /* already rolled back */

Definition at line 112 of file predicate_internals.h.

Referenced by ReleasePredicateLocks().

#define SXACT_FLAG_SUMMARY_CONFLICT_IN   0x00000200
#define SXACT_FLAG_SUMMARY_CONFLICT_OUT   0x00000400

Typedef Documentation

Definition at line 179 of file predicate_internals.h.

Definition at line 203 of file predicate_internals.h.

Definition at line 22 of file predicate_internals.h.

Enumeration Type Documentation

Enumerator
PREDLOCKTAG_RELATION 
PREDLOCKTAG_PAGE 
PREDLOCKTAG_TUPLE 

Definition at line 363 of file predicate_internals.h.

364 {
368  /* TODO SSI: Other types may be needed for index locking */
PredicateLockTargetType
Enumerator
TWOPHASEPREDICATERECORD_XACT 
TWOPHASEPREDICATERECORD_LOCK 

Definition at line 426 of file predicate_internals.h.

Function Documentation

PredicateLockData* GetPredicateLockStatusData ( void  )

Definition at line 1376 of file predicate.c.

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

Referenced by pg_lock_status().

1377 {
1378  PredicateLockData *data;
1379  int i;
1380  int els,
1381  el;
1382  HASH_SEQ_STATUS seqstat;
1383  PREDICATELOCK *predlock;
1384 
1385  data = (PredicateLockData *) palloc(sizeof(PredicateLockData));
1386 
1387  /*
1388  * To ensure consistency, take simultaneous locks on all partition locks
1389  * in ascending order, then SerializableXactHashLock.
1390  */
1391  for (i = 0; i < NUM_PREDICATELOCK_PARTITIONS; i++)
1393  LWLockAcquire(SerializableXactHashLock, LW_SHARED);
1394 
1395  /* Get number of locks and allocate appropriately-sized arrays. */
1397  data->nelements = els;
1398  data->locktags = (PREDICATELOCKTARGETTAG *)
1399  palloc(sizeof(PREDICATELOCKTARGETTAG) * els);
1400  data->xacts = (SERIALIZABLEXACT *)
1401  palloc(sizeof(SERIALIZABLEXACT) * els);
1402 
1403 
1404  /* Scan through PredicateLockHash and copy contents */
1405  hash_seq_init(&seqstat, PredicateLockHash);
1406 
1407  el = 0;
1408 
1409  while ((predlock = (PREDICATELOCK *) hash_seq_search(&seqstat)))
1410  {
1411  data->locktags[el] = predlock->tag.myTarget->tag;
1412  data->xacts[el] = *predlock->tag.myXact;
1413  el++;
1414  }
1415 
1416  Assert(el == els);
1417 
1418  /* Release locks in reverse order */
1419  LWLockRelease(SerializableXactHashLock);
1420  for (i = NUM_PREDICATELOCK_PARTITIONS - 1; i >= 0; i--)
1422 
1423  return data;
1424 }
long hash_get_num_entries(HTAB *hashp)
Definition: dynahash.c:1297
SERIALIZABLEXACT * xacts
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1715
static HTAB * PredicateLockHash
Definition: predicate.c:381
PREDICATELOCKTARGETTAG * locktags
PREDICATELOCKTAG tag
PREDICATELOCKTARGETTAG tag
#define Assert(condition)
Definition: c.h:675
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1111
void * hash_seq_search(HASH_SEQ_STATUS *status)
Definition: dynahash.c:1353
void hash_seq_init(HASH_SEQ_STATUS *status, HTAB *hashp)
Definition: dynahash.c:1343
#define PredicateLockHashPartitionLockByIndex(i)
Definition: predicate.c:248
void * palloc(Size size)
Definition: mcxt.c:849
int i
SERIALIZABLEXACT * myXact
PREDICATELOCKTARGET * myTarget
#define NUM_PREDICATELOCK_PARTITIONS
Definition: lwlock.h:121