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

Commitde9c553

Browse files
committed
Clean up locktable init code per recent gripe from Kurt Roeckx.
No change in behavior, but old code would have failed to detectoverrun of MAX_LOCKMODES.
1 parentc771838 commitde9c553

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lmgr.c,v 1.58 2003/08/04 02:40:03 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lmgr.c,v 1.59 2003/08/17 22:41:12 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -76,8 +76,10 @@ InitLockTable(int maxBackends)
7676
{
7777
intlockmethod;
7878

79+
/* number of lock modes is lengthof()-1 because of dummy zero */
7980
lockmethod=LockMethodTableInit("LockTable",
80-
LockConflicts,MAX_LOCKMODES-1,
81+
LockConflicts,
82+
lengthof(LockConflicts)-1,
8183
maxBackends);
8284
LockTableId=lockmethod;
8385

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.126 2003/08/04 02:40:03 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.127 2003/08/17 22:41:12 tgl Exp $
1212
*
1313
* NOTES
1414
* Outside modules can create a lock table and acquire/release
@@ -212,8 +212,8 @@ LockMethodInit(LOCKMETHODTABLE *lockMethodTable,
212212
inti;
213213

214214
lockMethodTable->numLockModes=numModes;
215-
numModes++;
216-
for (i=0;i<numModes;i++,conflictsP++)
215+
/* copies useless zero element as well as the N lockmodes */
216+
for (i=0;i <=numModes;i++,conflictsP++)
217217
lockMethodTable->conflictTab[i]=*conflictsP;
218218
}
219219

@@ -241,11 +241,8 @@ LockMethodTableInit(char *tabName,
241241
max_table_size;
242242

243243
if (numModes >=MAX_LOCKMODES)
244-
{
245-
elog(WARNING,"too many lock types %d (limit is %d)",
246-
numModes,MAX_LOCKMODES);
247-
returnINVALID_LOCKMETHOD;
248-
}
244+
elog(ERROR,"too many lock types %d (limit is %d)",
245+
numModes,MAX_LOCKMODES-1);
249246

250247
/* Compute init/max size to request for lock hashtables */
251248
max_table_size=NLOCKENTS(maxBackends);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp