diff -ru dbxml-2.4.16-original/dbxml/dist/swig/dbxml_python.i dbxml-2.4.16/dbxml/dist/swig/dbxml_python.i --- dbxml-2.4.16-original/dbxml/dist/swig/dbxml_python.i 2008-10-21 14:27:14.000000000 -0700 +++ dbxml-2.4.16/dbxml/dist/swig/dbxml_python.i 2008-12-30 11:57:20.000000000 -0800 @@ -316,7 +316,15 @@ if ($1) $result = PyString_FromString((const char*)$1); else - $result = NULL; + $result = Py_None; +} + +%typemap(typecheck,precedence=SWIG_TYPECHECK_STRING) const unsigned char * { + $1 = PyString_Check($input) ? 1 : 0; +} + +%typemap(typecheck,precedence=SWIG_TYPECHECK_STRING) const unsigned char * { + $1 = PyString_Check($input) ? 1 : 0; } %typemap(in) Dbt *, Dbt & (Dbt dbt) { @@ -329,7 +337,7 @@ if ($1) $result = PyString_FromStringAndSize((char *)$1->get_data(), $1->get_size()); else - $result = NULL; + $result = Py_None; } %typemap(in) XmlData *, XmlData & (XmlData xml_data) { @@ -345,7 +353,7 @@ $1->get_size()); delete $1; // done with new XmlData } else - $result = NULL; + $result = Py_None; } %{ @@ -468,14 +476,14 @@ %pythoncode %{ class XmlException(Exception): - """Base class for BDB XML exceptions. + """Base class for BDB XML exceptions. It should never be called directly, and + if it is, it's an unknown error Attributes: - exceptionCode -- integer value what -- the exception message """ - def __init__(self, ec, msg): - self.exceptionCode = ec - self.what = msg + def __init__(self, msg): + self.exceptionCode = INTERNAL_ERROR + self.what = "Unknown exception thrown: ",msg def __str__(self): return "XmlException %d, %s"%(self.exceptionCode,self.what) def getexceptionCode(self): @@ -488,7 +496,7 @@ Attributes: dbError -- the Berkeley DB errno """ - def __init__(self, dberr, msg): + def __init__(self, msg, dberr): self.exceptionCode = DATABASE_ERROR self.what = msg self.dbError = dberr diff -ru dbxml-2.4.16-original/dbxml/src/dbxml/ConfigurationDatabase.cpp dbxml-2.4.16/dbxml/src/dbxml/ConfigurationDatabase.cpp --- dbxml-2.4.16-original/dbxml/src/dbxml/ConfigurationDatabase.cpp 2008-10-21 14:27:22.000000000 -0700 +++ dbxml-2.4.16/dbxml/src/dbxml/ConfigurationDatabase.cpp 2008-12-30 11:57:20.000000000 -0800 @@ -52,7 +52,7 @@ dbtxn = txn->getDbTxn(); // always set DB_CREATE and DB_THREAD - flags &= ~(DB_TXN_NOSYNC); + flags &= ~(DB_TXN_NOSYNC|DBXML_ENCRYPT|DBXML_CHKSUM); flags |= DB_CREATE|DB_THREAD; DbSequence *seq = new DbSequence(&db, 0); if (seq) { diff -ru dbxml-2.4.16-original/dbxml/src/dbxml/Document.cpp dbxml-2.4.16/dbxml/src/dbxml/Document.cpp --- dbxml-2.4.16-original/dbxml/src/dbxml/Document.cpp 2008-10-21 14:27:22.000000000 -0700 +++ dbxml-2.4.16/dbxml/src/dbxml/Document.cpp 2008-12-30 11:57:20.000000000 -0800 @@ -571,6 +571,10 @@ consumed(getName(), consumed_); ret = new MemBufInputStream(0, 0, getName().c_str(),false); } + if(definitiveContent_ == DBT) { + dbtContent_ = 0; + definitiveContent_ = NONE; + } return ret; } @@ -680,6 +684,7 @@ { changeContentToNsDom(isns); + if (!nsDocument_) return 0; //empty document if (nid.isDocRootNid()) return nsDocument_->getDocumentNode(); NsNode *nsNode = nsDocument_->getNode(nid, /*getNext*/false); diff -ru dbxml-2.4.16-original/dbxml/src/dbxml/DocumentDatabase.cpp dbxml-2.4.16/dbxml/src/dbxml/DocumentDatabase.cpp --- dbxml-2.4.16-original/dbxml/src/dbxml/DocumentDatabase.cpp 2008-10-21 14:27:22.000000000 -0700 +++ dbxml-2.4.16/dbxml/src/dbxml/DocumentDatabase.cpp 2008-12-30 11:57:20.000000000 -0800 @@ -184,9 +184,6 @@ id = ((Document&)old_document).getID(); new_document.getIDToSet() = id; resetId = true; - // clear modified flag if set on name - const_cast(&new_document)-> - clearModified(Name(metaDataName_uri_name)); } } else { err = indexer.getContainer()->getDocument( diff -ru dbxml-2.4.16-original/dbxml/src/dbxml/nodeStore/NsDocumentDatabase.cpp dbxml-2.4.16/dbxml/src/dbxml/nodeStore/NsDocumentDatabase.cpp --- dbxml-2.4.16-original/dbxml/src/dbxml/nodeStore/NsDocumentDatabase.cpp 2008-10-21 14:27:22.000000000 -0700 +++ dbxml-2.4.16/dbxml/src/dbxml/nodeStore/NsDocumentDatabase.cpp 2008-12-30 11:57:20.000000000 -0800 @@ -173,9 +173,6 @@ id = ((Document&)old_document).getID(); new_document.getIDToSet() = id; resetId = true; - // clear modified flag if set on name - const_cast(&new_document)-> - clearModified(Name(metaDataName_uri_name)); } } else { diff -ru dbxml-2.4.16-original/dbxml/src/dbxml/nodeStore/NsNid.cpp dbxml-2.4.16/dbxml/src/dbxml/nodeStore/NsNid.cpp --- dbxml-2.4.16-original/dbxml/src/dbxml/nodeStore/NsNid.cpp 2008-10-21 14:27:17.000000000 -0700 +++ dbxml-2.4.16/dbxml/src/dbxml/nodeStore/NsNid.cpp 2008-12-30 11:57:20.000000000 -0800 @@ -62,9 +62,9 @@ * 3. Between "1a0" and "1ab" ==> 1aam (cannot use "1aa") */ -const NsFullNid NsFullNid::docRootFullNid = NsFullNid(); -const NsNid NsNid::docRootNid; -const NsNid NsNid::docMetaDataNid; +NsFullNid NsFullNid::docRootFullNid; +NsNid NsNid::docRootNid; +NsNid NsNid::docMetaDataNid; #define NID_BETW_INITIAL_SIZE 4 // must be two or more #define NID_INITIAL_DIGIT 0 diff -ru dbxml-2.4.16-original/dbxml/src/dbxml/nodeStore/NsNid.hpp dbxml-2.4.16/dbxml/src/dbxml/nodeStore/NsNid.hpp --- dbxml-2.4.16-original/dbxml/src/dbxml/nodeStore/NsNid.hpp 2008-10-21 14:27:17.000000000 -0700 +++ dbxml-2.4.16/dbxml/src/dbxml/nodeStore/NsNid.hpp 2008-12-30 11:57:20.000000000 -0800 @@ -108,23 +108,23 @@ // static methods static void initDocRoot() { - const_cast(docRootNid) = rootNid; - const_cast(docMetaDataNid) = metadataNid; + docRootNid = rootNid; + docMetaDataNid = metadataNid; } static void displayNid(std::ostream &out, const char *buf, uint32_t len); static const NsNid *getRootNid() { - return &docRootNid; + return const_cast(&docRootNid); } static const NsNid *getMetaDataNid() { - return &docMetaDataNid; + return const_cast(&docMetaDataNid); } static int compare(const unsigned char *n1, const unsigned char *n2); protected: const unsigned char *nid_; - static const NsNid docRootNid; - static const NsNid docMetaDataNid; + static NsNid docRootNid; + static NsNid docMetaDataNid; }; class NsFullNid { @@ -215,15 +215,15 @@ return 4; } static const NsFullNid *getRootNid() { - return &docRootFullNid; + return const_cast(&docRootFullNid); } static void initDocRootNid() { - const_cast(docRootFullNid).setDocRootNid(); + docRootFullNid.setDocRootNid(); NsNid::initDocRoot(); } static void initNid(xmlbyte_t *buf, xmlbyte_t id); private: - static const NsFullNid docRootFullNid; + static NsFullNid docRootFullNid; }; class DBXML_EXPORT NsNidGen { diff -ru dbxml-2.4.16-original/dbxml/src/dbxml/query/DecisionPointQP.cpp dbxml-2.4.16/dbxml/src/dbxml/query/DecisionPointQP.cpp --- dbxml-2.4.16-original/dbxml/src/dbxml/query/DecisionPointQP.cpp 2008-10-21 14:27:22.000000000 -0700 +++ dbxml-2.4.16/dbxml/src/dbxml/query/DecisionPointQP.cpp 2008-12-30 11:57:20.000000000 -0800 @@ -3,7 +3,6 @@ // // Copyright (c) 2002,2008 Oracle. All rights reserved. // -// $Id$ // #include "../DbXmlInternal.hpp" @@ -274,7 +273,7 @@ // **** IMPORTANT - This algorithm is very carefully arranged to avoid // **** deadlocks and race-conditions. Don't rearrange things unless you // **** know what you are doing! - + // Get the runtime configuration DbXmlConfiguration *conf = GET_CONFIGURATION(context); @@ -354,7 +353,8 @@ } { OptimizationContext opt(OptimizationContext::ALTERNATIVES, context, 0, container); - qp = qp->chooseAlternative(opt, "decision point", container->getContainerID() == 0); + opt.setCheckForSS(container->getContainerID() == 0); + qp = qp->chooseAlternative(opt, "decision point"); qp->logQP(opt.getLog(), "OQP", qp, opt.getPhase()); } { @@ -395,16 +395,27 @@ { if(arg_ != 0) _src.add(arg_->getStaticAnalysis()); + + bool checkForSS = opt.checkForSS(); + + try { + ListItem **li = &qpList_; + for(ListItem *oli = o->qpList_; oli != 0; oli = oli->next) { + opt.setCheckForSS(oli->container->getContainerID() == 0); + + *li = new (mm) ListItem(oli->container, 0); + (*li)->qp = oli->qp->chooseAlternative(opt, "decision point"); - ListItem **li = &qpList_; - for(ListItem *oli = o->qpList_; oli != 0; oli = oli->next) { - *li = new (mm) ListItem(oli->container, 0); - (*li)->qp = oli->qp->chooseAlternative(opt, "decision point", oli->container->getContainerID() == 0); + _src.add((*li)->qp->getStaticAnalysis()); - _src.add((*li)->qp->getStaticAnalysis()); - - li = &(*li)->next; + li = &(*li)->next; + } + } + catch(...) { + opt.setCheckForSS(checkForSS); + throw; } + opt.setCheckForSS(checkForSS); } DecisionPointQP::DecisionPointQP(const DecisionPointQP *o, XPath2MemoryManager *mm) diff -ru dbxml-2.4.16-original/dbxml/src/dbxml/query/QueryPlan.cpp dbxml-2.4.16/dbxml/src/dbxml/query/QueryPlan.cpp --- dbxml-2.4.16-original/dbxml/src/dbxml/query/QueryPlan.cpp 2008-10-21 14:27:22.000000000 -0700 +++ dbxml-2.4.16/dbxml/src/dbxml/query/QueryPlan.cpp 2008-12-30 11:57:20.000000000 -0800 @@ -3,7 +3,6 @@ // // Copyright (c) 2002,2008 Oracle. All rights reserved. // -// $Id$ // #include "../DbXmlInternal.hpp" @@ -133,13 +132,44 @@ } } -CostSortItem::CostSortItem(QueryPlan *qp, OperationContext &oc, QueryExecutionContext &qec) - : qp_(qp), cost_(qp->cost(oc, qec)) +class ContainsSequentialScan : public NodeVisitingOptimizer +{ +public: + bool run(QueryPlan *qp) + { + found = false; + optimizeQP(qp); + return found; + } + +private: + virtual void resetInternal() {} + + virtual ASTNode *optimize(ASTNode *item) + { + // Don't look inside ASTNode objects + return item; + } + virtual QueryPlan *optimizeSequentialScan(SequentialScanQP *item) + { + found = true; + return item; + } + + bool found; +}; + +CostSortItem::CostSortItem(QueryPlan *qp, OperationContext &oc, QueryExecutionContext &qec, bool checkForSS) + : qp_(qp), cost_(qp->cost(oc, qec)), + hasSS_(false) { + if(checkForSS) hasSS_ = ContainsSequentialScan().run(qp); } bool CostSortItem::operator<(const CostSortItem &o) const { + if(hasSS_ != o.hasSS_) return !hasSS_; + if(cost_.totalPages() < o.cost_.totalPages()) return true; if(cost_.totalPages() > o.cost_.totalPages()) return false; @@ -194,12 +224,12 @@ } ++alternativesCount; - costSortSet.insert(CostSortItem(*it, oc, qec)); + costSortSet.insert(CostSortItem(*it, oc, qec, opt.checkForSS())); if(costSortSet.size() > ALTERNATIVES_THRESHOLD) { // Trim all QueryPlans outside of a factor of the cost of the lowest cost QueryPlan // TBD Make the specific factor configurable - jpcs - set::iterator cutPoint = costSortSet.lower_bound(costSortSet.begin()->cost_.totalPages() * cutOffFactor); + set::iterator cutPoint = costSortSet.lower_bound(CostSortItem(costSortSet.begin()->cost_.totalPages() * cutOffFactor, false)); if(cutPoint != costSortSet.begin() && cutPoint != costSortSet.end()) { for(i = cutPoint; i != costSortSet.end(); ++i) { if(Log::isLogEnabled(Log::C_OPTIMIZER, Log::L_DEBUG)) { @@ -252,36 +282,9 @@ } } -class ContainsSequentialScan : public NodeVisitingOptimizer -{ -public: - bool run(QueryPlan *qp) - { - found = false; - optimizeQP(qp); - return found; - } - -private: - virtual void resetInternal() {} - - virtual ASTNode *optimize(ASTNode *item) - { - // Don't look inside ASTNode objects - return item; - } - virtual QueryPlan *optimizeSequentialScan(SequentialScanQP *item) - { - found = true; - return item; - } - - bool found; -}; - -static bool betterAlternativeCost(const Cost &costA, bool ssA, const Cost &costB, bool ssB, bool noSequentialScan) +static bool betterAlternativeCost(const Cost &costA, bool ssA, const Cost &costB, bool ssB, bool checkForSS) { - if(ssA != ssB && noSequentialScan) return ssB; + if(ssA != ssB && checkForSS) return ssB; if(costA.totalPages() < costB.totalPages()) return true; if(costA.totalPages() > costB.totalPages()) return false; @@ -289,7 +292,7 @@ return costA.pagesOverhead < costB.pagesOverhead; } -QueryPlan *QueryPlan::chooseAlternative(OptimizationContext &opt, const char *name, bool noSequentialScan) const +QueryPlan *QueryPlan::chooseAlternative(OptimizationContext &opt, const char *name) const { QueryPlans combinations; createCombinations(MAX_ALTERNATIVES, opt, combinations); @@ -318,7 +321,7 @@ Cost itCost = qp->cost(opt.getOperationContext(), qec); bool itSS = ContainsSequentialScan().run(qp); - if(bestQP == 0 || betterAlternativeCost(itCost, itSS, bestCost, bestSS, noSequentialScan)) { + if(bestQP == 0 || betterAlternativeCost(itCost, itSS, bestCost, bestSS, opt.checkForSS())) { if(bestQP != 0) { log(qec, "Rejected Alternative (not best)"); bestQP->logCost(qec, bestCost, 0); diff -ru dbxml-2.4.16-original/dbxml/src/dbxml/query/QueryPlan.hpp dbxml-2.4.16/dbxml/src/dbxml/query/QueryPlan.hpp --- dbxml-2.4.16-original/dbxml/src/dbxml/query/QueryPlan.hpp 2008-10-21 14:27:22.000000000 -0700 +++ dbxml-2.4.16/dbxml/src/dbxml/query/QueryPlan.hpp 2008-12-30 11:57:20.000000000 -0800 @@ -3,7 +3,6 @@ // // Copyright (c) 2002,2008 Oracle. All rights reserved. // -// $Id$ // #ifndef __QUERYPLAN_HPP @@ -65,7 +64,7 @@ }; OptimizationContext(Phase ph, DynamicContext *cn, QueryPlanOptimizer *qpo, ContainerBase *c = 0) - : phase_(ph), context_(cn), qpo_(qpo), container_(c), isFetched_(false) {} + : phase_(ph), context_(cn), qpo_(qpo), container_(c), isFetched_(false), checkForSS_(false) {} Phase getPhase() const { return phase_; } @@ -82,6 +81,9 @@ const IndexSpecification &getIndexSpecification() const; const Log &getLog() const; + bool checkForSS() const { return checkForSS_; } + void setCheckForSS(bool val) { checkForSS_ = val; } + private: Phase phase_; DynamicContext *context_; @@ -89,6 +91,7 @@ ContainerBase *container_; mutable IndexSpecification is_; mutable bool isFetched_; + bool checkForSS_; }; class QueryPlan : public LocationInfo @@ -181,7 +184,7 @@ void createAlternatives(unsigned int maxAlternatives, OptimizationContext &opt, QueryPlans &alternatives) const; void createReducedAlternatives(double cutOffFactor, unsigned int maxAlternatives, OptimizationContext &opt, QueryPlans &alternatives) const; - QueryPlan *chooseAlternative(OptimizationContext &opt, const char *name, bool noSequentialScan = false) const; + QueryPlan *chooseAlternative(OptimizationContext &opt, const char *name) const; virtual NodeIterator *createNodeIterator(DynamicContext *context) const = 0; virtual Cost cost(OperationContext &context, QueryExecutionContext &qec) const = 0; @@ -541,13 +544,14 @@ }; struct CostSortItem { - CostSortItem(double cost) : qp_(0), cost_(0, cost) {} - CostSortItem(QueryPlan *qp, OperationContext &oc, QueryExecutionContext &qec); + CostSortItem(double cost, bool hasSS) : qp_(0), cost_(0, cost), hasSS_(hasSS) {} + CostSortItem(QueryPlan *qp, OperationContext &oc, QueryExecutionContext &qec, bool checkForSS); bool operator<(const CostSortItem &o) const; QueryPlan *qp_; Cost cost_; + bool hasSS_; }; } diff -ru dbxml-2.4.16-original/dbxml/src/dbxml/query/SequentialScanQP.cpp dbxml-2.4.16/dbxml/src/dbxml/query/SequentialScanQP.cpp --- dbxml-2.4.16-original/dbxml/src/dbxml/query/SequentialScanQP.cpp 2008-10-21 14:27:22.000000000 -0700 +++ dbxml-2.4.16/dbxml/src/dbxml/query/SequentialScanQP.cpp 2008-12-30 11:57:20.000000000 -0800 @@ -3,7 +3,6 @@ // // Copyright (c) 2002,2008 Oracle. All rights reserved. // -// $Id$ // #include "../DbXmlInternal.hpp" @@ -139,6 +138,7 @@ NodeIterator *SequentialScanQP::createNodeIterator(DynamicContext *context) const { + DBXML_ASSERT(container_->getContainerID() != 0); if(nodeType_ == ImpliedSchemaNode::METADATA) { return container_->createDocumentIterator(context, this); } else { diff -ru dbxml-2.4.16-original/dbxml/src/dbxml/query/StructuralJoinQP.cpp dbxml-2.4.16/dbxml/src/dbxml/query/StructuralJoinQP.cpp --- dbxml-2.4.16-original/dbxml/src/dbxml/query/StructuralJoinQP.cpp 2008-10-21 14:27:22.000000000 -0700 +++ dbxml-2.4.16/dbxml/src/dbxml/query/StructuralJoinQP.cpp 2008-12-30 11:57:20.000000000 -0800 @@ -1070,15 +1070,6 @@ if(!SuitableForPredicate().check(sj->getLeftArg())) return 0; - switch(sj->getRightArg()->getType()) { -// case QueryPlan::PRESENCE: -// case QueryPlan::VALUE: -// case QueryPlan::RANGE: -// case QueryPlan::SEQUENTIAL_SCAN: - case QueryPlan::VARIABLE: return 0; - default: break; - } - if((sj->getFlags() & QueryPlan::SKIP_LEFT_TO_PREDICATE) != 0) return 0; const XMLCh *varName = GET_CONFIGURATION(opt.getContext())->allocateTempVarName(mm); @@ -1119,15 +1110,6 @@ if(!SuitableForPredicate().check(l)) return 0; - switch(r->getType()) { - case QueryPlan::PRESENCE: - case QueryPlan::VALUE: - case QueryPlan::RANGE: - case QueryPlan::SEQUENTIAL_SCAN: - case QueryPlan::VARIABLE: return 0; - default: break; - } - if((flags & QueryPlan::SKIP_LEFT_TO_PREDICATE) != 0) return 0; const XMLCh *varName = GET_CONFIGURATION(opt.getContext())->allocateTempVarName(mm); diff -ru dbxml-2.4.16-original/dbxml/src/dbxml/RawNodeValue.cpp dbxml-2.4.16/dbxml/src/dbxml/RawNodeValue.cpp --- dbxml-2.4.16-original/dbxml/src/dbxml/RawNodeValue.cpp 2008-10-21 14:27:22.000000000 -0700 +++ dbxml-2.4.16/dbxml/src/dbxml/RawNodeValue.cpp 2008-12-30 11:57:20.000000000 -0800 @@ -84,6 +84,12 @@ // it comes from the Container. DbWrapper *RawNodeValue::getDocDB() const { + //Make sure the doc db of this node and the document are the same + if (!xdoc_.isNull()) { + DbWrapper *docDb = (*xdoc_).getDocDb(); + if (docDb) return docDb; + } + Results &res = GET_RESULTS(); XmlManager &mgr = res.getManager(); CacheDatabaseMinder &minder = res.getDbMinder(); diff -ru dbxml-2.4.16-original/dbxml/src/dbxml/Results.cpp dbxml-2.4.16/dbxml/src/dbxml/Results.cpp --- dbxml-2.4.16-original/dbxml/src/dbxml/Results.cpp 2008-10-21 14:27:22.000000000 -0700 +++ dbxml-2.4.16/dbxml/src/dbxml/Results.cpp 2008-12-30 11:57:20.000000000 -0800 @@ -241,12 +241,13 @@ if (contextItem && (contextItem->getType() == XmlValue::NODE)) { XmlDocument &xdoc = (XmlDocument&)contextItem->asDocument(); CacheDatabaseMinder &minder = ((Document *)xdoc)->getDbMinder(); - if (minder.isNull()) { + if (minder.isNull() && !((Document*)xdoc)->getContainerID()) { dbMinder_.findOrAllocate((Manager&)(context->getManager()), ((Document *)xdoc)->getContainerID()); minder = dbMinder_; }else dbMinder_ = minder; + if ((*xdoc).isUninitialized()) (*xdoc).changeContentToNsDom(0); } oc_.set(txn); conf_.setMinder(&evaluationMinder_); diff -ru dbxml-2.4.16-original/dbxml/src/java/com/sleepycat/dbxml/dbxml_javaJNI.java dbxml-2.4.16/dbxml/src/java/com/sleepycat/dbxml/dbxml_javaJNI.java --- dbxml-2.4.16-original/dbxml/src/java/com/sleepycat/dbxml/dbxml_javaJNI.java 2008-10-21 14:28:16.000000000 -0700 +++ dbxml-2.4.16/dbxml/src/java/com/sleepycat/dbxml/dbxml_javaJNI.java 2008-12-30 11:57:20.000000000 -0800 @@ -100,7 +100,6 @@ public final static native void XmlManager_setDefaultContainerType(long jarg1, XmlManager jarg1_, int jarg2); public final static native int XmlManager_getDefaultContainerType(long jarg1, XmlManager jarg1_); public final static native String XmlManager_getHome(long jarg1, XmlManager jarg1_); - public final static native void XmlManager_registerResolver(long jarg1, XmlManager jarg1_, long jarg2, XmlResolver jarg2_); public final static native int XmlManager_getImplicitTimezone(long jarg1, XmlManager jarg1_); public final static native void XmlManager_setImplicitTimezone(long jarg1, XmlManager jarg1_, int jarg2); public final static native int XmlManager_existsContainer(long jarg1, XmlManager jarg1_, String jarg2); @@ -159,6 +158,7 @@ public final static native int XmlManager_get_version_patch(); public final static native String XmlManager_get_version_string(); public final static native XmlDocument XmlManager_createDocumentInternal(long jarg1, XmlManager jarg1_); + public final static native void XmlManager_registerResolverInternal(long jarg1, XmlManager jarg1_, long jarg2, XmlResolver jarg2_); public final static native void delete_XmlIndexLookup(long jarg1); public final static native boolean XmlIndexLookup_isNull(long jarg1, XmlIndexLookup jarg1_); public final static native String XmlIndexLookup_getIndex(long jarg1, XmlIndexLookup jarg1_); diff -ru dbxml-2.4.16-original/dbxml/src/java/com/sleepycat/dbxml/XmlDocument.java dbxml-2.4.16/dbxml/src/java/com/sleepycat/dbxml/XmlDocument.java --- dbxml-2.4.16-original/dbxml/src/java/com/sleepycat/dbxml/XmlDocument.java 2008-10-21 14:27:22.000000000 -0700 +++ dbxml-2.4.16/dbxml/src/java/com/sleepycat/dbxml/XmlDocument.java 2008-12-30 11:57:20.000000000 -0800 @@ -115,9 +115,7 @@ content.stream = null; content.type = NONE; return ins; - }else if (!content.hasContent() && docID == 0) - return null; - else + } else return HelperFunctions.getContentAsXmlInputStream(this); } @@ -127,9 +125,7 @@ content.reader = null; content.type = NONE; return xer; - }else if (!content.hasContent() && docID == 0) - return null; - else + } else return HelperFunctions.getContentAsEventReader(this); } @@ -214,6 +210,13 @@ } //The rest of this class is for internal use. + protected boolean isConstructed() + { + if(results == null && docID == 0) + return true; + return false; + } + /* If both modified and removed are set to false then the meta data is * only being added if it does not already exist. */ @@ -259,11 +262,6 @@ content = new Content(); } - protected void finalize() throws XmlException { - metaData.clear(); - content.clear(); - } - protected void copy(XmlDocument o) throws XmlException { docID = o.docID; cid = o.cid; @@ -360,6 +358,10 @@ protected void setEventWriter(long writer){ eventWriter = writer; } + + protected Content getEmptyContent() { + return new Content(); + } class Content { public XmlEventReader reader; diff -ru dbxml-2.4.16-original/dbxml/src/java/com/sleepycat/dbxml/XmlInputStream.java dbxml-2.4.16/dbxml/src/java/com/sleepycat/dbxml/XmlInputStream.java --- dbxml-2.4.16-original/dbxml/src/java/com/sleepycat/dbxml/XmlInputStream.java 2008-10-21 14:28:16.000000000 -0700 +++ dbxml-2.4.16/dbxml/src/java/com/sleepycat/dbxml/XmlInputStream.java 2008-12-30 11:57:20.000000000 -0800 @@ -21,10 +21,6 @@ return (obj == null) ? 0 : obj.swigCPtr; } - protected void finalize() { - delete(); - } - public void delete() /* no exception */ { if(swigCPtr != 0 && swigCMemOwn) { swigCMemOwn = false; diff -ru dbxml-2.4.16-original/dbxml/src/java/com/sleepycat/dbxml/XmlManager.java dbxml-2.4.16/dbxml/src/java/com/sleepycat/dbxml/XmlManager.java --- dbxml-2.4.16-original/dbxml/src/java/com/sleepycat/dbxml/XmlManager.java 2008-10-21 14:28:16.000000000 -0700 +++ dbxml-2.4.16/dbxml/src/java/com/sleepycat/dbxml/XmlManager.java 2008-12-30 11:57:20.000000000 -0800 @@ -16,6 +16,7 @@ import com.sleepycat.db.internal.DbEnv; import com.sleepycat.db.internal.DbConstants; import com.sleepycat.db.XmlHelper; + import java.util.LinkedList; public class XmlManager { private long swigCPtr; @@ -49,6 +50,7 @@ private boolean threaded = true; // default on if no Environment private boolean adopted = false; private XmlManagerConfig config = null; + private LinkedList resolverStore; public XmlManager(final Environment dbenv, XmlManagerConfig config) @@ -385,6 +387,18 @@ public void close() throws XmlException { delete(); } + + private synchronized void setResolver(XmlResolver resolver) + { + if (resolverStore == null) resolverStore = new LinkedList(); + resolverStore.add(resolver); //prevents premature garbage collection + } + + public void registerResolver(XmlResolver resolver) throws XmlException + { + setResolver(resolver); + registerResolverInternal(resolver); + } public final static int LEVEL_NONE = dbxml_java.LEVEL_NONE; public final static int LEVEL_DEBUG = dbxml_java.LEVEL_DEBUG; @@ -438,10 +452,6 @@ return dbxml_javaJNI.XmlManager_getHome(swigCPtr, this); } - public void registerResolver(XmlResolver resolver) throws XmlException { - dbxml_javaJNI.XmlManager_registerResolver(swigCPtr, this, XmlResolver.getCPtr(resolver), resolver); - } - public int getImplicitTimezone() throws XmlException { return dbxml_javaJNI.XmlManager_getImplicitTimezone(swigCPtr, this); } @@ -703,4 +713,8 @@ public XmlDocument createDocumentInternal() throws XmlException { return dbxml_javaJNI.XmlManager_createDocumentInternal(swigCPtr, this); } + public void registerResolverInternal(XmlResolver resolver) throws XmlException { + dbxml_javaJNI.XmlManager_registerResolverInternal(swigCPtr, this, XmlResolver.getCPtr(resolver), resolver); + } + } diff -ru dbxml-2.4.16-original/dbxml/src/java/com/sleepycat/dbxml/XmlValue.java dbxml-2.4.16/dbxml/src/java/com/sleepycat/dbxml/XmlValue.java --- dbxml-2.4.16-original/dbxml/src/java/com/sleepycat/dbxml/XmlValue.java 2008-10-21 14:27:22.000000000 -0700 +++ dbxml-2.4.16/dbxml/src/java/com/sleepycat/dbxml/XmlValue.java 2008-12-30 11:57:20.000000000 -0800 @@ -10,6 +10,8 @@ import java.util.*; +import com.sleepycat.dbxml.XmlDocument.Content; + public class XmlValue { protected Value value; protected int valueType; @@ -69,7 +71,10 @@ public XmlValue(XmlDocument document) throws XmlException { - XmlValue xmlvalue = HelperFunctions.createDocumentValue(document); + Content con = document.content; + document.content = document.getEmptyContent(); //Prevents the content from being consumed + XmlValue xmlvalue = HelperFunctions.createDocumentValue(document); + document.content = con; valueType = xmlvalue.getType(); value = new NodeValue((NodeValue)xmlvalue.value); ((NodeValue)value).setDocument(document); diff -ru dbxml-2.4.16-original/dbxml/src/java/dbxml_java_wrap.cpp dbxml-2.4.16/dbxml/src/java/dbxml_java_wrap.cpp --- dbxml-2.4.16-original/dbxml/src/java/dbxml_java_wrap.cpp 2008-10-21 14:28:16.000000000 -0700 +++ dbxml-2.4.16/dbxml/src/java/dbxml_java_wrap.cpp 2008-12-30 11:57:20.000000000 -0800 @@ -1516,10 +1516,8 @@ XmlValue value((XmlValue::Type)type, v); } SWIGINTERN XmlInputStream *HelperFunctions_getContentAsXmlInputStream(XmlDocument &doc){ - XmlEventReader &reader = doc.getContentAsEventReader(); - doc.setContentAsEventReader(reader); - return doc.getContentAsXmlInputStream(); - } + return doc.getContentAsXmlInputStream(); + } SWIGINTERN XmlEventReader &HelperFunctions_getContentAsEventReader(XmlDocument &doc){ return doc.getContentAsEventReader(); } @@ -1790,6 +1788,9 @@ SWIGINTERN XmlDocument XmlManager_createDocumentInternal(XmlManager *self){ return self->createDocument(); } +SWIGINTERN void XmlManager_registerResolverInternal(XmlManager *self,XmlResolver *resolver){ + self->registerResolver(*resolver); + } SWIGINTERN XmlResults *XmlIndexLookup_execute__SWIG_0(XmlIndexLookup const *self,XmlQueryContext &context,u_int32_t flags=0){ return new XmlResults(self->execute(context, flags)); } @@ -4365,55 +4366,6 @@ } -SWIGEXPORT void JNICALL Java_com_sleepycat_dbxml_dbxml_1javaJNI_XmlManager_1registerResolver(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jobject jarg2_) { - XmlManager *arg1 = (XmlManager *) 0 ; - XmlResolver *arg2 = 0 ; - - (void)jenv; - (void)jcls; - (void)jarg1_; - (void)jarg2_; - arg1 = *(XmlManager **)&jarg1; - arg2 = *(XmlResolver **)&jarg2; - if(!arg2) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "XmlResolver const & reference is null"); - return ; - } - - if (!jarg1) { - jenv->Throw((jthrowable)jenv->NewObject(xmlex_class, xmlex_construct, - XmlException::INTERNAL_ERROR, - jenv->NewStringUTF("null object - call after object destroyed?"), - 0, 0, 0, 0)); - return ; - } - - { - jthrowable t = NULL; - try { - (arg1)->registerResolver((XmlResolver const &)*arg2); - } - catch (std::exception &se) { - t = createException(jenv, &se); - } - catch(JavaException & /* je */) { - // This means there's already an exception waiting in the JVM - return ; - } - catch (...) { - t = (jthrowable)jenv->NewObject(xmlex_class, xmlex_construct, - XmlException::INTERNAL_ERROR, - jenv->NewStringUTF("Uncaught exception from C++ API"), 0, 0, 0, 0); - } - - if (t) { - jenv->Throw(t); - return ; - } - } -} - - SWIGEXPORT jint JNICALL Java_com_sleepycat_dbxml_dbxml_1javaJNI_XmlManager_1getImplicitTimezone(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) { jint jresult = 0 ; XmlManager *arg1 = (XmlManager *) 0 ; @@ -8088,6 +8040,51 @@ } +SWIGEXPORT void JNICALL Java_com_sleepycat_dbxml_dbxml_1javaJNI_XmlManager_1registerResolverInternal(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jobject jarg2_) { + XmlManager *arg1 = (XmlManager *) 0 ; + XmlResolver *arg2 = (XmlResolver *) 0 ; + + (void)jenv; + (void)jcls; + (void)jarg1_; + (void)jarg2_; + arg1 = *(XmlManager **)&jarg1; + arg2 = *(XmlResolver **)&jarg2; + + if (!jarg1) { + jenv->Throw((jthrowable)jenv->NewObject(xmlex_class, xmlex_construct, + XmlException::INTERNAL_ERROR, + jenv->NewStringUTF("null object - call after object destroyed?"), + 0, 0, 0, 0)); + return ; + } + + { + jthrowable t = NULL; + try { + XmlManager_registerResolverInternal(arg1,arg2); + } + catch (std::exception &se) { + t = createException(jenv, &se); + } + catch(JavaException & /* je */) { + // This means there's already an exception waiting in the JVM + return ; + } + catch (...) { + t = (jthrowable)jenv->NewObject(xmlex_class, xmlex_construct, + XmlException::INTERNAL_ERROR, + jenv->NewStringUTF("Uncaught exception from C++ API"), 0, 0, 0, 0); + } + + if (t) { + jenv->Throw(t); + return ; + } + } +} + + SWIGEXPORT void JNICALL Java_com_sleepycat_dbxml_dbxml_1javaJNI_delete_1XmlIndexLookup(JNIEnv *jenv, jclass jcls, jlong jarg1) { XmlIndexLookup *arg1 = (XmlIndexLookup *) 0 ; diff -ru dbxml-2.4.16-original/dbxml/src/python/dbxml.py dbxml-2.4.16/dbxml/src/python/dbxml.py --- dbxml-2.4.16-original/dbxml/src/python/dbxml.py 2008-10-21 14:28:13.000000000 -0700 +++ dbxml-2.4.16/dbxml/src/python/dbxml.py 2008-12-30 11:57:20.000000000 -0800 @@ -56,14 +56,14 @@ class XmlException(Exception): - """Base class for BDB XML exceptions. + """Base class for BDB XML exceptions. It should never be called directly, and + if it is, it's an unknown error Attributes: - exceptionCode -- integer value what -- the exception message """ - def __init__(self, ec, msg): - self.exceptionCode = ec - self.what = msg + def __init__(self, msg): + self.exceptionCode = INTERNAL_ERROR + self.what = "Unknown exception thrown: ",msg def __str__(self): return "XmlException %d, %s"%(self.exceptionCode,self.what) def getexceptionCode(self): @@ -76,7 +76,7 @@ Attributes: dbError -- the Berkeley DB errno """ - def __init__(self, dberr, msg): + def __init__(self, msg, dberr): self.exceptionCode = DATABASE_ERROR self.what = msg self.dbError = dberr diff -ru dbxml-2.4.16-original/dbxml/src/python/dbxml_python_wrap.cpp dbxml-2.4.16/dbxml/src/python/dbxml_python_wrap.cpp --- dbxml-2.4.16-original/dbxml/src/python/dbxml_python_wrap.cpp 2008-10-21 14:28:16.000000000 -0700 +++ dbxml-2.4.16/dbxml/src/python/dbxml_python_wrap.cpp 2008-12-30 11:57:20.000000000 -0800 @@ -2994,9 +2994,8 @@ #define SWIGTYPE_p_XmlValue swig_types[22] #define SWIGTYPE_p_char swig_types[23] #define SWIGTYPE_p_int swig_types[24] -#define SWIGTYPE_p_unsigned_char swig_types[25] -static swig_type_info *swig_types[27]; -static swig_module_info swig_module = {swig_types, 26, 0, 0, 0, 0}; +static swig_type_info *swig_types[26]; +static swig_module_info swig_module = {swig_types, 25, 0, 0, 0, 0}; #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) @@ -23335,7 +23334,7 @@ result->get_size()); delete result; // done with new XmlData } else - resultobj = NULL; + resultobj = Py_None; } SWIG_PYTHON_THREAD_END_BLOCK; return resultobj; @@ -23408,7 +23407,7 @@ result->get_size()); delete result; // done with new XmlData } else - resultobj = NULL; + resultobj = Py_None; } if (SWIG_IsNewObj(res2)) delete arg2; if (SWIG_IsNewObj(res3)) delete arg3; @@ -34216,7 +34215,7 @@ if (result) resultobj = PyString_FromString((const char*)result); else - resultobj = NULL; + resultobj = Py_None; } SWIG_PYTHON_THREAD_END_BLOCK; return resultobj; @@ -34258,7 +34257,7 @@ if (result) resultobj = PyString_FromString((const char*)result); else - resultobj = NULL; + resultobj = Py_None; } SWIG_PYTHON_THREAD_END_BLOCK; return resultobj; @@ -34300,7 +34299,7 @@ if (result) resultobj = PyString_FromString((const char*)result); else - resultobj = NULL; + resultobj = Py_None; } SWIG_PYTHON_THREAD_END_BLOCK; return resultobj; @@ -34342,7 +34341,7 @@ if (result) resultobj = PyString_FromString((const char*)result); else - resultobj = NULL; + resultobj = Py_None; } SWIG_PYTHON_THREAD_END_BLOCK; return resultobj; @@ -34513,7 +34512,7 @@ if (result) resultobj = PyString_FromString((const char*)result); else - resultobj = NULL; + resultobj = Py_None; } SWIG_PYTHON_THREAD_END_BLOCK; return resultobj; @@ -34564,7 +34563,7 @@ if (result) resultobj = PyString_FromString((const char*)result); else - resultobj = NULL; + resultobj = Py_None; } SWIG_PYTHON_THREAD_END_BLOCK; return resultobj; @@ -34615,7 +34614,7 @@ if (result) resultobj = PyString_FromString((const char*)result); else - resultobj = NULL; + resultobj = Py_None; } SWIG_PYTHON_THREAD_END_BLOCK; return resultobj; @@ -34666,7 +34665,7 @@ if (result) resultobj = PyString_FromString((const char*)result); else - resultobj = NULL; + resultobj = Py_None; } SWIG_PYTHON_THREAD_END_BLOCK; return resultobj; @@ -34708,7 +34707,7 @@ if (result) resultobj = PyString_FromString((const char*)result); else - resultobj = NULL; + resultobj = Py_None; } SWIG_PYTHON_THREAD_END_BLOCK; return resultobj; @@ -34750,7 +34749,7 @@ if (result) resultobj = PyString_FromString((const char*)result); else - resultobj = NULL; + resultobj = Py_None; } SWIG_PYTHON_THREAD_END_BLOCK; return resultobj; @@ -34792,7 +34791,7 @@ if (result) resultobj = PyString_FromString((const char*)result); else - resultobj = NULL; + resultobj = Py_None; } SWIG_PYTHON_THREAD_END_BLOCK; return resultobj; @@ -35564,9 +35563,9 @@ _v = SWIG_CheckState(res); } if (_v) { - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_unsigned_char, 0); - _v = SWIG_CheckState(res); + { + _v = PyString_Check(argv[2]) ? 1 : 0; + } if (_v) { SWIG_PYTHON_THREAD_END_BLOCK; return _wrap_XmlEventWriter_writeText__SWIG_1(self, args); @@ -35585,9 +35584,9 @@ _v = SWIG_CheckState(res); } if (_v) { - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_unsigned_char, 0); - _v = SWIG_CheckState(res); + { + _v = PyString_Check(argv[2]) ? 1 : 0; + } if (_v) { { int res = SWIG_AsVal_size_t(argv[3], NULL); @@ -35674,9 +35673,9 @@ int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XmlEventWriter, 0); _v = SWIG_CheckState(res); if (_v) { - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_unsigned_char, 0); - _v = SWIG_CheckState(res); + { + _v = PyString_Check(argv[1]) ? 1 : 0; + } if (_v) { SWIG_PYTHON_THREAD_END_BLOCK; return _wrap_XmlEventWriter_writeDTD__SWIG_1(self, args); @@ -35689,9 +35688,9 @@ int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_XmlEventWriter, 0); _v = SWIG_CheckState(res); if (_v) { - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_unsigned_char, 0); - _v = SWIG_CheckState(res); + { + _v = PyString_Check(argv[1]) ? 1 : 0; + } if (_v) { { int res = SWIG_AsVal_size_t(argv[2], NULL); @@ -36782,7 +36781,6 @@ static swig_type_info _swigt__p_XmlValue = {"_p_XmlValue", "XmlValue *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_int = {"_p_int", "int *|int32_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_unsigned_char = {"_p_unsigned_char", "unsigned char *", 0, 0, (void*)0, 0}; static swig_type_info *swig_type_initial[] = { &_swigt__p_DbTxn, @@ -36810,7 +36808,6 @@ &_swigt__p_XmlValue, &_swigt__p_char, &_swigt__p_int, - &_swigt__p_unsigned_char, }; static swig_cast_info _swigc__p_DbTxn[] = { {&_swigt__p_DbTxn, 0, 0, 0},{0, 0, 0, 0}}; @@ -36838,7 +36835,6 @@ static swig_cast_info _swigc__p_XmlValue[] = { {&_swigt__p_XmlValue, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_unsigned_char[] = { {&_swigt__p_unsigned_char, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info *swig_cast_initial[] = { _swigc__p_DbTxn, @@ -36866,7 +36862,6 @@ _swigc__p_XmlValue, _swigc__p_char, _swigc__p_int, - _swigc__p_unsigned_char, };