12
12
*
13
13
*
14
14
* IDENTIFICATION
15
- * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/Attic/multi.c,v 1.18 1998/06/28 21:17:35 momjian Exp $
15
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/Attic/multi.c,v 1.19 1998/06/30 02:33:31 momjian Exp $
16
16
*
17
17
* NOTES:
18
18
* (1) The lock.c module assumes that the caller here is doing
30
30
#include "miscadmin.h" /* MyDatabaseId */
31
31
32
32
static bool
33
- MultiAcquire (LockTableId tableId , LOCKTAG * tag , LOCKTYPE locktype ,
33
+ MultiAcquire (LOCKMETHOD lockmethod , LOCKTAG * tag , LOCKMODE lockmode ,
34
34
PG_LOCK_LEVEL level );
35
35
static bool
36
- MultiRelease (LockTableId tableId , LOCKTAG * tag , LOCKTYPE locktype ,
36
+ MultiRelease (LOCKMETHOD lockmethod , LOCKTAG * tag , LOCKMODE lockmode ,
37
37
PG_LOCK_LEVEL level );
38
38
39
39
/*
@@ -78,25 +78,27 @@ static int MultiPrios[] = {
78
78
* Lock table identifier for this lock table. The multi-level
79
79
* lock table is ONE lock table, not three.
80
80
*/
81
- LockTableId MultiTableId = (LockTableId ) NULL ;
82
- LockTableId ShortTermTableId = (LockTableId ) NULL ;
81
+ LOCKMETHOD MultiTableId = (LOCKMETHOD ) NULL ;
82
+ #ifdef NOT_USED
83
+ LOCKMETHOD ShortTermTableId = (LOCKMETHOD ) NULL ;
84
+ #endif
83
85
84
86
/*
85
87
* Create the lock table described by MultiConflicts and Multiprio.
86
88
*/
87
- LockTableId
89
+ LOCKMETHOD
88
90
InitMultiLevelLocks ()
89
91
{
90
- int tableId ;
92
+ int lockmethod ;
91
93
92
- tableId = LockTableInit ( "LockTable " , MultiConflicts , MultiPrios , 5 );
93
- MultiTableId = tableId ;
94
+ lockmethod = LockMethodTableInit ( "MultiLevelLockTable " , MultiConflicts , MultiPrios , 5 );
95
+ MultiTableId = lockmethod ;
94
96
if (!(MultiTableId ))
95
97
elog (ERROR , "InitMultiLocks: couldnt initialize lock table" );
96
98
/* -----------------------
97
99
* No short term lock table for now. -Jeff 15 July 1991
98
100
*
99
- * ShortTermTableId = LockTableRename(tableId );
101
+ * ShortTermTableId = LockTableRename(lockmethod );
100
102
* if (! (ShortTermTableId)) {
101
103
* elog(ERROR,"InitMultiLocks: couldnt rename lock table");
102
104
* }
@@ -111,7 +113,7 @@ InitMultiLevelLocks()
111
113
* Returns: TRUE if the lock can be set, FALSE otherwise.
112
114
*/
113
115
bool
114
- MultiLockReln (LockInfo linfo , LOCKTYPE locktype )
116
+ MultiLockReln (LockInfo linfo , LOCKMODE lockmode )
115
117
{
116
118
LOCKTAG tag ;
117
119
@@ -122,7 +124,7 @@ MultiLockReln(LockInfo linfo, LOCKTYPE locktype)
122
124
MemSet (& tag , 0 , sizeof (tag ));
123
125
tag .relId = linfo -> lRelId .relId ;
124
126
tag .dbId = linfo -> lRelId .dbId ;
125
- return (MultiAcquire (MultiTableId , & tag , locktype , RELN_LEVEL ));
127
+ return (MultiAcquire (MultiTableId , & tag , lockmode , RELN_LEVEL ));
126
128
}
127
129
128
130
/*
@@ -134,7 +136,7 @@ MultiLockReln(LockInfo linfo, LOCKTYPE locktype)
134
136
* at the page and relation level.
135
137
*/
136
138
bool
137
- MultiLockTuple (LockInfo linfo , ItemPointer tidPtr , LOCKTYPE locktype )
139
+ MultiLockTuple (LockInfo linfo , ItemPointer tidPtr , LOCKMODE lockmode )
138
140
{
139
141
LOCKTAG tag ;
140
142
@@ -149,14 +151,14 @@ MultiLockTuple(LockInfo linfo, ItemPointer tidPtr, LOCKTYPE locktype)
149
151
150
152
/* not locking any valid Tuple, just the page */
151
153
tag .tupleId = * tidPtr ;
152
- return (MultiAcquire (MultiTableId , & tag , locktype , TUPLE_LEVEL ));
154
+ return (MultiAcquire (MultiTableId , & tag , lockmode , TUPLE_LEVEL ));
153
155
}
154
156
155
157
/*
156
158
* same as above at page level
157
159
*/
158
160
bool
159
- MultiLockPage (LockInfo linfo , ItemPointer tidPtr , LOCKTYPE locktype )
161
+ MultiLockPage (LockInfo linfo , ItemPointer tidPtr , LOCKMODE lockmode )
160
162
{
161
163
LOCKTAG tag ;
162
164
@@ -179,7 +181,7 @@ MultiLockPage(LockInfo linfo, ItemPointer tidPtr, LOCKTYPE locktype)
179
181
tag .relId = linfo -> lRelId .relId ;
180
182
tag .dbId = linfo -> lRelId .dbId ;
181
183
BlockIdCopy (& (tag .tupleId .ip_blkid ), & (tidPtr -> ip_blkid ));
182
- return (MultiAcquire (MultiTableId , & tag , locktype , PAGE_LEVEL ));
184
+ return (MultiAcquire (MultiTableId , & tag , lockmode , PAGE_LEVEL ));
183
185
}
184
186
185
187
/*
@@ -189,12 +191,12 @@ MultiLockPage(LockInfo linfo, ItemPointer tidPtr, LOCKTYPE locktype)
189
191
* Side Effects:
190
192
*/
191
193
static bool
192
- MultiAcquire (LockTableId tableId ,
194
+ MultiAcquire (LOCKMETHOD lockmethod ,
193
195
LOCKTAG * tag ,
194
- LOCKTYPE locktype ,
196
+ LOCKMODE lockmode ,
195
197
PG_LOCK_LEVEL level )
196
198
{
197
- LOCKTYPE locks [N_LEVELS ];
199
+ LOCKMODE locks [N_LEVELS ];
198
200
int i ,
199
201
status ;
200
202
LOCKTAG xxTag ,
@@ -213,19 +215,19 @@ MultiAcquire(LockTableId tableId,
213
215
switch (level )
214
216
{
215
217
case RELN_LEVEL :
216
- locks [0 ] = locktype ;
218
+ locks [0 ] = lockmode ;
217
219
locks [1 ] = NO_LOCK ;
218
220
locks [2 ] = NO_LOCK ;
219
221
break ;
220
222
case PAGE_LEVEL :
221
- locks [0 ] = locktype + INTENT ;
222
- locks [1 ] = locktype ;
223
+ locks [0 ] = lockmode + INTENT ;
224
+ locks [1 ] = lockmode ;
223
225
locks [2 ] = NO_LOCK ;
224
226
break ;
225
227
case TUPLE_LEVEL :
226
- locks [0 ] = locktype + INTENT ;
227
- locks [1 ] = locktype + INTENT ;
228
- locks [2 ] = locktype ;
228
+ locks [0 ] = lockmode + INTENT ;
229
+ locks [1 ] = lockmode + INTENT ;
230
+ locks [2 ] = lockmode ;
229
231
break ;
230
232
default :
231
233
elog (ERROR , "MultiAcquire: bad lock level" );
@@ -274,7 +276,7 @@ MultiAcquire(LockTableId tableId,
274
276
break ;
275
277
}
276
278
277
- status = LockAcquire (tableId , tmpTag , locks [i ]);
279
+ status = LockAcquire (lockmethod , tmpTag , locks [i ]);
278
280
if (!status )
279
281
{
280
282
@@ -285,7 +287,7 @@ MultiAcquire(LockTableId tableId,
285
287
* the last level lock we successfully acquired
286
288
*/
287
289
retStatus = FALSE;
288
- MultiRelease (tableId , tag , locktype , i );
290
+ MultiRelease (lockmethod , tag , lockmode , i );
289
291
/* now leave the loop. Don't try for any more locks */
290
292
break ;
291
293
}
@@ -300,7 +302,7 @@ MultiAcquire(LockTableId tableId,
300
302
*/
301
303
#ifdef NOT_USED
302
304
bool
303
- MultiReleasePage (LockInfo linfo , ItemPointer tidPtr , LOCKTYPE locktype )
305
+ MultiReleasePage (LockInfo linfo , ItemPointer tidPtr , LOCKMODE lockmode )
304
306
{
305
307
LOCKTAG tag ;
306
308
@@ -316,7 +318,7 @@ MultiReleasePage(LockInfo linfo, ItemPointer tidPtr, LOCKTYPE locktype)
316
318
tag .dbId = linfo -> lRelId .dbId ;
317
319
BlockIdCopy (& (tag .tupleId .ip_blkid ), & (tidPtr -> ip_blkid ));
318
320
319
- return (MultiRelease (MultiTableId , & tag , locktype , PAGE_LEVEL ));
321
+ return (MultiRelease (MultiTableId , & tag , lockmode , PAGE_LEVEL ));
320
322
}
321
323
322
324
#endif
@@ -326,7 +328,7 @@ MultiReleasePage(LockInfo linfo, ItemPointer tidPtr, LOCKTYPE locktype)
326
328
* ------------------
327
329
*/
328
330
bool
329
- MultiReleaseReln (LockInfo linfo , LOCKTYPE locktype )
331
+ MultiReleaseReln (LockInfo linfo , LOCKMODE lockmode )
330
332
{
331
333
LOCKTAG tag ;
332
334
@@ -340,7 +342,7 @@ MultiReleaseReln(LockInfo linfo, LOCKTYPE locktype)
340
342
tag .relId = linfo -> lRelId .relId ;
341
343
tag .dbId = linfo -> lRelId .dbId ;
342
344
343
- return (MultiRelease (MultiTableId , & tag , locktype , RELN_LEVEL ));
345
+ return (MultiRelease (MultiTableId , & tag , lockmode , RELN_LEVEL ));
344
346
}
345
347
346
348
/*
@@ -349,12 +351,12 @@ MultiReleaseReln(LockInfo linfo, LOCKTYPE locktype)
349
351
* Returns: TRUE if successful, FALSE otherwise.
350
352
*/
351
353
static bool
352
- MultiRelease (LockTableId tableId ,
354
+ MultiRelease (LOCKMETHOD lockmethod ,
353
355
LOCKTAG * tag ,
354
- LOCKTYPE locktype ,
356
+ LOCKMODE lockmode ,
355
357
PG_LOCK_LEVEL level )
356
358
{
357
- LOCKTYPE locks [N_LEVELS ];
359
+ LOCKMODE locks [N_LEVELS ];
358
360
int i ,
359
361
status ;
360
362
LOCKTAG xxTag ,
@@ -366,22 +368,22 @@ MultiRelease(LockTableId tableId,
366
368
switch (level )
367
369
{
368
370
case RELN_LEVEL :
369
- locks [0 ] = locktype ;
371
+ locks [0 ] = lockmode ;
370
372
locks [1 ] = NO_LOCK ;
371
373
locks [2 ] = NO_LOCK ;
372
374
break ;
373
375
case PAGE_LEVEL :
374
- locks [0 ] = locktype + INTENT ;
375
- locks [1 ] = locktype ;
376
+ locks [0 ] = lockmode + INTENT ;
377
+ locks [1 ] = lockmode ;
376
378
locks [2 ] = NO_LOCK ;
377
379
break ;
378
380
case TUPLE_LEVEL :
379
- locks [0 ] = locktype + INTENT ;
380
- locks [1 ] = locktype + INTENT ;
381
- locks [2 ] = locktype ;
381
+ locks [0 ] = lockmode + INTENT ;
382
+ locks [1 ] = lockmode + INTENT ;
383
+ locks [2 ] = lockmode ;
382
384
break ;
383
385
default :
384
- elog (ERROR , "MultiRelease: bad locktype " );
386
+ elog (ERROR , "MultiRelease: bad lockmode " );
385
387
}
386
388
387
389
/*
@@ -423,7 +425,7 @@ MultiRelease(LockTableId tableId,
423
425
ItemPointerCopy (& tmpTag -> tupleId , & tag -> tupleId );
424
426
break ;
425
427
}
426
- status = LockRelease (tableId , tmpTag , locks [i ]);
428
+ status = LockRelease (lockmethod , tmpTag , locks [i ]);
427
429
if (!status )
428
430
elog (ERROR , "MultiRelease: couldn't release after error" );
429
431
}
0 commit comments