Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite7ca867

Browse files
committed
Try to reduce confusion about what is a lock method identifier, a lock
method control structure, or a table of control structures.. Use type LOCKMASK where an int is not a counter.. Get rid of INVALID_TABLEID, use INVALID_LOCKMETHOD instead.. Use INVALID_LOCKMETHOD instead of (LOCKMETHOD) NULL, because LOCKMETHOD is not a pointer.. Define and use macro LockMethodIsValid.. Rename LOCKMETHOD to LOCKMETHODID.. Remove global variable LongTermTableId in lmgr.c, because it is never used.. Make LockTableId static in lmgr.c, because it is used nowhere else. Why not remove it and use DEFAULT_LOCKMETHOD?. Rename the lock method control structure from LOCKMETHODTABLE to LockMethodData. Introduce a pointer type named LockMethod.. Remove elog(FATAL) after InitLockTable() call in CreateSharedMemoryAndSemaphores(), because if something goes wrong, there is elog(FATAL) in LockMethodTableInit(), and if this doesn't help, an elog(ERROR) in InitLockTable() is promoted to FATAL.. Make InitLockTable() void, because its only caller does not use its return value any more.. Rename variables in lock.c to avoid statements like LockMethodTable[NumLockMethods] = lockMethodTable; lockMethodTable = LockMethodTable[lockmethod];. Change LOCKMETHODID type to uint16 to fit into struct LOCKTAG.. Remove static variables BITS_OFF and BITS_ON from lock.c, because I agree to this doubt: * XXX is a fetch from a static array really faster than a shift?. Define and use macros LOCKBIT_ON/OFF.Manfred Koizar
1 parente2ac58c commite7ca867

File tree

8 files changed

+153
-181
lines changed

8 files changed

+153
-181
lines changed

‎src/backend/storage/ipc/ipci.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/storage/ipc/ipci.c,v 1.58 2003/11/29 19:51:56 pgsql Exp $
11+
* $PostgreSQL: pgsql/src/backend/storage/ipc/ipci.c,v 1.59 2003/12/01 21:59:25 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -111,8 +111,7 @@ CreateSharedMemoryAndSemaphores(bool makePrivate,
111111
* Set up lock manager
112112
*/
113113
InitLocks();
114-
if (InitLockTable(maxBackends)==INVALID_TABLEID)
115-
elog(FATAL,"could not create the lock table");
114+
InitLockTable(maxBackends);
116115

117116
/*
118117
* Set up process table

‎src/backend/storage/lmgr/deadlock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/backend/storage/lmgr/deadlock.c,v 1.26 2003/11/29 19:51:56 pgsql Exp $
15+
* $PostgreSQL: pgsql/src/backend/storage/lmgr/deadlock.c,v 1.27 2003/12/01 21:59:25 momjian Exp $
1616
*
1717
*Interface:
1818
*
@@ -428,7 +428,7 @@ FindLockCycleRecurse(PGPROC *checkProc,
428428
LOCK*lock;
429429
PROCLOCK*proclock;
430430
SHM_QUEUE*lockHolders;
431-
LOCKMETHODTABLE*lockMethodTable;
431+
LockMethodlockMethodTable;
432432
PROC_QUEUE*waitQueue;
433433
intqueue_size;
434434
intconflictMask;

‎src/backend/storage/lmgr/lmgr.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lmgr.c,v 1.61 2003/11/29 19:51:56 pgsql Exp $
11+
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lmgr.c,v 1.62 2003/12/01 21:59:25 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -65,38 +65,35 @@ static LOCKMASK LockConflicts[] = {
6565

6666
};
6767

68-
LOCKMETHODLockTableId= (LOCKMETHOD)NULL;
69-
LOCKMETHODLongTermTableId= (LOCKMETHOD)NULL;
68+
staticLOCKMETHODIDLockTableId=INVALID_LOCKMETHOD;
7069

7170
/*
7271
* Create the lock table described by LockConflicts
7372
*/
74-
LOCKMETHOD
73+
void
7574
InitLockTable(intmaxBackends)
7675
{
77-
intlockmethod;
76+
LOCKMETHODIDLongTermTableId;
7877

7978
/* number of lock modes is lengthof()-1 because of dummy zero */
80-
lockmethod=LockMethodTableInit("LockTable",
81-
LockConflicts,
82-
lengthof(LockConflicts)-1,
83-
maxBackends);
84-
LockTableId=lockmethod;
85-
86-
if (!(LockTableId))
79+
LockTableId=LockMethodTableInit("LockTable",
80+
LockConflicts,
81+
lengthof(LockConflicts)-1,
82+
maxBackends);
83+
if (!LockMethodIsValid(LockTableId))
8784
elog(ERROR,"could not initialize lock table");
85+
Assert(LockTableId==DEFAULT_LOCKMETHOD);
8886

8987
#ifdefUSER_LOCKS
9088

9189
/*
9290
* Allocate another tableId for long-term locks
9391
*/
9492
LongTermTableId=LockMethodTableRename(LockTableId);
95-
if (!(LongTermTableId))
93+
if (!LockMethodIsValid(LongTermTableId))
9694
elog(ERROR,"could not rename long-term lock table");
95+
Assert(LongTermTableId==USER_LOCKMETHOD);
9796
#endif
98-
99-
returnLockTableId;
10097
}
10198

10299
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp