diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/commands/indexcmds.c | 10 | ||||
-rw-r--r-- | src/backend/storage/ipc/procarray.c | 35 | ||||
-rw-r--r-- | src/include/storage/procarray.h | 5 |
3 files changed, 29 insertions, 21 deletions
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index ac56b583f17..5c418f8b7a3 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.163 2007/09/05 18:10:47 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.164 2007/09/07 00:58:56 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -535,10 +535,12 @@ DefineIndex(RangeVar *heapRelation, * * We can exclude any running transactions that have xmin >= the xmax of * our reference snapshot, since they are clearly not interested in any - * missing older tuples. Also, GetCurrentVirtualXIDs never reports our - * own vxid, so we need not check for that. + * missing older tuples. Transactions in other DBs aren't a problem + * either, since they'll never even be able to see this index. + * Also, GetCurrentVirtualXIDs never reports our own vxid, so we + * need not check for that. */ - old_snapshots = GetCurrentVirtualXIDs(ActiveSnapshot->xmax); + old_snapshots = GetCurrentVirtualXIDs(ActiveSnapshot->xmax, false); while (VirtualTransactionIdIsValid(*old_snapshots)) { diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c index a467df990e1..15701b959ce 100644 --- a/src/backend/storage/ipc/procarray.c +++ b/src/backend/storage/ipc/procarray.c @@ -23,7 +23,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/ipc/procarray.c,v 1.30 2007/09/05 21:11:19 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/storage/ipc/procarray.c,v 1.31 2007/09/07 00:58:56 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -891,10 +891,11 @@ IsBackendPid(int pid) * The array is palloc'd and is terminated with an invalid VXID. * * If limitXmin is not InvalidTransactionId, we skip any backends - * with xmin >= limitXmin. Also, our own process is always skipped. + * with xmin >= limitXmin. If allDbs is false, we skip backends attached + * to other databases. Also, our own process is always skipped. */ VirtualTransactionId * -GetCurrentVirtualXIDs(TransactionId limitXmin) +GetCurrentVirtualXIDs(TransactionId limitXmin, bool allDbs) { VirtualTransactionId *vxids; ProcArrayStruct *arrayP = procArray; @@ -910,24 +911,28 @@ GetCurrentVirtualXIDs(TransactionId limitXmin) for (index = 0; index < arrayP->numProcs; index++) { volatile PGPROC *proc = arrayP->procs[index]; - /* Fetch xmin just once - might change on us? */ - TransactionId pxmin = proc->xmin; if (proc == MyProc) continue; - /* - * Note that InvalidTransactionId precedes all other XIDs, so a - * proc that hasn't set xmin yet will always be included. - */ - if (!TransactionIdIsValid(limitXmin) || - TransactionIdPrecedes(pxmin, limitXmin)) + if (allDbs || proc->databaseId == MyDatabaseId) { - VirtualTransactionId vxid; + /* Fetch xmin just once - might change on us? */ + TransactionId pxmin = proc->xmin; + + /* + * Note that InvalidTransactionId precedes all other XIDs, so a + * proc that hasn't set xmin yet will always be included. + */ + if (!TransactionIdIsValid(limitXmin) || + TransactionIdPrecedes(pxmin, limitXmin)) + { + VirtualTransactionId vxid; - GET_VXID_FROM_PGPROC(vxid, *proc); - if (VirtualTransactionIdIsValid(vxid)) - vxids[count++] = vxid; + GET_VXID_FROM_PGPROC(vxid, *proc); + if (VirtualTransactionIdIsValid(vxid)) + vxids[count++] = vxid; + } } } diff --git a/src/include/storage/procarray.h b/src/include/storage/procarray.h index 524710506a7..21e0c839522 100644 --- a/src/include/storage/procarray.h +++ b/src/include/storage/procarray.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/storage/procarray.h,v 1.15 2007/09/05 18:10:48 tgl Exp $ + * $PostgreSQL: pgsql/src/include/storage/procarray.h,v 1.16 2007/09/07 00:58:57 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -33,7 +33,8 @@ extern PGPROC *BackendPidGetProc(int pid); extern int BackendXidGetPid(TransactionId xid); extern bool IsBackendPid(int pid); -extern VirtualTransactionId *GetCurrentVirtualXIDs(TransactionId limitXmin); +extern VirtualTransactionId *GetCurrentVirtualXIDs(TransactionId limitXmin, + bool allDbs); extern int CountActiveBackends(void); extern int CountDBBackends(Oid databaseid); extern int CountUserBackends(Oid roleid); |