From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 720FD26AD3 for ; Mon, 4 Jun 2018 09:27:31 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vLXdC1PThCoX for ; Mon, 4 Jun 2018 09:27:31 -0400 (EDT) Received: from smtp29.i.mail.ru (smtp29.i.mail.ru [94.100.177.89]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 2CA2E26B1E for ; Mon, 4 Jun 2018 09:27:31 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH v1 0/4] sql: remove Triggers to server References: From: Vladislav Shpilevoy Message-ID: <18d2ee06-3eca-bd53-be41-d580ae0f834e@tarantool.org> Date: Mon, 4 Jun 2018 16:27:29 +0300 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: Kirill Shcherbatov , tarantool-patches@freelists.org Thanks for the patch! Why did not you send it? See 1 comment below. > commit 7e6143c51e520f68db9a4fe96d6980ba65f653d8 > Author: Kirill Shcherbatov > Date: Fri Jun 1 15:38:30 2018 +0300 > > sql: refactor sql_expr_compile to return AST > > diff --git a/src/box/sql/tokenize.c b/src/box/sql/tokenize.c > index 42c70a255..2555adbf4 100644 > --- a/src/box/sql/tokenize.c > +++ b/src/box/sql/tokenize.c > @@ -539,9 +539,8 @@ sqlite3RunParser(Parse * pParse, const char *zSql, char **pzErrMsg) > return nErr; > } > > -int > -sql_expr_compile(sqlite3 *db, const char *expr, int expr_len, > - struct Expr **result) > +struct Expr * > +sql_expr_compile(sqlite3 *db, const char *expr, int expr_len) > { > const char *outer = "SELECT "; > int len = strlen(outer) + expr_len; > @@ -550,19 +549,23 @@ sql_expr_compile(sqlite3 *db, const char *expr, int expr_len, > sql_parser_create(&parser, db); > parser.parse_only = true; > > + struct Expr *expression = NULL; > char *stmt = (char *)region_alloc(&parser.region, len + 1); > if (stmt == NULL) { > diag_set(OutOfMemory, len + 1, "region_alloc", "stmt"); > - return -1; > + goto cleanup; > } > sprintf(stmt, "%s%.*s", outer, expr_len, expr); > > - char *unused; > - if (sqlite3RunParser(&parser, stmt, &unused) != SQLITE_OK) { > - diag_set(ClientError, ER_SQL_EXECUTE, expr); > - return -1; > + char *sql_error; > + if (sqlite3RunParser(&parser, stmt, &sql_error) != SQLITE_OK) { > + char *error = tt_static_buf(); > + snprintf(error, TT_STATIC_BUF_LEN, "%s", sql_error); > + diag_set(ClientError, ER_SQL_EXECUTE, stmt); > + goto cleanup; 1. What is happening here? 'Error' variable is unused, as well as sql_error as I can see.