diff --git a/Ahuacatl/ast-dump.h b/Ahuacatl/ast-dump.h index 9836bf32d3..b95c06e198 100644 --- a/Ahuacatl/ast-dump.h +++ b/Ahuacatl/ast-dump.h @@ -48,7 +48,7 @@ extern "C" { //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// -/// @brief internal state of dump +/// @brief internal state of dumper //////////////////////////////////////////////////////////////////////////////// typedef struct TRI_aql_dump_s { diff --git a/Ahuacatl/ast-node.c b/Ahuacatl/ast-node.c index 74408cad23..2991bc3949 100644 --- a/Ahuacatl/ast-node.c +++ b/Ahuacatl/ast-node.c @@ -74,7 +74,6 @@ static inline void InitNode (TRI_aql_parse_context_t* const context, static void FreeNodeList (TRI_aql_node_t* const node) { TRI_aql_node_list_t* _node = (TRI_aql_node_list_t*) node; - // todo: free values TRI_DestroyVectorPointer(&_node->_values); } @@ -85,7 +84,6 @@ static void FreeNodeList (TRI_aql_node_t* const node) { static void FreeNodeArray (TRI_aql_node_t* const node) { TRI_aql_node_array_t* _node = (TRI_aql_node_array_t*) node; - // todo: free values TRI_DestroyAssociativePointer(&_node->_values); } @@ -419,8 +417,8 @@ TRI_aql_node_t* TRI_CreateNodeVariableAql (TRI_aql_parse_context_t* const contex } if (!TRI_AddVariableParseContextAql(context, name)) { - printf("fail in %lu\n",(unsigned long) __LINE__); - TRI_SetErrorAql(context, TRI_ERROR_OUT_OF_MEMORY, name); // TODO: duplicate variable name + // duplicate variable name + TRI_SetErrorAql(context, TRI_ERROR_QUERY_VARIABLE_REDECLARED, name); return NULL; } @@ -1435,7 +1433,8 @@ bool TRI_PushArrayAql (TRI_aql_parse_context_t* const context, } if (TRI_InsertKeyAssociativePointer(&array->_values, element->_name, (void*) element, false)) { - // duplicate element TODO + // duplicate element in a document/array, e.g. { "name" : "John", "name" : "Jim" } + TRI_SetErrorAql(context, TRI_ERROR_QUERY_DOCUMENT_ATTRIBUTE_REDECLARED, name); return false; } diff --git a/BasicsC/errors.dat b/BasicsC/errors.dat index 5a5f88984e..9f363c85e7 100644 --- a/BasicsC/errors.dat +++ b/BasicsC/errors.dat @@ -116,6 +116,8 @@ ERROR_QUERY_BIND_PARAMETER_NUMBER_OUT_OF_RANGE,1517,"bind parameter number '%s' ERROR_QUERY_FUNCTION_NAME_UNKNOWN,1518,"usage of unknown function '%s'","Will be raised when an undefined function is called." ERROR_QUERY_RUNTIME_ERROR,1520,"runtime error in query","Will be raised when a Javascript runtime error occurs while executing a query." ERROR_QUERY_LIMIT_VALUE_OUT_OF_RANGE,1521,"limit value '%s' is out of range","Will be raised when a limit value in the query is outside the allowed range (e. g. when passing a negative skip value)." +ERROR_QUERY_VARIABLE_REDECLARED,1522,"variable '%s' is assigned multiple times","Will be raised when a variable gets re-assigned in a query." +ERROR_QUERY_DOCUMENT_ATTRIBUTE_REDECLARED,1523,"document attribute '%s' is assigned multiple times","Will be raised when a document attribute is re-assigned." ################################################################################ ## AvocadoDB cursor errors diff --git a/BasicsC/voc-errors.c b/BasicsC/voc-errors.c index d18dd98c52..bcfe538210 100644 --- a/BasicsC/voc-errors.c +++ b/BasicsC/voc-errors.c @@ -82,6 +82,8 @@ void TRI_InitialiseErrorMessages (void) { REG_ERROR(ERROR_QUERY_FUNCTION_NAME_UNKNOWN, "usage of unknown function '%s'"); REG_ERROR(ERROR_QUERY_RUNTIME_ERROR, "runtime error in query"); REG_ERROR(ERROR_QUERY_LIMIT_VALUE_OUT_OF_RANGE, "limit value '%s' is out of range"); + REG_ERROR(ERROR_QUERY_VARIABLE_REDECLARED, "variable '%s' is assigned multiple times"); + REG_ERROR(ERROR_QUERY_DOCUMENT_ATTRIBUTE_REDECLARED, "document attribute '%s' is assigned multiple times"); REG_ERROR(ERROR_CURSOR_NOT_FOUND, "cursor not found"); REG_ERROR(ERROR_SESSION_USERHANDLER_URL_INVALID, "expecting /user/"); REG_ERROR(ERROR_SESSION_USERHANDLER_CANNOT_CREATE_USER, "cannot create user"); diff --git a/BasicsC/voc-errors.h b/BasicsC/voc-errors.h index 959e76cd19..77008f875c 100644 --- a/BasicsC/voc-errors.h +++ b/BasicsC/voc-errors.h @@ -180,6 +180,10 @@ extern "C" { /// - 1521: @CODE{limit value '\%s' is out of range} /// Will be raised when a limit value in the query is outside the allowed /// range (e. g. when passing a negative skip value). +/// - 1522: @CODE{variable '\%s' is assigned multiple times} +/// Will be raised when a variable gets re-assigned in a query. +/// - 1523: @CODE{document attribute '\%s' is assigned multiple times} +/// Will be raised when a document attribute is re-assigned. /// - 1600: @CODE{cursor not found} /// Will be raised when a cursor is requested via its id but a cursor with /// that id cannot be found. @@ -1003,6 +1007,26 @@ void TRI_InitialiseErrorMessages (void); #define TRI_ERROR_QUERY_LIMIT_VALUE_OUT_OF_RANGE (1521) +//////////////////////////////////////////////////////////////////////////////// +/// @brief 1522: ERROR_QUERY_VARIABLE_REDECLARED +/// +/// variable '%s' is assigned multiple times +/// +/// Will be raised when a variable gets re-assigned in a query. +//////////////////////////////////////////////////////////////////////////////// + +#define TRI_ERROR_QUERY_VARIABLE_REDECLARED (1522) + +//////////////////////////////////////////////////////////////////////////////// +/// @brief 1523: ERROR_QUERY_DOCUMENT_ATTRIBUTE_REDECLARED +/// +/// document attribute '%s' is assigned multiple times +/// +/// Will be raised when a document attribute is re-assigned. +//////////////////////////////////////////////////////////////////////////////// + +#define TRI_ERROR_QUERY_DOCUMENT_ATTRIBUTE_REDECLARED (1523) + //////////////////////////////////////////////////////////////////////////////// /// @brief 1600: ERROR_CURSOR_NOT_FOUND /// diff --git a/js/common/bootstrap/errors.js b/js/common/bootstrap/errors.js index f759a313ce..f5a05dd198 100644 --- a/js/common/bootstrap/errors.js +++ b/js/common/bootstrap/errors.js @@ -76,6 +76,8 @@ ModuleCache["/internal"].exports.errors = { "ERROR_QUERY_FUNCTION_NAME_UNKNOWN" : { "code" : 1518, "message" : "usage of unknown function '%s'" }, "ERROR_QUERY_RUNTIME_ERROR" : { "code" : 1520, "message" : "runtime error in query" }, "ERROR_QUERY_LIMIT_VALUE_OUT_OF_RANGE" : { "code" : 1521, "message" : "limit value '%s' is out of range" }, + "ERROR_QUERY_VARIABLE_REDECLARED" : { "code" : 1522, "message" : "variable '%s' is assigned multiple times" }, + "ERROR_QUERY_DOCUMENT_ATTRIBUTE_REDECLARED" : { "code" : 1523, "message" : "document attribute '%s' is assigned multiple times" }, "ERROR_CURSOR_NOT_FOUND" : { "code" : 1600, "message" : "cursor not found" }, "ERROR_SESSION_USERHANDLER_URL_INVALID" : { "code" : 1700, "message" : "expecting /user/" }, "ERROR_SESSION_USERHANDLER_CANNOT_CREATE_USER" : { "code" : 1701, "message" : "cannot create user" }, diff --git a/js/common/bootstrap/js-errors.h b/js/common/bootstrap/js-errors.h index aca52d86c5..aa27d6f489 100644 --- a/js/common/bootstrap/js-errors.h +++ b/js/common/bootstrap/js-errors.h @@ -77,6 +77,8 @@ static string JS_common_bootstrap_errors = " \"ERROR_QUERY_FUNCTION_NAME_UNKNOWN\" : { \"code\" : 1518, \"message\" : \"usage of unknown function '%s'\" }, \n" " \"ERROR_QUERY_RUNTIME_ERROR\" : { \"code\" : 1520, \"message\" : \"runtime error in query\" }, \n" " \"ERROR_QUERY_LIMIT_VALUE_OUT_OF_RANGE\" : { \"code\" : 1521, \"message\" : \"limit value '%s' is out of range\" }, \n" + " \"ERROR_QUERY_VARIABLE_REDECLARED\" : { \"code\" : 1522, \"message\" : \"variable '%s' is assigned multiple times\" }, \n" + " \"ERROR_QUERY_DOCUMENT_ATTRIBUTE_REDECLARED\" : { \"code\" : 1523, \"message\" : \"document attribute '%s' is assigned multiple times\" }, \n" " \"ERROR_CURSOR_NOT_FOUND\" : { \"code\" : 1600, \"message\" : \"cursor not found\" }, \n" " \"ERROR_SESSION_USERHANDLER_URL_INVALID\" : { \"code\" : 1700, \"message\" : \"expecting /user/\" }, \n" " \"ERROR_SESSION_USERHANDLER_CANNOT_CREATE_USER\" : { \"code\" : 1701, \"message\" : \"cannot create user\" }, \n"