31
31
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
32
32
* Portions Copyright (c) 1994, Regents of the University of California
33
33
*
34
- * $PostgreSQL: pgsql/src/backend/access/transam/multixact.c,v 1.1 2005/04/28 21:47:10 tgl Exp $
34
+ * $PostgreSQL: pgsql/src/backend/access/transam/multixact.c,v 1.2 2005/05/03 19:42:40 tgl Exp $
35
35
*
36
36
*-------------------------------------------------------------------------
37
37
*/
@@ -218,19 +218,45 @@ static void TruncateMultiXact(void);
218
218
219
219
220
220
/*
221
- *MultiXactIdExpand
222
- *Add aTransactionId to a possibly-already-existing MultiXactId .
221
+ *MultiXactIdCreate
222
+ *Construct aMultiXactId representing two TransactionIds .
223
223
*
224
- * We abuse the notation for the first argument: if "isMulti" is true, then
225
- * it's really a MultiXactId; else it's a TransactionId. We are already
226
- * storing MultiXactId in HeapTupleHeader's xmax so assuming the datatypes
227
- * are equivalent is necessary anyway.
224
+ * The two XIDs must be different.
228
225
*
229
- * If isMulti is true, then get the members of the passed MultiXactId, add
230
- * the passed TransactionId, and create a new MultiXactId. If isMulti is
231
- * false, then take the two TransactionIds and create a new MultiXactId with
232
- * them. The caller must ensure that the multi and xid are different
233
- * in the latter case.
226
+ * NB - we don't worry about our local MultiXactId cache here, because that
227
+ * is handled by the lower-level routines.
228
+ */
229
+ MultiXactId
230
+ MultiXactIdCreate (TransactionId xid1 ,TransactionId xid2 )
231
+ {
232
+ MultiXactId newMulti ;
233
+ TransactionId xids [2 ];
234
+
235
+ AssertArg (TransactionIdIsValid (xid1 ));
236
+ AssertArg (TransactionIdIsValid (xid2 ));
237
+
238
+ Assert (!TransactionIdEquals (xid1 ,xid2 ));
239
+
240
+ /*
241
+ * Note: unlike MultiXactIdExpand, we don't bother to check that both
242
+ * XIDs are still running. In typical usage, xid2 will be our own XID
243
+ * and the caller just did a check on xid1, so it'd be wasted effort.
244
+ */
245
+
246
+ xids [0 ]= xid1 ;
247
+ xids [1 ]= xid2 ;
248
+
249
+ newMulti = CreateMultiXactId (2 ,xids );
250
+
251
+ debug_elog5 (DEBUG2 ,"Create: returning %u for %u, %u" ,
252
+ newMulti ,xid1 ,xid2 );
253
+
254
+ return newMulti ;
255
+ }
256
+
257
+ /*
258
+ * MultiXactIdExpand
259
+ *Add a TransactionId to a pre-existing MultiXactId.
234
260
*
235
261
* If the TransactionId is already a member of the passed MultiXactId,
236
262
* just return it as-is.
@@ -243,7 +269,7 @@ static void TruncateMultiXact(void);
243
269
* is handled by the lower-level routines.
244
270
*/
245
271
MultiXactId
246
- MultiXactIdExpand (MultiXactId multi ,bool isMulti , TransactionId xid )
272
+ MultiXactIdExpand (MultiXactId multi ,TransactionId xid )
247
273
{
248
274
MultiXactId newMulti ;
249
275
TransactionId * members ;
@@ -255,30 +281,9 @@ MultiXactIdExpand(MultiXactId multi, bool isMulti, TransactionId xid)
255
281
AssertArg (MultiXactIdIsValid (multi ));
256
282
AssertArg (TransactionIdIsValid (xid ));
257
283
258
- debug_elog5 (DEBUG2 ,"Expand: received %s %u, xid %u" ,
259
- isMulti ?"MultiXactId" :"TransactionId" ,
284
+ debug_elog4 (DEBUG2 ,"Expand: received multi %u, xid %u" ,
260
285
multi ,xid );
261
286
262
- if (!isMulti )
263
- {
264
- /*
265
- * The first argument is a TransactionId, not a MultiXactId.
266
- */
267
- TransactionId xids [2 ];
268
-
269
- Assert (!TransactionIdEquals (multi ,xid ));
270
-
271
- xids [0 ]= multi ;
272
- xids [1 ]= xid ;
273
-
274
- newMulti = CreateMultiXactId (2 ,xids );
275
-
276
- debug_elog5 (DEBUG2 ,"Expand: returning %u two-elem %u/%u" ,
277
- newMulti ,multi ,xid );
278
-
279
- return newMulti ;
280
- }
281
-
282
287
nmembers = GetMultiXactIdMembers (multi ,& members );
283
288
284
289
if (nmembers < 0 )