From: Sebastian Harl Date: Tue, 4 Nov 2014 19:14:32 +0000 (+0100) Subject: frontend: Let the parser run the analyzer. X-Git-Tag: sysdb-0.6.0~31 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=0b126bada8e1baa0ee4fe82ef182bb4139cd83bf;p=sysdb.git frontend: Let the parser run the analyzer. … but only when parsing a full statement. Otherwise, the analyzer is missing the context for verification. --- diff --git a/src/frontend/parser.c b/src/frontend/parser.c index 785b7e4..f8c82d3 100644 --- a/src/frontend/parser.c +++ b/src/frontend/parser.c @@ -72,6 +72,7 @@ sdb_fe_parse(const char *query, int len) { sdb_fe_yyscan_t scanner; sdb_fe_yyextra_t yyextra; + sdb_llist_iter_t *iter; int yyres; if (scanner_init(query, len, &scanner, &yyextra)) @@ -84,6 +85,18 @@ sdb_fe_parse(const char *query, int len) sdb_llist_destroy(yyextra.parsetree); return NULL; } + + iter = sdb_llist_get_iter(yyextra.parsetree); + while (sdb_llist_iter_has_next(iter)) { + sdb_conn_node_t *node; + node = SDB_CONN_NODE(sdb_llist_iter_get_next(iter)); + if (sdb_fe_analyze(node)) { + sdb_llist_iter_destroy(iter); + sdb_llist_destroy(yyextra.parsetree); + return NULL; + } + } + sdb_llist_iter_destroy(iter); return yyextra.parsetree; } /* sdb_fe_parse */ diff --git a/src/frontend/query.c b/src/frontend/query.c index 7b105e7..e5a1fc4 100644 --- a/src/frontend/query.c +++ b/src/frontend/query.c @@ -107,16 +107,7 @@ sdb_fe_query(sdb_conn_t *conn) } if (node) { - if (sdb_fe_analyze(node)) { - char query[conn->cmd_len + 1]; - strncpy(query, sdb_strbuf_string(conn->buf), conn->cmd_len); - query[sizeof(query) - 1] = '\0'; - sdb_log(SDB_LOG_ERR, "frontend: Failed to verify query '%s'", - query); - status = -1; - } - else - status = sdb_fe_exec(conn, node); + status = sdb_fe_exec(conn, node); sdb_object_deref(SDB_OBJ(node)); } @@ -214,6 +205,8 @@ sdb_fe_lookup(sdb_conn_t *conn) node.type = type; m_node.matcher = m; + /* run analyzer separately; parse_matcher is missing + * the right context to do so */ if (sdb_fe_analyze(SDB_CONN_NODE(&node))) { char expr[matcher_len + 1]; strncpy(expr, matcher, sizeof(expr));