⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 single.c

📁 关系型数据库 Postgresql 6.5.2
💻 C
字号:
/*------------------------------------------------------------------------- * * single.c *	  set single locks in the multi-level lock hierarchy * *	  Sometimes we don't want to set all levels of the multi-level *		lock hierarchy at once.  This allows us to set and release *		one level at a time.  It's useful in index scans when *		you can set an intent lock at the beginning and thereafter *		only set page locks.  Tends to speed things up. * * Copyright (c) 1994, Regents of the University of California * * * IDENTIFICATION *	  $Header: /usr/local/cvsroot/pgsql/src/backend/storage/lmgr/single.c,v 1.10 1999/02/13 23:18:29 momjian Exp $ * *------------------------------------------------------------------------- */#include <string.h>#include "postgres.h"#include "storage/lmgr.h"		/* where the declarations go */#include "storage/lock.h"#include "storage/multilev.h"#include "utils/rel.h"/* * SingleLockReln -- lock a relation * * Returns: TRUE if the lock can be set, FALSE otherwise. */boolSingleLockReln(LockInfo lockinfo, LOCKMODE lockmode, int action){	LOCKTAG		tag;	/*	 * LOCKTAG has two bytes of padding, unfortunately.  The hash function	 * will return miss if the padding bytes aren't zero'd.	 */	MemSet(&tag, 0, sizeof(tag));	tag.relId = lockinfo->lockRelId.relId;	tag.dbId = lockinfo->lockRelId.dbId;	BlockIdSet(&(tag.tupleId.ip_blkid), InvalidBlockNumber);	tag.tupleId.ip_posid = InvalidOffsetNumber;	if (action == UNLOCK)		return LockRelease(MultiTableId, &tag, lockmode);	else		return LockAcquire(MultiTableId, &tag, lockmode);}/* * SingleLockPage -- use multi-level lock table, but lock *		only at the page level. * * Assumes that an INTENT lock has already been set in the * multi-level lock table. * */boolSingleLockPage(LockInfo lockinfo,			   ItemPointer tidPtr,			   LOCKMODE lockmode,			   int action){	LOCKTAG		tag;	/*	 * LOCKTAG has two bytes of padding, unfortunately.  The hash function	 * will return miss if the padding bytes aren't zero'd.	 */	MemSet(&tag, 0, sizeof(tag));	tag.relId = lockinfo->lockRelId.relId;	tag.dbId = lockinfo->lockRelId.dbId;	BlockIdCopy(&(tag.tupleId.ip_blkid), &(tidPtr->ip_blkid));	tag.tupleId.ip_posid = InvalidOffsetNumber;	if (action == UNLOCK)		return LockRelease(MultiTableId, &tag, lockmode);	else		return LockAcquire(MultiTableId, &tag, lockmode);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -