Re: Facing a problem with SPI

From: "Gurjeet Singh" <singh(dot)gurjeet(at)gmail(dot)com>
To: "PGSQL Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Facing a problem with SPI
Date: 2006-12-04 15:10:11
Message-ID: 65937bea0612040710g5bf8e718rac2acb385eab9cfb@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Another question.

There are two global variables:

CurrentResourceOwner (CRO) and CurrentTransactionState (CTS). CTS has a
member curTransactionOwner(cTO). Now the question is:

is the following condition always supposed to be true?

CurrentResourceOwner==CurrentTransactionState->curTransactionOwner

While in executor, CRO->name is "Portal". Then I do the
BeginInternalSubTransaction() (BIST()); it pushes the current
(sub)transaction on a stack and and along with it, it sets the CTS as it's
parent. CTS->cTO->name is "TopTransaction". And a new resource-owner is
assigned to the new SubTransaction by AtSubStart_ResourceOwner().

After the adviser is done with it's work, it calls
RollbackAndReleaseCurrentSubTransaction() (RARCST()), which restores the
global CRO to the previously pushed SubTransaction's parent; this is
"TopTransaction". Now, we have lost record of which was the ResourceOwner
before BIST() and erroneously restored "TopTransaction" to be the CRO. This
is causing some diffcult to track ERROR conditions.

So, is the above mentioned condition supposed to hold always? (I am
assuming not). If not, then we should remember the CurrentResourceOwner
across BIST() and RARCST() calls!

Sorry to be pestering you guys with seemingly trivial stuff, but you
would also agree that it becomes very difficult to understand the code when
there are so many globals and the relationship between them is not very
clear.

Regards,

--
gurjeet[(dot)singh](at)EnterpriseDB(dot)com
singh(dot)gurjeet(at){ gmail | hotmail | yahoo }.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2006-12-04 15:12:05 Re: Notify enhancement
Previous Message Gregory Stark 2006-12-04 15:02:12 Re: Notify enhancement