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

Proposed by Paul J. Lucas
Status: Needs review
Proposed branch: lp:~zorba-coders/zorba/bug-1103819
Merge into: lp:zorba
Diff against target: 1283 lines (+397/-393)
16 files modified
src/api/xqueryimpl.cpp (+3/-17)
src/capi/cdynamic_context.cpp (+1/-4)
src/capi/cexpression.cpp (+1/-4)
src/capi/cimplementation.cpp (+1/-4)
src/capi/csequence.cpp (+1/-4)
src/capi/cstatic_context.cpp (+1/-4)
src/context/default_url_resolvers.cpp (+6/-0)
src/runtime/debug/debug_iterator_impl.cpp (+11/-18)
src/runtime/indexing/doc_indexer.cpp (+1/-3)
src/store/naive/loader_dtd.cpp (+118/-8)
src/store/naive/loader_fast.cpp (+51/-89)
src/store/naive/node_items.cpp (+13/-27)
src/store/naive/node_updates.cpp (+179/-186)
src/store/naive/pul_primitives.cpp (+5/-1)
src/store/naive/store.cpp (+2/-3)
src/types/schema/schema.cpp (+3/-21)
To merge this branch: bzr merge lp:~zorba-coders/zorba/bug-1103819
Reviewer Review Type Date Requested Status
Chris Hillery Needs Information
Paul J. Lucas Approve
Review via email: mp+146312@code.launchpad.net

Commit message

Reworked some catch clauses.

Description of the change

Reworked some catch clauses.

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 :

The attempt to merge lp:~zorba-coders/zorba/bug-1103819 into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:275 (message):
  Validation queue job bug-1103819-2013-02-09T08-51-07.388Z is finished. The
  final status was:

  31 tests did not succeed - changes not commited.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

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

The attempt to merge lp:~zorba-coders/zorba/bug-1103819 into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:275 (message):
  Validation queue job bug-1103819-2013-02-09T09-20-57.362Z is finished. The
  final status was:

  6 tests did not succeed - changes not commited.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

Revision history for this message
Paul J. Lucas (paul-lucas) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

The attempt to merge lp:~zorba-coders/zorba/bug-1103819 into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:275 (message):
  Validation queue job bug-1103819-2013-04-30T18-29-01.523Z is finished. The
  final status was:

  117 tests did not succeed - changes not commited.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

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

Validation queue starting for the following merge proposals:
https://code.launchpad.net/~zorba-coders/zorba/bug-1103819/+merge/146312

Progress dashboard at http://jenkins.lambda.nu/view/ValidationQueue

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

Validation queue result for https://code.launchpad.net/~zorba-coders/zorba/bug-1103819/+merge/146312

Stage "TestZorbaUbuntu" failed.
115 tests failed (8402 total tests run).

Check test results at http://jenkins.lambda.nu/job/TestZorbaUbuntu/193/testReport/ to view the results.

Revision history for this message
Chris Hillery (ceejatec) wrote :

A great number of parsing and serializing test cases fail with these changes. Do we have any plans to fix them up? It's not clear to me if anyone is driving this issue anymore...

review: Needs Information

Unmerged revisions

11213. By Cezar Andrei <email address hidden>

Remove catch throws, leave exceptions bubble up.

11212. By Cezar Andrei <email address hidden>

One more catch ... fix.

11211. By Cezar Andrei <email address hidden>

Fix catch( ... ).

11210. By Paul J. Lucas

Merge from bug1103819-catchAll.

11209. By Paul J. Lucas

Merge from trunk.

11208. By Paul J. Lucas

Merge from trunk.

11207. By Paul J. Lucas

Merge from trunk.

11206. By Paul J. Lucas

Merge from trunk.

11205. By Paul J. Lucas

Merge from trunk.

11204. By Paul J. Lucas

Merge from trunk.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/api/xqueryimpl.cpp'
--- src/api/xqueryimpl.cpp 2013-04-10 10:13:31 +0000
+++ src/api/xqueryimpl.cpp 2013-04-30 17:01:29 +0000
@@ -80,6 +80,7 @@
80namespace zorba80namespace zorba
81{81{
8282
83#define QUERY_TRY try
8384
84#define QUERY_CATCH \85#define QUERY_CATCH \
85 catch (ZorbaException const& e) \86 catch (ZorbaException const& e) \
@@ -942,7 +943,7 @@
942{943{
943 SYNC_CODE(AutoMutex lock(&theMutex);)944 SYNC_CODE(AutoMutex lock(&theMutex);)
944945
945 try946 QUERY_TRY
946 {947 {
947 checkNotClosed();948 checkNotClosed();
948 checkCompiled();949 checkCompiled();
@@ -965,22 +966,7 @@
965966
966 return true;967 return true;
967 }968 }
968 catch (ZorbaException const& e)969 QUERY_CATCH
969 {
970 ZorbaImpl::notifyError(theDiagnosticHandler, e);
971 }
972 catch (FlowCtlException const&)
973 {
974 ZorbaImpl::notifyError(theDiagnosticHandler, "User interrupt");
975 }
976 catch (std::exception const& e)
977 {
978 ZorbaImpl::notifyError(theDiagnosticHandler, e.what());
979 }
980 catch (...)
981 {
982 ZorbaImpl::notifyError(theDiagnosticHandler);
983 }
984970
985 return false;971 return false;
986}972}
987973
=== modified file 'src/capi/cdynamic_context.cpp'
--- src/capi/cdynamic_context.cpp 2013-02-07 17:24:36 +0000
+++ src/capi/cdynamic_context.cpp 2013-04-30 17:01:29 +0000
@@ -271,10 +271,7 @@
271 CDynamicContext::free(XQC_DynamicContext* context)271 CDynamicContext::free(XQC_DynamicContext* context)
272 {272 {
273 try {273 try {
274 CDynamicContext* me = CDynamicContext::get(context);274 delete CDynamicContext::get(context);
275 delete me;
276 } catch (ZorbaException const&) {
277 assert(false);
278 } catch (...) { 275 } catch (...) {
279 assert(false);276 assert(false);
280 }277 }
281278
=== modified file 'src/capi/cexpression.cpp'
--- src/capi/cexpression.cpp 2013-02-07 17:24:36 +0000
+++ src/capi/cexpression.cpp 2013-04-30 17:01:29 +0000
@@ -227,10 +227,7 @@
227 CExpression::free(XQC_Expression* expr)227 CExpression::free(XQC_Expression* expr)
228 {228 {
229 try {229 try {
230 CExpression* me = CExpression::get(expr);230 delete CExpression::get(expr);
231 delete me;
232 } catch (ZorbaException const&) {
233 assert(false);
234 } catch (...) {231 } catch (...) {
235 assert(false);232 assert(false);
236 }233 }
237234
=== modified file 'src/capi/cimplementation.cpp'
--- src/capi/cimplementation.cpp 2013-02-07 17:24:36 +0000
+++ src/capi/cimplementation.cpp 2013-04-30 17:01:29 +0000
@@ -507,10 +507,7 @@
507 CImplementation::free(XQC_Implementation* impl)507 CImplementation::free(XQC_Implementation* impl)
508 {508 {
509 try {509 try {
510 CImplementation* me = CImplementation::get(impl);510 delete CImplementation::get(impl);
511 delete me;
512 } catch (ZorbaException const&) {
513 assert(false);
514 } catch (...) {511 } catch (...) {
515 assert(false);512 assert(false);
516 }513 }
517514
=== modified file 'src/capi/csequence.cpp'
--- src/capi/csequence.cpp 2013-02-07 17:24:36 +0000
+++ src/capi/csequence.cpp 2013-04-30 17:01:29 +0000
@@ -492,10 +492,7 @@
492CSequence::free(XQC_Sequence* seq)492CSequence::free(XQC_Sequence* seq)
493{493{
494 try {494 try {
495 CSequence* me = CSequence::get(seq);495 delete CSequence::get(seq);
496 delete me;
497 } catch (ZorbaException const&) {
498 assert(false);
499 } catch (...) {496 } catch (...) {
500 assert(false);497 assert(false);
501 }498 }
502499
=== modified file 'src/capi/cstatic_context.cpp'
--- src/capi/cstatic_context.cpp 2013-02-07 17:24:36 +0000
+++ src/capi/cstatic_context.cpp 2013-04-30 17:01:29 +0000
@@ -666,10 +666,7 @@
666 CStaticContext::free(XQC_StaticContext* context)666 CStaticContext::free(XQC_StaticContext* context)
667 {667 {
668 try {668 try {
669 CStaticContext* me = CStaticContext::get(context);669 delete CStaticContext::get(context);
670 delete me;
671 } catch (ZorbaException const&) {
672 assert(false);
673 } catch (...) { 670 } catch (...) {
674 assert(false);671 assert(false);
675 }672 }
676673
=== modified file 'src/context/default_url_resolvers.cpp'
--- src/context/default_url_resolvers.cpp 2013-02-07 17:24:36 +0000
+++ src/context/default_url_resolvers.cpp 2013-04-30 17:01:29 +0000
@@ -21,6 +21,7 @@
21#include "util/uri_util.h"21#include "util/uri_util.h"
22#include "util/http_util.h"22#include "util/http_util.h"
23#include "util/fs_util.h"23#include "util/fs_util.h"
24#include "util/string_util.h"
24#include "store/api/store.h"25#include "store/api/store.h"
25#include "store/api/item_factory.h"26#include "store/api/item_factory.h"
26#include "store/api/collection.h"27#include "store/api/collection.h"
@@ -93,6 +94,11 @@
93 new StreamResource(&(lStream->getStream()), lStream->getStreamReleaser());94 new StreamResource(&(lStream->getStream()), lStream->getStreamReleaser());
94 lStream->setStreamReleaser(nullptr);95 lStream->setStreamReleaser(nullptr);
95 return lResource;96 return lResource;
97 } catch (std::exception const &e) {
98 std::string const msg(
99 BUILD_STRING( "Could not create stream resource: ", e.what() )
100 );
101 throw os_error::exception( "", aUrl.c_str(), msg.c_str() );
96 } catch (...) {102 } catch (...) {
97 throw os_error::exception("", aUrl.c_str(), "Could not create stream resource");103 throw os_error::exception("", aUrl.c_str(), "Could not create stream resource");
98 }104 }
99105
=== modified file 'src/runtime/debug/debug_iterator_impl.cpp'
--- src/runtime/debug/debug_iterator_impl.cpp 2013-02-07 17:24:36 +0000
+++ src/runtime/debug/debug_iterator_impl.cpp 2013-04-30 17:01:29 +0000
@@ -205,25 +205,18 @@
205 if (lCommons->canBreak() && (lCommons->mustBreak(lCause) ||205 if (lCommons->canBreak() && (lCommons->mustBreak(lCause) ||
206 lCommons->hasToBreakAt(loc) || lCommons->hasToBreakAt(this)))206 lCommons->hasToBreakAt(loc) || lCommons->hasToBreakAt(this)))
207 {207 {
208 try208 lCause = lCause == 0 ? CAUSE_BREAKPOINT : lCause;
209 {209
210 lCause = lCause == 0 ? CAUSE_BREAKPOINT : lCause;210 // tell everybody that we are the iterator who suspended
211 211 //lCommons->setCurrentIterator(this);
212 // tell everybody that we are the iterator who suspended212 lCommons->setCurrentStaticContext(getStaticContext());
213 //lCommons->setCurrentIterator(this);213 lCommons->setCurrentDynamicContext(planState->theLocalDynCtx);
214 lCommons->setCurrentStaticContext(getStaticContext());214 lCommons->setBreak(false);
215 lCommons->setCurrentDynamicContext(planState->theLocalDynCtx);215 lCommons->setPlanState(planState);
216 lCommons->setBreak(false);
217 lCommons->setPlanState(planState);
218216
219 // suspend217 // suspend
220 lCommons->getRuntime()->suspendRuntime(loc, lCause);218 lCommons->getRuntime()->suspendRuntime(loc, lCause);
221 lCause = 0;219 lCause = 0;
222 }
223 catch (...)
224 {
225 throw;
226 }
227 }220 }
228}221}
229#endif // ZORBA_WITH_DEBUGGER222#endif // ZORBA_WITH_DEBUGGER
230223
=== modified file 'src/runtime/indexing/doc_indexer.cpp'
--- src/runtime/indexing/doc_indexer.cpp 2013-02-07 17:24:36 +0000
+++ src/runtime/indexing/doc_indexer.cpp 2013-04-30 17:01:29 +0000
@@ -150,9 +150,7 @@
150 }150 }
151 catch(...)151 catch(...)
152 {152 {
153 if (key != NULL)153 delete key;
154 delete key;
155
156 throw;154 throw;
157 }155 }
158 }156 }
159157
=== modified file 'src/store/naive/loader_dtd.cpp'
--- src/store/naive/loader_dtd.cpp 2013-04-16 21:12:12 +0000
+++ src/store/naive/loader_dtd.cpp 2013-04-30 17:01:29 +0000
@@ -196,7 +196,9 @@
196 if (theFragmentStream->ctxt == NULL)196 if (theFragmentStream->ctxt == NULL)
197 {197 {
198 theXQueryDiagnostics->add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR, ERROR_PARAMS( ZED( XMLParserInitFailed ) )));198 theXQueryDiagnostics->add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR, ERROR_PARAMS( ZED( XMLParserInitFailed ) )));
199 throw 0; // the argument to throw is not used by the catch clause199 abortload();
200 thePathStack.clear();
201 return NULL;
200 }202 }
201203
202 // Apply parser options204 // Apply parser options
@@ -210,7 +212,9 @@
210 if (input == NULL)212 if (input == NULL)
211 {213 {
212 theXQueryDiagnostics->add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR, ERROR_PARAMS( ZED( XMLParserInitFailed ) )));214 theXQueryDiagnostics->add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR, ERROR_PARAMS( ZED( XMLParserInitFailed ) )));
213 throw 0; // the argument to throw is not used by the catch clause215 abortload();
216 thePathStack.clear();
217 return NULL;
214 }218 }
215219
216 // Initialize the parser input (only filename and the pointer to the current char)220 // Initialize the parser input (only filename and the pointer to the current char)
@@ -253,7 +257,9 @@
253 NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR, ERROR_PARAMS( ZED( BadXMLNoOpeningTag ))) :257 NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR, ERROR_PARAMS( ZED( BadXMLNoOpeningTag ))) :
254 NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR, ERROR_PARAMS( ZED( BadXMLNoOpeningTag ), theDocUri))258 NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR, ERROR_PARAMS( ZED( BadXMLNoOpeningTag ), theDocUri))
255 );259 );
256 throw 0; // the argument to throw is not used by the catch clause260 abortload();
261 thePathStack.clear();
262 return NULL;
257 }263 }
258 264
259 // parse the DOCTYPE declaration, if any265 // parse the DOCTYPE declaration, if any
@@ -281,7 +287,9 @@
281 NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR, ERROR_PARAMS( ZED( ParseFragmentDoctypeNotAllowedHere ))) :287 NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR, ERROR_PARAMS( ZED( ParseFragmentDoctypeNotAllowedHere ))) :
282 NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR, ERROR_PARAMS( ZED( ParseFragmentDoctypeNotAllowedHere ), theDocUri))288 NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR, ERROR_PARAMS( ZED( ParseFragmentDoctypeNotAllowedHere ), theDocUri))
283 );289 );
284 throw 0; // the argument to throw is not used by the catch clause290 abortload();
291 thePathStack.clear();
292 return NULL;
285 }293 }
286 else // theLoadProperties.getErrorOnDoctype() == true294 else // theLoadProperties.getErrorOnDoctype() == true
287 {295 {
@@ -289,7 +297,9 @@
289 NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR, ERROR_PARAMS( ZED( ParseFragmentDoctypeNotAllowed ))) :297 NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR, ERROR_PARAMS( ZED( ParseFragmentDoctypeNotAllowed ))) :
290 NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR, ERROR_PARAMS( ZED( ParseFragmentDoctypeNotAllowed ), theDocUri))298 NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR, ERROR_PARAMS( ZED( ParseFragmentDoctypeNotAllowed ), theDocUri))
291 );299 );
292 throw 0; // the argument to throw is not used by the catch clause300 abortload();
301 thePathStack.clear();
302 return NULL;
293 }303 }
294 }304 }
295 }305 }
@@ -332,7 +342,9 @@
332 }342 }
333343
334 if ( ! theXQueryDiagnostics->errors().empty())344 if ( ! theXQueryDiagnostics->errors().empty())
335 throw 0; // the argument to throw is not used by the catch clause345 abortload();
346 thePathStack.clear();
347 return NULL;
336 }348 }
337349
338 // this happens when there are tags that have not been closed350 // this happens when there are tags that have not been closed
@@ -344,7 +356,9 @@
344 NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR, ERROR_PARAMS( ZED( BadXMLDocument_2o ))) :356 NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR, ERROR_PARAMS( ZED( BadXMLDocument_2o ))) :
345 NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR, ERROR_PARAMS( ZED( BadXMLDocument_2o ), theDocUri))357 NEW_ZORBA_EXCEPTION(zerr::ZSTR0021_LOADER_PARSING_ERROR, ERROR_PARAMS( ZED( BadXMLDocument_2o ), theDocUri))
346 );358 );
347 throw 0;359 abortload();
360 thePathStack.clear();
361 return NULL;
348 }362 }
349 363
350 // this happens when the input is an empty string364 // this happens when the input is an empty string
@@ -355,11 +369,24 @@
355369
356 FragmentXmlLoader::endDocument(theFragmentStream->ctxt->userData); // this would not be called otherwise370 FragmentXmlLoader::endDocument(theFragmentStream->ctxt->userData); // this would not be called otherwise
357 }371 }
372 catch( std::exception const &e )
373 {
374 theXQueryDiagnostics->
375 add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0020_LOADER_IO_ERROR,
376 ERROR_PARAMS( e.what() )));
377
378 abortload();
379 thePathStack.clear();
380 return NULL;
381 }
358 catch (...)382 catch (...)
359 {383 {
384 theXQueryDiagnostics->
385 add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0020_LOADER_IO_ERROR));
386
360 abortload();387 abortload();
361 thePathStack.clear();388 thePathStack.clear();
362 return NULL;389 throw;
363 }390 }
364391
365 // The doc may be well formed, but it may have other kinds of errors, e.g., unresolved ns prefixes.392 // The doc may be well formed, but it may have other kinds of errors, e.g., unresolved ns prefixes.
@@ -733,6 +760,14 @@
733 )760 )
734 );761 );
735 }762 }
763 catch (std::exception const &e)
764 {
765 theXQueryDiagnostics->add_error(
766 NEW_ZORBA_EXCEPTION(
767 zerr::ZSTR0020_LOADER_IO_ERROR, ERROR_PARAMS( e.what() )
768 )
769 );
770 }
736 catch (...)771 catch (...)
737 {772 {
738 theXQueryDiagnostics->add_error(773 theXQueryDiagnostics->add_error(
@@ -850,8 +885,19 @@
850 return NULL;885 return NULL;
851 }886 }
852 }887 }
888 catch( std::exception const &e )
889 {
890 theXQueryDiagnostics->
891 add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0020_LOADER_IO_ERROR, ERROR_PARAMS( e.what() )));
892
893 abortload();
894 return NULL;
895 }
853 catch(...)896 catch(...)
854 {897 {
898 theXQueryDiagnostics->
899 add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0020_LOADER_IO_ERROR));
900
855 abortload();901 abortload();
856 thePathStack.clear();902 thePathStack.clear();
857 return NULL;903 return NULL;
@@ -1071,6 +1117,14 @@
1071 {1117 {
1072 loader.theXQueryDiagnostics->add_error( e );1118 loader.theXQueryDiagnostics->add_error( e );
1073 }1119 }
1120 catch( std::exception const &e )
1121 {
1122 loader.theXQueryDiagnostics->add_error(
1123 NEW_ZORBA_EXCEPTION(
1124 zerr::ZXQP0003_INTERNAL_ERROR, ERROR_PARAMS( e.what() )
1125 )
1126 );
1127 }
1074 catch (...)1128 catch (...)
1075 {1129 {
1076 loader.theXQueryDiagnostics->add_error(1130 loader.theXQueryDiagnostics->add_error(
@@ -1153,6 +1207,14 @@
1153 {1207 {
1154 loader.theXQueryDiagnostics->add_error( e );1208 loader.theXQueryDiagnostics->add_error( e );
1155 }1209 }
1210 catch( std::exception const &e )
1211 {
1212 loader.theXQueryDiagnostics->add_error(
1213 NEW_ZORBA_EXCEPTION(
1214 zerr::ZXQP0003_INTERNAL_ERROR, ERROR_PARAMS( e.what() )
1215 )
1216 );
1217 }
1156 catch (...)1218 catch (...)
1157 {1219 {
1158 loader.theXQueryDiagnostics->add_error(1220 loader.theXQueryDiagnostics->add_error(
@@ -1447,6 +1509,14 @@
1447 {1509 {
1448 loader.theXQueryDiagnostics->add_error( e );1510 loader.theXQueryDiagnostics->add_error( e );
1449 }1511 }
1512 catch( std::exception const &e )
1513 {
1514 loader.theXQueryDiagnostics->add_error(
1515 NEW_ZORBA_EXCEPTION(
1516 zerr::ZXQP0003_INTERNAL_ERROR, ERROR_PARAMS( e.what() )
1517 )
1518 );
1519 }
1450 catch (...)1520 catch (...)
1451 {1521 {
1452 loader.theXQueryDiagnostics->1522 loader.theXQueryDiagnostics->
@@ -1579,6 +1649,14 @@
1579 {1649 {
1580 loader.theXQueryDiagnostics->add_error( e );1650 loader.theXQueryDiagnostics->add_error( e );
1581 }1651 }
1652 catch( std::exception const &e )
1653 {
1654 loader.theXQueryDiagnostics->add_error(
1655 NEW_ZORBA_EXCEPTION(
1656 zerr::ZXQP0003_INTERNAL_ERROR, ERROR_PARAMS( e.what() )
1657 )
1658 );
1659 }
1582 catch (...)1660 catch (...)
1583 {1661 {
1584 loader.theXQueryDiagnostics->add_error(1662 loader.theXQueryDiagnostics->add_error(
@@ -1630,6 +1708,14 @@
1630 {1708 {
1631 loader.theXQueryDiagnostics->add_error( e );1709 loader.theXQueryDiagnostics->add_error( e );
1632 }1710 }
1711 catch( std::exception const &e )
1712 {
1713 loader.theXQueryDiagnostics->add_error(
1714 NEW_ZORBA_EXCEPTION(
1715 zerr::ZXQP0003_INTERNAL_ERROR, ERROR_PARAMS( e.what() )
1716 )
1717 );
1718 }
1633 catch (...)1719 catch (...)
1634 {1720 {
1635 loader.theXQueryDiagnostics->add_error(1721 loader.theXQueryDiagnostics->add_error(
@@ -1683,6 +1769,14 @@
1683 {1769 {
1684 loader.theXQueryDiagnostics->add_error( e );1770 loader.theXQueryDiagnostics->add_error( e );
1685 }1771 }
1772 catch( std::exception const &e )
1773 {
1774 loader.theXQueryDiagnostics->add_error(
1775 NEW_ZORBA_EXCEPTION(
1776 zerr::ZXQP0003_INTERNAL_ERROR, ERROR_PARAMS( e.what() )
1777 )
1778 );
1779 }
1686 catch (...)1780 catch (...)
1687 {1781 {
1688 loader.theXQueryDiagnostics->add_error(1782 loader.theXQueryDiagnostics->add_error(
@@ -1733,6 +1827,14 @@
1733 {1827 {
1734 loader.theXQueryDiagnostics->add_error( e );1828 loader.theXQueryDiagnostics->add_error( e );
1735 }1829 }
1830 catch( std::exception const &e )
1831 {
1832 loader.theXQueryDiagnostics->add_error(
1833 NEW_ZORBA_EXCEPTION(
1834 zerr::ZXQP0003_INTERNAL_ERROR, ERROR_PARAMS( e.what() )
1835 )
1836 );
1837 }
1736 catch (...)1838 catch (...)
1737 {1839 {
1738 loader.theXQueryDiagnostics->add_error(1840 loader.theXQueryDiagnostics->add_error(
@@ -1776,6 +1878,14 @@
1776 {1878 {
1777 loader.theXQueryDiagnostics->add_error( e );1879 loader.theXQueryDiagnostics->add_error( e );
1778 }1880 }
1881 catch( std::exception const &e )
1882 {
1883 loader.theXQueryDiagnostics->add_error(
1884 NEW_ZORBA_EXCEPTION(
1885 zerr::ZXQP0003_INTERNAL_ERROR, ERROR_PARAMS( e.what() )
1886 )
1887 );
1888 }
1779 catch (...)1889 catch (...)
1780 {1890 {
1781 loader.theXQueryDiagnostics->add_error(1891 loader.theXQueryDiagnostics->add_error(
17821892
=== modified file 'src/store/naive/loader_fast.cpp'
--- src/store/naive/loader_fast.cpp 2013-04-08 22:59:58 +0000
+++ src/store/naive/loader_fast.cpp 2013-04-30 17:01:29 +0000
@@ -72,6 +72,25 @@
72 return; \72 return; \
73 } while (0);73 } while (0);
7474
75#define LOADER_TRY try
76
77#define LOADER_CATCH \
78 catch ( ZorbaException const &e ) { \
79 loader.theXQueryDiagnostics->add_error( e ); \
80 } \
81 catch ( std::exception const &e ) { \
82 loader.theXQueryDiagnostics->add_error( \
83 NEW_ZORBA_EXCEPTION( \
84 zerr::ZXQP0003_INTERNAL_ERROR, ERROR_PARAMS( e.what() ) \
85 ) \
86 ); \
87 } \
88 catch ( ... ) { \
89 loader.theXQueryDiagnostics->add_error( \
90 NEW_ZORBA_EXCEPTION( zerr::ZXQP0003_INTERNAL_ERROR ) \
91 ); \
92 }
93
7594
76/*******************************************************************************95/*******************************************************************************
7796
@@ -334,7 +353,8 @@
334353
335 return stream.gcount();354 return stream.gcount();
336 }355 }
337 catch (std::iostream::failure e)356 // catch-TODO: should ZorbaException be caught seperately here?
357 catch (std::exception const &e)
338 {358 {
339 theXQueryDiagnostics->add_error(359 theXQueryDiagnostics->add_error(
340 NEW_ZORBA_EXCEPTION(360 NEW_ZORBA_EXCEPTION(
@@ -445,7 +465,7 @@
445 if (numChars < 0)465 if (numChars < 0)
446 {466 {
447 theXQueryDiagnostics->467 theXQueryDiagnostics->
448 add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0020_LOADER_IO_ERROR));468 add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0020_LOADER_IO_ERROR));
449469
450 abortload();470 abortload();
451 return NULL;471 return NULL;
@@ -453,10 +473,22 @@
453473
454 xmlParseChunk(ctxt, theBuffer, 0, 1);474 xmlParseChunk(ctxt, theBuffer, 0, 1);
455 }475 }
476 catch( std::exception const &e )
477 {
478 theXQueryDiagnostics->
479 add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0020_LOADER_IO_ERROR,
480 ERROR_PARAMS( e.what() )));
481
482 abortload();
483 return NULL;
484 }
456 catch(...)485 catch(...)
457 {486 {
487 theXQueryDiagnostics->
488 add_error(NEW_ZORBA_EXCEPTION(zerr::ZSTR0020_LOADER_IO_ERROR));
489
458 abortload();490 abortload();
459 return NULL;491 throw;
460 }492 }
461493
462 bool ok = ctxt->wellFormed != 0;494 bool ok = ctxt->wellFormed != 0;
@@ -505,7 +537,7 @@
505 FastXmlLoader& loader = *(static_cast<FastXmlLoader *>(ctx));537 FastXmlLoader& loader = *(static_cast<FastXmlLoader *>(ctx));
506 ZORBA_LOADER_CHECK_ERROR(loader);538 ZORBA_LOADER_CHECK_ERROR(loader);
507 539
508 try540 LOADER_TRY
509 {541 {
510 DocumentNode* docNode = GET_STORE().getNodeFactory().createDocumentNode();542 DocumentNode* docNode = GET_STORE().getNodeFactory().createDocumentNode();
511543
@@ -530,15 +562,7 @@
530562
531 LOADER_TRACE1("Start Doc Node = " << docNode);563 LOADER_TRACE1("Start Doc Node = " << docNode);
532 }564 }
533 catch (ZorbaException const& e)565 LOADER_CATCH
534 {
535 loader.theXQueryDiagnostics->add_error( e );
536 }
537 catch (...)
538 {
539 loader.theXQueryDiagnostics->
540 add_error(NEW_ZORBA_EXCEPTION(zerr::ZXQP0003_INTERNAL_ERROR));
541 }
542}566}
543567
544568
@@ -561,7 +585,7 @@
561 DocumentNode* docNode;585 DocumentNode* docNode;
562 XmlNode* currChild;586 XmlNode* currChild;
563 587
564 try588 LOADER_TRY
565 {589 {
566 // This check is required because it is possible (in case of mal-formed doc)590 // This check is required because it is possible (in case of mal-formed doc)
567 // that libXml calls endDocument() without having called startDocument().591 // that libXml calls endDocument() without having called startDocument().
@@ -615,16 +639,7 @@
615639
616 LOADER_TRACE2("End Doc Node = " << docNode);640 LOADER_TRACE2("End Doc Node = " << docNode);
617 }641 }
618 catch (ZorbaException const& e)642 LOADER_CATCH
619 {
620 loader.theXQueryDiagnostics->add_error( e );
621 }
622 catch (...)
623 {
624 loader.theXQueryDiagnostics->add_error(
625 NEW_ZORBA_EXCEPTION( zerr::ZXQP0003_INTERNAL_ERROR )
626 );
627 }
628}643}
629644
630645
@@ -665,7 +680,7 @@
665 zorba::Stack<PathStepInfo>& pathStack = loader.thePathStack;680 zorba::Stack<PathStepInfo>& pathStack = loader.thePathStack;
666 zstring baseUri;681 zstring baseUri;
667682
668 try683 LOADER_TRY
669 {684 {
670 csize numAttributes = static_cast<csize>(numAttrs);685 csize numAttributes = static_cast<csize>(numAttrs);
671 csize numBindings = static_cast<csize>(numNamespaces);686 csize numBindings = static_cast<csize>(numNamespaces);
@@ -856,15 +871,7 @@
856 nodeStack.push(NULL);871 nodeStack.push(NULL);
857 pathStack.push(PathStepInfo(elemNode, baseUri));872 pathStack.push(PathStepInfo(elemNode, baseUri));
858 }873 }
859 catch (ZorbaException const& e)874 LOADER_CATCH
860 {
861 loader.theXQueryDiagnostics->add_error( e );
862 }
863 catch (...)
864 {
865 loader.theXQueryDiagnostics->
866 add_error(NEW_ZORBA_EXCEPTION(zerr::ZXQP0003_INTERNAL_ERROR));
867 }
868}875}
869876
870877
@@ -897,7 +904,7 @@
897 XmlNode* prevChild = NULL;904 XmlNode* prevChild = NULL;
898 XmlNode* currChild;905 XmlNode* currChild;
899906
900 try907 LOADER_TRY
901 {908 {
902 // Find the position of the 1st child of this element node in the node stack909 // Find the position of the 1st child of this element node in the node stack
903 firstChildPos = stackSize - 1;910 firstChildPos = stackSize - 1;
@@ -984,16 +991,7 @@
984 }991 }
985#endif992#endif
986 }993 }
987 catch (ZorbaException const& e)994 LOADER_CATCH
988 {
989 loader.theXQueryDiagnostics->add_error( e );
990 }
991 catch (...)
992 {
993 loader.theXQueryDiagnostics->add_error(
994 NEW_ZORBA_EXCEPTION( zerr::ZXQP0003_INTERNAL_ERROR )
995 );
996 }
997}995}
998996
999997
@@ -1009,7 +1007,7 @@
1009 FastXmlLoader& loader = *(static_cast<FastXmlLoader *>( ctx ));1007 FastXmlLoader& loader = *(static_cast<FastXmlLoader *>( ctx ));
1010 ZORBA_LOADER_CHECK_ERROR(loader);1008 ZORBA_LOADER_CHECK_ERROR(loader);
10111009
1012 try1010 LOADER_TRY
1013 {1011 {
1014 const char* charp = reinterpret_cast<const char*>(ch);1012 const char* charp = reinterpret_cast<const char*>(ch);
1015 zstring content(charp, len);1013 zstring content(charp, len);
@@ -1035,16 +1033,7 @@
1035 LOADER_TRACE2(lSs.str());1033 LOADER_TRACE2(lSs.str());
1036#endif1034#endif
1037 }1035 }
1038 catch (ZorbaException const& e)1036 LOADER_CATCH
1039 {
1040 loader.theXQueryDiagnostics->add_error( e );
1041 }
1042 catch (...)
1043 {
1044 loader.theXQueryDiagnostics->add_error(
1045 NEW_ZORBA_EXCEPTION( zerr::ZXQP0003_INTERNAL_ERROR )
1046 );
1047 }
1048}1037}
10491038
10501039
@@ -1060,7 +1049,7 @@
1060 FastXmlLoader& loader = *(static_cast<FastXmlLoader *>( ctx ));1049 FastXmlLoader& loader = *(static_cast<FastXmlLoader *>( ctx ));
1061 ZORBA_LOADER_CHECK_ERROR(loader);1050 ZORBA_LOADER_CHECK_ERROR(loader);
10621051
1063 try1052 LOADER_TRY
1064 {1053 {
1065 // If a doc contains an element like <cdata><![CDATA[ <> ]]></cdata>,1054 // If a doc contains an element like <cdata><![CDATA[ <> ]]></cdata>,
1066 // libxml returns the string " <> ".1055 // libxml returns the string " <> ".
@@ -1088,16 +1077,7 @@
1088 LOADER_TRACE2(lSs.str());1077 LOADER_TRACE2(lSs.str());
1089#endif1078#endif
1090 }1079 }
1091 catch (ZorbaException const& e)1080 LOADER_CATCH
1092 {
1093 loader.theXQueryDiagnostics->add_error( e );
1094 }
1095 catch (...)
1096 {
1097 loader.theXQueryDiagnostics->add_error(
1098 NEW_ZORBA_EXCEPTION( zerr::ZXQP0003_INTERNAL_ERROR )
1099 );
1100 }
1101}1081}
11021082
11031083
@@ -1115,7 +1095,7 @@
1115 FastXmlLoader& loader = *(static_cast<FastXmlLoader *>( ctx ));1095 FastXmlLoader& loader = *(static_cast<FastXmlLoader *>( ctx ));
1116 ZORBA_LOADER_CHECK_ERROR(loader);1096 ZORBA_LOADER_CHECK_ERROR(loader);
11171097
1118 try1098 LOADER_TRY
1119 {1099 {
1120 // bugfix: handling PIs with no data (i.e. data being NULL)1100 // bugfix: handling PIs with no data (i.e. data being NULL)
1121 zstring content;1101 zstring content;
@@ -1138,16 +1118,7 @@
1138 << targetp << std::endl << " ordpath = "1118 << targetp << std::endl << " ordpath = "
1139 << piNode->getOrdPath().show() << std::endl);1119 << piNode->getOrdPath().show() << std::endl);
1140 }1120 }
1141 catch (ZorbaException const& e)1121 LOADER_CATCH
1142 {
1143 loader.theXQueryDiagnostics->add_error( e );
1144 }
1145 catch (...)
1146 {
1147 loader.theXQueryDiagnostics->add_error(
1148 NEW_ZORBA_EXCEPTION( zerr::ZXQP0003_INTERNAL_ERROR )
1149 );
1150 }
1151}1122}
11521123
11531124
@@ -1162,7 +1133,7 @@
1162 FastXmlLoader& loader = *(static_cast<FastXmlLoader *>( ctx ));1133 FastXmlLoader& loader = *(static_cast<FastXmlLoader *>( ctx ));
1163 ZORBA_LOADER_CHECK_ERROR(loader);1134 ZORBA_LOADER_CHECK_ERROR(loader);
11641135
1165 try1136 LOADER_TRY
1166 {1137 {
1167 const char* charp = reinterpret_cast<const char*>(ch);1138 const char* charp = reinterpret_cast<const char*>(ch);
1168 zstring content;1139 zstring content;
@@ -1183,16 +1154,7 @@
1183 << charp << std::endl << " ordpath = "1154 << charp << std::endl << " ordpath = "
1184 << commentNode->getOrdPath().show() << std::endl);1155 << commentNode->getOrdPath().show() << std::endl);
1185 }1156 }
1186 catch (ZorbaException const& e)1157 LOADER_CATCH
1187 {
1188 loader.theXQueryDiagnostics->add_error( e );
1189 }
1190 catch (...)
1191 {
1192 loader.theXQueryDiagnostics->add_error(
1193 NEW_ZORBA_EXCEPTION( zerr::ZXQP0003_INTERNAL_ERROR )
1194 );
1195 }
1196}1158}
11971159
11981160
11991161
=== modified file 'src/store/naive/node_items.cpp'
--- src/store/naive/node_items.cpp 2013-04-17 12:37:36 +0000
+++ src/store/naive/node_items.cpp 2013-04-30 17:01:29 +0000
@@ -763,26 +763,19 @@
763 if (theParent == NULL)763 if (theParent == NULL)
764 return false;764 return false;
765765
766 try766 if (getNodeKind() == store::StoreConsts::attributeNode)
767 {767 {
768 if (getNodeKind() == store::StoreConsts::attributeNode)768 csize numAttrs = theParent->numAttrs();
769 {769 pos = theParent->removeAttr(this);
770 csize numAttrs = theParent->numAttrs();770 ZORBA_FATAL(pos <= numAttrs, "");
771 pos = theParent->removeAttr(this);771 return (pos < numAttrs);
772 ZORBA_FATAL(pos <= numAttrs, "");
773 return (pos < numAttrs);
774 }
775 else
776 {
777 csize numChildren = theParent->numChildren();
778 pos = theParent->removeChild(this);
779 ZORBA_FATAL(pos <= numChildren, "");
780 return (pos < numChildren);
781 }
782 }772 }
783 catch(...)773 else
784 {774 {
785 ZORBA_FATAL(false, "Unexpected exception");775 csize numChildren = theParent->numChildren();
776 pos = theParent->removeChild(this);
777 ZORBA_FATAL(pos <= numChildren, "");
778 return (pos < numChildren);
786 }779 }
787}780}
788781
@@ -857,17 +850,10 @@
857********************************************************************************/850********************************************************************************/
858void XmlNode::destroy(bool removeType)851void XmlNode::destroy(bool removeType)
859{852{
860 try853 csize pos;
861 {854 disconnect(pos);
862 csize pos;
863 disconnect(pos);
864855
865 destroyInternal(removeType);856 destroyInternal(removeType);
866 }
867 catch (...)
868 {
869 ZORBA_FATAL(false, "Unexpected exception");
870 }
871}857}
872858
873859
874860
=== modified file 'src/store/naive/node_updates.cpp'
--- src/store/naive/node_updates.cpp 2013-02-07 17:24:36 +0000
+++ src/store/naive/node_updates.cpp 2013-04-30 17:01:29 +0000
@@ -328,200 +328,193 @@
328********************************************************************************/328********************************************************************************/
329void XmlNode::detach()329void XmlNode::detach()
330{330{
331 try331 ZORBA_ASSERT(theParent != NULL);
332 {332
333 ZORBA_ASSERT(theParent != NULL);333 ulong refcount = 0;
334334
335 ulong refcount = 0;335 XmlTree* oldTree = getTree();
336336 XmlTree* newTree = GET_STORE().getNodeFactory().createXmlTree();
337 XmlTree* oldTree = getTree();337 newTree->setRoot(this);
338 XmlTree* newTree = GET_STORE().getNodeFactory().createXmlTree();338
339 newTree->setRoot(this);339 if (oldTree->getRoot() == this)
340340 oldTree->setRoot(NULL);
341 if (oldTree->getRoot() == this)341
342 oldTree->setRoot(NULL);342 store::StoreConsts::NodeKind nodeKind = getNodeKind();
343343
344 store::StoreConsts::NodeKind nodeKind = getNodeKind();344 // ???? What we do here is not really thread-safe. For example, consider the
345345 // following scenario: Let T1 be "this" thread and T2 be another thread that
346 // ???? What we do here is not really thread-safe. For example, consider the346 // has an rchandle, rc2, on N. Right after T1 acquires the rclock on the old
347 // following scenario: Let T1 be "this" thread and T2 be another thread that347 // tree, T2 tries to make a copy of rc2; as a result, T2 will block on the
348 // has an rchandle, rc2, on N. Right after T1 acquires the rclock on the old348 // old tree rclock. When T1 releases the old rclock, the old tree may be
349 // tree, T2 tries to make a copy of rc2; as a result, T2 will block on the349 // destroyed already, so T2 will be trying to acquire a deallocated lock.
350 // old tree rclock. When T1 releases the old rclock, the old tree may be350 // Even if the old tree is there, T2 will increment the ref counter of the
351 // destroyed already, so T2 will be trying to acquire a deallocated lock. 351 // new tree while holding the lock of the old tree. In fact, the setTree()
352 // Even if the old tree is there, T2 will increment the ref counter of the352 // method istself is not safe (if T2 tries to copy rc2 after T1 has returned
353 // new tree while holding the lock of the old tree. In fact, the setTree()353 // from setTree(), then things are ok).
354 // method istself is not safe (if T2 tries to copy rc2 after T1 has returned354 SYNC_CODE(oldTree->getRCLock()->acquire());
355 // from setTree(), then things are ok).355 SYNC_CODE(newTree->getRCLock()->acquire());
356 SYNC_CODE(oldTree->getRCLock()->acquire());356
357 SYNC_CODE(newTree->getRCLock()->acquire());357 refcount += theRefCount;
358358
359 refcount += theRefCount;359 switch (nodeKind)
360360 {
361 switch (nodeKind)361 case store::StoreConsts::attributeNode:
362 {362 {
363 case store::StoreConsts::attributeNode:363 setTree(newTree);
364 {364 theParent->removeAttr(this);
365 setTree(newTree);365 theParent = NULL;
366 theParent->removeAttr(this);366 break;
367 theParent = NULL;367 }
368 break;368 case store::StoreConsts::piNode:
369 }369 case store::StoreConsts::commentNode:
370 case store::StoreConsts::piNode:370 {
371 case store::StoreConsts::commentNode:371 setTree(newTree);
372 {372 theParent->removeChild(this);
373 setTree(newTree);373 theParent = NULL;
374 theParent->removeChild(this);374 break;
375 theParent = NULL;375 }
376 break;376 case store::StoreConsts::textNode:
377 }377 {
378 case store::StoreConsts::textNode:378 setTree(newTree);
379 {379
380 setTree(newTree);380 reinterpret_cast<TextNode*>(this)->revertToTextContent();
381381
382 reinterpret_cast<TextNode*>(this)->revertToTextContent();382 theParent->removeChild(this);
383383 theParent = NULL;
384 theParent->removeChild(this);384 break;
385 theParent = NULL;385 }
386 break;386 case store::StoreConsts::elementNode:
387 }387 {
388 case store::StoreConsts::elementNode:388 ElementNode* rootNode = reinterpret_cast<ElementNode*>(this);
389 {389
390 ElementNode* rootNode = reinterpret_cast<ElementNode*>(this);390 // If the baseUri property of N is inherited from its ancestors, make a
391391 // local copy of it, before disconnecting N from its parent.
392 // If the baseUri property of N is inherited from its ancestors, make a392 bool localBaseUri;
393 // local copy of it, before disconnecting N from its parent.393 zstring baseUri;
394 bool localBaseUri;394 getBaseURIInternal(baseUri, localBaseUri);
395 zstring baseUri;395 if (!localBaseUri && !baseUri.empty())
396 getBaseURIInternal(baseUri, localBaseUri);396 {
397 if (!localBaseUri && !baseUri.empty())397 zstring dummyUri;
398 {398 rootNode->addBaseUriProperty(baseUri, dummyUri);
399 zstring dummyUri;399 }
400 rootNode->addBaseUriProperty(baseUri, dummyUri);400
401 }401 // For each node in the nodes stack, we must save the nsCtx of its
402402 // parent node in the parentNsCtxs stack, because the nsCtx of the
403 // For each node in the nodes stack, we must save the nsCtx of its403 // parent may change during the while loop below.
404 // parent node in the parentNsCtxs stack, because the nsCtx of the404 std::stack<XmlNode*> nodes;
405 // parent may change during the while loop below.405 std::stack<NsBindingsContext*> parentNsCtxs;
406 std::stack<XmlNode*> nodes;406
407 std::stack<NsBindingsContext*> parentNsCtxs;407 nodes.push(this);
408408 parentNsCtxs.push(rootNode->theParent->getNsContext());
409 nodes.push(this);409
410 parentNsCtxs.push(rootNode->theParent->getNsContext());410 while (!nodes.empty())
411411 {
412 while (!nodes.empty())412 XmlNode* node = nodes.top();
413 {413 nodes.pop();
414 XmlNode* node = nodes.top();414
415 nodes.pop();415 if (node->getNodeKind() == store::StoreConsts::elementNode)
416416 {
417 if (node->getNodeKind() == store::StoreConsts::elementNode)417 ElementNode* elemNode = reinterpret_cast<ElementNode*>(node);
418
419 node->setTree(newTree);
420
421 // Preserve the namespace bindings of the current node
422 NsBindingsContext* nsContext = elemNode->getNsContext();
423 NsBindingsContext* parentNsContext = parentNsCtxs.top();
424 parentNsCtxs.pop();
425
426 // If the current node is N, or a node in NT that does not inherit ns
427 // bindings directly from its parent (but may inherit from some other
428 // ancestor).
429 if (elemNode == rootNode ||
430 nsContext == NULL ||
431 (elemNode->haveLocalBindings() &&
432 nsContext->getParent() != parentNsContext) ||
433 nsContext != parentNsContext)
418 {434 {
419 ElementNode* elemNode = reinterpret_cast<ElementNode*>(node);435 if (nsContext != NULL)
420
421 node->setTree(newTree);
422
423 // Preserve the namespace bindings of the current node
424 NsBindingsContext* nsContext = elemNode->getNsContext();
425 NsBindingsContext* parentNsContext = parentNsCtxs.top();
426 parentNsCtxs.pop();
427
428 // If the current node is N, or a node in NT that does not inherit ns
429 // bindings directly from its parent (but may inherit from some other
430 // ancestor).
431 if (elemNode == rootNode ||
432 nsContext == NULL ||
433 (elemNode->haveLocalBindings() &&
434 nsContext->getParent() != parentNsContext) ||
435 nsContext != parentNsContext)
436 {436 {
437 if (nsContext != NULL)437 std::auto_ptr<NsBindingsContext> ctx(new NsBindingsContext());
438 elemNode->getNamespaceBindings(ctx->getBindings());
439
440 if (!ctx->empty())
438 {441 {
439 std::auto_ptr<NsBindingsContext> ctx(new NsBindingsContext());442 elemNode->theNsContext = ctx.release();
440 elemNode->getNamespaceBindings(ctx->getBindings());443 elemNode->theFlags |= HaveLocalBindings;
441
442 if (!ctx->empty())
443 {
444 elemNode->theNsContext = ctx.release();
445 elemNode->theFlags |= HaveLocalBindings;
446 }
447 }444 }
448 }445 }
449
450 // Else the current node is not N and it inherits ns bindings directly
451 // from its parent.
452 else
453 {
454 elemNode->setNsContext(elemNode->theParent->getNsContext());
455 }
456
457 // Detach the attributes of the current node
458 InternalNode::iterator ite = elemNode->attrsBegin();
459 InternalNode::iterator end = elemNode->attrsEnd();
460
461 for (; ite != end; ++ite)
462 {
463 AttributeNode* attrNode = static_cast<AttributeNode*>(*ite);
464 refcount += attrNode->theRefCount;
465 attrNode->setTree(newTree);
466 }
467
468 // Detach the children of the current node
469 ite = elemNode->childrenBegin();
470 end = elemNode->childrenEnd();
471
472 for (; ite != end; ++ite)
473 {
474 XmlNode* child = (*ite);
475 refcount += child->theRefCount;
476
477 nodes.push(child);
478
479 if (child->getNodeKind() == store::StoreConsts::elementNode)
480 parentNsCtxs.push(nsContext);
481 }
482 }446 }
447
448 // Else the current node is not N and it inherits ns bindings directly
449 // from its parent.
483 else450 else
484 {451 {
485 node->setTree(newTree);452 elemNode->setNsContext(elemNode->theParent->getNsContext());
486 }453 }
487 } // done traversing tree454
488455 // Detach the attributes of the current node
489 theParent->removeChild(this);456 InternalNode::iterator ite = elemNode->attrsBegin();
490 theParent = NULL;457 InternalNode::iterator end = elemNode->attrsEnd();
491458
492 break;459 for (; ite != end; ++ite)
493 }460 {
494 default:461 AttributeNode* attrNode = static_cast<AttributeNode*>(*ite);
495 {462 refcount += attrNode->theRefCount;
496 ZORBA_ASSERT(false);463 attrNode->setTree(newTree);
497 }464 }
498 }465
499466 // Detach the children of the current node
500 newTree->getRefCount() += refcount;467 ite = elemNode->childrenBegin();
501 if (newTree->getRefCount() == 0)468 end = elemNode->childrenEnd();
502 {469
503 SYNC_CODE(newTree->getRCLock()->release());470 for (; ite != end; ++ite)
504 newTree->free();471 {
505 }472 XmlNode* child = (*ite);
506 else473 refcount += child->theRefCount;
507 {474
508 SYNC_CODE(newTree->getRCLock()->release());475 nodes.push(child);
509 }476
510477 if (child->getNodeKind() == store::StoreConsts::elementNode)
511 oldTree->getRefCount() -= refcount;478 parentNsCtxs.push(nsContext);
512 if (oldTree->getRefCount() == 0)479 }
513 {480 }
514 SYNC_CODE(oldTree->getRCLock()->release());481 else
515 oldTree->free();482 {
516 }483 node->setTree(newTree);
517 else484 }
518 {485 } // done traversing tree
519 SYNC_CODE(oldTree->getRCLock()->release());486
520 }487 theParent->removeChild(this);
521 }488 theParent = NULL;
522 catch(...)489
523 {490 break;
524 ZORBA_FATAL(0, "Unexpected exception");491 }
492 default:
493 {
494 ZORBA_ASSERT(false);
495 }
496 }
497
498 newTree->getRefCount() += refcount;
499 if (newTree->getRefCount() == 0)
500 {
501 SYNC_CODE(newTree->getRCLock()->release());
502 newTree->free();
503 }
504 else
505 {
506 SYNC_CODE(newTree->getRCLock()->release());
507 }
508
509 oldTree->getRefCount() -= refcount;
510 if (oldTree->getRefCount() == 0)
511 {
512 SYNC_CODE(oldTree->getRCLock()->release());
513 oldTree->free();
514 }
515 else
516 {
517 SYNC_CODE(oldTree->getRCLock()->release());
525 }518 }
526}519}
527520
528521
=== modified file 'src/store/naive/pul_primitives.cpp'
--- src/store/naive/pul_primitives.cpp 2013-02-26 04:12:43 +0000
+++ src/store/naive/pul_primitives.cpp 2013-04-30 17:01:29 +0000
@@ -744,9 +744,13 @@
744 {744 {
745 theRevalidationPul->applyUpdates(false);745 theRevalidationPul->applyUpdates(false);
746 }746 }
747 catch (std::exception const &e)
748 {
749 ZORBA_FATAL(false, "Error during the in-place validation: " << e.what());
750 }
747 catch (...)751 catch (...)
748 {752 {
749 ZORBA_FATAL(0, "Error during the in-place validation");753 ZORBA_FATAL(false, "Error during the in-place validation");
750 }754 }
751755
752 theIsApplied = true;756 theIsApplied = true;
753757
=== modified file 'src/store/naive/store.cpp'
--- src/store/naive/store.cpp 2013-03-20 18:39:54 +0000
+++ src/store/naive/store.cpp 2013-04-30 17:01:29 +0000
@@ -575,9 +575,7 @@
575 }575 }
576 catch(...)576 catch(...)
577 {577 {
578 if (key != NULL)578 delete key;
579 delete key;
580
581 sourceIter->close();579 sourceIter->close();
582 throw;580 throw;
583 }581 }
@@ -1051,6 +1049,7 @@
1051 catch(...)1049 catch(...)
1052 {1050 {
1053 delete stream;1051 delete stream;
1052 // catch-TODO: "throw;" here?
1054 }1053 }
1055 return docitem;1054 return docitem;
1056}1055}
10571056
=== modified file 'src/types/schema/schema.cpp'
--- src/types/schema/schema.cpp 2013-04-16 21:12:12 +0000
+++ src/types/schema/schema.cpp 2013-04-30 17:01:29 +0000
@@ -1785,18 +1785,6 @@
1785 targetType->toSchemaString(),1785 targetType->toSchemaString(),
1786 msg));1786 msg));
1787 }1787 }
1788 catch(const OutOfMemoryException&)
1789 {
1790 throw;
1791 }
1792 catch (const ZorbaException&)
1793 {
1794 throw;
1795 }
1796 catch (...)
1797 {
1798 throw;
1799 }
1800#endif //ZORBA_NO_XMLSCHEMA1788#endif //ZORBA_NO_XMLSCHEMA
18011789
1802 // find the non user defined base type1790 // find the non user defined base type
@@ -2093,15 +2081,9 @@
2093 BinMemOutputStream binmemoutputstream;2081 BinMemOutputStream binmemoutputstream;
2094 zstring binstr;2082 zstring binstr;
20952083
2096 try2084 theGrammarPool->serializeGrammars(&binmemoutputstream);
2097 {2085 binstr.assign((char*)binmemoutputstream.getRawBuffer(),
2098 theGrammarPool->serializeGrammars(&binmemoutputstream);2086 static_cast<zstring::size_type>(binmemoutputstream.getSize()) );
2099 binstr.assign((char*)binmemoutputstream.getRawBuffer(),
2100 static_cast<zstring::size_type>(binmemoutputstream.getSize()) );
2101 }
2102 catch (...)
2103 {
2104 }
21052087
2106 ar & binstr;2088 ar & binstr;
2107 }2089 }

Subscribers

People subscribed via source and target branches