Hi Rodolfo, You really went quite far in your exploration....
I have a fix for this now, but since the trunk is frozen right now, i have to wait to commit it. cheers, Markos. >________________________________ > From: Rodolfo Ochoa <867...@bugs.launchpad.net> >To: markos...@yahoo.com >Sent: Saturday, May 5, 2012 7:46 AM >Subject: [Bug 867170] Re: Overwritten variables in prolog > >Captain James T. Kirk: Captain's log, stardate 9522.6: > >Trying to solve this bug I created this Prolog and Query: > >lProlog << "declare variable $A := <a>a</a>; declare variable $B := <b>b</b>; >"; >lQuery << "declare variable $C := <c>c</c>; declare variable $D := <d>d</d>; >$B "; > >Then I printed the execution plan, giving me this: > ><SequentialIterator id="0258F708"> > <SequentialIterator id="0258F778"> > <CtxVarDeclareIterator varid="2" varname="A" id="02783778"> > <ElementIterator id="02783700"> > <SingletonIterator value="xs:QName(,,a)" id="0279A900"/> > <TextIterator id="0279A780"> > <SingletonIterator value="xs:string(a)" id="0279A720"/> > </TextIterator> > </ElementIterator> > </CtxVarDeclareIterator> > <CtxVarDeclareIterator varid="3" varname="B" id="02783FE8"> > <ElementIterator id="02783D18"> > <SingletonIterator value="xs:QName(,,b)" id="0279A6C0"/> > <TextIterator id="0279A960"> > <SingletonIterator value="xs:string(b)" id="0279A660"/> > </TextIterator> > </ElementIterator> > </CtxVarDeclareIterator> > <FnConcatIterator id="0258F7E8"/> > </SequentialIterator> > <CtxVarDeclareIterator varid="2" varname="C" id="027840D8"> > <ElementIterator copyInputNodes="false" id="02784060"> > <SingletonIterator value="xs:QName(,,c)" id="0279A9C0"/> > <TextIterator id="0279AA80"> > <SingletonIterator value="xs:string(c)" id="0279AA20"/> > </TextIterator> > </ElementIterator> > </CtxVarDeclareIterator> > <CtxVarDeclareIterator varid="3" varname="D" id="027841C8"> > <ElementIterator copyInputNodes="false" id="02784150"> > <SingletonIterator value="xs:QName(,,d)" id="0279AAE0"/> > <TextIterator id="0279ABA0"> > <SingletonIterator value="xs:string(d)" id="0279AB40"/> > </TextIterator> > </ElementIterator> > </CtxVarDeclareIterator> > <CtxVarIterator varid="3" varname="B" varkind="global" id="00A9D3E8"/> ></SequentialIterator> > >So, I can see that the Iterators have variables with duplicated varids, >digging into the code, I found that to process the prolog an XQueryImpl >object is created, so for every XQueryImpl created on xqueryimpl.cpp:586 >the line: > > ulong nextDynamicVarId = 2; > >initializes the "unique" varid to 2, so, after the prolog is processed when >the real query starts it starts again from two... but why? >because on plan_visitor.cpp:605 the lines: > > if (varExpr->get_unique_id() == 0) > varExpr->set_unique_id(theNextDynamicVarId++); > >increment the varid only if it exists. So a quick fix could be to increment >the varid out this verification, and everytime a new query is created the >varid will be incremented correctly. >But this fix looks dirty, a better approach should be to initialize in >xqueryimpl the nextDynamicVarId considering the number of variables that the >prolog/staticContext has. >I tried to do that on staticContext, but it was very difficult, I tried >putting this value on StaticContext, but after a while I realize that >XQueryImpl uses static_context and this is different than StaticContext class. >So... my time went out and couldn't figure out how to pass this variable >accross the classes... > >Markos, hope this helps to fix this quickly.... >:) >-Rodolfo > >-- >You received this bug notification because you are a bug assignee. >https://bugs.launchpad.net/bugs/867170 > >Title: > Overwritten variables in prolog > >Status in Zorba - The XQuery Processor: > Confirmed > >Bug description: > Variables declared in Prolog are Overwritten inside the query. > example attached > >To manage notifications about this bug go to: >https://bugs.launchpad.net/zorba/+bug/867170/+subscriptions > > > -- You received this bug notification because you are a member of Zorba Coders, which is the registrant for Zorba. https://bugs.launchpad.net/bugs/867170 Title: Overwritten variables in prolog Status in Zorba - The XQuery Processor: Confirmed Bug description: Variables declared in Prolog are Overwritten inside the query. example attached To manage notifications about this bug go to: https://bugs.launchpad.net/zorba/+bug/867170/+subscriptions -- Mailing list: https://launchpad.net/~zorba-coders Post to : zorba-coders@lists.launchpad.net Unsubscribe : https://launchpad.net/~zorba-coders More help : https://help.launchpad.net/ListHelp