diff --git a/Admin/RestAdminLogHandler.cpp b/Admin/RestAdminLogHandler.cpp index 52f0606fad..cf689b2666 100644 --- a/Admin/RestAdminLogHandler.cpp +++ b/Admin/RestAdminLogHandler.cpp @@ -377,6 +377,7 @@ HttpHandler::status_e RestAdminLogHandler::execute () { } TRI_FreeBufferLogging(logs); + TRI_DestroyVector(&clean); generateResult(result); return HANDLER_DONE; diff --git a/Ahuacatl/ahuacatl-codegen-js.c b/Ahuacatl/ahuacatl-codegen-js.c index a92c048e38..f6290c7d72 100644 --- a/Ahuacatl/ahuacatl-codegen-js.c +++ b/Ahuacatl/ahuacatl-codegen-js.c @@ -630,6 +630,11 @@ static void StartFor (TRI_aql_codegen_js_t* const generator, static void CloseLoops (TRI_aql_codegen_js_t* const generator) { TRI_aql_codegen_scope_t* scope = CurrentScope(generator); + if (scope->_type == TRI_AQL_SCOPE_MAIN || scope->_type == TRI_AQL_SCOPE_SUBQUERY) { + // these scopes are closed by other means + return; + } + // we are closing at least one scope while (true) { TRI_aql_codegen_scope_e type = scope->_type; @@ -1471,10 +1476,18 @@ static void ProcessAssign (TRI_aql_codegen_js_t* const generator, static void ProcessFilter (TRI_aql_codegen_js_t* const generator, const TRI_aql_node_t* const node) { + TRI_aql_codegen_scope_t* scope = CurrentScope(generator); + ScopeOutput(generator, "if (!("); ProcessNode(generator, TRI_AQL_NODE_MEMBER(node, 0)); ScopeOutput(generator, ")) {\n"); - ScopeOutput(generator, "continue;\n"); + if (scope->_type == TRI_AQL_SCOPE_MAIN || scope->_type == TRI_AQL_SCOPE_SUBQUERY) { + // in these scopes, we must not generated a continue statement. this would be illegal + ScopeOutput(generator, "return [ ];\n"); + } + else { + ScopeOutput(generator, "continue;\n"); + } ScopeOutput(generator, "}\n"); } diff --git a/Ahuacatl/ahuacatl-context.c b/Ahuacatl/ahuacatl-context.c index f33fe0b118..e27ddfe186 100644 --- a/Ahuacatl/ahuacatl-context.c +++ b/Ahuacatl/ahuacatl-context.c @@ -69,9 +69,12 @@ //////////////////////////////////////////////////////////////////////////////// TRI_aql_context_t* TRI_CreateContextAql (TRI_vocbase_t* vocbase, - const char* const query) { + const char* const query) { TRI_aql_context_t* context; + assert(vocbase); + assert(query); + context = (TRI_aql_context_t*) TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_aql_context_t), false); if (!context) { return NULL; @@ -230,6 +233,12 @@ void TRI_FreeContextAql (TRI_aql_context_t* const context) { //////////////////////////////////////////////////////////////////////////////// bool TRI_ValidateQueryContextAql (TRI_aql_context_t* const context) { + if (context->_parser->_length == 0) { + // query is empty, no need to parse it + TRI_SetErrorContextAql(context, TRI_ERROR_QUERY_EMPTY, NULL); + return false; + } + // parse the query if (!TRI_ParseAql(context)) { // lexing/parsing failed diff --git a/Ahuacatl/ahuacatl-error.c b/Ahuacatl/ahuacatl-error.c index 649f070b07..92c67e117d 100644 --- a/Ahuacatl/ahuacatl-error.c +++ b/Ahuacatl/ahuacatl-error.c @@ -93,6 +93,7 @@ char* TRI_GetErrorMessageAql (const TRI_aql_error_t* const error) { if (error->_data && (NULL != strstr(message, "%s"))) { snprintf(buffer, sizeof(buffer), message, error->_data); + return TRI_DuplicateString((const char*) &buffer); } @@ -138,35 +139,48 @@ void TRI_FreeErrorAql (TRI_aql_error_t* const error) { //////////////////////////////////////////////////////////////////////////////// char* TRI_GetContextErrorAql (const char* const query, const size_t line, const size_t column) { - size_t currentLine = 1; - size_t currentColumn = 1; - const char* p = query; + const char* p; char* temp; char* result; - size_t offset; char c; - - while ((c = *p++)) { + // note: line numbers reported by bison/flex start at 1, columns start at 0 + size_t offset; + size_t currentLine = 1; + size_t currentColumn = 0; + + assert(query); + + p = query; + while ((c = *p)) { + if (currentLine > line || (currentLine >= line && currentColumn >= column)) { + break; + } + if (c == '\n') { + ++p; ++currentLine; currentColumn = 0; } else if (c == '\r') { + ++p; + ++currentLine; + currentColumn = 0; + if (*p == '\n') { - ++currentLine; - currentColumn = 0; - p++; + ++p; } } - - ++currentColumn; - - if (currentLine >= line && currentColumn >= column) { - break; + else { + ++currentColumn; + ++p; } } + // p is pointing at the position in the query the parse error occurred at + assert(p >= query); + offset = p - query; + if (strlen(query) < offset + SNIPPET_LENGTH) { return TRI_DuplicateString2(query + offset, strlen(query) - offset); } diff --git a/Ahuacatl/ahuacatl-grammar.c b/Ahuacatl/ahuacatl-grammar.c index 6d4a774986..1cc57636ed 100644 --- a/Ahuacatl/ahuacatl-grammar.c +++ b/Ahuacatl/ahuacatl-grammar.c @@ -1,8 +1,10 @@ -/* A Bison parser, made by GNU Bison 2.5. */ -/* Bison implementation for Yacc-like parsers in C +/* A Bison parser, made by GNU Bison 2.4.1. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -44,7 +46,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.5" +#define YYBISON_VERSION "2.4.1" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -73,7 +75,7 @@ /* Copy the first part of user declarations. */ -/* Line 268 of yacc.c */ +/* Line 189 of yacc.c */ #line 10 "Ahuacatl/ahuacatl-grammar.y" #include @@ -90,8 +92,8 @@ #include "Ahuacatl/ahuacatl-parser-functions.h" -/* Line 268 of yacc.c */ -#line 95 "Ahuacatl/ahuacatl-grammar.c" +/* Line 189 of yacc.c */ +#line 97 "Ahuacatl/ahuacatl-grammar.c" /* Enabling traces. */ #ifndef YYDEBUG @@ -176,7 +178,7 @@ typedef union YYSTYPE { -/* Line 293 of yacc.c */ +/* Line 214 of yacc.c */ #line 25 "Ahuacatl/ahuacatl-grammar.y" TRI_aql_node_t* node; @@ -186,8 +188,8 @@ typedef union YYSTYPE -/* Line 293 of yacc.c */ -#line 191 "Ahuacatl/ahuacatl-grammar.c" +/* Line 214 of yacc.c */ +#line 193 "Ahuacatl/ahuacatl-grammar.c" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ @@ -210,7 +212,7 @@ typedef struct YYLTYPE /* Copy the second part of user declarations. */ -/* Line 343 of yacc.c */ +/* Line 264 of yacc.c */ #line 32 "Ahuacatl/ahuacatl-grammar.y" @@ -239,8 +241,8 @@ void Ahuacatlerror (YYLTYPE* locp, TRI_aql_context_t* const context, const char* #define scanner context->_parser->_scanner -/* Line 343 of yacc.c */ -#line 244 "Ahuacatl/ahuacatl-grammar.c" +/* Line 264 of yacc.c */ +#line 246 "Ahuacatl/ahuacatl-grammar.c" #ifdef short # undef short @@ -290,7 +292,7 @@ typedef short int yytype_int16; #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ -# if defined YYENABLE_NLS && YYENABLE_NLS +# if YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ # define YY_(msgid) dgettext ("bison-runtime", msgid) @@ -343,11 +345,11 @@ YYID (yyi) # define alloca _alloca # else # define YYSTACK_ALLOC alloca -# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) # include /* INFRINGES ON USER NAME SPACE */ -# ifndef EXIT_SUCCESS -# define EXIT_SUCCESS 0 +# ifndef _STDLIB_H +# define _STDLIB_H 1 # endif # endif # endif @@ -370,24 +372,24 @@ YYID (yyi) # ifndef YYSTACK_ALLOC_MAXIMUM # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # endif -# if (defined __cplusplus && ! defined EXIT_SUCCESS \ +# if (defined __cplusplus && ! defined _STDLIB_H \ && ! ((defined YYMALLOC || defined malloc) \ && (defined YYFREE || defined free))) # include /* INFRINGES ON USER NAME SPACE */ -# ifndef EXIT_SUCCESS -# define EXIT_SUCCESS 0 +# ifndef _STDLIB_H +# define _STDLIB_H 1 # endif # endif # ifndef YYMALLOC # define YYMALLOC malloc -# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free -# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif @@ -418,7 +420,23 @@ union yyalloc ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ + 2 * YYSTACK_GAP_MAXIMUM) -# define YYCOPY_NEEDED 1 +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of @@ -438,26 +456,6 @@ union yyalloc #endif -#if defined YYCOPY_NEEDED && YYCOPY_NEEDED -/* Copy COUNT objects from FROM to TO. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if defined __GNUC__ && 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) -# else -# define YYCOPY(To, From, Count) \ - do \ - { \ - YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ - while (YYID (0)) -# endif -# endif -#endif /* !YYCOPY_NEEDED */ - /* YYFINAL -- State number of the termination state. */ #define YYFINAL 3 /* YYLAST -- Last index in YYTABLE. */ @@ -665,8 +663,8 @@ static const yytype_uint8 yyr2[] = 1, 1, 1, 2 }; -/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. - Performed when YYTABLE doesn't specify something else to do. Zero +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero means the default is an error. */ static const yytype_uint8 yydefact[] = { @@ -735,7 +733,8 @@ static const yytype_int8 yypgoto[] = /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which - number is the opposite. If YYTABLE_NINF, syntax error. */ + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ #define YYTABLE_NINF -102 static const yytype_int16 yytable[] = { @@ -777,12 +776,6 @@ static const yytype_int16 yytable[] = 74, 75, 76, 77 }; -#define yypact_value_is_default(yystate) \ - ((yystate) == (-40)) - -#define yytable_value_is_error(yytable_value) \ - YYID (0) - static const yytype_int16 yycheck[] = { 7, 8, 21, 5, 6, 44, 44, 19, 44, 33, @@ -858,18 +851,9 @@ static const yytype_uint8 yystos[] = /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. However, - YYFAIL appears to be in use. Nevertheless, it is formally deprecated - in Bison 2.4.2's NEWS entry, where a plan to phase it out is - discussed. */ + Once GCC version 2 has supplanted version 1, this can go. */ #define YYFAIL goto yyerrlab -#if defined YYFAIL - /* This is here to suppress warnings from the GCC cpp's - -Wunused-macros. Normally we don't worry about that warning, but - some users do, and we want to make it easy for users to remove - YYFAIL uses, which will produce warnings from Bison 2.5. */ -#endif #define YYRECOVERING() (!!yyerrstatus) @@ -879,6 +863,7 @@ do \ { \ yychar = (Token); \ yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ YYPOPSTACK (1); \ goto yybackup; \ } \ @@ -925,7 +910,7 @@ while (YYID (0)) we won't break user code: when these are the locations we know. */ #ifndef YY_LOCATION_PRINT -# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# if YYLTYPE_IS_TRIVIAL # define YY_LOCATION_PRINT(File, Loc) \ fprintf (File, "%d.%d-%d.%d", \ (Loc).first_line, (Loc).first_column, \ @@ -1134,6 +1119,7 @@ int yydebug; # define YYMAXDEPTH 10000 #endif + #if YYERROR_VERBOSE @@ -1236,142 +1222,115 @@ yytnamerr (char *yyres, const char *yystr) } # endif -/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message - about the unexpected token YYTOKEN for the state stack whose top is - YYSSP. - - Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is - not large enough to hold the message. In that case, also set - *YYMSG_ALLOC to the required number of bytes. Return 2 if the - required number of bytes is too large to store. */ -static int -yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, - yytype_int16 *yyssp, int yytoken) +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) { - YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]); - YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - /* Internationalized format string. */ - const char *yyformat = 0; - /* Arguments of yyformat. */ - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - /* Number of reported tokens (one for the "unexpected", one per - "expected"). */ - int yycount = 0; + int yyn = yypact[yystate]; - /* There are many possibilities here to consider: - - Assume YYFAIL is not used. It's too flawed to consider. See - - for details. YYERROR is fine as it does not invoke this - function. - - If this state is a consistent state with a default action, then - the only way this function was invoked is if the default action - is an error action. In that case, don't check for expected - tokens because there are none. - - The only way there can be no lookahead present (in yychar) is if - this state is a consistent state with a default action. Thus, - detecting the absence of a lookahead is sufficient to determine - that there is no unexpected or expected token to report. In that - case, just report a simple "syntax error". - - Don't assume there isn't a lookahead just because this state is a - consistent state with a default action. There might have been a - previous inconsistent state, consistent state with a non-default - action, or user semantic action that manipulated yychar. - - Of course, the expected token list depends on states to have - correct lookahead information, and it depends on the parser not - to perform extra reductions after fetching a lookahead from the - scanner and before detecting a syntax error. Thus, state merging - (from LALR or IELR) and default reductions corrupt the expected - token list. However, the list is correct for canonical LR with - one exception: it will still contain any token that will not be - accepted due to an error action in a later state. - */ - if (yytoken != YYEMPTY) + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else { - int yyn = yypact[*yyssp]; - yyarg[yycount++] = yytname[yytoken]; - if (!yypact_value_is_default (yyn)) - { - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. In other words, skip the first -YYN actions for - this state because they are default actions. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yyx; + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR - && !yytable_value_is_error (yytable[yyx + yyn])) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - break; - } - yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (0, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; - } - } +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; } - - switch (yycount) - { -# define YYCASE_(N, S) \ - case N: \ - yyformat = S; \ - break - YYCASE_(0, YY_("syntax error")); - YYCASE_(1, YY_("syntax error, unexpected %s")); - YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); - YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); - YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); - YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); -# undef YYCASE_ - } - - yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; - - if (*yymsg_alloc < yysize) - { - *yymsg_alloc = 2 * yysize; - if (! (yysize <= *yymsg_alloc - && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) - *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; - return 1; - } - - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - { - char *yyp = *yymsg; - int yyi = 0; - while ((*yyp = *yyformat) != '\0') - if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyformat += 2; - } - else - { - yyp++; - yyformat++; - } - } - return 0; } #endif /* YYERROR_VERBOSE */ + /*-----------------------------------------------. | Release the memory associated to this symbol. | @@ -1408,7 +1367,6 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp, context) } } - /* Prevent warnings from -Wmissing-prototypes. */ #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus @@ -1425,9 +1383,12 @@ int yyparse (); #endif /* ! YYPARSE_PARAM */ -/*----------. -| yyparse. | -`----------*/ + + + +/*-------------------------. +| yyparse or yypush_parse. | +`-------------------------*/ #ifdef YYPARSE_PARAM #if (defined __STDC__ || defined __C99__FUNC__ \ @@ -1491,7 +1452,7 @@ YYLTYPE yylloc; YYLTYPE *yylsp; /* The locations where the error started and ended. */ - YYLTYPE yyerror_range[3]; + YYLTYPE yyerror_range[2]; YYSIZE_T yystacksize; @@ -1538,7 +1499,7 @@ YYLTYPE yylloc; yyvsp = yyvs; yylsp = yyls; -#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +#if YYLTYPE_IS_TRIVIAL /* Initialize the default location before parsing starts. */ yylloc.first_line = yylloc.last_line = 1; yylloc.first_column = yylloc.last_column = 1; @@ -1640,7 +1601,7 @@ yybackup: /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; - if (yypact_value_is_default (yyn)) + if (yyn == YYPACT_NINF) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ @@ -1671,8 +1632,8 @@ yybackup: yyn = yytable[yyn]; if (yyn <= 0) { - if (yytable_value_is_error (yyn)) - goto yyerrlab; + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; yyn = -yyn; goto yyreduce; } @@ -1728,95 +1689,95 @@ yyreduce: { case 2: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 183 "Ahuacatl/ahuacatl-grammar.y" { // a query or a sub-query always starts a new scope if (!TRI_StartScopeContextAql(context)) { ABORT_OOM } - } + ;} break; case 3: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 188 "Ahuacatl/ahuacatl-grammar.y" { // end the scope (yyval.node) = (TRI_aql_node_t*) TRI_GetFirstStatementAql(context); TRI_EndScopeContextAql(context); - } + ;} break; case 4: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 197 "Ahuacatl/ahuacatl-grammar.y" { - } + ;} break; case 5: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 199 "Ahuacatl/ahuacatl-grammar.y" { - } + ;} break; case 6: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 204 "Ahuacatl/ahuacatl-grammar.y" { - } + ;} break; case 7: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 206 "Ahuacatl/ahuacatl-grammar.y" { - } + ;} break; case 8: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 208 "Ahuacatl/ahuacatl-grammar.y" { - } + ;} break; case 9: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 210 "Ahuacatl/ahuacatl-grammar.y" { - } + ;} break; case 10: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 212 "Ahuacatl/ahuacatl-grammar.y" { - } + ;} break; case 11: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 214 "Ahuacatl/ahuacatl-grammar.y" { - } + ;} break; case 12: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 218 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeForAql(context, (yyvsp[(2) - (4)].strval), (yyvsp[(4) - (4)].node)); @@ -1829,12 +1790,12 @@ yyreduce: } (yyval.node) = node; - } + ;} break; case 13: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 233 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeFilterAql(context, (yyvsp[(2) - (2)].node)); @@ -1847,12 +1808,12 @@ yyreduce: } (yyval.node) = node; - } + ;} break; case 14: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 248 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeLetAql(context, (yyvsp[(2) - (4)].strval), (yyvsp[(4) - (4)].node)); @@ -1865,12 +1826,12 @@ yyreduce: } (yyval.node) = node; - } + ;} break; case 15: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 263 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeListAql(context); @@ -1880,12 +1841,12 @@ yyreduce: } TRI_PushStackParseAql(context, node); - } + ;} break; case 16: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 271 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeCollectAql(context, TRI_PopStackParseAql(context), (yyvsp[(4) - (4)].strval)); @@ -1898,28 +1859,28 @@ yyreduce: } (yyval.node) = node; - } + ;} break; case 17: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 286 "Ahuacatl/ahuacatl-grammar.y" { - } + ;} break; case 18: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 288 "Ahuacatl/ahuacatl-grammar.y" { - } + ;} break; case 19: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 293 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeAssignAql(context, (yyvsp[(1) - (3)].strval), (yyvsp[(3) - (3)].node)); @@ -1930,41 +1891,41 @@ yyreduce: if (!TRI_PushListAql(context, node)) { ABORT_OOM } - } + ;} break; case 20: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 303 "Ahuacatl/ahuacatl-grammar.y" { if (!TRI_PushListAql(context, (yyvsp[(1) - (1)].node))) { ABORT_OOM } - } + ;} break; case 21: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 311 "Ahuacatl/ahuacatl-grammar.y" { (yyval.strval) = NULL; - } + ;} break; case 22: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 314 "Ahuacatl/ahuacatl-grammar.y" { (yyval.strval) = (yyvsp[(2) - (2)].strval); - } + ;} break; case 23: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 320 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeListAql(context); @@ -1974,12 +1935,12 @@ yyreduce: } TRI_PushStackParseAql(context, node); - } + ;} break; case 24: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 328 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* list = TRI_PopStackParseAql(context); @@ -1993,34 +1954,34 @@ yyreduce: } (yyval.node) = node; - } + ;} break; case 25: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 344 "Ahuacatl/ahuacatl-grammar.y" { if (!TRI_PushListAql(context, (yyvsp[(1) - (1)].node))) { ABORT_OOM } - } + ;} break; case 26: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 349 "Ahuacatl/ahuacatl-grammar.y" { if (!TRI_PushListAql(context, (yyvsp[(3) - (3)].node))) { ABORT_OOM } - } + ;} break; case 27: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 357 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeSortElementAql(context, (yyvsp[(1) - (2)].node), (yyvsp[(2) - (2)].boolval)); @@ -2029,39 +1990,39 @@ yyreduce: } (yyval.node) = node; - } + ;} break; case 28: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 368 "Ahuacatl/ahuacatl-grammar.y" { (yyval.boolval) = true; - } + ;} break; case 29: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 371 "Ahuacatl/ahuacatl-grammar.y" { (yyval.boolval) = true; - } + ;} break; case 30: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 374 "Ahuacatl/ahuacatl-grammar.y" { (yyval.boolval) = false; - } + ;} break; case 31: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 380 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeLimitAql(context, TRI_CreateNodeValueIntAql(context, 0), TRI_CreateNodeValueIntAql(context, (yyvsp[(2) - (2)].intval))); @@ -2074,12 +2035,12 @@ yyreduce: } (yyval.node) = node; - } + ;} break; case 32: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 392 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeLimitAql(context, TRI_CreateNodeValueIntAql(context, (yyvsp[(2) - (4)].intval)), TRI_CreateNodeValueIntAql(context, (yyvsp[(4) - (4)].intval))); @@ -2092,12 +2053,12 @@ yyreduce: } (yyval.node) = node; - } + ;} break; case 33: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 407 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeReturnAql(context, (yyvsp[(2) - (2)].node)); @@ -2110,21 +2071,21 @@ yyreduce: } (yyval.node) = node; - } + ;} break; case 34: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 423 "Ahuacatl/ahuacatl-grammar.y" { (yyval.node) = (yyvsp[(2) - (3)].node); - } + ;} break; case 35: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 426 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* subQuery; @@ -2153,39 +2114,39 @@ yyreduce: // return the result (yyval.node) = result; - } + ;} break; case 36: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 454 "Ahuacatl/ahuacatl-grammar.y" { (yyval.node) = (yyvsp[(1) - (1)].node); - } + ;} break; case 37: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 457 "Ahuacatl/ahuacatl-grammar.y" { (yyval.node) = (yyvsp[(1) - (1)].node); - } + ;} break; case 38: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 460 "Ahuacatl/ahuacatl-grammar.y" { (yyval.node) = (yyvsp[(1) - (1)].node); - } + ;} break; case 39: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 463 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node; @@ -2200,12 +2161,12 @@ yyreduce: } TRI_PushStackParseAql(context, node); - } + ;} break; case 40: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 476 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* list = TRI_PopStackParseAql(context); @@ -2215,39 +2176,39 @@ yyreduce: } (yyval.node) = node; - } + ;} break; case 41: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 485 "Ahuacatl/ahuacatl-grammar.y" { (yyval.node) = (yyvsp[(1) - (1)].node); - } + ;} break; case 42: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 488 "Ahuacatl/ahuacatl-grammar.y" { (yyval.node) = (yyvsp[(1) - (1)].node); - } + ;} break; case 43: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 491 "Ahuacatl/ahuacatl-grammar.y" { (yyval.node) = (yyvsp[(1) - (1)].node); - } + ;} break; case 44: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 497 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeOperatorUnaryPlusAql(context, (yyvsp[(2) - (2)].node)); @@ -2256,12 +2217,12 @@ yyreduce: } (yyval.node) = node; - } + ;} break; case 45: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 505 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeOperatorUnaryMinusAql(context, (yyvsp[(2) - (2)].node)); @@ -2270,12 +2231,12 @@ yyreduce: } (yyval.node) = node; - } + ;} break; case 46: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 513 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeOperatorUnaryNotAql(context, (yyvsp[(2) - (2)].node)); @@ -2284,12 +2245,12 @@ yyreduce: } (yyval.node) = node; - } + ;} break; case 47: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 524 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryOrAql(context, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); @@ -2298,12 +2259,12 @@ yyreduce: } (yyval.node) = node; - } + ;} break; case 48: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 532 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryAndAql(context, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); @@ -2312,12 +2273,12 @@ yyreduce: } (yyval.node) = node; - } + ;} break; case 49: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 540 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryPlusAql(context, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); @@ -2326,12 +2287,12 @@ yyreduce: } (yyval.node) = node; - } + ;} break; case 50: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 548 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryMinusAql(context, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); @@ -2340,12 +2301,12 @@ yyreduce: } (yyval.node) = node; - } + ;} break; case 51: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 556 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryTimesAql(context, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); @@ -2354,12 +2315,12 @@ yyreduce: } (yyval.node) = node; - } + ;} break; case 52: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 564 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryDivAql(context, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); @@ -2368,12 +2329,12 @@ yyreduce: } (yyval.node) = node; - } + ;} break; case 53: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 572 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryModAql(context, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); @@ -2382,12 +2343,12 @@ yyreduce: } (yyval.node) = node; - } + ;} break; case 54: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 580 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryEqAql(context, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); @@ -2396,12 +2357,12 @@ yyreduce: } (yyval.node) = node; - } + ;} break; case 55: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 588 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryNeAql(context, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); @@ -2410,12 +2371,12 @@ yyreduce: } (yyval.node) = node; - } + ;} break; case 56: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 596 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryLtAql(context, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); @@ -2424,12 +2385,12 @@ yyreduce: } (yyval.node) = node; - } + ;} break; case 57: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 604 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryGtAql(context, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); @@ -2438,12 +2399,12 @@ yyreduce: } (yyval.node) = node; - } + ;} break; case 58: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 612 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryLeAql(context, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); @@ -2452,12 +2413,12 @@ yyreduce: } (yyval.node) = node; - } + ;} break; case 59: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 620 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryGeAql(context, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); @@ -2466,12 +2427,12 @@ yyreduce: } (yyval.node) = node; - } + ;} break; case 60: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 628 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryInAql(context, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); @@ -2480,12 +2441,12 @@ yyreduce: } (yyval.node) = node; - } + ;} break; case 61: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 639 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeOperatorTernaryAql(context, (yyvsp[(1) - (5)].node), (yyvsp[(3) - (5)].node), (yyvsp[(5) - (5)].node)); @@ -2494,64 +2455,64 @@ yyreduce: } (yyval.node) = node; - } + ;} break; case 62: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 650 "Ahuacatl/ahuacatl-grammar.y" { - } + ;} break; case 63: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 652 "Ahuacatl/ahuacatl-grammar.y" { - } + ;} break; case 64: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 657 "Ahuacatl/ahuacatl-grammar.y" { TRI_PushListAql(context, (yyvsp[(1) - (1)].node)); - } + ;} break; case 65: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 660 "Ahuacatl/ahuacatl-grammar.y" { TRI_PushListAql(context, (yyvsp[(3) - (3)].node)); - } + ;} break; case 66: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 666 "Ahuacatl/ahuacatl-grammar.y" { (yyval.node) = (yyvsp[(1) - (1)].node); - } + ;} break; case 67: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 669 "Ahuacatl/ahuacatl-grammar.y" { (yyval.node) = (yyvsp[(1) - (1)].node); - } + ;} break; case 68: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 675 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeListAql(context); @@ -2560,59 +2521,59 @@ yyreduce: } TRI_PushStackParseAql(context, node); - } + ;} break; case 69: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 682 "Ahuacatl/ahuacatl-grammar.y" { (yyval.node) = TRI_PopStackParseAql(context); - } + ;} break; case 70: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 688 "Ahuacatl/ahuacatl-grammar.y" { - } + ;} break; case 71: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 690 "Ahuacatl/ahuacatl-grammar.y" { - } + ;} break; case 72: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 695 "Ahuacatl/ahuacatl-grammar.y" { if (!TRI_PushListAql(context, (yyvsp[(1) - (1)].node))) { ABORT_OOM } - } + ;} break; case 73: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 700 "Ahuacatl/ahuacatl-grammar.y" { if (!TRI_PushListAql(context, (yyvsp[(3) - (3)].node))) { ABORT_OOM } - } + ;} break; case 74: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 708 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeArrayAql(context); @@ -2621,74 +2582,74 @@ yyreduce: } TRI_PushStackParseAql(context, node); - } + ;} break; case 75: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 715 "Ahuacatl/ahuacatl-grammar.y" { (yyval.node) = TRI_PopStackParseAql(context); - } + ;} break; case 76: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 721 "Ahuacatl/ahuacatl-grammar.y" { - } + ;} break; case 77: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 723 "Ahuacatl/ahuacatl-grammar.y" { - } + ;} break; case 78: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 728 "Ahuacatl/ahuacatl-grammar.y" { - } + ;} break; case 79: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 730 "Ahuacatl/ahuacatl-grammar.y" { - } + ;} break; case 80: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 735 "Ahuacatl/ahuacatl-grammar.y" { if (!TRI_PushArrayAql(context, (yyvsp[(1) - (3)].strval), (yyvsp[(3) - (3)].node))) { ABORT_OOM } - } + ;} break; case 81: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 744 "Ahuacatl/ahuacatl-grammar.y" { // start of reference (collection or variable name) (yyval.node) = (yyvsp[(1) - (1)].node); - } + ;} break; case 82: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 748 "Ahuacatl/ahuacatl-grammar.y" { // expanded variable access, e.g. variable[*] @@ -2714,12 +2675,12 @@ yyreduce: // push the variable TRI_PushStackParseAql(context, node); - } + ;} break; case 83: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 772 "Ahuacatl/ahuacatl-grammar.y" { // return from the "expansion" subrule @@ -2746,12 +2707,12 @@ yyreduce: if (!(yyval.node)) { ABORT_OOM } - } + ;} break; case 84: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 801 "Ahuacatl/ahuacatl-grammar.y" { // variable or collection @@ -2769,12 +2730,12 @@ yyreduce: } (yyval.node) = node; - } + ;} break; case 85: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 818 "Ahuacatl/ahuacatl-grammar.y" { // named variable access, e.g. variable.reference @@ -2783,12 +2744,12 @@ yyreduce: if (!(yyval.node)) { ABORT_OOM } - } + ;} break; case 86: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 826 "Ahuacatl/ahuacatl-grammar.y" { // indexed variable access, e.g. variable[index] @@ -2797,12 +2758,12 @@ yyreduce: if (!(yyval.node)) { ABORT_OOM } - } + ;} break; case 87: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 837 "Ahuacatl/ahuacatl-grammar.y" { // named variable access, continuation from * expansion, e.g. [*].variable.reference @@ -2813,12 +2774,12 @@ yyreduce: if (!(yyval.node)) { ABORT_OOM } - } + ;} break; case 88: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 847 "Ahuacatl/ahuacatl-grammar.y" { // indexed variable access, continuation from * expansion, e.g. [*].variable[index] @@ -2829,12 +2790,12 @@ yyreduce: if (!(yyval.node)) { ABORT_OOM } - } + ;} break; case 89: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 857 "Ahuacatl/ahuacatl-grammar.y" { // named variable access, continuation from * expansion, e.g. [*].variable.xx.reference @@ -2842,12 +2803,12 @@ yyreduce: if (!(yyval.node)) { ABORT_OOM } - } + ;} break; case 90: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 864 "Ahuacatl/ahuacatl-grammar.y" { // indexed variable access, continuation from * expansion, e.g. [*].variable.xx.[index] @@ -2855,30 +2816,30 @@ yyreduce: if (!(yyval.node)) { ABORT_OOM } - } + ;} break; case 91: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 874 "Ahuacatl/ahuacatl-grammar.y" { (yyval.node) = (yyvsp[(1) - (1)].node); - } + ;} break; case 92: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 877 "Ahuacatl/ahuacatl-grammar.y" { (yyval.node) = (yyvsp[(1) - (1)].node); - } + ;} break; case 93: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 883 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeValueStringAql(context, (yyvsp[(1) - (1)].strval)); @@ -2887,12 +2848,12 @@ yyreduce: } (yyval.node) = node; - } + ;} break; case 94: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 891 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node; @@ -2907,12 +2868,12 @@ yyreduce: } (yyval.node) = node; - } + ;} break; case 95: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 905 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeValueNullAql(context); @@ -2921,12 +2882,12 @@ yyreduce: } (yyval.node) = node; - } + ;} break; case 96: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 913 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeValueBoolAql(context, true); @@ -2935,12 +2896,12 @@ yyreduce: } (yyval.node) = node; - } + ;} break; case 97: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 921 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeValueBoolAql(context, false); @@ -2949,12 +2910,12 @@ yyreduce: } (yyval.node) = node; - } + ;} break; case 98: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 932 "Ahuacatl/ahuacatl-grammar.y" { TRI_aql_node_t* node = TRI_CreateNodeParameterAql(context, (yyvsp[(1) - (1)].strval)); @@ -2963,12 +2924,12 @@ yyreduce: } (yyval.node) = node; - } + ;} break; case 99: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 943 "Ahuacatl/ahuacatl-grammar.y" { if (!(yyvsp[(1) - (1)].strval)) { @@ -2976,12 +2937,12 @@ yyreduce: } (yyval.strval) = (yyvsp[(1) - (1)].strval); - } + ;} break; case 100: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 950 "Ahuacatl/ahuacatl-grammar.y" { if (!(yyvsp[(1) - (1)].strval)) { @@ -2989,21 +2950,21 @@ yyreduce: } (yyval.strval) = (yyvsp[(1) - (1)].strval); - } + ;} break; case 101: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 959 "Ahuacatl/ahuacatl-grammar.y" { (yyval.strval) = (yyvsp[(1) - (1)].strval); - } + ;} break; case 102: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 965 "Ahuacatl/ahuacatl-grammar.y" { if (!(yyvsp[(1) - (1)].strval)) { @@ -3011,12 +2972,12 @@ yyreduce: } (yyval.intval) = TRI_Int64String((yyvsp[(1) - (1)].strval)); - } + ;} break; case 103: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 972 "Ahuacatl/ahuacatl-grammar.y" { if (!(yyvsp[(2) - (2)].strval)) { @@ -3024,26 +2985,15 @@ yyreduce: } (yyval.intval) = - TRI_Int64String((yyvsp[(2) - (2)].strval)); - } + ;} break; -/* Line 1806 of yacc.c */ -#line 3034 "Ahuacatl/ahuacatl-grammar.c" +/* Line 1455 of yacc.c */ +#line 2995 "Ahuacatl/ahuacatl-grammar.c" default: break; } - /* User semantic actions sometimes alter yychar, and that requires - that yytoken be updated with the new translation. We take the - approach of translating immediately before every use of yytoken. - One alternative is translating here after every semantic action, - but that translation would be missed if the semantic action invokes - YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or - if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an - incorrect destructor might then be invoked immediately. In the - case of YYERROR or YYBACKUP, subsequent parser actions might lead - to an incorrect destructor call or verbose syntax error message - before the lookahead is translated. */ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YYPOPSTACK (yylen); @@ -3072,10 +3022,6 @@ yyreduce: | yyerrlab -- here on detecting error | `------------------------------------*/ yyerrlab: - /* Make sure we have latest lookahead translation. See comments at - user semantic actions for why this is necessary. */ - yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); - /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { @@ -3083,40 +3029,41 @@ yyerrlab: #if ! YYERROR_VERBOSE yyerror (&yylloc, context, YY_("syntax error")); #else -# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ - yyssp, yytoken) { - char const *yymsgp = YY_("syntax error"); - int yysyntax_error_status; - yysyntax_error_status = YYSYNTAX_ERROR; - if (yysyntax_error_status == 0) - yymsgp = yymsg; - else if (yysyntax_error_status == 1) - { - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); - if (!yymsg) - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - yysyntax_error_status = 2; - } - else - { - yysyntax_error_status = YYSYNTAX_ERROR; - yymsgp = yymsg; - } - } - yyerror (&yylloc, context, yymsgp); - if (yysyntax_error_status == 2) - goto yyexhaustedlab; + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (&yylloc, context, yymsg); + } + else + { + yyerror (&yylloc, context, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } } -# undef YYSYNTAX_ERROR #endif } - yyerror_range[1] = yylloc; + yyerror_range[0] = yylloc; if (yyerrstatus == 3) { @@ -3153,7 +3100,7 @@ yyerrorlab: if (/*CONSTCOND*/ 0) goto yyerrorlab; - yyerror_range[1] = yylsp[1-yylen]; + yyerror_range[0] = yylsp[1-yylen]; /* Do not reclaim the symbols of the rule which action triggered this YYERROR. */ YYPOPSTACK (yylen); @@ -3172,7 +3119,7 @@ yyerrlab1: for (;;) { yyn = yypact[yystate]; - if (!yypact_value_is_default (yyn)) + if (yyn != YYPACT_NINF) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) @@ -3187,7 +3134,7 @@ yyerrlab1: if (yyssp == yyss) YYABORT; - yyerror_range[1] = *yylsp; + yyerror_range[0] = *yylsp; yydestruct ("Error: popping", yystos[yystate], yyvsp, yylsp, context); YYPOPSTACK (1); @@ -3197,10 +3144,10 @@ yyerrlab1: *++yyvsp = yylval; - yyerror_range[2] = yylloc; + yyerror_range[1] = yylloc; /* Using YYLLOC is tempting, but would change the location of the lookahead. YYLOC is available though. */ - YYLLOC_DEFAULT (yyloc, yyerror_range, 2); + YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); *++yylsp = yyloc; /* Shift the error token. */ @@ -3236,13 +3183,8 @@ yyexhaustedlab: yyreturn: if (yychar != YYEMPTY) - { - /* Make sure we have latest lookahead translation. See comments at - user semantic actions for why this is necessary. */ - yytoken = YYTRANSLATE (yychar); - yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval, &yylloc, context); - } + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, &yylloc, context); /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); diff --git a/Ahuacatl/ahuacatl-grammar.h b/Ahuacatl/ahuacatl-grammar.h index a411b916e8..7940078974 100644 --- a/Ahuacatl/ahuacatl-grammar.h +++ b/Ahuacatl/ahuacatl-grammar.h @@ -1,8 +1,10 @@ -/* A Bison parser, made by GNU Bison 2.5. */ -/* Bison interface for Yacc-like parsers in C +/* A Bison parser, made by GNU Bison 2.4.1. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -95,7 +97,7 @@ typedef union YYSTYPE { -/* Line 2068 of yacc.c */ +/* Line 1676 of yacc.c */ #line 25 "Ahuacatl/ahuacatl-grammar.y" TRI_aql_node_t* node; @@ -105,8 +107,8 @@ typedef union YYSTYPE -/* Line 2068 of yacc.c */ -#line 110 "Ahuacatl/ahuacatl-grammar.h" +/* Line 1676 of yacc.c */ +#line 112 "Ahuacatl/ahuacatl-grammar.h" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ diff --git a/Ahuacatl/ahuacatl-optimiser.c b/Ahuacatl/ahuacatl-optimiser.c index 04b7ade116..a697131580 100644 --- a/Ahuacatl/ahuacatl-optimiser.c +++ b/Ahuacatl/ahuacatl-optimiser.c @@ -43,7 +43,11 @@ /// @{ //////////////////////////////////////////////////////////////////////////////// -static TRI_aql_node_t* ModifyNode (void*, TRI_aql_node_t*); +//////////////////////////////////////////////////////////////////////////////// +/// @brief optimise nodes recursively +//////////////////////////////////////////////////////////////////////////////// + +static TRI_aql_node_t* ProcessNode (void*, TRI_aql_node_t*); //////////////////////////////////////////////////////////////////////////////// /// @} @@ -382,7 +386,7 @@ static TRI_aql_node_t* OptimiseFcall (TRI_aql_context_t* const context, json = TRI_ExecuteResultContext(execContext); TRI_FreeExecutionContext(execContext); if (!json) { - TRI_SetErrorContextAql(context, TRI_ERROR_QUERY_SCRIPT, NULL); + TRI_SetErrorContextAql(context, TRI_ERROR_QUERY_SCRIPT, "function optimisation"); return NULL; } @@ -468,7 +472,7 @@ static TRI_aql_node_t* OptimiseFilter (TRI_aql_context_t* const context, if (changed) { // expression code was changed, re-optimise it - node->_members._buffer[0] = ModifyNode((void*) context, expression); + node->_members._buffer[0] = ProcessNode((void*) context, expression); expression = TRI_AQL_NODE_MEMBER(node, 0); // try again if it is constant @@ -828,7 +832,7 @@ static TRI_aql_node_t* OptimiseNode (TRI_aql_context_t* const context, /// this is the callback function used by the tree walker //////////////////////////////////////////////////////////////////////////////// -static TRI_aql_node_t* ModifyNode (void* data, TRI_aql_node_t* node) { +static TRI_aql_node_t* ProcessNode (void* data, TRI_aql_node_t* node) { TRI_aql_context_t* context = (TRI_aql_context_t*) data; TRI_aql_node_t* result = node; @@ -883,7 +887,7 @@ TRI_aql_node_t* TRI_OptimiseAql (TRI_aql_context_t* const context, TRI_aql_node_t* node) { TRI_aql_modify_tree_walker_t* walker; - walker = TRI_CreateModifyTreeWalkerAql((void*) context, &ModifyNode); + walker = TRI_CreateModifyTreeWalkerAql((void*) context, &ProcessNode); if (!walker) { TRI_SetErrorContextAql(context, TRI_ERROR_OUT_OF_MEMORY, NULL); return node; diff --git a/Ahuacatl/ahuacatl-parser-functions.c b/Ahuacatl/ahuacatl-parser-functions.c index 857e7b9f15..099f777787 100644 --- a/Ahuacatl/ahuacatl-parser-functions.c +++ b/Ahuacatl/ahuacatl-parser-functions.c @@ -73,7 +73,13 @@ void TRI_SetErrorParseAql (TRI_aql_context_t* const context, const int line, const int column) { char buffer[1024]; - char* region = TRI_GetContextErrorAql(context->_query, line, column); + char* region; + + assert(context); + assert(context->_query); + assert(message); + + region = TRI_GetContextErrorAql(context->_query, line, column); if (!region) { // OOM diff --git a/Ahuacatl/ahuacatl-tokens.c b/Ahuacatl/ahuacatl-tokens.c index 9c4b0186c0..6e12a94157 100644 --- a/Ahuacatl/ahuacatl-tokens.c +++ b/Ahuacatl/ahuacatl-tokens.c @@ -53,6 +53,7 @@ typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN @@ -83,8 +84,6 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif -#endif /* ! C99 */ - #endif /* ! FLEXINT_H */ #ifdef __cplusplus @@ -158,15 +157,7 @@ typedef void* yyscan_t; /* Size of default input buffer. */ #ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else #define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer. @@ -728,12 +719,7 @@ static int input (yyscan_t yyscanner ); /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else #define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */ @@ -741,7 +727,7 @@ static int input (yyscan_t yyscanner ); /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) +#define ECHO fwrite( yytext, yyleng, 1, yyout ) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -752,7 +738,7 @@ static int input (yyscan_t yyscanner ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - size_t n; \ + int n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -1991,8 +1977,8 @@ YY_BUFFER_STATE Ahuacatl_scan_string (yyconst char * yystr , yyscan_t yyscanner) /** Setup the input buffer state to scan the given bytes. The next call to Ahuacatllex() will * scan from a @e copy of @a bytes. - * @param yybytes the byte buffer to scan - * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * @param bytes the byte buffer to scan + * @param len the number of bytes in the buffer pointed to by @a bytes. * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ diff --git a/BasicsC/errors.dat b/BasicsC/errors.dat index 86630b35b5..81fd45bb1c 100644 --- a/BasicsC/errors.dat +++ b/BasicsC/errors.dat @@ -101,34 +101,20 @@ ERROR_AVOCADO_DATAFILE_FULL,1300,"datafile full","Will be raised when the datafi ERROR_QUERY_KILLED,1500,"query killed","Will be raised when a running query is killed by an explicit admin command." ERROR_QUERY_PARSE,1501,"%s","Will be raised when query is parsed and is found to be syntactially invalid." ERROR_QUERY_EMPTY,1502,"query is empty","Will be raised when an empty query is specified." -ERROR_QUERY_SPECIFICATION_INVALID,1503,"query specification invalid","Will be raised when a query is sent to the server with an incomplete or invalid query specification structure." -ERROR_QUERY_NUMBER_OUT_OF_RANGE,1504,"number '%s' is out of range","Will be raised when a numeric value inside a query is out of the allowed value range." -ERROR_QUERY_TOO_MANY_JOINS,1505,"too many joins.","Will be raised when the number of joins in a query is beyond the allowed value." -ERROR_QUERY_COLLECTION_NAME_INVALID,1506,"collection name '%s' is invalid","Will be raised when an invalid collection name is used in the from clause of a query." -ERROR_QUERY_COLLECTION_ALIAS_INVALID,1507,"collection alias '%s' is invalid","Will be raised when an invalid alias name is used for a collection." -ERROR_QUERY_COLLECTION_ALIAS_REDECLARED,1508,"collection alias '%s' is declared multiple times in the same query","Will be raised when the same alias name is declared multiple times in the same query's from clause." -ERROR_QUERY_COLLECTION_ALIAS_UNDECLARED,1509,"collection alias '%s' is used but was not declared in the from clause","Will be raised when an alias not declared in the from clause is used in the query." -ERROR_QUERY_COLLECTION_NOT_FOUND,1510,"unable to open collection '%s'","Will be raised when one of the collections referenced in the query was not found." -ERROR_QUERY_GEO_RESTRICTION_INVALID,1511,"geo restriction for alias '%s' is invalid","Will be raised when a specified geo restriction is invalid." -ERROR_QUERY_GEO_INDEX_MISSING,1512,"no suitable geo index found for geo restriction on '%s'","Will be raised when a geo restriction was specified but no suitable geo index is found to resolve it." -ERROR_QUERY_BIND_PARAMETER_MISSING,1513,"no value specified for declared bind parameter '%s'","Will be raised when a bind parameter was declared in the query but the query is being executed with no value for that parameter." -ERROR_QUERY_BIND_PARAMETER_REDECLARED,1514,"value for bind parameter '%s' is declared multiple times","Will be raised when a value gets specified multiple times for the same bind parameter." -ERROR_QUERY_BIND_PARAMETER_UNDECLARED,1515,"bind parameter '%s' was not declared in the query","Will be raised when a value gets specified for an undeclared bind parameter." -ERROR_QUERY_BIND_PARAMETER_VALUE_INVALID,1516,"invalid value for bind parameter '%s'","Will be raised when an invalid value is specified for one of the bind parameters." -ERROR_QUERY_BIND_PARAMETER_NUMBER_OUT_OF_RANGE,1517,"bind parameter number '%s' out of range","Will be specified when the numeric index for a bind parameter of type @n is out of the allowed range." -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 '%s'","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." -ERROR_QUERY_VARIABLE_NAME_INVALID,1524,"variable name '%s' has an invalid format","Will be raised when an invalid variable name is used." -ERROR_QUERY_BIND_PARAMETERS_INVALID,1525,"invalid structure of bind parameters","Will be raised when the structure of bind parameters passed has an unexpected format." -ERROR_QUERY_COLLECTION_LOCK_FAILED,1526,"unable to read-lock collection %s","Will be raised when a read lock on the collection cannot be acquired." -ERROR_QUERY_TOO_MANY_COLLECTIONS,1527,"too many collections","Will be raised when the number of collections in a query is beyond the allowed value." -ERROR_QUERY_INVALID_LOGICAL_VALUE,1528,"invalid logical value","Will be raised when a non-boolean value is used in a logical operation." -ERROR_QUERY_INVALID_ARITHMETIC_VALUE,1529,"invalid arithmetic value","Will be raised when a non-numeric value is used in an arithmetic operation." -ERROR_QUERY_DIVISON_BY_ZERO,1530,"division by zero","Will be raised when there is an attempt to divide by zero." -ERROR_QUERY_SCRIPT,1531,"runtime error","Will be raised when a runtime error is caused by the query." +ERROR_QUERY_SCRIPT,1503,"runtime error '%s'","Will be raised when a runtime error is caused by the query." +ERROR_QUERY_VARIABLE_NAME_INVALID,1510,"variable name '%s' has an invalid format","Will be raised when an invalid variable name is used." +ERROR_QUERY_VARIABLE_REDECLARED,1511,"variable '%s' is assigned multiple times","Will be raised when a variable gets re-assigned in a query." +ERROR_QUERY_COLLECTION_NOT_FOUND,1520,"unable to open collection '%s'","Will be raised when one of the collections referenced in the query was not found." +ERROR_QUERY_COLLECTION_LOCK_FAILED,1521,"unable to read-lock collection %s","Will be raised when a read lock on the collection cannot be acquired." +ERROR_QUERY_TOO_MANY_COLLECTIONS,1522,"too many collections","Will be raised when the number of collections in a query is beyond the allowed value." +ERROR_QUERY_DOCUMENT_ATTRIBUTE_REDECLARED,1530,"document attribute '%s' is assigned multiple times","Will be raised when a document attribute is re-assigned." +ERROR_QUERY_FUNCTION_NAME_UNKNOWN,1540,"usage of unknown function '%s'","Will be raised when an undefined function is called." +ERROR_QUERY_BIND_PARAMETERS_INVALID,1550,"invalid structure of bind parameters","Will be raised when the structure of bind parameters passed has an unexpected format." +ERROR_QUERY_BIND_PARAMETER_MISSING,1551,"no value specified for declared bind parameter '%s'","Will be raised when a bind parameter was declared in the query but the query is being executed with no value for that parameter." +ERROR_QUERY_BIND_PARAMETER_UNDECLARED,1552,"bind parameter '%s' was not declared in the query","Will be raised when a value gets specified for an undeclared bind parameter." +ERROR_QUERY_INVALID_LOGICAL_VALUE,1560,"invalid logical value","Will be raised when a non-boolean value is used in a logical operation." +ERROR_QUERY_INVALID_ARITHMETIC_VALUE,1561,"invalid arithmetic value","Will be raised when a non-numeric value is used in an arithmetic operation." +ERROR_QUERY_DIVISON_BY_ZERO,1562,"division by zero","Will be raised when there is an attempt to divide by zero." ################################################################################ ## AvocadoDB cursor errors diff --git a/BasicsC/voc-errors.c b/BasicsC/voc-errors.c index 554a2cc51e..61ffa7d20a 100644 --- a/BasicsC/voc-errors.c +++ b/BasicsC/voc-errors.c @@ -67,34 +67,20 @@ void TRI_InitialiseErrorMessages (void) { REG_ERROR(ERROR_QUERY_KILLED, "query killed"); REG_ERROR(ERROR_QUERY_PARSE, "%s"); REG_ERROR(ERROR_QUERY_EMPTY, "query is empty"); - REG_ERROR(ERROR_QUERY_SPECIFICATION_INVALID, "query specification invalid"); - REG_ERROR(ERROR_QUERY_NUMBER_OUT_OF_RANGE, "number '%s' is out of range"); - REG_ERROR(ERROR_QUERY_TOO_MANY_JOINS, "too many joins."); - REG_ERROR(ERROR_QUERY_COLLECTION_NAME_INVALID, "collection name '%s' is invalid"); - REG_ERROR(ERROR_QUERY_COLLECTION_ALIAS_INVALID, "collection alias '%s' is invalid"); - REG_ERROR(ERROR_QUERY_COLLECTION_ALIAS_REDECLARED, "collection alias '%s' is declared multiple times in the same query"); - REG_ERROR(ERROR_QUERY_COLLECTION_ALIAS_UNDECLARED, "collection alias '%s' is used but was not declared in the from clause"); - REG_ERROR(ERROR_QUERY_COLLECTION_NOT_FOUND, "unable to open collection '%s'"); - REG_ERROR(ERROR_QUERY_GEO_RESTRICTION_INVALID, "geo restriction for alias '%s' is invalid"); - REG_ERROR(ERROR_QUERY_GEO_INDEX_MISSING, "no suitable geo index found for geo restriction on '%s'"); - REG_ERROR(ERROR_QUERY_BIND_PARAMETER_MISSING, "no value specified for declared bind parameter '%s'"); - REG_ERROR(ERROR_QUERY_BIND_PARAMETER_REDECLARED, "value for bind parameter '%s' is declared multiple times"); - REG_ERROR(ERROR_QUERY_BIND_PARAMETER_UNDECLARED, "bind parameter '%s' was not declared in the query"); - REG_ERROR(ERROR_QUERY_BIND_PARAMETER_VALUE_INVALID, "invalid value for bind parameter '%s'"); - REG_ERROR(ERROR_QUERY_BIND_PARAMETER_NUMBER_OUT_OF_RANGE, "bind parameter number '%s' out of range"); - REG_ERROR(ERROR_QUERY_FUNCTION_NAME_UNKNOWN, "usage of unknown function '%s'"); - REG_ERROR(ERROR_QUERY_RUNTIME_ERROR, "runtime error '%s'"); - 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_QUERY_SCRIPT, "runtime error '%s'"); REG_ERROR(ERROR_QUERY_VARIABLE_NAME_INVALID, "variable name '%s' has an invalid format"); - REG_ERROR(ERROR_QUERY_BIND_PARAMETERS_INVALID, "invalid structure of bind parameters"); + REG_ERROR(ERROR_QUERY_VARIABLE_REDECLARED, "variable '%s' is assigned multiple times"); + REG_ERROR(ERROR_QUERY_COLLECTION_NOT_FOUND, "unable to open collection '%s'"); REG_ERROR(ERROR_QUERY_COLLECTION_LOCK_FAILED, "unable to read-lock collection %s"); REG_ERROR(ERROR_QUERY_TOO_MANY_COLLECTIONS, "too many collections"); + REG_ERROR(ERROR_QUERY_DOCUMENT_ATTRIBUTE_REDECLARED, "document attribute '%s' is assigned multiple times"); + REG_ERROR(ERROR_QUERY_FUNCTION_NAME_UNKNOWN, "usage of unknown function '%s'"); + REG_ERROR(ERROR_QUERY_BIND_PARAMETERS_INVALID, "invalid structure of bind parameters"); + REG_ERROR(ERROR_QUERY_BIND_PARAMETER_MISSING, "no value specified for declared bind parameter '%s'"); + REG_ERROR(ERROR_QUERY_BIND_PARAMETER_UNDECLARED, "bind parameter '%s' was not declared in the query"); REG_ERROR(ERROR_QUERY_INVALID_LOGICAL_VALUE, "invalid logical value"); REG_ERROR(ERROR_QUERY_INVALID_ARITHMETIC_VALUE, "invalid arithmetic value"); REG_ERROR(ERROR_QUERY_DIVISON_BY_ZERO, "division by zero"); - REG_ERROR(ERROR_QUERY_SCRIPT, "runtime error"); 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 aeaf3a46eb..b37403f3ef 100644 --- a/BasicsC/voc-errors.h +++ b/BasicsC/voc-errors.h @@ -135,80 +135,40 @@ extern "C" { /// invalid. /// - 1502: @CODE{query is empty} /// Will be raised when an empty query is specified. -/// - 1503: @CODE{query specification invalid} -/// Will be raised when a query is sent to the server with an incomplete or -/// invalid query specification structure. -/// - 1504: @CODE{number '\%s' is out of range} -/// Will be raised when a numeric value inside a query is out of the allowed -/// value range. -/// - 1505: @CODE{too many joins.} -/// Will be raised when the number of joins in a query is beyond the allowed -/// value. -/// - 1506: @CODE{collection name '\%s' is invalid} -/// Will be raised when an invalid collection name is used in the from clause -/// of a query. -/// - 1507: @CODE{collection alias '\%s' is invalid} -/// Will be raised when an invalid alias name is used for a collection. -/// - 1508: @CODE{collection alias '\%s' is declared multiple times in the same query} -/// Will be raised when the same alias name is declared multiple times in the -/// same query's from clause. -/// - 1509: @CODE{collection alias '\%s' is used but was not declared in the from clause} -/// Will be raised when an alias not declared in the from clause is used in -/// the query. -/// - 1510: @CODE{unable to open collection '\%s'} +/// - 1503: @CODE{runtime error '\%s'} +/// Will be raised when a runtime error is caused by the query. +/// - 1510: @CODE{variable name '\%s' has an invalid format} +/// Will be raised when an invalid variable name is used. +/// - 1511: @CODE{variable '\%s' is assigned multiple times} +/// Will be raised when a variable gets re-assigned in a query. +/// - 1520: @CODE{unable to open collection '\%s'} /// Will be raised when one of the collections referenced in the query was /// not found. -/// - 1511: @CODE{geo restriction for alias '\%s' is invalid} -/// Will be raised when a specified geo restriction is invalid. -/// - 1512: @CODE{no suitable geo index found for geo restriction on '\%s'} -/// Will be raised when a geo restriction was specified but no suitable geo -/// index is found to resolve it. -/// - 1513: @CODE{no value specified for declared bind parameter '\%s'} -/// Will be raised when a bind parameter was declared in the query but the -/// query is being executed with no value for that parameter. -/// - 1514: @CODE{value for bind parameter '\%s' is declared multiple times} -/// Will be raised when a value gets specified multiple times for the same -/// bind parameter. -/// - 1515: @CODE{bind parameter '\%s' was not declared in the query} -/// Will be raised when a value gets specified for an undeclared bind -/// parameter. -/// - 1516: @CODE{invalid value for bind parameter '\%s'} -/// Will be raised when an invalid value is specified for one of the bind -/// parameters. -/// - 1517: @CODE{bind parameter number '\%s' out of range} -/// Will be specified when the numeric index for a bind parameter of type @n -/// is out of the allowed range. -/// - 1518: @CODE{usage of unknown function '\%s'} -/// Will be raised when an undefined function is called. -/// - 1520: @CODE{runtime error '\%s'} -/// Will be raised when a Javascript runtime error occurs while executing a -/// query. -/// - 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. -/// - 1524: @CODE{variable name '\%s' has an invalid format} -/// Will be raised when an invalid variable name is used. -/// - 1525: @CODE{invalid structure of bind parameters} -/// Will be raised when the structure of bind parameters passed has an -/// unexpected format. -/// - 1526: @CODE{unable to read-lock collection \%s} +/// - 1521: @CODE{unable to read-lock collection \%s} /// Will be raised when a read lock on the collection cannot be acquired. -/// - 1527: @CODE{too many collections} +/// - 1522: @CODE{too many collections} /// Will be raised when the number of collections in a query is beyond the /// allowed value. -/// - 1528: @CODE{invalid logical value} +/// - 1530: @CODE{document attribute '\%s' is assigned multiple times} +/// Will be raised when a document attribute is re-assigned. +/// - 1540: @CODE{usage of unknown function '\%s'} +/// Will be raised when an undefined function is called. +/// - 1550: @CODE{invalid structure of bind parameters} +/// Will be raised when the structure of bind parameters passed has an +/// unexpected format. +/// - 1551: @CODE{no value specified for declared bind parameter '\%s'} +/// Will be raised when a bind parameter was declared in the query but the +/// query is being executed with no value for that parameter. +/// - 1552: @CODE{bind parameter '\%s' was not declared in the query} +/// Will be raised when a value gets specified for an undeclared bind +/// parameter. +/// - 1560: @CODE{invalid logical value} /// Will be raised when a non-boolean value is used in a logical operation. -/// - 1529: @CODE{invalid arithmetic value} +/// - 1561: @CODE{invalid arithmetic value} /// Will be raised when a non-numeric value is used in an arithmetic /// operation. -/// - 1530: @CODE{division by zero} +/// - 1562: @CODE{division by zero} /// Will be raised when there is an attempt to divide by zero. -/// - 1531: @CODE{runtime error} -/// Will be raised when a runtime error is caused by the query. /// - 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. @@ -909,83 +869,37 @@ void TRI_InitialiseErrorMessages (void); #define TRI_ERROR_QUERY_EMPTY (1502) //////////////////////////////////////////////////////////////////////////////// -/// @brief 1503: ERROR_QUERY_SPECIFICATION_INVALID +/// @brief 1503: ERROR_QUERY_SCRIPT /// -/// query specification invalid +/// runtime error '%s' /// -/// Will be raised when a query is sent to the server with an incomplete or -/// invalid query specification structure. +/// Will be raised when a runtime error is caused by the query. //////////////////////////////////////////////////////////////////////////////// -#define TRI_ERROR_QUERY_SPECIFICATION_INVALID (1503) +#define TRI_ERROR_QUERY_SCRIPT (1503) //////////////////////////////////////////////////////////////////////////////// -/// @brief 1504: ERROR_QUERY_NUMBER_OUT_OF_RANGE +/// @brief 1510: ERROR_QUERY_VARIABLE_NAME_INVALID /// -/// number '%s' is out of range +/// variable name '%s' has an invalid format /// -/// Will be raised when a numeric value inside a query is out of the allowed -/// value range. +/// Will be raised when an invalid variable name is used. //////////////////////////////////////////////////////////////////////////////// -#define TRI_ERROR_QUERY_NUMBER_OUT_OF_RANGE (1504) +#define TRI_ERROR_QUERY_VARIABLE_NAME_INVALID (1510) //////////////////////////////////////////////////////////////////////////////// -/// @brief 1505: ERROR_QUERY_TOO_MANY_JOINS +/// @brief 1511: ERROR_QUERY_VARIABLE_REDECLARED /// -/// too many joins. +/// variable '%s' is assigned multiple times /// -/// Will be raised when the number of joins in a query is beyond the allowed -/// value. +/// Will be raised when a variable gets re-assigned in a query. //////////////////////////////////////////////////////////////////////////////// -#define TRI_ERROR_QUERY_TOO_MANY_JOINS (1505) +#define TRI_ERROR_QUERY_VARIABLE_REDECLARED (1511) //////////////////////////////////////////////////////////////////////////////// -/// @brief 1506: ERROR_QUERY_COLLECTION_NAME_INVALID -/// -/// collection name '%s' is invalid -/// -/// Will be raised when an invalid collection name is used in the from clause -/// of a query. -//////////////////////////////////////////////////////////////////////////////// - -#define TRI_ERROR_QUERY_COLLECTION_NAME_INVALID (1506) - -//////////////////////////////////////////////////////////////////////////////// -/// @brief 1507: ERROR_QUERY_COLLECTION_ALIAS_INVALID -/// -/// collection alias '%s' is invalid -/// -/// Will be raised when an invalid alias name is used for a collection. -//////////////////////////////////////////////////////////////////////////////// - -#define TRI_ERROR_QUERY_COLLECTION_ALIAS_INVALID (1507) - -//////////////////////////////////////////////////////////////////////////////// -/// @brief 1508: ERROR_QUERY_COLLECTION_ALIAS_REDECLARED -/// -/// collection alias '%s' is declared multiple times in the same query -/// -/// Will be raised when the same alias name is declared multiple times in the -/// same query's from clause. -//////////////////////////////////////////////////////////////////////////////// - -#define TRI_ERROR_QUERY_COLLECTION_ALIAS_REDECLARED (1508) - -//////////////////////////////////////////////////////////////////////////////// -/// @brief 1509: ERROR_QUERY_COLLECTION_ALIAS_UNDECLARED -/// -/// collection alias '%s' is used but was not declared in the from clause -/// -/// Will be raised when an alias not declared in the from clause is used in the -/// query. -//////////////////////////////////////////////////////////////////////////////// - -#define TRI_ERROR_QUERY_COLLECTION_ALIAS_UNDECLARED (1509) - -//////////////////////////////////////////////////////////////////////////////// -/// @brief 1510: ERROR_QUERY_COLLECTION_NOT_FOUND +/// @brief 1520: ERROR_QUERY_COLLECTION_NOT_FOUND /// /// unable to open collection '%s' /// @@ -993,168 +907,20 @@ void TRI_InitialiseErrorMessages (void); /// found. //////////////////////////////////////////////////////////////////////////////// -#define TRI_ERROR_QUERY_COLLECTION_NOT_FOUND (1510) +#define TRI_ERROR_QUERY_COLLECTION_NOT_FOUND (1520) //////////////////////////////////////////////////////////////////////////////// -/// @brief 1511: ERROR_QUERY_GEO_RESTRICTION_INVALID -/// -/// geo restriction for alias '%s' is invalid -/// -/// Will be raised when a specified geo restriction is invalid. -//////////////////////////////////////////////////////////////////////////////// - -#define TRI_ERROR_QUERY_GEO_RESTRICTION_INVALID (1511) - -//////////////////////////////////////////////////////////////////////////////// -/// @brief 1512: ERROR_QUERY_GEO_INDEX_MISSING -/// -/// no suitable geo index found for geo restriction on '%s' -/// -/// Will be raised when a geo restriction was specified but no suitable geo -/// index is found to resolve it. -//////////////////////////////////////////////////////////////////////////////// - -#define TRI_ERROR_QUERY_GEO_INDEX_MISSING (1512) - -//////////////////////////////////////////////////////////////////////////////// -/// @brief 1513: ERROR_QUERY_BIND_PARAMETER_MISSING -/// -/// no value specified for declared bind parameter '%s' -/// -/// Will be raised when a bind parameter was declared in the query but the -/// query is being executed with no value for that parameter. -//////////////////////////////////////////////////////////////////////////////// - -#define TRI_ERROR_QUERY_BIND_PARAMETER_MISSING (1513) - -//////////////////////////////////////////////////////////////////////////////// -/// @brief 1514: ERROR_QUERY_BIND_PARAMETER_REDECLARED -/// -/// value for bind parameter '%s' is declared multiple times -/// -/// Will be raised when a value gets specified multiple times for the same bind -/// parameter. -//////////////////////////////////////////////////////////////////////////////// - -#define TRI_ERROR_QUERY_BIND_PARAMETER_REDECLARED (1514) - -//////////////////////////////////////////////////////////////////////////////// -/// @brief 1515: ERROR_QUERY_BIND_PARAMETER_UNDECLARED -/// -/// bind parameter '%s' was not declared in the query -/// -/// Will be raised when a value gets specified for an undeclared bind parameter. -//////////////////////////////////////////////////////////////////////////////// - -#define TRI_ERROR_QUERY_BIND_PARAMETER_UNDECLARED (1515) - -//////////////////////////////////////////////////////////////////////////////// -/// @brief 1516: ERROR_QUERY_BIND_PARAMETER_VALUE_INVALID -/// -/// invalid value for bind parameter '%s' -/// -/// Will be raised when an invalid value is specified for one of the bind -/// parameters. -//////////////////////////////////////////////////////////////////////////////// - -#define TRI_ERROR_QUERY_BIND_PARAMETER_VALUE_INVALID (1516) - -//////////////////////////////////////////////////////////////////////////////// -/// @brief 1517: ERROR_QUERY_BIND_PARAMETER_NUMBER_OUT_OF_RANGE -/// -/// bind parameter number '%s' out of range -/// -/// Will be specified when the numeric index for a bind parameter of type @n is -/// out of the allowed range. -//////////////////////////////////////////////////////////////////////////////// - -#define TRI_ERROR_QUERY_BIND_PARAMETER_NUMBER_OUT_OF_RANGE (1517) - -//////////////////////////////////////////////////////////////////////////////// -/// @brief 1518: ERROR_QUERY_FUNCTION_NAME_UNKNOWN -/// -/// usage of unknown function '%s' -/// -/// Will be raised when an undefined function is called. -//////////////////////////////////////////////////////////////////////////////// - -#define TRI_ERROR_QUERY_FUNCTION_NAME_UNKNOWN (1518) - -//////////////////////////////////////////////////////////////////////////////// -/// @brief 1520: ERROR_QUERY_RUNTIME_ERROR -/// -/// runtime error '%s' -/// -/// Will be raised when a Javascript runtime error occurs while executing a -/// query. -//////////////////////////////////////////////////////////////////////////////// - -#define TRI_ERROR_QUERY_RUNTIME_ERROR (1520) - -//////////////////////////////////////////////////////////////////////////////// -/// @brief 1521: ERROR_QUERY_LIMIT_VALUE_OUT_OF_RANGE -/// -/// 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). -//////////////////////////////////////////////////////////////////////////////// - -#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 1524: ERROR_QUERY_VARIABLE_NAME_INVALID -/// -/// variable name '%s' has an invalid format -/// -/// Will be raised when an invalid variable name is used. -//////////////////////////////////////////////////////////////////////////////// - -#define TRI_ERROR_QUERY_VARIABLE_NAME_INVALID (1524) - -//////////////////////////////////////////////////////////////////////////////// -/// @brief 1525: ERROR_QUERY_BIND_PARAMETERS_INVALID -/// -/// invalid structure of bind parameters -/// -/// Will be raised when the structure of bind parameters passed has an -/// unexpected format. -//////////////////////////////////////////////////////////////////////////////// - -#define TRI_ERROR_QUERY_BIND_PARAMETERS_INVALID (1525) - -//////////////////////////////////////////////////////////////////////////////// -/// @brief 1526: ERROR_QUERY_COLLECTION_LOCK_FAILED +/// @brief 1521: ERROR_QUERY_COLLECTION_LOCK_FAILED /// /// unable to read-lock collection %s /// /// Will be raised when a read lock on the collection cannot be acquired. //////////////////////////////////////////////////////////////////////////////// -#define TRI_ERROR_QUERY_COLLECTION_LOCK_FAILED (1526) +#define TRI_ERROR_QUERY_COLLECTION_LOCK_FAILED (1521) //////////////////////////////////////////////////////////////////////////////// -/// @brief 1527: ERROR_QUERY_TOO_MANY_COLLECTIONS +/// @brief 1522: ERROR_QUERY_TOO_MANY_COLLECTIONS /// /// too many collections /// @@ -1162,47 +928,89 @@ void TRI_InitialiseErrorMessages (void); /// allowed value. //////////////////////////////////////////////////////////////////////////////// -#define TRI_ERROR_QUERY_TOO_MANY_COLLECTIONS (1527) +#define TRI_ERROR_QUERY_TOO_MANY_COLLECTIONS (1522) //////////////////////////////////////////////////////////////////////////////// -/// @brief 1528: ERROR_QUERY_INVALID_LOGICAL_VALUE +/// @brief 1530: 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 (1530) + +//////////////////////////////////////////////////////////////////////////////// +/// @brief 1540: ERROR_QUERY_FUNCTION_NAME_UNKNOWN +/// +/// usage of unknown function '%s' +/// +/// Will be raised when an undefined function is called. +//////////////////////////////////////////////////////////////////////////////// + +#define TRI_ERROR_QUERY_FUNCTION_NAME_UNKNOWN (1540) + +//////////////////////////////////////////////////////////////////////////////// +/// @brief 1550: ERROR_QUERY_BIND_PARAMETERS_INVALID +/// +/// invalid structure of bind parameters +/// +/// Will be raised when the structure of bind parameters passed has an +/// unexpected format. +//////////////////////////////////////////////////////////////////////////////// + +#define TRI_ERROR_QUERY_BIND_PARAMETERS_INVALID (1550) + +//////////////////////////////////////////////////////////////////////////////// +/// @brief 1551: ERROR_QUERY_BIND_PARAMETER_MISSING +/// +/// no value specified for declared bind parameter '%s' +/// +/// Will be raised when a bind parameter was declared in the query but the +/// query is being executed with no value for that parameter. +//////////////////////////////////////////////////////////////////////////////// + +#define TRI_ERROR_QUERY_BIND_PARAMETER_MISSING (1551) + +//////////////////////////////////////////////////////////////////////////////// +/// @brief 1552: ERROR_QUERY_BIND_PARAMETER_UNDECLARED +/// +/// bind parameter '%s' was not declared in the query +/// +/// Will be raised when a value gets specified for an undeclared bind parameter. +//////////////////////////////////////////////////////////////////////////////// + +#define TRI_ERROR_QUERY_BIND_PARAMETER_UNDECLARED (1552) + +//////////////////////////////////////////////////////////////////////////////// +/// @brief 1560: ERROR_QUERY_INVALID_LOGICAL_VALUE /// /// invalid logical value /// /// Will be raised when a non-boolean value is used in a logical operation. //////////////////////////////////////////////////////////////////////////////// -#define TRI_ERROR_QUERY_INVALID_LOGICAL_VALUE (1528) +#define TRI_ERROR_QUERY_INVALID_LOGICAL_VALUE (1560) //////////////////////////////////////////////////////////////////////////////// -/// @brief 1529: ERROR_QUERY_INVALID_ARITHMETIC_VALUE +/// @brief 1561: ERROR_QUERY_INVALID_ARITHMETIC_VALUE /// /// invalid arithmetic value /// /// Will be raised when a non-numeric value is used in an arithmetic operation. //////////////////////////////////////////////////////////////////////////////// -#define TRI_ERROR_QUERY_INVALID_ARITHMETIC_VALUE (1529) +#define TRI_ERROR_QUERY_INVALID_ARITHMETIC_VALUE (1561) //////////////////////////////////////////////////////////////////////////////// -/// @brief 1530: ERROR_QUERY_DIVISON_BY_ZERO +/// @brief 1562: ERROR_QUERY_DIVISON_BY_ZERO /// /// division by zero /// /// Will be raised when there is an attempt to divide by zero. //////////////////////////////////////////////////////////////////////////////// -#define TRI_ERROR_QUERY_DIVISON_BY_ZERO (1530) - -//////////////////////////////////////////////////////////////////////////////// -/// @brief 1531: ERROR_QUERY_SCRIPT -/// -/// runtime error -/// -/// Will be raised when a runtime error is caused by the query. -//////////////////////////////////////////////////////////////////////////////// - -#define TRI_ERROR_QUERY_SCRIPT (1531) +#define TRI_ERROR_QUERY_DIVISON_BY_ZERO (1562) //////////////////////////////////////////////////////////////////////////////// /// @brief 1600: ERROR_CURSOR_NOT_FOUND diff --git a/Doxygen/avocado.doxy.in b/Doxygen/avocado.doxy.in index 91b872c544..d04fb79dbf 100644 --- a/Doxygen/avocado.doxy.in +++ b/Doxygen/avocado.doxy.in @@ -620,6 +620,7 @@ WARN_LOGFILE = INPUT = \ @srcdir@/Admin \ + @srcdir@/Ahuacatl \ @srcdir@/ApplicationServer \ @srcdir@/Basics \ @srcdir@/BasicsC \ @@ -664,7 +665,7 @@ RECURSIVE = YES EXCLUDE = \ @srcdir@/V8/v8-json.h \ @srcdir@/V8/v8-json.cpp \ - @srcdir@/QL/tokens.c + @srcdir@/Ahuacatl/ahuacatl-tokens.c # The EXCLUDE_SYMLINKS tag can be used select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded diff --git a/Makefile.in b/Makefile.in index 28febdad2b..ae3572612e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1039,6 +1039,7 @@ UNITTESTS_SERVER = $(addprefix --unit-tests ,$(SHELL_SERVER)) SHELL_SERVER_AHUACATL = @srcdir@/js/server/tests/ahuacatl-operators.js \ @srcdir@/js/server/tests/ahuacatl-escaping.js \ @srcdir@/js/server/tests/ahuacatl-functions.js \ + @srcdir@/js/server/tests/ahuacatl-queries-simple.js \ @srcdir@/js/server/tests/ahuacatl-queries-variables.js \ @srcdir@/js/server/tests/ahuacatl-queries-collection.js \ @srcdir@/js/server/tests/ahuacatl-queries-noncollection.js diff --git a/Makefile.unittests b/Makefile.unittests index 66ac981107..79d69e4a75 100644 --- a/Makefile.unittests +++ b/Makefile.unittests @@ -176,6 +176,7 @@ unittests-shell-server: SHELL_SERVER_AHUACATL = @srcdir@/js/server/tests/ahuacatl-operators.js \ @srcdir@/js/server/tests/ahuacatl-escaping.js \ @srcdir@/js/server/tests/ahuacatl-functions.js \ + @srcdir@/js/server/tests/ahuacatl-queries-simple.js \ @srcdir@/js/server/tests/ahuacatl-queries-variables.js \ @srcdir@/js/server/tests/ahuacatl-queries-collection.js \ @srcdir@/js/server/tests/ahuacatl-queries-noncollection.js diff --git a/RestServer/AvocadoServer.cpp b/RestServer/AvocadoServer.cpp index 0d75ac76d3..24367926ea 100644 --- a/RestServer/AvocadoServer.cpp +++ b/RestServer/AvocadoServer.cpp @@ -1062,6 +1062,9 @@ void AvocadoServer::openDatabase () { LOGGER_FATAL << "cannot open database '" << _databasePath << "'"; LOGGER_INFO << "please use the '--database.directory' option"; TRI_FlushLogging(); + + ApplicationUserManager::unloadUsers(); + ApplicationUserManager::unloadRoles(); exit(EXIT_FAILURE); } diff --git a/RestServer/home.dox b/RestServer/home.dox index edc932cca8..f1f5736820 100644 --- a/RestServer/home.dox +++ b/RestServer/home.dox @@ -67,10 +67,10 @@ /// @subsection HomePHP PHP /// /// There is a PHP client available in a separate project: -/// https://github.com/triAGENS/AvocadoDB-PHP +/// https://github.com/triAGENS/ArangoDB-PHP /// /// See also Packagist: -/// http://packagist.org/packages/triagens/Avocado +/// http://packagist.org/packages/triagens/ArangoDb /// /// @subsection HomePython Python /// diff --git a/V8/v8-vocbase.cpp b/V8/v8-vocbase.cpp index 1b810eb244..ae5e3d0863 100644 --- a/V8/v8-vocbase.cpp +++ b/V8/v8-vocbase.cpp @@ -1725,7 +1725,7 @@ static v8::Handle JS_RunAhuacatl (v8::Arguments const& argv) { } if (tryCatch.HasCaught()) { - TRI_SetErrorContextAql(context, TRI_ERROR_QUERY_RUNTIME_ERROR, TRI_ObjectToString(tryCatch.Exception()).c_str()); + TRI_SetErrorContextAql(context, TRI_ERROR_QUERY_SCRIPT, TRI_ObjectToString(tryCatch.Exception()).c_str()); v8::Handle errorObject = TRI_CreateErrorObjectAhuacatl(&context->_error); TRI_FreeContextAql(context); diff --git a/VocBase/collection.c b/VocBase/collection.c index 441cafdcf0..dc7fe03fe1 100644 --- a/VocBase/collection.c +++ b/VocBase/collection.c @@ -128,6 +128,7 @@ static bool CheckCollection (TRI_collection_t* collection) { char* filename; filename = TRI_Concatenate2File(collection->_directory, file); + // TODO: memory allocation might fail TRI_PushBackVectorString(&collection->_indexFiles, filename); } @@ -141,6 +142,7 @@ static bool CheckCollection (TRI_collection_t* collection) { TRI_col_header_marker_t* cm; filename = TRI_Concatenate2File(collection->_directory, file); + // TODO: memory allocation might fail datafile = TRI_OpenDatafile(filename); if (datafile == NULL) { @@ -152,6 +154,8 @@ static bool CheckCollection (TRI_collection_t* collection) { break; } + assert(datafile); + TRI_PushBackVectorPointer(&all, datafile); // check the document header @@ -242,8 +246,11 @@ static bool CheckCollection (TRI_collection_t* collection) { datafile = sealed._buffer[i]; number = TRI_StringUInt32(datafile->_fid); + // TODO: memory allocation might fail dname = TRI_Concatenate3String("datafile-", number, ".db"); + // TODO: memory allocation might fail filename = TRI_Concatenate2File(collection->_directory, dname); + // TODO: memory allocation might fail TRI_FreeString(TRI_CORE_MEM_ZONE, dname); TRI_FreeString(TRI_CORE_MEM_ZONE, number); @@ -546,6 +553,7 @@ int TRI_LoadParameterInfoCollection (char const* path, TRI_col_info_t* parameter // find parameter file filename = TRI_Concatenate2File(path, TRI_COL_PARAMETER_FILE); + // TODO: memory allocation might fail if (! TRI_ExistsFile(filename)) { TRI_FreeString(TRI_CORE_MEM_ZONE, filename); @@ -857,7 +865,7 @@ TRI_collection_t* TRI_OpenCollection (TRI_vocbase_t* vocbase, res = TRI_LoadParameterInfoCollection(path, &info); if (res != TRI_ERROR_NO_ERROR) { - LOG_ERROR("cannot save collection parameter '%s': '%s'", path, TRI_last_error()); + LOG_ERROR("cannot load collection parameter '%s': '%s'", path, TRI_last_error()); return NULL; } diff --git a/VocBase/datafile.c b/VocBase/datafile.c index 21a2493233..04272c1be5 100644 --- a/VocBase/datafile.c +++ b/VocBase/datafile.c @@ -309,8 +309,9 @@ static TRI_datafile_t* OpenDatafile (char const* filename, bool ignoreErrors) { // create datafile structure datafile = TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_datafile_t), false); + if (!datafile) { - // TODO: FIXME + return NULL; } InitDatafile(datafile, @@ -739,6 +740,8 @@ TRI_datafile_t* TRI_OpenDatafile (char const* filename) { close(datafile->_fd); LOG_ERROR("datafile '%s' is corrupt", datafile->_filename); + // must free datafile here + TRI_FreeDatafile(datafile); return NULL; } diff --git a/VocBase/vocbase.c b/VocBase/vocbase.c index 51111b3e03..d01b59c465 100644 --- a/VocBase/vocbase.c +++ b/VocBase/vocbase.c @@ -796,6 +796,8 @@ static int LoadCollectionVocBase (TRI_vocbase_t* vocbase, TRI_vocbase_col_t* col // someone else loaded the collection, release the WRITE lock and try again if (collection->_status == TRI_VOC_COL_STATUS_LOADED) { TRI_WRITE_UNLOCK_STATUS_VOCBASE_COL(collection); + + // TODO: might this cause endless recursion in some obscure cases?? return LoadCollectionVocBase(vocbase, collection); } @@ -804,6 +806,8 @@ static int LoadCollectionVocBase (TRI_vocbase_t* vocbase, TRI_vocbase_col_t* col if (collection->_status == TRI_VOC_COL_STATUS_UNLOADING) { collection->_status = TRI_VOC_COL_STATUS_LOADED; TRI_WRITE_UNLOCK_STATUS_VOCBASE_COL(collection); + + // TODO: might this cause endless recursion in some obscure cases?? return LoadCollectionVocBase(vocbase, collection); } @@ -829,6 +833,7 @@ static int LoadCollectionVocBase (TRI_vocbase_t* vocbase, TRI_vocbase_col_t* col return res; } + // TODO: might this cause endless recursion in some obscure cases?? return LoadCollectionVocBase(vocbase, collection); } @@ -855,6 +860,8 @@ static int LoadCollectionVocBase (TRI_vocbase_t* vocbase, TRI_vocbase_col_t* col // release the WRITE lock and try again TRI_WRITE_UNLOCK_STATUS_VOCBASE_COL(collection); + + // TODO: might this cause endless recursion in some obscure cases?? return LoadCollectionVocBase(vocbase, collection); } else { diff --git a/js/common/bootstrap/errors.js b/js/common/bootstrap/errors.js index 27fa31f9cb..4e970ff488 100644 --- a/js/common/bootstrap/errors.js +++ b/js/common/bootstrap/errors.js @@ -61,34 +61,20 @@ ModuleCache["/internal"].exports.errors = { "ERROR_QUERY_KILLED" : { "code" : 1500, "message" : "query killed" }, "ERROR_QUERY_PARSE" : { "code" : 1501, "message" : "%s" }, "ERROR_QUERY_EMPTY" : { "code" : 1502, "message" : "query is empty" }, - "ERROR_QUERY_SPECIFICATION_INVALID" : { "code" : 1503, "message" : "query specification invalid" }, - "ERROR_QUERY_NUMBER_OUT_OF_RANGE" : { "code" : 1504, "message" : "number '%s' is out of range" }, - "ERROR_QUERY_TOO_MANY_JOINS" : { "code" : 1505, "message" : "too many joins." }, - "ERROR_QUERY_COLLECTION_NAME_INVALID" : { "code" : 1506, "message" : "collection name '%s' is invalid" }, - "ERROR_QUERY_COLLECTION_ALIAS_INVALID" : { "code" : 1507, "message" : "collection alias '%s' is invalid" }, - "ERROR_QUERY_COLLECTION_ALIAS_REDECLARED" : { "code" : 1508, "message" : "collection alias '%s' is declared multiple times in the same query" }, - "ERROR_QUERY_COLLECTION_ALIAS_UNDECLARED" : { "code" : 1509, "message" : "collection alias '%s' is used but was not declared in the from clause" }, - "ERROR_QUERY_COLLECTION_NOT_FOUND" : { "code" : 1510, "message" : "unable to open collection '%s'" }, - "ERROR_QUERY_GEO_RESTRICTION_INVALID" : { "code" : 1511, "message" : "geo restriction for alias '%s' is invalid" }, - "ERROR_QUERY_GEO_INDEX_MISSING" : { "code" : 1512, "message" : "no suitable geo index found for geo restriction on '%s'" }, - "ERROR_QUERY_BIND_PARAMETER_MISSING" : { "code" : 1513, "message" : "no value specified for declared bind parameter '%s'" }, - "ERROR_QUERY_BIND_PARAMETER_REDECLARED" : { "code" : 1514, "message" : "value for bind parameter '%s' is declared multiple times" }, - "ERROR_QUERY_BIND_PARAMETER_UNDECLARED" : { "code" : 1515, "message" : "bind parameter '%s' was not declared in the query" }, - "ERROR_QUERY_BIND_PARAMETER_VALUE_INVALID" : { "code" : 1516, "message" : "invalid value for bind parameter '%s'" }, - "ERROR_QUERY_BIND_PARAMETER_NUMBER_OUT_OF_RANGE" : { "code" : 1517, "message" : "bind parameter number '%s' out of range" }, - "ERROR_QUERY_FUNCTION_NAME_UNKNOWN" : { "code" : 1518, "message" : "usage of unknown function '%s'" }, - "ERROR_QUERY_RUNTIME_ERROR" : { "code" : 1520, "message" : "runtime error '%s'" }, - "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_QUERY_VARIABLE_NAME_INVALID" : { "code" : 1524, "message" : "variable name '%s' has an invalid format" }, - "ERROR_QUERY_BIND_PARAMETERS_INVALID" : { "code" : 1525, "message" : "invalid structure of bind parameters" }, - "ERROR_QUERY_COLLECTION_LOCK_FAILED" : { "code" : 1526, "message" : "unable to read-lock collection %s" }, - "ERROR_QUERY_TOO_MANY_COLLECTIONS" : { "code" : 1527, "message" : "too many collections" }, - "ERROR_QUERY_INVALID_LOGICAL_VALUE" : { "code" : 1528, "message" : "invalid logical value" }, - "ERROR_QUERY_INVALID_ARITHMETIC_VALUE" : { "code" : 1529, "message" : "invalid arithmetic value" }, - "ERROR_QUERY_DIVISON_BY_ZERO" : { "code" : 1530, "message" : "division by zero" }, - "ERROR_QUERY_SCRIPT" : { "code" : 1531, "message" : "runtime error" }, + "ERROR_QUERY_SCRIPT" : { "code" : 1503, "message" : "runtime error '%s'" }, + "ERROR_QUERY_VARIABLE_NAME_INVALID" : { "code" : 1510, "message" : "variable name '%s' has an invalid format" }, + "ERROR_QUERY_VARIABLE_REDECLARED" : { "code" : 1511, "message" : "variable '%s' is assigned multiple times" }, + "ERROR_QUERY_COLLECTION_NOT_FOUND" : { "code" : 1520, "message" : "unable to open collection '%s'" }, + "ERROR_QUERY_COLLECTION_LOCK_FAILED" : { "code" : 1521, "message" : "unable to read-lock collection %s" }, + "ERROR_QUERY_TOO_MANY_COLLECTIONS" : { "code" : 1522, "message" : "too many collections" }, + "ERROR_QUERY_DOCUMENT_ATTRIBUTE_REDECLARED" : { "code" : 1530, "message" : "document attribute '%s' is assigned multiple times" }, + "ERROR_QUERY_FUNCTION_NAME_UNKNOWN" : { "code" : 1540, "message" : "usage of unknown function '%s'" }, + "ERROR_QUERY_BIND_PARAMETERS_INVALID" : { "code" : 1550, "message" : "invalid structure of bind parameters" }, + "ERROR_QUERY_BIND_PARAMETER_MISSING" : { "code" : 1551, "message" : "no value specified for declared bind parameter '%s'" }, + "ERROR_QUERY_BIND_PARAMETER_UNDECLARED" : { "code" : 1552, "message" : "bind parameter '%s' was not declared in the query" }, + "ERROR_QUERY_INVALID_LOGICAL_VALUE" : { "code" : 1560, "message" : "invalid logical value" }, + "ERROR_QUERY_INVALID_ARITHMETIC_VALUE" : { "code" : 1561, "message" : "invalid arithmetic value" }, + "ERROR_QUERY_DIVISON_BY_ZERO" : { "code" : 1562, "message" : "division by zero" }, "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 4c8ac4d2b0..f0750545d9 100644 --- a/js/common/bootstrap/js-errors.h +++ b/js/common/bootstrap/js-errors.h @@ -62,34 +62,20 @@ static string JS_common_bootstrap_errors = " \"ERROR_QUERY_KILLED\" : { \"code\" : 1500, \"message\" : \"query killed\" }, \n" " \"ERROR_QUERY_PARSE\" : { \"code\" : 1501, \"message\" : \"%s\" }, \n" " \"ERROR_QUERY_EMPTY\" : { \"code\" : 1502, \"message\" : \"query is empty\" }, \n" - " \"ERROR_QUERY_SPECIFICATION_INVALID\" : { \"code\" : 1503, \"message\" : \"query specification invalid\" }, \n" - " \"ERROR_QUERY_NUMBER_OUT_OF_RANGE\" : { \"code\" : 1504, \"message\" : \"number '%s' is out of range\" }, \n" - " \"ERROR_QUERY_TOO_MANY_JOINS\" : { \"code\" : 1505, \"message\" : \"too many joins.\" }, \n" - " \"ERROR_QUERY_COLLECTION_NAME_INVALID\" : { \"code\" : 1506, \"message\" : \"collection name '%s' is invalid\" }, \n" - " \"ERROR_QUERY_COLLECTION_ALIAS_INVALID\" : { \"code\" : 1507, \"message\" : \"collection alias '%s' is invalid\" }, \n" - " \"ERROR_QUERY_COLLECTION_ALIAS_REDECLARED\" : { \"code\" : 1508, \"message\" : \"collection alias '%s' is declared multiple times in the same query\" }, \n" - " \"ERROR_QUERY_COLLECTION_ALIAS_UNDECLARED\" : { \"code\" : 1509, \"message\" : \"collection alias '%s' is used but was not declared in the from clause\" }, \n" - " \"ERROR_QUERY_COLLECTION_NOT_FOUND\" : { \"code\" : 1510, \"message\" : \"unable to open collection '%s'\" }, \n" - " \"ERROR_QUERY_GEO_RESTRICTION_INVALID\" : { \"code\" : 1511, \"message\" : \"geo restriction for alias '%s' is invalid\" }, \n" - " \"ERROR_QUERY_GEO_INDEX_MISSING\" : { \"code\" : 1512, \"message\" : \"no suitable geo index found for geo restriction on '%s'\" }, \n" - " \"ERROR_QUERY_BIND_PARAMETER_MISSING\" : { \"code\" : 1513, \"message\" : \"no value specified for declared bind parameter '%s'\" }, \n" - " \"ERROR_QUERY_BIND_PARAMETER_REDECLARED\" : { \"code\" : 1514, \"message\" : \"value for bind parameter '%s' is declared multiple times\" }, \n" - " \"ERROR_QUERY_BIND_PARAMETER_UNDECLARED\" : { \"code\" : 1515, \"message\" : \"bind parameter '%s' was not declared in the query\" }, \n" - " \"ERROR_QUERY_BIND_PARAMETER_VALUE_INVALID\" : { \"code\" : 1516, \"message\" : \"invalid value for bind parameter '%s'\" }, \n" - " \"ERROR_QUERY_BIND_PARAMETER_NUMBER_OUT_OF_RANGE\" : { \"code\" : 1517, \"message\" : \"bind parameter number '%s' out of range\" }, \n" - " \"ERROR_QUERY_FUNCTION_NAME_UNKNOWN\" : { \"code\" : 1518, \"message\" : \"usage of unknown function '%s'\" }, \n" - " \"ERROR_QUERY_RUNTIME_ERROR\" : { \"code\" : 1520, \"message\" : \"runtime error '%s'\" }, \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_QUERY_VARIABLE_NAME_INVALID\" : { \"code\" : 1524, \"message\" : \"variable name '%s' has an invalid format\" }, \n" - " \"ERROR_QUERY_BIND_PARAMETERS_INVALID\" : { \"code\" : 1525, \"message\" : \"invalid structure of bind parameters\" }, \n" - " \"ERROR_QUERY_COLLECTION_LOCK_FAILED\" : { \"code\" : 1526, \"message\" : \"unable to read-lock collection %s\" }, \n" - " \"ERROR_QUERY_TOO_MANY_COLLECTIONS\" : { \"code\" : 1527, \"message\" : \"too many collections\" }, \n" - " \"ERROR_QUERY_INVALID_LOGICAL_VALUE\" : { \"code\" : 1528, \"message\" : \"invalid logical value\" }, \n" - " \"ERROR_QUERY_INVALID_ARITHMETIC_VALUE\" : { \"code\" : 1529, \"message\" : \"invalid arithmetic value\" }, \n" - " \"ERROR_QUERY_DIVISON_BY_ZERO\" : { \"code\" : 1530, \"message\" : \"division by zero\" }, \n" - " \"ERROR_QUERY_SCRIPT\" : { \"code\" : 1531, \"message\" : \"runtime error\" }, \n" + " \"ERROR_QUERY_SCRIPT\" : { \"code\" : 1503, \"message\" : \"runtime error '%s'\" }, \n" + " \"ERROR_QUERY_VARIABLE_NAME_INVALID\" : { \"code\" : 1510, \"message\" : \"variable name '%s' has an invalid format\" }, \n" + " \"ERROR_QUERY_VARIABLE_REDECLARED\" : { \"code\" : 1511, \"message\" : \"variable '%s' is assigned multiple times\" }, \n" + " \"ERROR_QUERY_COLLECTION_NOT_FOUND\" : { \"code\" : 1520, \"message\" : \"unable to open collection '%s'\" }, \n" + " \"ERROR_QUERY_COLLECTION_LOCK_FAILED\" : { \"code\" : 1521, \"message\" : \"unable to read-lock collection %s\" }, \n" + " \"ERROR_QUERY_TOO_MANY_COLLECTIONS\" : { \"code\" : 1522, \"message\" : \"too many collections\" }, \n" + " \"ERROR_QUERY_DOCUMENT_ATTRIBUTE_REDECLARED\" : { \"code\" : 1530, \"message\" : \"document attribute '%s' is assigned multiple times\" }, \n" + " \"ERROR_QUERY_FUNCTION_NAME_UNKNOWN\" : { \"code\" : 1540, \"message\" : \"usage of unknown function '%s'\" }, \n" + " \"ERROR_QUERY_BIND_PARAMETERS_INVALID\" : { \"code\" : 1550, \"message\" : \"invalid structure of bind parameters\" }, \n" + " \"ERROR_QUERY_BIND_PARAMETER_MISSING\" : { \"code\" : 1551, \"message\" : \"no value specified for declared bind parameter '%s'\" }, \n" + " \"ERROR_QUERY_BIND_PARAMETER_UNDECLARED\" : { \"code\" : 1552, \"message\" : \"bind parameter '%s' was not declared in the query\" }, \n" + " \"ERROR_QUERY_INVALID_LOGICAL_VALUE\" : { \"code\" : 1560, \"message\" : \"invalid logical value\" }, \n" + " \"ERROR_QUERY_INVALID_ARITHMETIC_VALUE\" : { \"code\" : 1561, \"message\" : \"invalid arithmetic value\" }, \n" + " \"ERROR_QUERY_DIVISON_BY_ZERO\" : { \"code\" : 1562, \"message\" : \"division by zero\" }, \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" diff --git a/js/server/tests/ahuacatl-queries-simple.js b/js/server/tests/ahuacatl-queries-simple.js new file mode 100644 index 0000000000..48a9748b6c --- /dev/null +++ b/js/server/tests/ahuacatl-queries-simple.js @@ -0,0 +1,330 @@ +//////////////////////////////////////////////////////////////////////////////// +/// @brief tests for query language, simple queries +/// +/// @file +/// +/// DISCLAIMER +/// +/// Copyright 2010-2012 triagens GmbH, Cologne, Germany +/// +/// Licensed under the Apache License, Version 2.0 (the "License"); +/// you may not use this file except in compliance with the License. +/// You may obtain a copy of the License at +/// +/// http://www.apache.org/licenses/LICENSE-2.0 +/// +/// Unless required by applicable law or agreed to in writing, software +/// distributed under the License is distributed on an "AS IS" BASIS, +/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +/// See the License for the specific language governing permissions and +/// limitations under the License. +/// +/// Copyright holder is triAGENS GmbH, Cologne, Germany +/// +/// @author Jan Steemann +/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany +//////////////////////////////////////////////////////////////////////////////// + +var jsunity = require("jsunity"); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test suite +//////////////////////////////////////////////////////////////////////////////// + +function ahuacatlQuerySimpleTestSuite () { + + //////////////////////////////////////////////////////////////////////////////// +/// @brief execute a given query +//////////////////////////////////////////////////////////////////////////////// + + function executeQuery (query) { + var cursor = AHUACATL_RUN(query, undefined); + if (cursor instanceof AvocadoError) { + print(query, cursor.errorMessage); + } + assertFalse(cursor instanceof AvocadoError); + return cursor; + } + +//////////////////////////////////////////////////////////////////////////////// +/// @brief execute a given query and return the results as an array +//////////////////////////////////////////////////////////////////////////////// + + function getQueryResults (query) { + var result = executeQuery(query).getRows(); + var results = [ ]; + + for (var i in result) { + if (!result.hasOwnProperty(i)) { + continue; + } + + results.push(result[i]); + } + + return results; + } + + + return { + +//////////////////////////////////////////////////////////////////////////////// +/// @brief set up +//////////////////////////////////////////////////////////////////////////////// + + setUp : function () { + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief tear down +//////////////////////////////////////////////////////////////////////////////// + + tearDown : function () { + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief return null +//////////////////////////////////////////////////////////////////////////////// + + testReturnOnlyQuery1 : function () { + var expected = [ null ]; + + var actual = getQueryResults("return null"); + assertEqual(expected, actual); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief return a number +//////////////////////////////////////////////////////////////////////////////// + + testReturnOnlyQuery2 : function () { + var expected = [ 0 ]; + + var actual = getQueryResults("return 0"); + assertEqual(expected, actual); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief return a string +//////////////////////////////////////////////////////////////////////////////// + + testReturnOnlyQuery3 : function () { + var expected = [ "a string value" ]; + + var actual = getQueryResults("return \"a string value\""); + assertEqual(expected, actual); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief return a list +//////////////////////////////////////////////////////////////////////////////// + + testReturnOnlyQuery4 : function () { + var expected = [ [ 1, 2, 9 ] ]; + + var actual = getQueryResults("return [ 1, 2, 9 ]"); + assertEqual(expected, actual); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief return an array +//////////////////////////////////////////////////////////////////////////////// + + testReturnOnlyQuery5 : function () { + var expected = [ { "name" : "Peter", "id" : 15, "age" : 35, "active" : false, "likes" : [ ] } ]; + + var actual = getQueryResults("return { \"name\" : \"Peter\", \"id\" : 15, \"age\" : 35, \"active\" : false, \"likes\" : [ ] }"); + assertEqual(expected, actual); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief return a list of arrays +//////////////////////////////////////////////////////////////////////////////// + + testReturnOnlyQuery6 : function () { + var expected = [ [ { "name" : "Max", "id" : 1 }, { "name" : "Vanessa", "id" : 2 }, { "unrelated" : [ "some", "stuff", "goes", "here" ] } ] ]; + + var actual = getQueryResults("return [ { \"name\" : \"Max\", \"id\" : 1 }, { \"name\" : \"Vanessa\", \"id\" : 2 }, { \"unrelated\" : [ \"some\", \"stuff\", \"goes\", \"here\" ] } ]"); + assertEqual(expected, actual); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief return a computed value +//////////////////////////////////////////////////////////////////////////////// + + testReturnOnlyQuery7 : function () { + var expected = [ 42 ]; + + var actual = getQueryResults("return 1 + 40 + 1"); + assertEqual(expected, actual); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief return a value from let +//////////////////////////////////////////////////////////////////////////////// + + testReturnLet1 : function () { + var expected = [ 1 ]; + + var actual = getQueryResults("let x = 1 return x"); + assertEqual(expected, actual); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief return a value from let +//////////////////////////////////////////////////////////////////////////////// + + testReturnLet2 : function () { + var expected = [ [ 1, 2, 42 ] ]; + + var actual = getQueryResults("let x = [ 1, 2, 42 ] return x"); + assertEqual(expected, actual); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief return a value from let +//////////////////////////////////////////////////////////////////////////////// + + testReturnLet3 : function () { + var expected = [ null ]; + + var actual = getQueryResults("let x = null return x"); + assertEqual(expected, actual); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief return a value from let +//////////////////////////////////////////////////////////////////////////////// + + testReturnLet4 : function () { + var expected = [ [ 1, 2, 3 ] ]; + + var actual = getQueryResults("let x = (for u in [ 1, 2, 3 ] return u) return x"); + assertEqual(expected, actual); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief return a value from let +//////////////////////////////////////////////////////////////////////////////// + + testReturnLet5 : function () { + var expected = [ [ 2, 3, 4 ] ]; + + var actual = getQueryResults("let x = (for u in (for v in [ 1, 2, 3 ] return v + 1) return u) return x"); + assertEqual(expected, actual); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief return a value from let +//////////////////////////////////////////////////////////////////////////////// + + testReturnLet6 : function () { + var expected = [ [ 1 ] ]; + + var actual = getQueryResults("let x = (return 1) return x"); + assertEqual(expected, actual); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief return a value from a filter +//////////////////////////////////////////////////////////////////////////////// + + testReturnFilter1 : function () { + var expected = [ ]; + + var actual = getQueryResults("filter 1 == 0 return 1"); + assertEqual(expected, actual); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief return a value from a filter +//////////////////////////////////////////////////////////////////////////////// + + testReturnFilter2 : function () { + var expected = [ ]; + + var actual = getQueryResults("filter 1 == 1 filter 1 == 0 return 1"); + assertEqual(expected, actual); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief return a value from a filter +//////////////////////////////////////////////////////////////////////////////// + + testReturnFilter3 : function () { + var expected = [ 1 ]; + + var actual = getQueryResults("filter 1 == 1 return 1"); + assertEqual(expected, actual); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief return a value from a filter +//////////////////////////////////////////////////////////////////////////////// + + testReturnFilter4 : function () { + var expected = [ 1 ]; + + var actual = getQueryResults("filter 1 == 1 filter \"true\" == \"true\" return 1"); + assertEqual(expected, actual); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief return a value from a filter +//////////////////////////////////////////////////////////////////////////////// + + testReturnFilter5 : function () { + var expected = [ 2 ]; + + var actual = getQueryResults("let x = (filter 1 == 1 return 1) return 2"); + assertEqual(expected, actual); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief return a value from a filter +//////////////////////////////////////////////////////////////////////////////// + + testReturnFilter6 : function () { + var expected = [ ]; + + var actual = getQueryResults("let x = (filter 0 == 1 return 1) return 2"); + assertEqual(expected, actual); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief return a value from a filter +//////////////////////////////////////////////////////////////////////////////// + + testReturnFilter7 : function () { + var expected = [ ]; + + var actual = getQueryResults("let x = (filter 0 == 1 return 1) filter x == [ 1 ] return 2"); + assertEqual(expected, actual); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief return a value from a filter +//////////////////////////////////////////////////////////////////////////////// + + testReturnFilter8 : function () { + var expected = [ 2 ]; + + var actual = getQueryResults("let x = (filter 1 == 1 return 1) filter x == [ 1 ] return 2"); + assertEqual(expected, actual); + }, + + }; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief executes the test suite +//////////////////////////////////////////////////////////////////////////////// + +jsunity.run(ahuacatlQuerySimpleTestSuite); + +return jsunity.done(); + +// Local Variables: +// mode: outline-minor +// outline-regexp: "^\\(/// @brief\\|/// @addtogroup\\|// --SECTION--\\|/// @page\\|/// @}\\)" +// End: