Merge lp:~zorba-coders/zorba/bug-1111487 into lp:zorba

Proposed by Ghislain Fourny
Status: Merged
Approved by: Markos Zaharioudakis
Approved revision: 11220
Merged at revision: 11373
Proposed branch: lp:~zorba-coders/zorba/bug-1111487
Merge into: lp:zorba
Diff against target: 105 lines (+46/-18)
3 files modified
ChangeLog (+2/-0)
src/store/naive/node_items.cpp (+27/-18)
test/rbkt/Queries/zorba/collections/edit/edit_collection_005.xq (+17/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/bug-1111487
Reviewer Review Type Date Requested Status
Markos Zaharioudakis Approve
Dennis Knochenwefel Approve
Till Westmann Approve
Review via email: mp+145868@code.launchpad.net

Commit message

Fixing bug 1111487 (db:edit swaps).

Description of the change

Fixing bug 1111487 (db:edit swaps).

To post a comment you must log in.
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug-1111487-2013-01-31T14-17-24.185Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 2 Pending.

Revision history for this message
Till Westmann (tillw) :
review: Approve
Revision history for this message
Dennis Knochenwefel (dennis-knochenwefel) wrote :

- could we add a test for this?
- could you add a Changelog entry

thanks

review: Needs Fixing
lp:~zorba-coders/zorba/bug-1111487 updated
11216. By Ghislain Fourny

Merge trunk back.

11217. By Ghislain Fourny

Adding back test.

11218. By Ghislain Fourny

Fixed bug 1102997.

11219. By Ghislain Fourny

Updated ChangeLog.

Revision history for this message
Ghislain Fourny (gislenius) wrote :

I updated the ChangeLog.

lp:~zorba-coders/zorba/bug-1111487 updated
11220. By Ghislain Fourny

Fixed conflict and merged trunk back.

Revision history for this message
Dennis Knochenwefel (dennis-knochenwefel) :
review: Approve
Revision history for this message
Markos Zaharioudakis (markos-za) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug-1111487-2013-04-16T09-27-11.147Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2013-04-10 10:13:31 +0000
3+++ ChangeLog 2013-04-10 12:19:24 +0000
4@@ -38,6 +38,8 @@
5 * Extented index join rule to general flwor expressions.
6
7 Bug Fixes/Other Changes:
8+ * Fixed bug #1102997 (Swapping referenced nodes)
9+ * Fixed bug #1111487 (Swapping nodes that are in collections)
10 * Fixed bug #1123836 (overflows in date/time casts now return FODT0001 and
11 in durations return FODT0002)
12 * Fixed bug #1114228 (unrecognized options in the XQuery namespace now raise an error)
13
14=== modified file 'src/store/naive/node_items.cpp'
15--- src/store/naive/node_items.cpp 2013-03-07 10:10:10 +0000
16+++ src/store/naive/node_items.cpp 2013-04-10 12:19:24 +0000
17@@ -796,20 +796,12 @@
18 assert(theParent == NULL);
19 assert(lOtherItem->theParent == NULL);
20
21- // Swap flags expect hasReference.
22- bool lHasReference = haveReference();
23- bool lOtherHasReference = lOtherItem->haveReference();
24- std::swap(theFlags, lOtherItem->theFlags);
25- if(lHasReference)
26- {
27- setHaveReference();
28- }
29- if(lOtherHasReference)
30- {
31- setHaveReference();
32- }
33-
34- // Swap root nodes and adjust type maps.
35+ // But some things must be "unswapped"
36+ std::swap(getTree()->theCollectionInfo, lOtherItem->getTree()->theCollectionInfo);
37+ std::swap(getTree()->theTreeId, lOtherItem->getTree()->theTreeId);
38+
39+ // Before unswapping root nodes as well, their references in the type maps
40+ // must be erased.
41 store::Item_t lRootNodeType;
42 store::Item_t lOtherRootNodeType;
43 bool lRootHasType = getTree()->theTypesMap->get(
44@@ -825,7 +817,11 @@
45 lOtherItem->getTree()->theTypesMap->erase(
46 lOtherItem->getTree()->theRootNode);
47 }
48+
49+ // Now unswapping root nodes.
50 std::swap(getTree()->theRootNode, lOtherItem->getTree()->theRootNode);
51+
52+ // And putting references back into the type maps.
53 if(lRootHasType)
54 {
55 getTree()->theTypesMap->insert(getTree()->theRootNode, lRootNodeType);
56@@ -836,10 +832,23 @@
57 lOtherItem->getTree()->theRootNode, lOtherRootNodeType);
58 }
59
60- // Adjust trees.
61-#ifndef EMBEDED_TYPE
62- std::swap(getTree()->theTypesMap, lOtherItem->getTree()->theTypesMap);
63-#endif
64+ // Swap flags expect hasReference.
65+ bool lHasReference = haveReference();
66+ bool lOtherHasReference = lOtherItem->haveReference();
67+ std::swap(theFlags, lOtherItem->theFlags);
68+ if(lHasReference)
69+ {
70+ setHaveReference();
71+ } else {
72+ resetHaveReference();
73+ }
74+ if(lOtherHasReference)
75+ {
76+ lOtherItem->setHaveReference();
77+ } else {
78+ lOtherItem->resetHaveReference();
79+ }
80+
81 }
82
83
84
85=== added file 'test/rbkt/Queries/zorba/collections/edit/edit_collection_005.xq'
86--- test/rbkt/Queries/zorba/collections/edit/edit_collection_005.xq 1970-01-01 00:00:00 +0000
87+++ test/rbkt/Queries/zorba/collections/edit/edit_collection_005.xq 2013-04-10 12:19:24 +0000
88@@ -0,0 +1,17 @@
89+import module namespace ddl = "http://www.zorba-xquery.com/modules/store/static/collections/ddl";
90+import module namespace dml = "http://www.zorba-xquery.com/modules/store/static/collections/dml";
91+import module namespace ref = "http://www.zorba-xquery.com/modules/node-reference";
92+
93+import module namespace ns = "http://www.example.com/example" at "../collection_001.xqdata";
94+
95+ddl:create(xs:QName("ns:collection"));
96+
97+dml:insert(xs:QName("ns:collection"), (<a/>, <b/>, <c/>));
98+
99+variable $old := ref:node-reference(dml:collection(xs:QName("ns:collection"))[2]);
100+
101+dml:edit(dml:collection(xs:QName("ns:collection"))[2], <d/>);
102+
103+variable $new := ref:node-reference(dml:collection(xs:QName("ns:collection"))[2]);
104+
105+$old eq $new

Subscribers

People subscribed via source and target branches