Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3d59ad0

Browse files
committed
Remove useless LockDisable() function and associated overhead, per my
proposal of 26-Aug.
1 parent 19656b7 commit 3d59ad0

File tree

8 files changed

+45
-127
lines changed

8 files changed

+45
-127
lines changed

doc/src/sgml/ref/postgres-ref.sgml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/postgres-ref.sgml,v 1.19 2001/09/08 15:24:00 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/postgres-ref.sgml,v 1.20 2001/09/27 16:29:12 tgl Exp $
33
Postgres documentation
44
-->
55

@@ -33,7 +33,6 @@ Postgres documentation
3333
<arg>-f<group choice="plain"><arg>s</arg><arg>i</arg><arg>t</arg><arg>n</arg><arg>m</arg><arg>h</arg></group></arg>
3434
<arg>-F</arg>
3535
<arg>-i</arg>
36-
<arg>-L</arg>
3736
<arg>-N</arg>
3837
<arg>-o <replaceable>filename</replaceable></arg>
3938
<arg>-O</arg>
@@ -57,7 +56,6 @@ Postgres documentation
5756
<arg>-f<group choice="plain"><arg>s</arg><arg>i</arg><arg>t</arg><arg>n</arg><arg>m</arg><arg>h</arg></group></arg>
5857
<arg>-F</arg>
5958
<arg>-i</arg>
60-
<arg>-L</arg>
6159
<arg>-o <replaceable>filename</replaceable></arg>
6260
<arg>-O</arg>
6361
<arg>-p <replaceable>database</replaceable></arg>
@@ -293,15 +291,6 @@ Postgres documentation
293291
</listitem>
294292
</varlistentry>
295293

296-
<varlistentry>
297-
<term>-L</term>
298-
<listitem>
299-
<para>
300-
Turns off the locking system.
301-
</para>
302-
</listitem>
303-
</varlistentry>
304-
305294
<varlistentry>
306295
<term>-O</term>
307296
<listitem>

src/backend/bootstrap/bootstrap.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.115 2001/08/25 00:31:17 petere Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.116 2001/09/27 16:29:12 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -389,7 +389,6 @@ BootstrapMain(int argc, char *argv[])
389389
* backend initialization
390390
*/
391391
InitPostgres(dbName, NULL);
392-
LockDisable(true);
393392

394393
for (i = 0; i < MAXATTR; i++)
395394
{

src/backend/storage/lmgr/lmgr.c

Lines changed: 24 additions & 48 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.50 2001/08/25 18:52:42 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lmgr.c,v 1.51 2001/09/27 16:29:12 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -145,9 +145,6 @@ LockRelation(Relation relation, LOCKMODE lockmode)
145145
{
146146
LOCKTAG tag;
147147

148-
if (LockingDisabled())
149-
return;
150-
151148
MemSet(&tag, 0, sizeof(tag));
152149
tag.relId = relation->rd_lockInfo.lockRelId.relId;
153150
tag.dbId = relation->rd_lockInfo.lockRelId.dbId;
@@ -182,9 +179,6 @@ ConditionalLockRelation(Relation relation, LOCKMODE lockmode)
182179
{
183180
LOCKTAG tag;
184181

185-
if (LockingDisabled())
186-
return true;
187-
188182
MemSet(&tag, 0, sizeof(tag));
189183
tag.relId = relation->rd_lockInfo.lockRelId.relId;
190184
tag.dbId = relation->rd_lockInfo.lockRelId.dbId;
@@ -215,9 +209,6 @@ UnlockRelation(Relation relation, LOCKMODE lockmode)
215209
{
216210
LOCKTAG tag;
217211

218-
if (LockingDisabled())
219-
return;
220-
221212
MemSet(&tag, 0, sizeof(tag));
222213
tag.relId = relation->rd_lockInfo.lockRelId.relId;
223214
tag.dbId = relation->rd_lockInfo.lockRelId.dbId;
@@ -243,9 +234,6 @@ LockRelationForSession(LockRelId *relid, LOCKMODE lockmode)
243234
{
244235
LOCKTAG tag;
245236

246-
if (LockingDisabled())
247-
return;
248-
249237
MemSet(&tag, 0, sizeof(tag));
250238
tag.relId = relid->relId;
251239
tag.dbId = relid->dbId;
@@ -264,9 +252,6 @@ UnlockRelationForSession(LockRelId *relid, LOCKMODE lockmode)
264252
{
265253
LOCKTAG tag;
266254

267-
if (LockingDisabled())
268-
return;
269-
270255
MemSet(&tag, 0, sizeof(tag));
271256
tag.relId = relid->relId;
272257
tag.dbId = relid->dbId;
@@ -277,15 +262,16 @@ UnlockRelationForSession(LockRelId *relid, LOCKMODE lockmode)
277262

278263
/*
279264
* LockPage
265+
*
266+
* Obtain a page-level lock. This is currently used by some index access
267+
* methods to lock index pages. For heap relations, it is used only with
268+
* blkno == 0 to signify locking the relation for extension.
280269
*/
281270
void
282271
LockPage(Relation relation, BlockNumber blkno, LOCKMODE lockmode)
283272
{
284273
LOCKTAG tag;
285274

286-
if (LockingDisabled())
287-
return;
288-
289275
MemSet(&tag, 0, sizeof(tag));
290276
tag.relId = relation->rd_lockInfo.lockRelId.relId;
291277
tag.dbId = relation->rd_lockInfo.lockRelId.dbId;
@@ -304,9 +290,6 @@ UnlockPage(Relation relation, BlockNumber blkno, LOCKMODE lockmode)
304290
{
305291
LOCKTAG tag;
306292

307-
if (LockingDisabled())
308-
return;
309-
310293
MemSet(&tag, 0, sizeof(tag));
311294
tag.relId = relation->rd_lockInfo.lockRelId.relId;
312295
tag.dbId = relation->rd_lockInfo.lockRelId.dbId;
@@ -315,14 +298,21 @@ UnlockPage(Relation relation, BlockNumber blkno, LOCKMODE lockmode)
315298
LockRelease(LockTableId, &tag, GetCurrentTransactionId(), lockmode);
316299
}
317300

301+
/*
302+
* XactLockTableInsert
303+
*
304+
* Insert a lock showing that the given transaction ID is running ---
305+
* this is done during xact startup. The lock can then be used to wait
306+
* for the transaction to finish.
307+
*
308+
* We need no corresponding unlock function, since the lock will always
309+
* be released implicitly at transaction commit/abort, never any other way.
310+
*/
318311
void
319312
XactLockTableInsert(TransactionId xid)
320313
{
321314
LOCKTAG tag;
322315

323-
if (LockingDisabled())
324-
return;
325-
326316
MemSet(&tag, 0, sizeof(tag));
327317
tag.relId = XactLockTableId;
328318
tag.dbId = InvalidOid; /* xids are globally unique */
@@ -333,43 +323,29 @@ XactLockTableInsert(TransactionId xid)
333323
elog(ERROR, "XactLockTableInsert: LockAcquire failed");
334324
}
335325

336-
#ifdef NOT_USED
337-
void
338-
XactLockTableDelete(TransactionId xid)
339-
{
340-
LOCKTAG tag;
341-
342-
if (LockingDisabled())
343-
return;
344-
345-
MemSet(&tag, 0, sizeof(tag));
346-
tag.relId = XactLockTableId;
347-
tag.dbId = InvalidOid;
348-
tag.objId.xid = xid;
349-
350-
LockRelease(LockTableId, &tag, xid, ExclusiveLock);
351-
}
352-
353-
#endif
354-
326+
/*
327+
* XactLockTableWait
328+
*
329+
* Wait for the specified transaction to commit or abort.
330+
*/
355331
void
356332
XactLockTableWait(TransactionId xid)
357333
{
358334
LOCKTAG tag;
335+
TransactionId myxid = GetCurrentTransactionId();
359336

360-
if (LockingDisabled())
361-
return;
337+
Assert(! TransactionIdEquals(xid, myxid));
362338

363339
MemSet(&tag, 0, sizeof(tag));
364340
tag.relId = XactLockTableId;
365341
tag.dbId = InvalidOid;
366342
tag.objId.xid = xid;
367343

368-
if (!LockAcquire(LockTableId, &tag, GetCurrentTransactionId(),
344+
if (!LockAcquire(LockTableId, &tag, myxid,
369345
ShareLock, false))
370346
elog(ERROR, "XactLockTableWait: LockAcquire failed");
371347

372-
LockRelease(LockTableId, &tag, GetCurrentTransactionId(), ShareLock);
348+
LockRelease(LockTableId, &tag, myxid, ShareLock);
373349

374350
/*
375351
* Transaction was committed/aborted/crashed - we have to update

src/backend/storage/lmgr/lock.c

Lines changed: 1 addition & 29 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.94 2001/09/07 00:27:29 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.95 2001/09/27 16:29:12 tgl Exp $
1212
*
1313
* NOTES
1414
* Outside modules can create a lock table and acquire/release
@@ -165,11 +165,6 @@ SPINLOCK LockMgrLock; /* in Shmem or created in
165165
static LOCKMASK BITS_OFF[MAX_LOCKMODES];
166166
static LOCKMASK BITS_ON[MAX_LOCKMODES];
167167

168-
/*
169-
* Disable flag
170-
*/
171-
static bool LockingIsDisabled;
172-
173168
/*
174169
* map from lockmethod to the lock table structure
175170
*/
@@ -195,23 +190,6 @@ InitLocks(void)
195190
}
196191
}
197192

198-
/*
199-
* LockDisable -- sets LockingIsDisabled flag to TRUE or FALSE.
200-
*/
201-
void
202-
LockDisable(bool status)
203-
{
204-
LockingIsDisabled = status;
205-
}
206-
207-
/*
208-
* Boolean function to determine current locking status
209-
*/
210-
bool
211-
LockingDisabled(void)
212-
{
213-
return LockingIsDisabled;
214-
}
215193

216194
/*
217195
* Fetch the lock method table associated with a given lock
@@ -509,9 +487,6 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag,
509487
return FALSE;
510488
}
511489

512-
if (LockingIsDisabled)
513-
return TRUE;
514-
515490
masterLock = lockMethodTable->ctl->masterLock;
516491

517492
SpinAcquire(masterLock);
@@ -1047,9 +1022,6 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag,
10471022
return FALSE;
10481023
}
10491024

1050-
if (LockingIsDisabled)
1051-
return TRUE;
1052-
10531025
masterLock = lockMethodTable->ctl->masterLock;
10541026
SpinAcquire(masterLock);
10551027

src/backend/tcop/postgres.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.233 2001/09/21 17:06:12 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.234 2001/09/27 16:29:12 tgl Exp $
1212
*
1313
* NOTES
1414
* this is the "main" module of the postgres backend and
@@ -1096,7 +1096,6 @@ usage(char *progname)
10961096
printf("Developer options:\n");
10971097
printf(" -f [s|i|n|m|h] forbid use of some plan types\n");
10981098
printf(" -i do not execute queries\n");
1099-
printf(" -L turn off locking\n");
11001099
printf(" -O allow system table structure changes\n");
11011100
printf(" -t [pa|pl|ex] show timings after each query\n");
11021101
printf(" -W NUM wait NUM seconds to allow attach from a debugger\n");
@@ -1207,7 +1206,7 @@ PostgresMain(int argc, char *argv[],
12071206

12081207
optind = 1; /* reset after postmaster's usage */
12091208

1210-
while ((flag = getopt(argc, argv, "A:B:c:CD:d:Eef:FiLNOPo:p:S:st:v:W:x:-:")) != EOF)
1209+
while ((flag = getopt(argc, argv, "A:B:c:CD:d:Eef:FiNOPo:p:S:st:v:W:x:-:")) != EOF)
12111210
switch (flag)
12121211
{
12131212
case 'A':
@@ -1314,15 +1313,6 @@ PostgresMain(int argc, char *argv[],
13141313
dontExecute = true;
13151314
break;
13161315

1317-
case 'L':
1318-
1319-
/*
1320-
* turn off locking
1321-
*/
1322-
if (secure)
1323-
lockingOff = 1;
1324-
break;
1325-
13261316
case 'N':
13271317

13281318
/*
@@ -1726,7 +1716,7 @@ PostgresMain(int argc, char *argv[],
17261716
if (!IsUnderPostmaster)
17271717
{
17281718
puts("\nPOSTGRES backend interactive interface ");
1729-
puts("$Revision: 1.233 $ $Date: 2001/09/21 17:06:12 $\n");
1719+
puts("$Revision: 1.234 $ $Date: 2001/09/27 16:29:12 $\n");
17301720
}
17311721

17321722
/*

src/backend/utils/init/postinit.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.91 2001/09/08 15:24:00 petere Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.92 2001/09/27 16:29:12 tgl Exp $
1212
*
1313
*
1414
*-------------------------------------------------------------------------
@@ -46,8 +46,6 @@ static void InitCommunication(void);
4646
static void ShutdownPostgres(void);
4747
static bool ThereIsAtLeastOneUser(void);
4848

49-
int lockingOff = 0; /* backend -L switch */
50-
5149

5250
/*** InitPostgres support ***/
5351

@@ -327,9 +325,6 @@ InitPostgres(const char *dbname, const char *username)
327325
/* replace faked-up relcache entries with the real info */
328326
RelationCacheInitializePhase2();
329327

330-
if (lockingOff)
331-
LockDisable(true);
332-
333328
/*
334329
* Figure out our postgres user id. In standalone mode we use a
335330
* fixed id, otherwise we figure it out from the authenticated

0 commit comments

Comments
 (0)