summaryrefslogtreecommitdiff
path: root/src/backend/libpq/be-fsstubs.c
diff options
context:
space:
mode:
authorTom Lane2004-09-16 16:58:44 +0000
committerTom Lane2004-09-16 16:58:44 +0000
commit8f9f1986034a2273e09ad10671e10d1adda21d1f (patch)
tree4c2c8a226db335cf1e653b09026402363d0488e7 /src/backend/libpq/be-fsstubs.c
parent42c0d1f3cd01ac737b182353934531d1fd382c80 (diff)
Restructure subtransaction handling to reduce resource consumption,
as per recent discussions. Invent SubTransactionIds that are managed like CommandIds (ie, counter is reset at start of each top transaction), and use these instead of TransactionIds to keep track of subtransaction status in those modules that need it. This means that a subtransaction does not need an XID unless it actually inserts/modifies rows in the database. Accordingly, don't assign it an XID nor take a lock on the XID until it tries to do that. This saves a lot of overhead for subtransactions that are only used for error recovery (eg plpgsql exceptions). Also, arrange to release a subtransaction's XID lock as soon as the subtransaction exits, in both the commit and abort cases. This avoids holding many unique locks after a long series of subtransactions. The price is some additional overhead in XactLockTableWait, but that seems acceptable. Finally, restructure the state machine in xact.c to have a more orthogonal set of states for subtransactions.
Diffstat (limited to 'src/backend/libpq/be-fsstubs.c')
-rw-r--r--src/backend/libpq/be-fsstubs.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/backend/libpq/be-fsstubs.c b/src/backend/libpq/be-fsstubs.c
index b059c05240a..85ebbd483d5 100644
--- a/src/backend/libpq/be-fsstubs.c
+++ b/src/backend/libpq/be-fsstubs.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/libpq/be-fsstubs.c,v 1.75 2004/09/11 15:56:46 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/libpq/be-fsstubs.c,v 1.76 2004/09/16 16:58:30 tgl Exp $
*
* NOTES
* This should be moved to a more appropriate place. It is here
@@ -551,11 +551,11 @@ AtEOXact_LargeObject(bool isCommit)
* Take care of large objects at subtransaction commit/abort
*
* Reassign LOs created/opened during a committing subtransaction
- * to the parent transaction. On abort, just close them.
+ * to the parent subtransaction. On abort, just close them.
*/
void
-AtEOSubXact_LargeObject(bool isCommit, TransactionId myXid,
- TransactionId parentXid)
+AtEOSubXact_LargeObject(bool isCommit, SubTransactionId mySubid,
+ SubTransactionId parentSubid)
{
int i;
@@ -566,10 +566,10 @@ AtEOSubXact_LargeObject(bool isCommit, TransactionId myXid,
{
LargeObjectDesc *lo = cookies[i];
- if (lo != NULL && lo->xid == myXid)
+ if (lo != NULL && lo->subid == mySubid)
{
if (isCommit)
- lo->xid = parentXid;
+ lo->subid = parentSubid;
else
{
/*