Thanks to visit codestin.com
Credit goes to doxygen.postgresql.org

PostgreSQL Source Code git master
lmgr.c File Reference
#include "postgres.h"
#include "access/subtrans.h"
#include "access/xact.h"
#include "catalog/catalog.h"
#include "commands/progress.h"
#include "miscadmin.h"
#include "pgstat.h"
#include "storage/lmgr.h"
#include "storage/proc.h"
#include "storage/procarray.h"
#include "utils/inval.h"
Include dependency graph for lmgr.c:

Go to the source code of this file.

Data Structures

struct  XactLockTableWaitInfo
 

Typedefs

typedef struct XactLockTableWaitInfo XactLockTableWaitInfo
 

Functions

static void XactLockTableWaitErrorCb (void *arg)
 
void RelationInitLockInfo (Relation relation)
 
static void SetLocktagRelationOid (LOCKTAG *tag, Oid relid)
 
void LockRelationOid (Oid relid, LOCKMODE lockmode)
 
bool ConditionalLockRelationOid (Oid relid, LOCKMODE lockmode)
 
void LockRelationId (LockRelId *relid, LOCKMODE lockmode)
 
void UnlockRelationId (LockRelId *relid, LOCKMODE lockmode)
 
void UnlockRelationOid (Oid relid, LOCKMODE lockmode)
 
void LockRelation (Relation relation, LOCKMODE lockmode)
 
bool ConditionalLockRelation (Relation relation, LOCKMODE lockmode)
 
void UnlockRelation (Relation relation, LOCKMODE lockmode)
 
bool CheckRelationLockedByMe (Relation relation, LOCKMODE lockmode, bool orstronger)
 
bool CheckRelationOidLockedByMe (Oid relid, LOCKMODE lockmode, bool orstronger)
 
bool LockHasWaitersRelation (Relation relation, LOCKMODE lockmode)
 
void LockRelationIdForSession (LockRelId *relid, LOCKMODE lockmode)
 
void UnlockRelationIdForSession (LockRelId *relid, LOCKMODE lockmode)
 
void LockRelationForExtension (Relation relation, LOCKMODE lockmode)
 
bool ConditionalLockRelationForExtension (Relation relation, LOCKMODE lockmode)
 
int RelationExtensionLockWaiterCount (Relation relation)
 
void UnlockRelationForExtension (Relation relation, LOCKMODE lockmode)
 
void LockDatabaseFrozenIds (LOCKMODE lockmode)
 
void LockPage (Relation relation, BlockNumber blkno, LOCKMODE lockmode)
 
bool ConditionalLockPage (Relation relation, BlockNumber blkno, LOCKMODE lockmode)
 
void UnlockPage (Relation relation, BlockNumber blkno, LOCKMODE lockmode)
 
void LockTuple (Relation relation, const ItemPointerData *tid, LOCKMODE lockmode)
 
bool ConditionalLockTuple (Relation relation, const ItemPointerData *tid, LOCKMODE lockmode, bool logLockFailure)
 
void UnlockTuple (Relation relation, const ItemPointerData *tid, LOCKMODE lockmode)
 
void XactLockTableInsert (TransactionId xid)
 
void XactLockTableDelete (TransactionId xid)
 
void XactLockTableWait (TransactionId xid, Relation rel, const ItemPointerData *ctid, XLTW_Oper oper)
 
bool ConditionalXactLockTableWait (TransactionId xid, bool logLockFailure)
 
uint32 SpeculativeInsertionLockAcquire (TransactionId xid)
 
void SpeculativeInsertionLockRelease (TransactionId xid)
 
void SpeculativeInsertionWait (TransactionId xid, uint32 token)
 
void WaitForLockersMultiple (List *locktags, LOCKMODE lockmode, bool progress)
 
void WaitForLockers (LOCKTAG heaplocktag, LOCKMODE lockmode, bool progress)
 
void LockDatabaseObject (Oid classid, Oid objid, uint16 objsubid, LOCKMODE lockmode)
 
bool ConditionalLockDatabaseObject (Oid classid, Oid objid, uint16 objsubid, LOCKMODE lockmode)
 
void UnlockDatabaseObject (Oid classid, Oid objid, uint16 objsubid, LOCKMODE lockmode)
 
void LockSharedObject (Oid classid, Oid objid, uint16 objsubid, LOCKMODE lockmode)
 
bool ConditionalLockSharedObject (Oid classid, Oid objid, uint16 objsubid, LOCKMODE lockmode)
 
void UnlockSharedObject (Oid classid, Oid objid, uint16 objsubid, LOCKMODE lockmode)
 
void LockSharedObjectForSession (Oid classid, Oid objid, uint16 objsubid, LOCKMODE lockmode)
 
void UnlockSharedObjectForSession (Oid classid, Oid objid, uint16 objsubid, LOCKMODE lockmode)
 
void LockApplyTransactionForSession (Oid suboid, TransactionId xid, uint16 objid, LOCKMODE lockmode)
 
void UnlockApplyTransactionForSession (Oid suboid, TransactionId xid, uint16 objid, LOCKMODE lockmode)
 
void DescribeLockTag (StringInfo buf, const LOCKTAG *tag)
 
const char * GetLockNameFromTagType (uint16 locktag_type)
 

Variables

static uint32 speculativeInsertionToken = 0
 

Typedef Documentation

◆ XactLockTableWaitInfo

Function Documentation

◆ CheckRelationLockedByMe()

bool CheckRelationLockedByMe ( Relation  relation,
LOCKMODE  lockmode,
bool  orstronger 
)

Definition at line 334 of file lmgr.c.

335{
336 LOCKTAG tag;
337
339 relation->rd_lockInfo.lockRelId.dbId,
340 relation->rd_lockInfo.lockRelId.relId);
341
342 return LockHeldByMe(&tag, lockmode, orstronger);
343}
bool LockHeldByMe(const LOCKTAG *locktag, LOCKMODE lockmode, bool orstronger)
Definition: lock.c:643
#define SET_LOCKTAG_RELATION(locktag, dboid, reloid)
Definition: lock.h:183
Definition: lock.h:167
LockRelId lockRelId
Definition: rel.h:46
Oid relId
Definition: rel.h:40
Oid dbId
Definition: rel.h:41
LockInfoData rd_lockInfo
Definition: rel.h:114

References LockRelId::dbId, LockHeldByMe(), LockInfoData::lockRelId, RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_RELATION.

Referenced by addFkRecurseReferenced(), addFkRecurseReferencing(), addRangeTableEntryForRelation(), cluster_rel(), ExecGetRangeTableRelation(), rebuild_relation(), relation_open(), and try_relation_open().

◆ CheckRelationOidLockedByMe()

bool CheckRelationOidLockedByMe ( Oid  relid,
LOCKMODE  lockmode,
bool  orstronger 
)

Definition at line 351 of file lmgr.c.

352{
353 LOCKTAG tag;
354
355 SetLocktagRelationOid(&tag, relid);
356
357 return LockHeldByMe(&tag, lockmode, orstronger);
358}
static void SetLocktagRelationOid(LOCKTAG *tag, Oid relid)
Definition: lmgr.c:88

References LockHeldByMe(), and SetLocktagRelationOid().

Referenced by ATRewriteTable(), build_index_value_desc(), errdetail_apply_conflict(), rebuild_relation(), RefreshMatViewByOid(), SetRelationHasSubclass(), and UpdateSubscriptionRelState().

◆ ConditionalLockDatabaseObject()

bool ConditionalLockDatabaseObject ( Oid  classid,
Oid  objid,
uint16  objsubid,
LOCKMODE  lockmode 
)

Definition at line 1032 of file lmgr.c.

1034{
1035 LOCKTAG tag;
1036 LOCALLOCK *locallock;
1038
1041 classid,
1042 objid,
1043 objsubid);
1044
1045 res = LockAcquireExtended(&tag, lockmode, false, true, true, &locallock,
1046 false);
1047
1048 if (res == LOCKACQUIRE_NOT_AVAIL)
1049 return false;
1050
1051 /*
1052 * Now that we have the lock, check for invalidation messages; see notes
1053 * in LockRelationOid.
1054 */
1055 if (res != LOCKACQUIRE_ALREADY_CLEAR)
1056 {
1058 MarkLockClear(locallock);
1059 }
1060
1061 return true;
1062}
Oid MyDatabaseId
Definition: globals.c:94
void AcceptInvalidationMessages(void)
Definition: inval.c:930
LockAcquireResult LockAcquireExtended(const LOCKTAG *locktag, LOCKMODE lockmode, bool sessionLock, bool dontWait, bool reportMemoryError, LOCALLOCK **locallockp, bool logLockFailure)
Definition: lock.c:836
void MarkLockClear(LOCALLOCK *locallock)
Definition: lock.c:1920
#define SET_LOCKTAG_OBJECT(locktag, dboid, classoid, objoid, objsubid)
Definition: lock.h:264
LockAcquireResult
Definition: lock.h:502
@ LOCKACQUIRE_ALREADY_CLEAR
Definition: lock.h:506
@ LOCKACQUIRE_NOT_AVAIL
Definition: lock.h:503

References AcceptInvalidationMessages(), LOCKACQUIRE_ALREADY_CLEAR, LOCKACQUIRE_NOT_AVAIL, LockAcquireExtended(), MarkLockClear(), MyDatabaseId, and SET_LOCKTAG_OBJECT.

Referenced by do_autovacuum().

◆ ConditionalLockPage()

bool ConditionalLockPage ( Relation  relation,
BlockNumber  blkno,
LOCKMODE  lockmode 
)

Definition at line 526 of file lmgr.c.

527{
528 LOCKTAG tag;
529
531 relation->rd_lockInfo.lockRelId.dbId,
532 relation->rd_lockInfo.lockRelId.relId,
533 blkno);
534
535 return (LockAcquire(&tag, lockmode, false, true) != LOCKACQUIRE_NOT_AVAIL);
536}
LockAcquireResult LockAcquire(const LOCKTAG *locktag, LOCKMODE lockmode, bool sessionLock, bool dontWait)
Definition: lock.c:809
#define SET_LOCKTAG_PAGE(locktag, dboid, reloid, blocknum)
Definition: lock.h:210

References LockRelId::dbId, LockAcquire(), LOCKACQUIRE_NOT_AVAIL, LockInfoData::lockRelId, RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_PAGE.

Referenced by ginInsertCleanup().

◆ ConditionalLockRelation()

bool ConditionalLockRelation ( Relation  relation,
LOCKMODE  lockmode 
)

Definition at line 278 of file lmgr.c.

279{
280 LOCKTAG tag;
281 LOCALLOCK *locallock;
283
285 relation->rd_lockInfo.lockRelId.dbId,
286 relation->rd_lockInfo.lockRelId.relId);
287
288 res = LockAcquireExtended(&tag, lockmode, false, true, true, &locallock,
289 false);
290
291 if (res == LOCKACQUIRE_NOT_AVAIL)
292 return false;
293
294 /*
295 * Now that we have the lock, check for invalidation messages; see notes
296 * in LockRelationOid.
297 */
298 if (res != LOCKACQUIRE_ALREADY_CLEAR)
299 {
301 MarkLockClear(locallock);
302 }
303
304 return true;
305}

References AcceptInvalidationMessages(), LockRelId::dbId, LOCKACQUIRE_ALREADY_CLEAR, LOCKACQUIRE_NOT_AVAIL, LockAcquireExtended(), LockInfoData::lockRelId, MarkLockClear(), RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_RELATION.

Referenced by lazy_truncate_heap().

◆ ConditionalLockRelationForExtension()

bool ConditionalLockRelationForExtension ( Relation  relation,
LOCKMODE  lockmode 
)

Definition at line 442 of file lmgr.c.

443{
444 LOCKTAG tag;
445
447 relation->rd_lockInfo.lockRelId.dbId,
448 relation->rd_lockInfo.lockRelId.relId);
449
450 return (LockAcquire(&tag, lockmode, false, true) != LOCKACQUIRE_NOT_AVAIL);
451}
#define SET_LOCKTAG_RELATION_EXTEND(locktag, dboid, reloid)
Definition: lock.h:192

References LockRelId::dbId, LockAcquire(), LOCKACQUIRE_NOT_AVAIL, LockInfoData::lockRelId, RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_RELATION_EXTEND.

◆ ConditionalLockRelationOid()

bool ConditionalLockRelationOid ( Oid  relid,
LOCKMODE  lockmode 
)

Definition at line 151 of file lmgr.c.

152{
153 LOCKTAG tag;
154 LOCALLOCK *locallock;
156
157 SetLocktagRelationOid(&tag, relid);
158
159 res = LockAcquireExtended(&tag, lockmode, false, true, true, &locallock,
160 false);
161
162 if (res == LOCKACQUIRE_NOT_AVAIL)
163 return false;
164
165 /*
166 * Now that we have the lock, check for invalidation messages; see notes
167 * in LockRelationOid.
168 */
169 if (res != LOCKACQUIRE_ALREADY_CLEAR)
170 {
172 MarkLockClear(locallock);
173 }
174
175 return true;
176}

References AcceptInvalidationMessages(), LOCKACQUIRE_ALREADY_CLEAR, LOCKACQUIRE_NOT_AVAIL, LockAcquireExtended(), MarkLockClear(), and SetLocktagRelationOid().

Referenced by AlterTableMoveAll(), do_autovacuum(), LockTableRecurse(), LockViewRecurse_walker(), RangeVarGetRelidExtended(), and vacuum_open_relation().

◆ ConditionalLockSharedObject()

bool ConditionalLockSharedObject ( Oid  classid,
Oid  objid,
uint16  objsubid,
LOCKMODE  lockmode 
)

Definition at line 1112 of file lmgr.c.

1114{
1115 LOCKTAG tag;
1116 LOCALLOCK *locallock;
1118
1120 InvalidOid,
1121 classid,
1122 objid,
1123 objsubid);
1124
1125 res = LockAcquireExtended(&tag, lockmode, false, true, true, &locallock,
1126 false);
1127
1128 if (res == LOCKACQUIRE_NOT_AVAIL)
1129 return false;
1130
1131 /*
1132 * Now that we have the lock, check for invalidation messages; see notes
1133 * in LockRelationOid.
1134 */
1135 if (res != LOCKACQUIRE_ALREADY_CLEAR)
1136 {
1138 MarkLockClear(locallock);
1139 }
1140
1141 return true;
1142}
#define InvalidOid
Definition: postgres_ext.h:37

References AcceptInvalidationMessages(), InvalidOid, LOCKACQUIRE_ALREADY_CLEAR, LOCKACQUIRE_NOT_AVAIL, LockAcquireExtended(), MarkLockClear(), and SET_LOCKTAG_OBJECT.

Referenced by EventTriggerOnLogin().

◆ ConditionalLockTuple()

bool ConditionalLockTuple ( Relation  relation,
const ItemPointerData tid,
LOCKMODE  lockmode,
bool  logLockFailure 
)

Definition at line 582 of file lmgr.c.

584{
585 LOCKTAG tag;
586
588 relation->rd_lockInfo.lockRelId.dbId,
589 relation->rd_lockInfo.lockRelId.relId,
592
593 return (LockAcquireExtended(&tag, lockmode, false, true, true, NULL,
594 logLockFailure) != LOCKACQUIRE_NOT_AVAIL);
595}
static OffsetNumber ItemPointerGetOffsetNumber(const ItemPointerData *pointer)
Definition: itemptr.h:124
static BlockNumber ItemPointerGetBlockNumber(const ItemPointerData *pointer)
Definition: itemptr.h:103
#define SET_LOCKTAG_TUPLE(locktag, dboid, reloid, blocknum, offnum)
Definition: lock.h:219

References LockRelId::dbId, ItemPointerGetBlockNumber(), ItemPointerGetOffsetNumber(), LOCKACQUIRE_NOT_AVAIL, LockAcquireExtended(), LockInfoData::lockRelId, RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_TUPLE.

◆ ConditionalXactLockTableWait()

bool ConditionalXactLockTableWait ( TransactionId  xid,
bool  logLockFailure 
)

Definition at line 739 of file lmgr.c.

740{
741 LOCKTAG tag;
742 bool first = true;
743
744 for (;;)
745 {
748
749 SET_LOCKTAG_TRANSACTION(tag, xid);
750
751 if (LockAcquireExtended(&tag, ShareLock, false, true, true, NULL,
752 logLockFailure)
754 return false;
755
756 LockRelease(&tag, ShareLock, false);
757
759 break;
760
761 /* See XactLockTableWait about this case */
762 if (!first)
763 {
765 pg_usleep(1000L);
766 }
767 first = false;
769 }
770
771 return true;
772}
Assert(PointerIsAligned(start, uint64))
bool LockRelease(const LOCKTAG *locktag, LOCKMODE lockmode, bool sessionLock)
Definition: lock.c:2102
#define SET_LOCKTAG_TRANSACTION(locktag, xid)
Definition: lock.h:228
#define ShareLock
Definition: lockdefs.h:40
#define CHECK_FOR_INTERRUPTS()
Definition: miscadmin.h:122
bool TransactionIdIsInProgress(TransactionId xid)
Definition: procarray.c:1402
void pg_usleep(long microsec)
Definition: signal.c:53
TransactionId SubTransGetTopmostTransaction(TransactionId xid)
Definition: subtrans.c:162
#define TransactionIdEquals(id1, id2)
Definition: transam.h:43
#define TransactionIdIsValid(xid)
Definition: transam.h:41
TransactionId GetTopTransactionIdIfAny(void)
Definition: xact.c:441

References Assert(), CHECK_FOR_INTERRUPTS, GetTopTransactionIdIfAny(), LOCKACQUIRE_NOT_AVAIL, LockAcquireExtended(), LockRelease(), pg_usleep(), SET_LOCKTAG_TRANSACTION, ShareLock, SubTransGetTopmostTransaction(), TransactionIdEquals, TransactionIdIsInProgress(), and TransactionIdIsValid.

Referenced by Do_MultiXactIdWait(), heap_lock_tuple(), and heapam_tuple_lock().

◆ DescribeLockTag()

void DescribeLockTag ( StringInfo  buf,
const LOCKTAG tag 
)

Definition at line 1249 of file lmgr.c.

1250{
1251 switch ((LockTagType) tag->locktag_type)
1252 {
1253 case LOCKTAG_RELATION:
1255 _("relation %u of database %u"),
1256 tag->locktag_field2,
1257 tag->locktag_field1);
1258 break;
1261 _("extension of relation %u of database %u"),
1262 tag->locktag_field2,
1263 tag->locktag_field1);
1264 break;
1267 _("pg_database.datfrozenxid of database %u"),
1268 tag->locktag_field1);
1269 break;
1270 case LOCKTAG_PAGE:
1272 _("page %u of relation %u of database %u"),
1273 tag->locktag_field3,
1274 tag->locktag_field2,
1275 tag->locktag_field1);
1276 break;
1277 case LOCKTAG_TUPLE:
1279 _("tuple (%u,%u) of relation %u of database %u"),
1280 tag->locktag_field3,
1281 tag->locktag_field4,
1282 tag->locktag_field2,
1283 tag->locktag_field1);
1284 break;
1287 _("transaction %u"),
1288 tag->locktag_field1);
1289 break;
1292 _("virtual transaction %d/%u"),
1293 tag->locktag_field1,
1294 tag->locktag_field2);
1295 break;
1298 _("speculative token %u of transaction %u"),
1299 tag->locktag_field2,
1300 tag->locktag_field1);
1301 break;
1302 case LOCKTAG_OBJECT:
1304 _("object %u of class %u of database %u"),
1305 tag->locktag_field3,
1306 tag->locktag_field2,
1307 tag->locktag_field1);
1308 break;
1309 case LOCKTAG_USERLOCK:
1310 /* reserved for old contrib code, now on pgfoundry */
1312 _("user lock [%u,%u,%u]"),
1313 tag->locktag_field1,
1314 tag->locktag_field2,
1315 tag->locktag_field3);
1316 break;
1317 case LOCKTAG_ADVISORY:
1319 _("advisory lock [%u,%u,%u,%u]"),
1320 tag->locktag_field1,
1321 tag->locktag_field2,
1322 tag->locktag_field3,
1323 tag->locktag_field4);
1324 break;
1327 _("remote transaction %u of subscription %u of database %u"),
1328 tag->locktag_field3,
1329 tag->locktag_field2,
1330 tag->locktag_field1);
1331 break;
1332 default:
1334 _("unrecognized locktag type %d"),
1335 (int) tag->locktag_type);
1336 break;
1337 }
1338}
#define _(x)
Definition: elog.c:91
LockTagType
Definition: lock.h:138
@ LOCKTAG_OBJECT
Definition: lock.h:147
@ LOCKTAG_RELATION_EXTEND
Definition: lock.h:140
@ LOCKTAG_RELATION
Definition: lock.h:139
@ LOCKTAG_TUPLE
Definition: lock.h:143
@ LOCKTAG_SPECULATIVE_TOKEN
Definition: lock.h:146
@ LOCKTAG_APPLY_TRANSACTION
Definition: lock.h:150
@ LOCKTAG_USERLOCK
Definition: lock.h:148
@ LOCKTAG_DATABASE_FROZEN_IDS
Definition: lock.h:141
@ LOCKTAG_VIRTUALTRANSACTION
Definition: lock.h:145
@ LOCKTAG_TRANSACTION
Definition: lock.h:144
@ LOCKTAG_PAGE
Definition: lock.h:142
@ LOCKTAG_ADVISORY
Definition: lock.h:149
static char * buf
Definition: pg_test_fsync.c:72
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:145
uint8 locktag_type
Definition: lock.h:172
uint32 locktag_field3
Definition: lock.h:170
uint32 locktag_field1
Definition: lock.h:168
uint16 locktag_field4
Definition: lock.h:171
uint32 locktag_field2
Definition: lock.h:169

References _, appendStringInfo(), buf, LOCKTAG_ADVISORY, LOCKTAG_APPLY_TRANSACTION, LOCKTAG_DATABASE_FROZEN_IDS, LOCKTAG::locktag_field1, LOCKTAG::locktag_field2, LOCKTAG::locktag_field3, LOCKTAG::locktag_field4, LOCKTAG_OBJECT, LOCKTAG_PAGE, LOCKTAG_RELATION, LOCKTAG_RELATION_EXTEND, LOCKTAG_SPECULATIVE_TOKEN, LOCKTAG_TRANSACTION, LOCKTAG_TUPLE, LOCKTAG::locktag_type, LOCKTAG_USERLOCK, and LOCKTAG_VIRTUALTRANSACTION.

Referenced by DeadLockReport(), LockAcquireExtended(), ProcSleep(), and waitonlock_error_callback().

◆ GetLockNameFromTagType()

const char * GetLockNameFromTagType ( uint16  locktag_type)

Definition at line 1346 of file lmgr.c.

1347{
1348 if (locktag_type > LOCKTAG_LAST_TYPE)
1349 return "???";
1350 return LockTagTypeNames[locktag_type];
1351}
#define LOCKTAG_LAST_TYPE
Definition: lock.h:154
const char *const LockTagTypeNames[]
Definition: lockfuncs.c:28

References LOCKTAG_LAST_TYPE, and LockTagTypeNames.

Referenced by pgstat_get_wait_event().

◆ LockApplyTransactionForSession()

void LockApplyTransactionForSession ( Oid  suboid,
TransactionId  xid,
uint16  objid,
LOCKMODE  lockmode 
)

Definition at line 1209 of file lmgr.c.

1211{
1212 LOCKTAG tag;
1213
1216 suboid,
1217 xid,
1218 objid);
1219
1220 (void) LockAcquire(&tag, lockmode, true, false);
1221}
#define SET_LOCKTAG_APPLY_TRANSACTION(locktag, dboid, suboid, xid, objid)
Definition: lock.h:284

References LockAcquire(), MyDatabaseId, and SET_LOCKTAG_APPLY_TRANSACTION.

Referenced by pa_lock_stream(), and pa_lock_transaction().

◆ LockDatabaseFrozenIds()

void LockDatabaseFrozenIds ( LOCKMODE  lockmode)

Definition at line 491 of file lmgr.c.

492{
493 LOCKTAG tag;
494
496
497 (void) LockAcquire(&tag, lockmode, false, false);
498}
#define SET_LOCKTAG_DATABASE_FROZEN_IDS(locktag, dboid)
Definition: lock.h:201

References LockAcquire(), MyDatabaseId, and SET_LOCKTAG_DATABASE_FROZEN_IDS.

Referenced by vac_update_datfrozenxid().

◆ LockDatabaseObject()

void LockDatabaseObject ( Oid  classid,
Oid  objid,
uint16  objsubid,
LOCKMODE  lockmode 
)

Definition at line 1008 of file lmgr.c.

1010{
1011 LOCKTAG tag;
1012
1015 classid,
1016 objid,
1017 objsubid);
1018
1019 (void) LockAcquire(&tag, lockmode, false, false);
1020
1021 /* Make sure syscaches are up-to-date with any changes we waited for */
1023}

References AcceptInvalidationMessages(), LockAcquire(), MyDatabaseId, and SET_LOCKTAG_OBJECT.

Referenced by AcquireDeletionLock(), AddEnumLabel(), AlterPublication(), AlterPublicationOptions(), get_object_address(), LockSchemaList(), RangeVarGetAndCheckCreationNamespace(), and RenameEnumLabel().

◆ LockHasWaitersRelation()

bool LockHasWaitersRelation ( Relation  relation,
LOCKMODE  lockmode 
)

Definition at line 367 of file lmgr.c.

368{
369 LOCKTAG tag;
370
372 relation->rd_lockInfo.lockRelId.dbId,
373 relation->rd_lockInfo.lockRelId.relId);
374
375 return LockHasWaiters(&tag, lockmode, false);
376}
bool LockHasWaiters(const LOCKTAG *locktag, LOCKMODE lockmode, bool sessionLock)
Definition: lock.c:696

References LockRelId::dbId, LockHasWaiters(), LockInfoData::lockRelId, RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_RELATION.

Referenced by count_nondeletable_pages().

◆ LockPage()

void LockPage ( Relation  relation,
BlockNumber  blkno,
LOCKMODE  lockmode 
)

Definition at line 507 of file lmgr.c.

508{
509 LOCKTAG tag;
510
512 relation->rd_lockInfo.lockRelId.dbId,
513 relation->rd_lockInfo.lockRelId.relId,
514 blkno);
515
516 (void) LockAcquire(&tag, lockmode, false, false);
517}

References LockRelId::dbId, LockAcquire(), LockInfoData::lockRelId, RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_PAGE.

Referenced by ginInsertCleanup().

◆ LockRelation()

void LockRelation ( Relation  relation,
LOCKMODE  lockmode 
)

Definition at line 246 of file lmgr.c.

247{
248 LOCKTAG tag;
249 LOCALLOCK *locallock;
251
253 relation->rd_lockInfo.lockRelId.dbId,
254 relation->rd_lockInfo.lockRelId.relId);
255
256 res = LockAcquireExtended(&tag, lockmode, false, false, true, &locallock,
257 false);
258
259 /*
260 * Now that we have the lock, check for invalidation messages; see notes
261 * in LockRelationOid.
262 */
263 if (res != LOCKACQUIRE_ALREADY_CLEAR)
264 {
266 MarkLockClear(locallock);
267 }
268}

References AcceptInvalidationMessages(), LockRelId::dbId, LOCKACQUIRE_ALREADY_CLEAR, LockAcquireExtended(), LockInfoData::lockRelId, MarkLockClear(), RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_RELATION.

Referenced by index_create().

◆ LockRelationForExtension()

void LockRelationForExtension ( Relation  relation,
LOCKMODE  lockmode 
)

◆ LockRelationId()

void LockRelationId ( LockRelId relid,
LOCKMODE  lockmode 
)

Definition at line 185 of file lmgr.c.

186{
187 LOCKTAG tag;
188 LOCALLOCK *locallock;
190
191 SET_LOCKTAG_RELATION(tag, relid->dbId, relid->relId);
192
193 res = LockAcquireExtended(&tag, lockmode, false, false, true, &locallock,
194 false);
195
196 /*
197 * Now that we have the lock, check for invalidation messages; see notes
198 * in LockRelationOid.
199 */
200 if (res != LOCKACQUIRE_ALREADY_CLEAR)
201 {
203 MarkLockClear(locallock);
204 }
205}

References AcceptInvalidationMessages(), LockRelId::dbId, LOCKACQUIRE_ALREADY_CLEAR, LockAcquireExtended(), MarkLockClear(), LockRelId::relId, and SET_LOCKTAG_RELATION.

Referenced by CreateDatabaseUsingWalLog(), and ScanSourceDatabasePgClass().

◆ LockRelationIdForSession()

void LockRelationIdForSession ( LockRelId relid,
LOCKMODE  lockmode 
)

Definition at line 391 of file lmgr.c.

392{
393 LOCKTAG tag;
394
395 SET_LOCKTAG_RELATION(tag, relid->dbId, relid->relId);
396
397 (void) LockAcquire(&tag, lockmode, true, false);
398}

References LockRelId::dbId, LockAcquire(), LockRelId::relId, and SET_LOCKTAG_RELATION.

Referenced by DefineIndex(), index_drop(), ReindexRelationConcurrently(), and vacuum_rel().

◆ LockRelationOid()

void LockRelationOid ( Oid  relid,
LOCKMODE  lockmode 
)

Definition at line 107 of file lmgr.c.

108{
109 LOCKTAG tag;
110 LOCALLOCK *locallock;
112
113 SetLocktagRelationOid(&tag, relid);
114
115 res = LockAcquireExtended(&tag, lockmode, false, false, true, &locallock,
116 false);
117
118 /*
119 * Now that we have the lock, check for invalidation messages, so that we
120 * will update or flush any stale relcache entry before we try to use it.
121 * RangeVarGetRelid() specifically relies on us for this. We can skip
122 * this in the not-uncommon case that we already had the same type of lock
123 * being requested, since then no one else could have modified the
124 * relcache entry in an undesirable way. (In the case where our own xact
125 * modifies the rel, the relcache update happens via
126 * CommandCounterIncrement, not here.)
127 *
128 * However, in corner cases where code acts on tables (usually catalogs)
129 * recursively, we might get here while still processing invalidation
130 * messages in some outer execution of this function or a sibling. The
131 * "cleared" status of the lock tells us whether we really are done
132 * absorbing relevant inval messages.
133 */
134 if (res != LOCKACQUIRE_ALREADY_CLEAR)
135 {
137 MarkLockClear(locallock);
138 }
139}

References AcceptInvalidationMessages(), LOCKACQUIRE_ALREADY_CLEAR, LockAcquireExtended(), MarkLockClear(), and SetLocktagRelationOid().

Referenced by AcquireDeletionLock(), AcquireExecutorLocks(), AlterTableMoveAll(), ATExecAttachPartition(), ATExecDetachPartition(), ATPostAlterTypeCleanup(), binary_upgrade_replorigin_advance(), copy_table_data(), CreateTriggerFiringOn(), find_inheritance_children_extended(), heap_create_with_catalog(), heap_drop_with_catalog(), index_create(), IndexSetParentIndex(), InitCatCachePhase2(), load_critical_index(), lock_and_open_sequence(), LockTableRecurse(), LockViewRecurse_walker(), LogicalRepSyncTableStart(), pg_replication_origin_advance(), RangeVarCallbackForAttachIndex(), RangeVarCallbackForDropRelation(), RangeVarCallbackForReindexIndex(), RangeVarGetAndCheckCreationNamespace(), RangeVarGetRelidExtended(), relation_open(), ScanQueryForLocks(), SequenceChangePersistence(), and try_relation_open().

◆ LockSharedObject()

◆ LockSharedObjectForSession()

void LockSharedObjectForSession ( Oid  classid,
Oid  objid,
uint16  objsubid,
LOCKMODE  lockmode 
)

Definition at line 1169 of file lmgr.c.

1171{
1172 LOCKTAG tag;
1173
1175 InvalidOid,
1176 classid,
1177 objid,
1178 objsubid);
1179
1180 (void) LockAcquire(&tag, lockmode, true, false);
1181}

References InvalidOid, LockAcquire(), and SET_LOCKTAG_OBJECT.

Referenced by dbase_redo(), and movedb().

◆ LockTuple()

◆ RelationExtensionLockWaiterCount()

int RelationExtensionLockWaiterCount ( Relation  relation)

Definition at line 459 of file lmgr.c.

460{
461 LOCKTAG tag;
462
464 relation->rd_lockInfo.lockRelId.dbId,
465 relation->rd_lockInfo.lockRelId.relId);
466
467 return LockWaiterCount(&tag);
468}
int LockWaiterCount(const LOCKTAG *locktag)
Definition: lock.c:4856

References LockRelId::dbId, LockInfoData::lockRelId, LockWaiterCount(), RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_RELATION_EXTEND.

Referenced by RelationAddBlocks().

◆ RelationInitLockInfo()

void RelationInitLockInfo ( Relation  relation)

Definition at line 70 of file lmgr.c.

71{
72 Assert(RelationIsValid(relation));
74
75 relation->rd_lockInfo.lockRelId.relId = RelationGetRelid(relation);
76
77 if (relation->rd_rel->relisshared)
79 else
81}
#define OidIsValid(objectId)
Definition: c.h:775
#define RelationGetRelid(relation)
Definition: rel.h:514
#define RelationIsValid(relation)
Definition: rel.h:489
Form_pg_class rd_rel
Definition: rel.h:111

References Assert(), LockRelId::dbId, InvalidOid, LockInfoData::lockRelId, MyDatabaseId, OidIsValid, RelationData::rd_lockInfo, RelationData::rd_rel, RelationGetRelid, RelationIsValid, and LockRelId::relId.

Referenced by formrdesc(), load_relcache_init_file(), RelationBuildDesc(), and RelationBuildLocalRelation().

◆ SetLocktagRelationOid()

static void SetLocktagRelationOid ( LOCKTAG tag,
Oid  relid 
)
inlinestatic

Definition at line 88 of file lmgr.c.

89{
90 Oid dbid;
91
92 if (IsSharedRelation(relid))
93 dbid = InvalidOid;
94 else
95 dbid = MyDatabaseId;
96
97 SET_LOCKTAG_RELATION(*tag, dbid, relid);
98}
bool IsSharedRelation(Oid relationId)
Definition: catalog.c:304
unsigned int Oid
Definition: postgres_ext.h:32

References InvalidOid, IsSharedRelation(), MyDatabaseId, and SET_LOCKTAG_RELATION.

Referenced by CheckRelationOidLockedByMe(), ConditionalLockRelationOid(), LockRelationOid(), and UnlockRelationOid().

◆ SpeculativeInsertionLockAcquire()

uint32 SpeculativeInsertionLockAcquire ( TransactionId  xid)

Definition at line 786 of file lmgr.c.

787{
788 LOCKTAG tag;
789
791
792 /*
793 * Check for wrap-around. Zero means no token is held, so don't use that.
794 */
797
799
800 (void) LockAcquire(&tag, ExclusiveLock, false, false);
801
803}
static uint32 speculativeInsertionToken
Definition: lmgr.c:45
#define SET_LOCKTAG_SPECULATIVE_INSERTION(locktag, xid, token)
Definition: lock.h:249
#define ExclusiveLock
Definition: lockdefs.h:42

References ExclusiveLock, LockAcquire(), SET_LOCKTAG_SPECULATIVE_INSERTION, and speculativeInsertionToken.

Referenced by ExecInsert().

◆ SpeculativeInsertionLockRelease()

void SpeculativeInsertionLockRelease ( TransactionId  xid)

Definition at line 812 of file lmgr.c.

813{
814 LOCKTAG tag;
815
817
818 LockRelease(&tag, ExclusiveLock, false);
819}

References ExclusiveLock, LockRelease(), SET_LOCKTAG_SPECULATIVE_INSERTION, and speculativeInsertionToken.

Referenced by ExecInsert().

◆ SpeculativeInsertionWait()

void SpeculativeInsertionWait ( TransactionId  xid,
uint32  token 
)

Definition at line 828 of file lmgr.c.

829{
830 LOCKTAG tag;
831
833
835 Assert(token != 0);
836
837 (void) LockAcquire(&tag, ShareLock, false, false);
838 LockRelease(&tag, ShareLock, false);
839}

References Assert(), LockAcquire(), LockRelease(), SET_LOCKTAG_SPECULATIVE_INSERTION, ShareLock, and TransactionIdIsValid.

Referenced by _bt_doinsert(), and check_exclusion_or_unique_constraint().

◆ UnlockApplyTransactionForSession()

void UnlockApplyTransactionForSession ( Oid  suboid,
TransactionId  xid,
uint16  objid,
LOCKMODE  lockmode 
)

Definition at line 1227 of file lmgr.c.

1229{
1230 LOCKTAG tag;
1231
1234 suboid,
1235 xid,
1236 objid);
1237
1238 LockRelease(&tag, lockmode, true);
1239}

References LockRelease(), MyDatabaseId, and SET_LOCKTAG_APPLY_TRANSACTION.

Referenced by pa_unlock_stream(), and pa_unlock_transaction().

◆ UnlockDatabaseObject()

void UnlockDatabaseObject ( Oid  classid,
Oid  objid,
uint16  objsubid,
LOCKMODE  lockmode 
)

Definition at line 1068 of file lmgr.c.

1070{
1071 LOCKTAG tag;
1072
1075 classid,
1076 objid,
1077 objsubid);
1078
1079 LockRelease(&tag, lockmode, false);
1080}

References LockRelease(), MyDatabaseId, and SET_LOCKTAG_OBJECT.

Referenced by get_object_address(), RangeVarGetAndCheckCreationNamespace(), and ReleaseDeletionLock().

◆ UnlockPage()

void UnlockPage ( Relation  relation,
BlockNumber  blkno,
LOCKMODE  lockmode 
)

Definition at line 542 of file lmgr.c.

543{
544 LOCKTAG tag;
545
547 relation->rd_lockInfo.lockRelId.dbId,
548 relation->rd_lockInfo.lockRelId.relId,
549 blkno);
550
551 LockRelease(&tag, lockmode, false);
552}

References LockRelId::dbId, LockRelease(), LockInfoData::lockRelId, RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_PAGE.

Referenced by ginInsertCleanup().

◆ UnlockRelation()

void UnlockRelation ( Relation  relation,
LOCKMODE  lockmode 
)

Definition at line 314 of file lmgr.c.

315{
316 LOCKTAG tag;
317
319 relation->rd_lockInfo.lockRelId.dbId,
320 relation->rd_lockInfo.lockRelId.relId);
321
322 LockRelease(&tag, lockmode, false);
323}

References LockRelId::dbId, LockRelease(), LockInfoData::lockRelId, RelationData::rd_lockInfo, LockRelId::relId, and SET_LOCKTAG_RELATION.

Referenced by lazy_truncate_heap().

◆ UnlockRelationForExtension()

◆ UnlockRelationId()

void UnlockRelationId ( LockRelId relid,
LOCKMODE  lockmode 
)

Definition at line 214 of file lmgr.c.

215{
216 LOCKTAG tag;
217
218 SET_LOCKTAG_RELATION(tag, relid->dbId, relid->relId);
219
220 LockRelease(&tag, lockmode, false);
221}

References LockRelId::dbId, LockRelease(), LockRelId::relId, and SET_LOCKTAG_RELATION.

Referenced by CreateDatabaseUsingWalLog(), index_close(), relation_close(), and ScanSourceDatabasePgClass().

◆ UnlockRelationIdForSession()

void UnlockRelationIdForSession ( LockRelId relid,
LOCKMODE  lockmode 
)

Definition at line 404 of file lmgr.c.

405{
406 LOCKTAG tag;
407
408 SET_LOCKTAG_RELATION(tag, relid->dbId, relid->relId);
409
410 LockRelease(&tag, lockmode, true);
411}

References LockRelId::dbId, LockRelease(), LockRelId::relId, and SET_LOCKTAG_RELATION.

Referenced by DefineIndex(), index_drop(), ReindexRelationConcurrently(), and vacuum_rel().

◆ UnlockRelationOid()

◆ UnlockSharedObject()

void UnlockSharedObject ( Oid  classid,
Oid  objid,
uint16  objsubid,
LOCKMODE  lockmode 
)

Definition at line 1148 of file lmgr.c.

1150{
1151 LOCKTAG tag;
1152
1154 InvalidOid,
1155 classid,
1156 objid,
1157 objsubid);
1158
1159 LockRelease(&tag, lockmode, false);
1160}

References InvalidOid, LockRelease(), and SET_LOCKTAG_OBJECT.

Referenced by AddSubscriptionRelState(), AlterDatabaseSet(), createdb_failure_callback(), drop_local_obsolete_slots(), get_db_info(), get_object_address(), replorigin_drop_by_name(), and synchronize_slots().

◆ UnlockSharedObjectForSession()

void UnlockSharedObjectForSession ( Oid  classid,
Oid  objid,
uint16  objsubid,
LOCKMODE  lockmode 
)

Definition at line 1187 of file lmgr.c.

1189{
1190 LOCKTAG tag;
1191
1193 InvalidOid,
1194 classid,
1195 objid,
1196 objsubid);
1197
1198 LockRelease(&tag, lockmode, true);
1199}

References InvalidOid, LockRelease(), and SET_LOCKTAG_OBJECT.

Referenced by dbase_redo(), and movedb().

◆ UnlockTuple()

◆ WaitForLockers()

void WaitForLockers ( LOCKTAG  heaplocktag,
LOCKMODE  lockmode,
bool  progress 
)

Definition at line 989 of file lmgr.c.

990{
991 List *l;
992
993 l = list_make1(&heaplocktag);
994 WaitForLockersMultiple(l, lockmode, progress);
995 list_free(l);
996}
void list_free(List *list)
Definition: list.c:1546
void WaitForLockersMultiple(List *locktags, LOCKMODE lockmode, bool progress)
Definition: lmgr.c:911
#define list_make1(x1)
Definition: pg_list.h:212
static int progress
Definition: pgbench.c:262
Definition: pg_list.h:54

References list_free(), list_make1, progress, and WaitForLockersMultiple().

Referenced by DefineIndex(), and index_drop().

◆ WaitForLockersMultiple()

void WaitForLockersMultiple ( List locktags,
LOCKMODE  lockmode,
bool  progress 
)

Definition at line 911 of file lmgr.c.

912{
913 List *holders = NIL;
914 ListCell *lc;
915 int total = 0;
916 int done = 0;
917
918 /* Done if no locks to wait for */
919 if (locktags == NIL)
920 return;
921
922 /* Collect the transactions we need to wait on */
923 foreach(lc, locktags)
924 {
925 LOCKTAG *locktag = lfirst(lc);
926 int count;
927
928 holders = lappend(holders,
929 GetLockConflicts(locktag, lockmode,
930 progress ? &count : NULL));
931 if (progress)
932 total += count;
933 }
934
935 if (progress)
937
938 /*
939 * Note: GetLockConflicts() never reports our own xid, hence we need not
940 * check for that. Also, prepared xacts are reported and awaited.
941 */
942
943 /* Finally wait for each such transaction to complete */
944 foreach(lc, holders)
945 {
946 VirtualTransactionId *lockholders = lfirst(lc);
947
948 while (VirtualTransactionIdIsValid(*lockholders))
949 {
950 /* If requested, publish who we're going to wait for. */
951 if (progress)
952 {
953 PGPROC *holder = ProcNumberGetProc(lockholders->procNumber);
954
955 if (holder)
957 holder->pid);
958 }
959 VirtualXactLock(*lockholders, true);
960 lockholders++;
961
962 if (progress)
964 }
965 }
966 if (progress)
967 {
968 const int index[] = {
972 };
973 const int64 values[] = {
974 0, 0, 0
975 };
976
978 }
979
980 list_free_deep(holders);
981}
void pgstat_progress_update_param(int index, int64 val)
void pgstat_progress_update_multi_param(int nparam, const int *index, const int64 *val)
static Datum values[MAXATTR]
Definition: bootstrap.c:153
int64_t int64
Definition: c.h:536
List * lappend(List *list, void *datum)
Definition: list.c:339
void list_free_deep(List *list)
Definition: list.c:1560
bool VirtualXactLock(VirtualTransactionId vxid, bool wait)
Definition: lock.c:4745
VirtualTransactionId * GetLockConflicts(const LOCKTAG *locktag, LOCKMODE lockmode, int *countp)
Definition: lock.c:3069
#define VirtualTransactionIdIsValid(vxid)
Definition: lock.h:69
#define lfirst(lc)
Definition: pg_list.h:172
#define NIL
Definition: pg_list.h:68
PGPROC * ProcNumberGetProc(ProcNumber procNumber)
Definition: procarray.c:3100
#define PROGRESS_WAITFOR_DONE
Definition: progress.h:120
#define PROGRESS_WAITFOR_TOTAL
Definition: progress.h:119
#define PROGRESS_WAITFOR_CURRENT_PID
Definition: progress.h:121
Definition: proc.h:179
int pid
Definition: proc.h:199
ProcNumber procNumber
Definition: lock.h:63
Definition: type.h:96

References GetLockConflicts(), lappend(), lfirst, list_free_deep(), NIL, pgstat_progress_update_multi_param(), pgstat_progress_update_param(), PGPROC::pid, VirtualTransactionId::procNumber, ProcNumberGetProc(), progress, PROGRESS_WAITFOR_CURRENT_PID, PROGRESS_WAITFOR_DONE, PROGRESS_WAITFOR_TOTAL, values, VirtualTransactionIdIsValid, and VirtualXactLock().

Referenced by ATExecDetachPartition(), ReindexRelationConcurrently(), and WaitForLockers().

◆ XactLockTableDelete()

void XactLockTableDelete ( TransactionId  xid)

Definition at line 639 of file lmgr.c.

640{
641 LOCKTAG tag;
642
643 SET_LOCKTAG_TRANSACTION(tag, xid);
644
645 LockRelease(&tag, ExclusiveLock, false);
646}

References ExclusiveLock, LockRelease(), and SET_LOCKTAG_TRANSACTION.

Referenced by CommitSubTransaction().

◆ XactLockTableInsert()

void XactLockTableInsert ( TransactionId  xid)

Definition at line 622 of file lmgr.c.

623{
624 LOCKTAG tag;
625
626 SET_LOCKTAG_TRANSACTION(tag, xid);
627
628 (void) LockAcquire(&tag, ExclusiveLock, false, false);
629}

References ExclusiveLock, LockAcquire(), and SET_LOCKTAG_TRANSACTION.

Referenced by AssignTransactionId().

◆ XactLockTableWait()

void XactLockTableWait ( TransactionId  xid,
Relation  rel,
const ItemPointerData ctid,
XLTW_Oper  oper 
)

Definition at line 663 of file lmgr.c.

665{
666 LOCKTAG tag;
669 bool first = true;
670
671 /*
672 * If an operation is specified, set up our verbose error context
673 * callback.
674 */
675 if (oper != XLTW_None)
676 {
679
680 info.rel = rel;
681 info.ctid = ctid;
682 info.oper = oper;
683
685 callback.arg = &info;
686 callback.previous = error_context_stack;
688 }
689
690 for (;;)
691 {
694
695 SET_LOCKTAG_TRANSACTION(tag, xid);
696
697 (void) LockAcquire(&tag, ShareLock, false, false);
698
699 LockRelease(&tag, ShareLock, false);
700
702 break;
703
704 /*
705 * If the Xid belonged to a subtransaction, then the lock would have
706 * gone away as soon as it was finished; for correct tuple visibility,
707 * the right action is to wait on its parent transaction to go away.
708 * But instead of going levels up one by one, we can just wait for the
709 * topmost transaction to finish with the same end result, which also
710 * incurs less locktable traffic.
711 *
712 * Some uses of this function don't involve tuple visibility -- such
713 * as when building snapshots for logical decoding. It is possible to
714 * see a transaction in ProcArray before it registers itself in the
715 * locktable. The topmost transaction in that case is the same xid,
716 * so we try again after a short sleep. (Don't sleep the first time
717 * through, to avoid slowing down the normal case.)
718 */
719 if (!first)
720 {
722 pg_usleep(1000L);
723 }
724 first = false;
726 }
727
728 if (oper != XLTW_None)
729 error_context_stack = callback.previous;
730}
ErrorContextCallback * error_context_stack
Definition: elog.c:95
static bool ItemPointerIsValid(const ItemPointerData *pointer)
Definition: itemptr.h:83
static void XactLockTableWaitErrorCb(void *arg)
Definition: lmgr.c:846
@ XLTW_None
Definition: lmgr.h:26
Operator oper(ParseState *pstate, List *opname, Oid ltypeId, Oid rtypeId, bool noError, int location)
Definition: parse_oper.c:371
const ItemPointerData * ctid
Definition: lmgr.c:58
XLTW_Oper oper
Definition: lmgr.c:56
Relation rel
Definition: lmgr.c:57
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
Definition: test_ifaddrs.c:46

References Assert(), callback(), CHECK_FOR_INTERRUPTS, XactLockTableWaitInfo::ctid, error_context_stack, GetTopTransactionIdIfAny(), ItemPointerIsValid(), LockAcquire(), LockRelease(), oper(), XactLockTableWaitInfo::oper, pg_usleep(), XactLockTableWaitInfo::rel, RelationIsValid, SET_LOCKTAG_TRANSACTION, ShareLock, SubTransGetTopmostTransaction(), TransactionIdEquals, TransactionIdIsInProgress(), TransactionIdIsValid, XactLockTableWaitErrorCb(), and XLTW_None.

Referenced by _bt_doinsert(), check_exclusion_or_unique_constraint(), Do_MultiXactIdWait(), heap_delete(), heap_inplace_lock(), heap_lock_tuple(), heap_lock_updated_tuple_rec(), heap_update(), heapam_index_build_range_scan(), heapam_tuple_lock(), RelationFindReplTupleByIndex(), RelationFindReplTupleSeq(), and SnapBuildWaitSnapshot().

◆ XactLockTableWaitErrorCb()

static void XactLockTableWaitErrorCb ( void *  arg)
static

Definition at line 846 of file lmgr.c.

847{
849
850 /*
851 * We would like to print schema name too, but that would require a
852 * syscache lookup.
853 */
854 if (info->oper != XLTW_None &&
856 {
857 const char *cxt;
858
859 switch (info->oper)
860 {
861 case XLTW_Update:
862 cxt = gettext_noop("while updating tuple (%u,%u) in relation \"%s\"");
863 break;
864 case XLTW_Delete:
865 cxt = gettext_noop("while deleting tuple (%u,%u) in relation \"%s\"");
866 break;
867 case XLTW_Lock:
868 cxt = gettext_noop("while locking tuple (%u,%u) in relation \"%s\"");
869 break;
870 case XLTW_LockUpdated:
871 cxt = gettext_noop("while locking updated version (%u,%u) of tuple in relation \"%s\"");
872 break;
873 case XLTW_InsertIndex:
874 cxt = gettext_noop("while inserting index tuple (%u,%u) in relation \"%s\"");
875 break;
877 cxt = gettext_noop("while checking uniqueness of tuple (%u,%u) in relation \"%s\"");
878 break;
880 cxt = gettext_noop("while rechecking updated tuple (%u,%u) in relation \"%s\"");
881 break;
883 cxt = gettext_noop("while checking exclusion constraint on tuple (%u,%u) in relation \"%s\"");
884 break;
885
886 default:
887 return;
888 }
889
890 errcontext(cxt,
894 }
895}
#define gettext_noop(x)
Definition: c.h:1196
#define errcontext
Definition: elog.h:198
@ XLTW_FetchUpdated
Definition: lmgr.h:33
@ XLTW_Lock
Definition: lmgr.h:29
@ XLTW_Delete
Definition: lmgr.h:28
@ XLTW_InsertIndex
Definition: lmgr.h:31
@ XLTW_LockUpdated
Definition: lmgr.h:30
@ XLTW_RecheckExclusionConstr
Definition: lmgr.h:34
@ XLTW_Update
Definition: lmgr.h:27
@ XLTW_InsertIndexUnique
Definition: lmgr.h:32
void * arg
#define RelationGetRelationName(relation)
Definition: rel.h:548

References arg, XactLockTableWaitInfo::ctid, errcontext, gettext_noop, ItemPointerGetBlockNumber(), ItemPointerGetOffsetNumber(), ItemPointerIsValid(), XactLockTableWaitInfo::oper, XactLockTableWaitInfo::rel, RelationGetRelationName, RelationIsValid, XLTW_Delete, XLTW_FetchUpdated, XLTW_InsertIndex, XLTW_InsertIndexUnique, XLTW_Lock, XLTW_LockUpdated, XLTW_None, XLTW_RecheckExclusionConstr, and XLTW_Update.

Referenced by XactLockTableWait().

Variable Documentation

◆ speculativeInsertionToken

uint32 speculativeInsertionToken = 0
static

Definition at line 45 of file lmgr.c.

Referenced by SpeculativeInsertionLockAcquire(), and SpeculativeInsertionLockRelease().