zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #05908
[Merge] lp:~zorba-coders/zorba/bug-945241 into lp:zorba
Matthias Brantner has proposed merging lp:~zorba-coders/zorba/bug-945241 into lp:zorba.
Requested reviews:
Matthias Brantner (matthias-brantner)
Till Westmann (tillw)
Related bugs:
Bug #945241 in Zorba: "StaticCollectionManager::declaredIndexes() and temporary indexes"
https://bugs.launchpad.net/zorba/+bug/945241
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug-945241/+merge/96278
StaticCollectionManager::declaredIndexes() doesn't return temporary indexes anymore. Also isDeclaredIndex also doesn't return true if asked whether a temporary index is declared.
--
https://code.launchpad.net/~zorba-coders/zorba/bug-945241/+merge/96278
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog 2012-03-06 22:43:17 +0000
+++ ChangeLog 2012-03-07 01:39:21 +0000
@@ -26,6 +26,7 @@
case of early-out)
* More efficient implementation for base64Binary items
* Added index management function to the C++ api's StaticCollectionManager.
+ * Fixed bug #945241 (StaticCollectionManager::declaredIndexes() and temporary indexes)
* Fixed bug #872288 (reset recursive flag during node rename)
* Fixed bug #905041 (allow for the default element and function namespaces to be
set multiple times via the c++ api).
=== modified file 'src/runtime/collections/collections_impl.cpp'
--- src/runtime/collections/collections_impl.cpp 2012-02-16 12:48:17 +0000
+++ src/runtime/collections/collections_impl.cpp 2012-03-07 01:39:21 +0000
@@ -30,6 +30,7 @@
#include "context/uri_resolver.h"
#include "context/static_context_consts.h"
+#include "compiler/xqddf/value_index.h"
#include "compiler/xqddf/value_ic.h"
#include "runtime/collections/collections.h"
@@ -2331,20 +2332,21 @@
PlanState& aPlanState) const
{
store::Item_t lName;
+ zorba::IndexDecl* lDecl;
PlanIteratorState* lState;
DEFAULT_STACK_INIT(PlanIteratorState, lState, aPlanState);
consumeNext(lName, theChildren[0].getp(), aPlanState);
- if (theSctx->lookup_index(lName.getp()) == 0)
+ if ((lDecl = theSctx->lookup_index(lName.getp())) && !lDecl->isTemp())
+ {
+ STACK_PUSH(GENV_ITEMFACTORY->createBoolean(aResult, true), lState);
+ }
+ else
{
STACK_PUSH(GENV_ITEMFACTORY->createBoolean(aResult, false), lState);
}
- else
- {
- STACK_PUSH(GENV_ITEMFACTORY->createBoolean(aResult, true), lState);
- }
STACK_END(lState);
}
@@ -2386,6 +2388,10 @@
for ((lState->nameItState = theSctx->index_names())->open();
lState->nameItState->next(lName); )
{
+ if (theSctx->lookup_index(lName.getp())->isTemp())
+ {
+ continue;
+ }
aResult = lName;
STACK_PUSH(true, lState);
}
=== modified file 'test/unit/module1.xq'
--- test/unit/module1.xq 2011-08-05 02:21:55 +0000
+++ test/unit/module1.xq 2012-03-07 01:39:21 +0000
@@ -18,4 +18,4 @@
import module namespace ddl = "http://www.zorba-xquery.com/modules/store/static/collections/ddl";
-1+1
+mod2:foo()
=== modified file 'test/unit/module2.xq'
--- test/unit/module2.xq 2011-12-21 14:40:33 +0000
+++ test/unit/module2.xq 2012-03-07 01:39:21 +0000
@@ -27,3 +27,14 @@
declare index mod2:index
on nodes ddl:collection(xs:QName("mod2:coll"))
by data(@id) as xs:string;
+
+
+(: test that a temp index doesn't have impact on the indexes
+ returned by the static collection mgr :)
+declare function mod2:foo()
+{
+ for $i in 1 to 10
+ for $j in 1 to 10
+ where $i eq $j
+ return $i
+};
=== modified file 'test/unit/staticcollectionmanager.cpp'
--- test/unit/staticcollectionmanager.cpp 2012-03-05 23:44:54 +0000
+++ test/unit/staticcollectionmanager.cpp 2012-03-07 01:39:21 +0000
@@ -206,23 +206,25 @@
Item lCollName2 = lFac->createQName("http://www.mod2.com/", "coll");
lColMgr->createCollection(lCollName2);
- Collection_t lColl = lColMgr->getCollection(lCollName2);
-
- std::vector<Annotation_t> lAnnotations;
- lColl->getAnnotations(lAnnotations);
- size_t num_annotations = 0;
- for (std::vector<Annotation_t>::const_iterator lIter = lAnnotations.begin();
- lIter != lAnnotations.end(); ++lIter)
- {
- std::cout << "Annotation QName " << (*lIter)->getQName().getStringValue() << std::endl;
- ++num_annotations;
- }
-
- if (num_annotations != 3)
- {
- return false;
- }
-
+ {
+ Collection_t lColl = lColMgr->getCollection(lCollName2);
+
+ std::vector<Annotation_t> lAnnotations;
+ lColl->getAnnotations(lAnnotations);
+ size_t num_annotations = 0;
+ for (std::vector<Annotation_t>::const_iterator lIter = lAnnotations.begin();
+ lIter != lAnnotations.end(); ++lIter)
+ {
+ std::cout << "Annotation QName " << (*lIter)->getQName().getStringValue() << std::endl;
+ ++num_annotations;
+ }
+
+ if (num_annotations != 3)
+ {
+ return false;
+ }
+ }
+ lColMgr->deleteCollection(lCollName2);
return true;
}
@@ -418,6 +420,46 @@
return true;
}
+/**
+ * test that declaredIndexes doesn't return temporary indexes and crashes
+ * if one tries to create one
+ */
+bool
+staticcollectionmanager6(zorba::Zorba* z)
+{
+ std::ifstream lIn("module1.xq");
+
+ zorba::XQuery_t lQuery = z->createQuery();
+ Zorba_CompilerHints lHints;
+ lQuery->compile(lIn, lHints);
+
+ StaticCollectionManager* lColMgr = lQuery->getStaticCollectionManager();
+
+ ItemFactory* lFac = z->getItemFactory();
+ Item lCollName2 = lFac->createQName("http://www.mod2.com/", "coll");
+ Item lIdxName = lFac->createQName("http://www.mod2.com/", "index");
+ Item lCollName3 = lFac->createQName("http://www.mod3.com/", "coll");
+
+ ItemSequence_t lSeq = lColMgr->declaredCollections();
+ Iterator_t lIter = lSeq->getIterator();
+ lIter->open();
+ Item lTmp;
+ while (lIter->next(lTmp)) {
+ std::cout << "name " << lTmp.getStringValue() << std::endl;
+ lColMgr->createCollection(lTmp);
+ }
+
+ lSeq = lColMgr->declaredIndexes();
+ lIter = lSeq->getIterator();
+ lIter->open();
+ while (lIter->next(lTmp)) {
+ std::cout << "name " << lTmp.getStringValue() << std::endl;
+ lColMgr->createIndex(lTmp);
+ }
+
+ return true;
+}
+
int
staticcollectionmanager(int argc, char* argv[])
{
@@ -451,6 +493,11 @@
return 5;
std::cout << std::endl;
+ std::cout << "executing example 6" << std::endl;
+ if (!staticcollectionmanager6(z))
+ return 6;
+ std::cout << std::endl;
+
return 0;
}
Follow ups
-
[Merge] lp:~zorba-coders/zorba/bug-945241 into lp:zorba
From: noreply, 2012-03-09
-
[Merge] lp:~zorba-coders/zorba/bug-945241 into lp:zorba
From: Zorba Build Bot, 2012-03-09
-
[Merge] lp:~zorba-coders/zorba/bug-945241 into lp:zorba
From: Zorba Build Bot, 2012-03-09
-
[Merge] lp:~zorba-coders/zorba/bug-945241 into lp:zorba
From: Till Westmann, 2012-03-09
-
Re: [Merge] lp:~zorba-coders/zorba/bug-945241 into lp:zorba
From: Till Westmann, 2012-03-09
-
[Merge] lp:~zorba-coders/zorba/bug-945241 into lp:zorba
From: Zorba Build Bot, 2012-03-07
-
Re: [Merge] lp:~zorba-coders/zorba/bug-945241 into lp:zorba
From: Zorba Build Bot, 2012-03-07
-
[Merge] lp:~zorba-coders/zorba/bug-945241 into lp:zorba
From: Zorba Build Bot, 2012-03-07
-
[Merge] lp:~zorba-coders/zorba/bug-945241 into lp:zorba
From: Zorba Build Bot, 2012-03-07
-
[Merge] lp:~zorba-coders/zorba/bug-945241 into lp:zorba
From: Matthias Brantner, 2012-03-07
-
[Merge] lp:~zorba-coders/zorba/bug-945241 into lp:zorba
From: Zorba Build Bot, 2012-03-07
-
Re: [Merge] lp:~zorba-coders/zorba/bug-945241 into lp:zorba
From: Zorba Build Bot, 2012-03-07
-
[Merge] lp:~zorba-coders/zorba/bug-945241 into lp:zorba
From: Zorba Build Bot, 2012-03-07
-
Re: [Merge] lp:~zorba-coders/zorba/bug-945241 into lp:zorba
From: Matthias Brantner, 2012-03-07
-
[Merge] lp:~zorba-coders/zorba/bug-945241 into lp:zorba
From: Matthias Brantner, 2012-03-07
-
[Merge] lp:~zorba-coders/zorba/bug-945241 into lp:zorba
From: Matthias Brantner, 2012-03-07