From 2b40f8d7fb2bb03decb37f31bfbae90bb7d9a69f Mon Sep 17 00:00:00 2001 From: Frank Celler Date: Wed, 4 Apr 2012 11:15:41 +0200 Subject: [PATCH] merged --- .gitignore | 1 + Admin/RestBaseHandler.cpp | 3 +- BasicsC/error.c | 5 +- BasicsC/error.h | 2 +- BasicsC/process-utils.c | 3 + BasicsC/vector.c | 4 - BasicsC/voc-errors.c | 3 + BasicsC/voc-errors.h | 38 +++++++++ Doxygen/Scripts/avocadodb_footer.html | 2 +- Doxygen/Scripts/avocadodb_header.html | 2 +- Makefile.am | 1 + Makefile.doxygen | 13 ++-- Makefile.files | 95 +++++++++++------------ Makefile.in | 107 +++++++++++++------------- QL/ast-query.c | 2 +- QL/formatter.c | 10 +-- QL/formatter.h | 4 +- V8/v8-actions.cpp | 2 +- V8/v8-vocbase.cpp | 32 +++++--- VocBase/query-execute.c | 6 +- js/common/bootstrap/errors.js | 3 + js/common/bootstrap/js-errors.h | 3 + 22 files changed, 201 insertions(+), 140 deletions(-) diff --git a/.gitignore b/.gitignore index 3cd7fe70a4..c0399f43c4 100644 --- a/.gitignore +++ b/.gitignore @@ -72,3 +72,4 @@ UnitTests/test_suite .v8-build VC++ UnitTests/HttpInterface/logs +Makefile.local diff --git a/Admin/RestBaseHandler.cpp b/Admin/RestBaseHandler.cpp index f0b4be83ef..d22e7ed642 100644 --- a/Admin/RestBaseHandler.cpp +++ b/Admin/RestBaseHandler.cpp @@ -187,7 +187,8 @@ void RestBaseHandler::generateResult (VariantObject* result) { //////////////////////////////////////////////////////////////////////////////// void RestBaseHandler::generateError (HttpResponse::HttpResponseCode code, int errorCode) { - char* message = TRI_get_errno_string(errorCode); + char const* message = TRI_errno_string(errorCode); + if (message) { generateError(code, errorCode, string(message)); } diff --git a/BasicsC/error.c b/BasicsC/error.c index 231ff2f33a..7a80672c11 100644 --- a/BasicsC/error.c +++ b/BasicsC/error.c @@ -318,11 +318,12 @@ void TRI_set_errno_string (int error, char const* msg) { /// @brief return an error message for an error code //////////////////////////////////////////////////////////////////////////////// -char* TRI_get_errno_string (const int error) { +char const* TRI_errno_string (int error) { TRI_error_t* entry; entry = (TRI_error_t*) TRI_LookupByKeyAssociativePointer(&ErrorMessages, (void const*) &error); - if (!entry) { + + if (entry == NULL) { return NULL; } diff --git a/BasicsC/error.h b/BasicsC/error.h index 217c597c81..cc9b0c2285 100644 --- a/BasicsC/error.h +++ b/BasicsC/error.h @@ -96,7 +96,7 @@ void TRI_set_errno_string (int, char const*); /// @brief return an error message for an error code //////////////////////////////////////////////////////////////////////////////// -char* TRI_get_errno_string (const int); +char const* TRI_errno_string (int); //////////////////////////////////////////////////////////////////////////////// /// @} diff --git a/BasicsC/process-utils.c b/BasicsC/process-utils.c index b1b188f2d9..8c6aa2254c 100644 --- a/BasicsC/process-utils.c +++ b/BasicsC/process-utils.c @@ -152,9 +152,12 @@ TRI_process_info_t TRI_ProcessInfo (TRI_pid_t pid) { n = read(fd, str, 1024); close(fd); + // size_t is always >= 0, comparison will never be false + /* if (n < 0) { return result; } + */ sscanf(str, "%d %s %c %d %d %d %d %d %u %lu %lu %lu %lu %lu %lu %lu %ld %ld %ld %ld %ld %llu %lu %ld", &st.pid, (char*) &st.comm, &st.state, &st.ppid, &st.pgrp, &st.session, &st.tty_nr, &st.tpgid, diff --git a/BasicsC/vector.c b/BasicsC/vector.c index eff452edfa..7b71421df8 100644 --- a/BasicsC/vector.c +++ b/BasicsC/vector.c @@ -396,8 +396,6 @@ void TRI_ClearVectorPointer (TRI_vector_pointer_t* vector) { //////////////////////////////////////////////////////////////////////////////// void TRI_ResizeVectorPointer (TRI_vector_pointer_t* vector, size_t n) { - assert(n >= 0); - if (vector->_length == n) { return; } @@ -456,8 +454,6 @@ void TRI_PushBackVectorPointer (TRI_vector_pointer_t* vector, void* element) { //////////////////////////////////////////////////////////////////////////////// void TRI_InsertVectorPointer (TRI_vector_pointer_t* vector, void* element, size_t n) { - assert(n >= 0); - if (vector->_length >= vector->_capacity) { void* newBuffer; size_t newSize = (size_t) (1 + GROW_FACTOR * vector->_capacity); diff --git a/BasicsC/voc-errors.c b/BasicsC/voc-errors.c index 0684ec88e2..3ecb865154 100644 --- a/BasicsC/voc-errors.c +++ b/BasicsC/voc-errors.c @@ -21,6 +21,7 @@ void TRI_InitialiseErrorMessages (void) { REG_ERROR(ERROR_ILLEGAL_OPTION, "illegal option"); REG_ERROR(ERROR_DEAD_PID, "dead process identifier"); REG_ERROR(ERROR_NOT_IMPLEMENTED, "not implemented"); + REG_ERROR(ERROR_BAD_PARAMETER, "bad parameter"); REG_ERROR(ERROR_HTTP_BAD_PARAMETER, "bad parameter"); REG_ERROR(ERROR_HTTP_NOT_FOUND, "not found"); REG_ERROR(ERROR_HTTP_METHOD_NOT_ALLOWED, "method not supported"); @@ -55,6 +56,7 @@ void TRI_InitialiseErrorMessages (void) { REG_ERROR(ERROR_AVOCADO_UNIQUE_CONSTRAINT_VIOLATED, "unique constraint violated"); REG_ERROR(ERROR_AVOCADO_GEO_INDEX_VIOLATED, "geo index violated"); REG_ERROR(ERROR_AVOCADO_INDEX_NOT_FOUND, "index not found"); + REG_ERROR(ERROR_AVOCADO_CROSS_COLLECTION_REQUEST, "cross collection request not allowed"); REG_ERROR(ERROR_AVOCADO_DATAFILE_FULL, "datafile full"); REG_ERROR(ERROR_QUERY_KILLED, "query killed"); REG_ERROR(ERROR_QUERY_PARSE, "parse error: %s"); @@ -104,6 +106,7 @@ void TRI_InitialiseErrorMessages (void) { REG_ERROR(SIMPLE_CLIENT_COULD_NOT_CONNECT, "could not connect to server"); REG_ERROR(SIMPLE_CLIENT_COULD_NOT_WRITE, "could not write to server"); REG_ERROR(SIMPLE_CLIENT_COULD_NOT_READ, "could not read from server"); + REG_ERROR(ERROR_AVOCADO_INDEX_PQ_INSERT_FAILED, "priority queue insert failure"); } //////////////////////////////////////////////////////////////////////////////// diff --git a/BasicsC/voc-errors.h b/BasicsC/voc-errors.h index 33576f1fdd..4d7ab3195c 100644 --- a/BasicsC/voc-errors.h +++ b/BasicsC/voc-errors.h @@ -31,6 +31,8 @@ extern "C" { /// Will be raised when a PID without a living process was found. /// - 9: @CODE{not implemented} /// Will be raised when hitting an unimplemented feature. +/// - 10: @CODE{bad parameter} +/// Will be raised when the parameter does not fulfill the requirements. /// - 400: @CODE{bad parameter} /// Will be raised when the HTTP request does not fulfill the requirements. /// - 404: @CODE{not found} @@ -109,6 +111,8 @@ extern "C" { /// Will be raised when a illegale coordinate is used. /// - 1212: @CODE{index not found} /// Will be raised when an index with a given identifier is unknown. +/// - 1213: @CODE{cross collection request not allowed} +/// Will be raised when a cross-collection is requested. /// - 1300: @CODE{datafile full} /// Will be raised when the datafile reaches its limit. /// - 1500: @CODE{query killed} @@ -225,6 +229,9 @@ extern "C" { /// Will be raised when the client could not write data. /// - 2003: @CODE{could not read from server} /// Will be raised when the client could not read data. +/// - 3100: @CODE{priority queue insert failure} +/// Will be raised when an attempt to insert a document into a priority queue +/// index fails for some reason. //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// @@ -344,6 +351,16 @@ void TRI_InitialiseErrorMessages (void); #define TRI_ERROR_NOT_IMPLEMENTED (9) +//////////////////////////////////////////////////////////////////////////////// +/// @brief 10: ERROR_BAD_PARAMETER +/// +/// bad parameter +/// +/// Will be raised when the parameter does not fulfill the requirements. +//////////////////////////////////////////////////////////////////////////////// + +#define TRI_ERROR_BAD_PARAMETER (10) + //////////////////////////////////////////////////////////////////////////////// /// @brief 400: ERROR_HTTP_BAD_PARAMETER /// @@ -691,6 +708,16 @@ void TRI_InitialiseErrorMessages (void); #define TRI_ERROR_AVOCADO_INDEX_NOT_FOUND (1212) +//////////////////////////////////////////////////////////////////////////////// +/// @brief 1213: ERROR_AVOCADO_CROSS_COLLECTION_REQUEST +/// +/// cross collection request not allowed +/// +/// Will be raised when a cross-collection is requested. +//////////////////////////////////////////////////////////////////////////////// + +#define TRI_ERROR_AVOCADO_CROSS_COLLECTION_REQUEST (1213) + //////////////////////////////////////////////////////////////////////////////// /// @brief 1300: ERROR_AVOCADO_DATAFILE_FULL /// @@ -1196,6 +1223,17 @@ void TRI_InitialiseErrorMessages (void); #define TRI_SIMPLE_CLIENT_COULD_NOT_READ (2003) +//////////////////////////////////////////////////////////////////////////////// +/// @brief 3100: ERROR_AVOCADO_INDEX_PQ_INSERT_FAILED +/// +/// priority queue insert failure +/// +/// Will be raised when an attempt to insert a document into a priority queue +/// index fails for some reason. +//////////////////////////////////////////////////////////////////////////////// + +#define TRI_ERROR_AVOCADO_INDEX_PQ_INSERT_FAILED (3100) + //////////////////////////////////////////////////////////////////////////////// /// @} diff --git a/Doxygen/Scripts/avocadodb_footer.html b/Doxygen/Scripts/avocadodb_footer.html index 1c7ca2c95c..34d09d29c9 100644 --- a/Doxygen/Scripts/avocadodb_footer.html +++ b/Doxygen/Scripts/avocadodb_footer.html @@ -1 +1 @@ - + \ No newline at end of file diff --git a/Doxygen/Scripts/avocadodb_header.html b/Doxygen/Scripts/avocadodb_header.html index 962fe8b585..147c191d76 100644 --- a/Doxygen/Scripts/avocadodb_header.html +++ b/Doxygen/Scripts/avocadodb_header.html @@ -1 +1 @@ - + diff --git a/Makefile.am b/Makefile.am index 1645dc541c..d6d016aa62 100644 --- a/Makefile.am +++ b/Makefile.am @@ -66,6 +66,7 @@ include Makefile.files include Makefile.doxygen include Makefile.javascript include Makefile.unittests +-include Makefile.local if ENABLE_FLEX include Makefile.flex diff --git a/Makefile.doxygen b/Makefile.doxygen index 892a9c5b7e..d65f038846 100644 --- a/Makefile.doxygen +++ b/Makefile.doxygen @@ -53,15 +53,16 @@ doxygen: Doxygen/avocado.doxy $(DOXYGEN) .PHONY: wiki -wiki: doxygen $(addprefix Doxygen/xml/,$(WIKI)) +wiki: doxygen $(addsuffix .md,$(addprefix Doxygen/xml/,$(WIKI))) @test -d Doxygen/wiki || mkdir Doxygen/wiki - @for w in $(WIKI); do @top_srcdir@/Doxygen/Scripts/pandoc.sh Doxygen/xml/$$w; done - @for w in $(WIKI); do @top_srcdir@/Doxygen/Scripts/md2html.sh Doxygen/wiki/$$w; done + @for w in $(WIKI); do @top_srcdir@/Doxygen/Scripts/pandoc.sh Doxygen/xml/$$w.md; done + @for w in $(WIKI); do @top_srcdir@/Doxygen/Scripts/md2html.sh Doxygen/wiki/$$w.md; done ################################################################################ ## CLEANUP ################################################################################ -CLEANUP += $(DOXYGEN) $(addprefix Doxygen/xml/,$(WIKI)) $(addprefix Doxygen/wiki/,$(WIKI)) - - +CLEANUP += \ + $(DOXYGEN) \ + $(addsuffix .md,$(addprefix Doxygen/xml/,$(WIKI))) \ + $(addsuffix .md,$(addprefix Doxygen/wiki/,$(WIKI))) diff --git a/Makefile.files b/Makefile.files index e534a26353..0e981165b1 100644 --- a/Makefile.files +++ b/Makefile.files @@ -291,51 +291,50 @@ DOXYGEN = \ ################################################################################ WIKI = \ - AQLBasics.md \ - Actions.md \ - AvocadoErrors.md \ - AvocadoScript.md \ - CommandLine.md \ - CommandLineAvocado.md \ - CommandLineLogging.md \ - CommandLineRandom.md \ - CommandLineScheduler.md \ - Compiling.md \ - DBAdmin.md \ - DefineAction.md \ - ExamplesSetup.md \ - Glossary.md \ - Graphs.md \ - Home.md \ - HttpCollection.md \ - HttpIndex.md \ - HttpInterface.md \ - IndexGeo.md \ - IndexHash.md \ - IndexSkiplist.md \ - IndexUsage.md \ - Indexes.md \ - InstallManual.md \ - Installing.md \ - JSModuleActions.md \ - JSModuleConsole.md \ - JSModuleFs.md \ - JSModuleGraph.md \ - JSModuleInternal.md \ - JSModules.md \ - JavaScriptFunc.md \ - JavaScriptFuncIndex.md \ - Key-Value.md \ - OTWP.md \ - Optimizer.md \ - RefManual.md \ - RestCursor.md \ - RestDocument.md \ - RestEdge.md \ - RestSystem.md \ - SimpleQueries.md \ - UserManualServer.md \ - UserManualShell.md \ - UserManualShellStartStop.md \ - jsUnity.md - + AQLBasics \ + Actions \ + AvocadoErrors \ + AvocadoScript \ + CommandLine \ + CommandLineAvocado \ + CommandLineLogging \ + CommandLineRandom \ + CommandLineScheduler \ + Compiling \ + DBAdmin \ + DefineAction \ + ExamplesSetup \ + Glossary \ + Graphs \ + Home \ + HttpCollection \ + HttpIndex \ + HttpInterface \ + IndexGeo \ + IndexHash \ + IndexSkiplist \ + IndexUsage \ + Indexes \ + InstallManual \ + Installing \ + JSModuleActions \ + JSModuleConsole \ + JSModuleFs \ + JSModuleGraph \ + JSModuleInternal \ + JSModules \ + JavaScriptFunc \ + JavaScriptFuncIndex \ + Key-Value \ + OTWP \ + Optimizer \ + RefManual \ + RestCursor \ + RestDocument \ + RestEdge \ + RestSystem \ + SimpleQueries \ + UserManualServer \ + UserManualShell \ + UserManualShellStartStop \ + jsUnity diff --git a/Makefile.in b/Makefile.in index 68192e89e2..b235a3d38c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -542,8 +542,9 @@ BUILT_SOURCES = build.h $(JAVASCRIPT_HEADER) $(FLEX_FILES) \ ################################################################################ ################################################################################ -CLEANUP = $(DOXYGEN) $(addprefix Doxygen/xml/,$(WIKI)) $(addprefix \ - Doxygen/wiki/,$(WIKI)) $(JAVASCRIPT_HEADER) $(am__append_1) \ +CLEANUP = $(DOXYGEN) $(addsuffix .md,$(addprefix \ + Doxygen/xml/,$(WIKI))) $(addsuffix .md,$(addprefix \ + Doxygen/wiki/,$(WIKI))) $(JAVASCRIPT_HEADER) $(am__append_1) \ $(am__append_2) noinst_LIBRARIES = libavocado.a nobase_pkgdata_DATA = \ @@ -824,53 +825,53 @@ DOXYGEN = \ ################################################################################ ################################################################################ WIKI = \ - AQLBasics.md \ - Actions.md \ - AvocadoErrors.md \ - AvocadoScript.md \ - CommandLine.md \ - CommandLineAvocado.md \ - CommandLineLogging.md \ - CommandLineRandom.md \ - CommandLineScheduler.md \ - Compiling.md \ - DBAdmin.md \ - DefineAction.md \ - ExamplesSetup.md \ - Glossary.md \ - Graphs.md \ - Home.md \ - HttpCollection.md \ - HttpIndex.md \ - HttpInterface.md \ - IndexGeo.md \ - IndexHash.md \ - IndexSkiplist.md \ - IndexUsage.md \ - Indexes.md \ - InstallManual.md \ - Installing.md \ - JSModuleActions.md \ - JSModuleConsole.md \ - JSModuleFs.md \ - JSModuleGraph.md \ - JSModuleInternal.md \ - JSModules.md \ - JavaScriptFunc.md \ - JavaScriptFuncIndex.md \ - Key-Value.md \ - OTWP.md \ - Optimizer.md \ - RefManual.md \ - RestCursor.md \ - RestDocument.md \ - RestEdge.md \ - RestSystem.md \ - SimpleQueries.md \ - UserManualServer.md \ - UserManualShell.md \ - UserManualShellStartStop.md \ - jsUnity.md + AQLBasics \ + Actions \ + AvocadoErrors \ + AvocadoScript \ + CommandLine \ + CommandLineAvocado \ + CommandLineLogging \ + CommandLineRandom \ + CommandLineScheduler \ + Compiling \ + DBAdmin \ + DefineAction \ + ExamplesSetup \ + Glossary \ + Graphs \ + Home \ + HttpCollection \ + HttpIndex \ + HttpInterface \ + IndexGeo \ + IndexHash \ + IndexSkiplist \ + IndexUsage \ + Indexes \ + InstallManual \ + Installing \ + JSModuleActions \ + JSModuleConsole \ + JSModuleFs \ + JSModuleGraph \ + JSModuleInternal \ + JSModules \ + JavaScriptFunc \ + JavaScriptFuncIndex \ + Key-Value \ + OTWP \ + Optimizer \ + RefManual \ + RestCursor \ + RestDocument \ + RestEdge \ + RestSystem \ + SimpleQueries \ + UserManualServer \ + UserManualShell \ + UserManualShellStartStop \ + jsUnity @ENABLE_BOOST_TEST_TRUE@UnitTests_test_suite_LDADD = -L@top_builddir@ -lavocado -lboost_unit_test_framework @ENABLE_BOOST_TEST_TRUE@UnitTests_test_suite_DEPENDENCIES = @top_builddir@/libavocado.a @@ -2549,10 +2550,10 @@ doxygen: Doxygen/avocado.doxy $(DOXYGEN) .PHONY: wiki -wiki: doxygen $(addprefix Doxygen/xml/,$(WIKI)) +wiki: doxygen $(addsuffix .md,$(addprefix Doxygen/xml/,$(WIKI))) @test -d Doxygen/wiki || mkdir Doxygen/wiki - @for w in $(WIKI); do @top_srcdir@/Doxygen/Scripts/pandoc.sh Doxygen/xml/$$w; done - @for w in $(WIKI); do @top_srcdir@/Doxygen/Scripts/md2html.sh Doxygen/wiki/$$w; done + @for w in $(WIKI); do @top_srcdir@/Doxygen/Scripts/pandoc.sh Doxygen/xml/$$w.md; done + @for w in $(WIKI); do @top_srcdir@/Doxygen/Scripts/md2html.sh Doxygen/wiki/$$w.md; done .setup-directories: @test -d js || mkdir js @@ -2581,6 +2582,8 @@ js/server/js-%.h: @srcdir@/js/server/%.js .setup-directories @ENABLE_BOOST_TEST_FALSE@unittests: @ENABLE_BOOST_TEST_FALSE@ @echo "enable unit-testing with 'configure --with-boost-test'" +-include Makefile.local + @ENABLE_FLEX_TRUE@JsonParser/%.c: @srcdir@/JsonParser/%.l @ENABLE_FLEX_TRUE@ @top_srcdir@/config/flex-c.sh $(LEX) $@ $< diff --git a/QL/ast-query.c b/QL/ast-query.c index c09fd34d3f..6e35ebf770 100644 --- a/QL/ast-query.c +++ b/QL/ast-query.c @@ -579,7 +579,7 @@ bool QLAstQueryAddGeoRestriction (QL_ast_query_t* query, restriction->_arg._radius = restrictionNode->_value._doubleValue; } else { - restriction->_arg._numDocuments = restrictionNode->_value._intValue; + restriction->_arg._numDocuments = (size_t) restrictionNode->_value._intValue; } TRI_InsertKeyAssociativePointer(&query->_geo._restrictions, diff --git a/QL/formatter.c b/QL/formatter.c index 85a3f41f6a..cd34f8368d 100644 --- a/QL/formatter.c +++ b/QL/formatter.c @@ -73,7 +73,7 @@ void QLFormatterPrintBlockStart (QL_formatter_t* formatter, const char* name) { /// @brief Print end of a block //////////////////////////////////////////////////////////////////////////////// -void QLFormatterPrintBlockEnd (QL_formatter_t* formatter, const char* name) { +void QLFormatterPrintBlockEnd (QL_formatter_t* formatter) { QLFormatterPrintIndentation(formatter); printf("}\n"); } @@ -82,9 +82,9 @@ void QLFormatterPrintBlockEnd (QL_formatter_t* formatter, const char* name) { /// @brief Print an indented int value //////////////////////////////////////////////////////////////////////////////// -void QLFormatterPrintInt (QL_formatter_t* formatter, const char* name, uint64_t value) { +void QLFormatterPrintInt (QL_formatter_t* formatter, const char* name, int64_t value) { QLFormatterPrintIndentation(formatter); - printf("%s: %lu\n",name,(unsigned long) value); + printf("%s: %li\n",name, (long) value); } //////////////////////////////////////////////////////////////////////////////// @@ -132,7 +132,7 @@ void QLFormatterDump (TRI_query_node_t* node, QL_formatter_t* formatter) { next = next->_next; } QLFormatterIndentationDec(formatter); - QLFormatterPrintBlockEnd(formatter,""); + QLFormatterPrintBlockEnd(formatter); return; } @@ -166,7 +166,7 @@ void QLFormatterDump (TRI_query_node_t* node, QL_formatter_t* formatter) { } QLFormatterIndentationDec(formatter); - QLFormatterPrintBlockEnd(formatter,""); + QLFormatterPrintBlockEnd(formatter); } //////////////////////////////////////////////////////////////////////////////// diff --git a/QL/formatter.h b/QL/formatter.h index bcc20d3e5b..1d839dc47f 100644 --- a/QL/formatter.h +++ b/QL/formatter.h @@ -80,13 +80,13 @@ void QLFormatterPrintBlockStart (QL_formatter_t*, const char*); /// @brief Print end of a block //////////////////////////////////////////////////////////////////////////////// -void QLFormatterPrintBlockEnd (QL_formatter_t*, const char*); +void QLFormatterPrintBlockEnd (QL_formatter_t*); //////////////////////////////////////////////////////////////////////////////// /// @brief Print an indented int value //////////////////////////////////////////////////////////////////////////////// -void QLFormatterPrintInt (QL_formatter_t*, const char*, uint64_t); +void QLFormatterPrintInt (QL_formatter_t*, const char*, int64_t); //////////////////////////////////////////////////////////////////////////////// /// @brief Print an indented double value diff --git a/V8/v8-actions.cpp b/V8/v8-actions.cpp index b2e4d61848..f3c925d6b3 100644 --- a/V8/v8-actions.cpp +++ b/V8/v8-actions.cpp @@ -570,7 +570,7 @@ HttpResponse* TRI_ExecuteActionVocBase (TRI_vocbase_t* vocbase, if (v8Headers->IsObject()) { v8::Handle props = v8Headers->GetPropertyNames(); - for (size_t i = 0; i < props->Length(); i++) { + for (uint32_t i = 0; i < props->Length(); i++) { v8::Handle key = props->Get(v8::Integer::New(i)); response->setHeader(TRI_ObjectToString(key), TRI_ObjectToString(v8Headers->Get(key))); } diff --git a/V8/v8-vocbase.cpp b/V8/v8-vocbase.cpp index d8a6be1c85..df31abab9e 100644 --- a/V8/v8-vocbase.cpp +++ b/V8/v8-vocbase.cpp @@ -279,7 +279,7 @@ static v8::Handle CreateErrorObject (int errorNumber, string const& v8::Handle errorObject = v8g->ErrorTempl->NewInstance(); - string msg = TRI_last_error() + string(": ") + message; + string msg = TRI_errno_string(errorNumber) + string(": ") + message; errorObject->Set(v8::String::New("errorNum"), v8::Number::New(errorNumber)); errorObject->Set(v8::String::New("errorMessage"), v8::String::New(msg.c_str())); @@ -1187,11 +1187,11 @@ static v8::Handle JS_AllQuery (v8::Arguments const& argv) { //////////////////////////////////////////////////////////////////////////////// /// @brief looks up a document /// -/// @FUN{document(@FA{document-identifier})} +/// @FUN{@FA{collection}.document(@FA{document-identifier})} /// -/// The @FN{document} operator finds a document given it's identifier. It -/// returns the document. Undefined is returned if the document identifier is -/// not valid. +/// The @FN{document} operator finds a document given it's identifier. +/// It returns the document. @LIT{undefined} is returned if the +/// document identifier is not known. /// /// Note that the returned docuement contains two pseudo-attributes, namely /// @LIT{_id} and @LIT{_rev}. The attribute @LIT{_id} contains the document @@ -1202,7 +1202,7 @@ static v8::Handle JS_AllQuery (v8::Arguments const& argv) { /// @verbinclude simple1 //////////////////////////////////////////////////////////////////////////////// -static v8::Handle JS_DocumentQuery (v8::Arguments const& argv) { +static v8::Handle JS_DocumentVocbaseCol (v8::Arguments const& argv) { v8::HandleScope scope; // extract the collection @@ -1218,7 +1218,9 @@ static v8::Handle JS_DocumentQuery (v8::Arguments const& argv) { // first and only argument schould be an document idenfifier if (argv.Length() != 1) { ReleaseCollection(collection); - return scope.Close(v8::ThrowException(v8::String::New("usage: document_wrapped()"))); + return scope.Close(v8::ThrowException( + CreateErrorObject(TRI_ERROR_BAD_PARAMETER, + "usage: document()"))); } v8::Handle arg1 = argv[0]; @@ -1227,12 +1229,16 @@ static v8::Handle JS_DocumentQuery (v8::Arguments const& argv) { if (! IsDocumentId(arg1, cid, did)) { ReleaseCollection(collection); - return scope.Close(v8::ThrowException(v8::String::New(" must be a document identifier"))); + return scope.Close(v8::ThrowException( + CreateErrorObject(TRI_ERROR_BAD_PARAMETER, + " must be a document identifier"))); } if (cid != collection->_collection->base._cid) { ReleaseCollection(collection); - return scope.Close(v8::ThrowException(v8::String::New("cannot execute cross collection query"))); + return scope.Close(v8::ThrowException( + CreateErrorObject(TRI_ERROR_AVOCADO_CROSS_COLLECTION_REQUEST, + "cannot execute cross collection query"))); } // ............................................................................. @@ -1265,7 +1271,9 @@ static v8::Handle JS_DocumentQuery (v8::Arguments const& argv) { if (document._did == 0) { ReleaseCollection(collection); - return scope.Close(v8::ThrowException(v8::String::New("document not found"))); + return scope.Close(v8::ThrowException( + CreateErrorObject(TRI_ERROR_AVOCADO_DOCUMENT_NOT_FOUND, + "document not found"))); } ReleaseCollection(collection); @@ -5155,7 +5163,7 @@ void TRI_InitV8VocBridge (v8::Handle context, TRI_vocbase_t* vocbas rt->Set(AllFuncName, v8::FunctionTemplate::New(JS_AllQuery)); rt->Set(CountFuncName, v8::FunctionTemplate::New(JS_CountVocbaseCol)); rt->Set(DeleteFuncName, v8::FunctionTemplate::New(JS_DeleteVocbaseCol)); - rt->Set(DocumentFuncName, v8::FunctionTemplate::New(JS_DocumentQuery)); + rt->Set(DocumentFuncName, v8::FunctionTemplate::New(JS_DocumentVocbaseCol)); rt->Set(DropFuncName, v8::FunctionTemplate::New(JS_DropVocbaseCol)); rt->Set(DropIndexFuncName, v8::FunctionTemplate::New(JS_DropIndexVocbaseCol)); rt->Set(EnsureGeoIndexFuncName, v8::FunctionTemplate::New(JS_EnsureGeoIndexVocbaseCol)); @@ -5194,7 +5202,7 @@ void TRI_InitV8VocBridge (v8::Handle context, TRI_vocbase_t* vocbas rt->Set(AllFuncName, v8::FunctionTemplate::New(JS_AllQuery)); rt->Set(CountFuncName, v8::FunctionTemplate::New(JS_CountVocbaseCol)); rt->Set(DeleteFuncName, v8::FunctionTemplate::New(JS_DeleteVocbaseCol)); - rt->Set(DocumentFuncName, v8::FunctionTemplate::New(JS_DocumentQuery)); + rt->Set(DocumentFuncName, v8::FunctionTemplate::New(JS_DocumentVocbaseCol)); rt->Set(DropFuncName, v8::FunctionTemplate::New(JS_DropVocbaseCol)); rt->Set(DropIndexFuncName, v8::FunctionTemplate::New(JS_DropIndexVocbaseCol)); rt->Set(EnsureGeoIndexFuncName, v8::FunctionTemplate::New(JS_EnsureGeoIndexVocbaseCol)); diff --git a/VocBase/query-execute.c b/VocBase/query-execute.c index aa9928f0ab..c25dfa2cc2 100644 --- a/VocBase/query-execute.c +++ b/VocBase/query-execute.c @@ -54,9 +54,9 @@ static bool TransformDataSkipLimit (TRI_rc_result_t* result, return TRI_SliceSelectResult(_result, 0, 0); } - // positive limit, skip and slice from front + // positive limit. skip and slice from front if (limit > 0) { - if (_result->_numRows - skip < limit) { + if ((int64_t) limit > (int64_t) (_result->_numRows - skip)) { return TRI_SliceSelectResult(_result, skip, _result->_numRows - skip); } @@ -64,7 +64,7 @@ static bool TransformDataSkipLimit (TRI_rc_result_t* result, } // negative limit, slice from back - if (_result->_numRows - skip < -limit) { + if ((int64_t) (_result->_numRows - skip) < (int64_t) (-limit)) { return TRI_SliceSelectResult(_result, 0, _result->_numRows - skip); } diff --git a/js/common/bootstrap/errors.js b/js/common/bootstrap/errors.js index f782ac8a69..fe2aff0800 100644 --- a/js/common/bootstrap/errors.js +++ b/js/common/bootstrap/errors.js @@ -15,6 +15,7 @@ ModuleCache["/internal"].exports.errors = { "ERROR_ILLEGAL_OPTION" : { "code" : 7, "message" : "illegal option" }, "ERROR_DEAD_PID" : { "code" : 8, "message" : "dead process identifier" }, "ERROR_NOT_IMPLEMENTED" : { "code" : 9, "message" : "not implemented" }, + "ERROR_BAD_PARAMETER" : { "code" : 10, "message" : "bad parameter" }, "ERROR_HTTP_BAD_PARAMETER" : { "code" : 400, "message" : "bad parameter" }, "ERROR_HTTP_NOT_FOUND" : { "code" : 404, "message" : "not found" }, "ERROR_HTTP_METHOD_NOT_ALLOWED" : { "code" : 405, "message" : "method not supported" }, @@ -49,6 +50,7 @@ ModuleCache["/internal"].exports.errors = { "ERROR_AVOCADO_UNIQUE_CONSTRAINT_VIOLATED" : { "code" : 1210, "message" : "unique constraint violated" }, "ERROR_AVOCADO_GEO_INDEX_VIOLATED" : { "code" : 1211, "message" : "geo index violated" }, "ERROR_AVOCADO_INDEX_NOT_FOUND" : { "code" : 1212, "message" : "index not found" }, + "ERROR_AVOCADO_CROSS_COLLECTION_REQUEST" : { "code" : 1213, "message" : "cross collection request not allowed" }, "ERROR_AVOCADO_DATAFILE_FULL" : { "code" : 1300, "message" : "datafile full" }, "ERROR_QUERY_KILLED" : { "code" : 1500, "message" : "query killed" }, "ERROR_QUERY_PARSE" : { "code" : 1501, "message" : "parse error: %s" }, @@ -98,5 +100,6 @@ ModuleCache["/internal"].exports.errors = { "SIMPLE_CLIENT_COULD_NOT_CONNECT" : { "code" : 2001, "message" : "could not connect to server" }, "SIMPLE_CLIENT_COULD_NOT_WRITE" : { "code" : 2002, "message" : "could not write to server" }, "SIMPLE_CLIENT_COULD_NOT_READ" : { "code" : 2003, "message" : "could not read from server" }, + "ERROR_AVOCADO_INDEX_PQ_INSERT_FAILED" : { "code" : 3100, "message" : "priority queue insert failure" }, }; diff --git a/js/common/bootstrap/js-errors.h b/js/common/bootstrap/js-errors.h index b5b1886c26..4ae8a53f7a 100644 --- a/js/common/bootstrap/js-errors.h +++ b/js/common/bootstrap/js-errors.h @@ -16,6 +16,7 @@ static string JS_common_bootstrap_errors = " \"ERROR_ILLEGAL_OPTION\" : { \"code\" : 7, \"message\" : \"illegal option\" }, \n" " \"ERROR_DEAD_PID\" : { \"code\" : 8, \"message\" : \"dead process identifier\" }, \n" " \"ERROR_NOT_IMPLEMENTED\" : { \"code\" : 9, \"message\" : \"not implemented\" }, \n" + " \"ERROR_BAD_PARAMETER\" : { \"code\" : 10, \"message\" : \"bad parameter\" }, \n" " \"ERROR_HTTP_BAD_PARAMETER\" : { \"code\" : 400, \"message\" : \"bad parameter\" }, \n" " \"ERROR_HTTP_NOT_FOUND\" : { \"code\" : 404, \"message\" : \"not found\" }, \n" " \"ERROR_HTTP_METHOD_NOT_ALLOWED\" : { \"code\" : 405, \"message\" : \"method not supported\" }, \n" @@ -50,6 +51,7 @@ static string JS_common_bootstrap_errors = " \"ERROR_AVOCADO_UNIQUE_CONSTRAINT_VIOLATED\" : { \"code\" : 1210, \"message\" : \"unique constraint violated\" }, \n" " \"ERROR_AVOCADO_GEO_INDEX_VIOLATED\" : { \"code\" : 1211, \"message\" : \"geo index violated\" }, \n" " \"ERROR_AVOCADO_INDEX_NOT_FOUND\" : { \"code\" : 1212, \"message\" : \"index not found\" }, \n" + " \"ERROR_AVOCADO_CROSS_COLLECTION_REQUEST\" : { \"code\" : 1213, \"message\" : \"cross collection request not allowed\" }, \n" " \"ERROR_AVOCADO_DATAFILE_FULL\" : { \"code\" : 1300, \"message\" : \"datafile full\" }, \n" " \"ERROR_QUERY_KILLED\" : { \"code\" : 1500, \"message\" : \"query killed\" }, \n" " \"ERROR_QUERY_PARSE\" : { \"code\" : 1501, \"message\" : \"parse error: %s\" }, \n" @@ -99,6 +101,7 @@ static string JS_common_bootstrap_errors = " \"SIMPLE_CLIENT_COULD_NOT_CONNECT\" : { \"code\" : 2001, \"message\" : \"could not connect to server\" }, \n" " \"SIMPLE_CLIENT_COULD_NOT_WRITE\" : { \"code\" : 2002, \"message\" : \"could not write to server\" }, \n" " \"SIMPLE_CLIENT_COULD_NOT_READ\" : { \"code\" : 2003, \"message\" : \"could not read from server\" }, \n" + " \"ERROR_AVOCADO_INDEX_PQ_INSERT_FAILED\" : { \"code\" : 3100, \"message\" : \"priority queue insert failure\" }, \n" "};\n" "\n" ;