From 99bc88a6f7df2f888279ab20fd60ee90fb737894 Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Wed, 4 Apr 2012 11:12:45 +0200 Subject: [PATCH] merge with SVN --- BasicsC/process-utils.c | 3 +++ BasicsC/vector.c | 4 ---- BasicsC/voc-errors.c | 3 +++ BasicsC/voc-errors.h | 38 +++++++++++++++++++++++++++++++++++ QL/ast-query.c | 2 +- QL/formatter.c | 10 ++++----- QL/formatter.h | 4 ++-- V8/v8-actions.cpp | 2 +- VocBase/query-execute.c | 6 +++--- js/common/bootstrap/errors.js | 3 +++ 10 files changed, 59 insertions(+), 16 deletions(-) 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/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/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" }, };