3131 * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
3232 * Portions Copyright (c) 1994, Regents of the University of California
3333 *
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 $
3535 *
3636 *-------------------------------------------------------------------------
3737 */
@@ -218,19 +218,45 @@ static void TruncateMultiXact(void);
218218
219219
220220/*
221- *MultiXactIdExpand
222- *Add aTransactionId to a possibly-already-existing MultiXactId .
221+ *MultiXactIdCreate
222+ *Construct aMultiXactId representing two TransactionIds .
223223 *
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.
228225 *
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.
234260 *
235261 * If the TransactionId is already a member of the passed MultiXactId,
236262 * just return it as-is.
@@ -243,7 +269,7 @@ static void TruncateMultiXact(void);
243269 * is handled by the lower-level routines.
244270 */
245271MultiXactId
246- MultiXactIdExpand (MultiXactId multi ,bool isMulti , TransactionId xid )
272+ MultiXactIdExpand (MultiXactId multi ,TransactionId xid )
247273{
248274MultiXactId newMulti ;
249275TransactionId * members ;
@@ -255,30 +281,9 @@ MultiXactIdExpand(MultiXactId multi, bool isMulti, TransactionId xid)
255281AssertArg (MultiXactIdIsValid (multi ));
256282AssertArg (TransactionIdIsValid (xid ));
257283
258- debug_elog5 (DEBUG2 ,"Expand: received %s %u, xid %u" ,
259- isMulti ?"MultiXactId" :"TransactionId" ,
284+ debug_elog4 (DEBUG2 ,"Expand: received multi %u, xid %u" ,
260285multi ,xid );
261286
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-
282287nmembers = GetMultiXactIdMembers (multi ,& members );
283288
284289if (nmembers < 0 )