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 C0B3924C68 for ; Fri, 25 May 2018 07:54:00 -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 Rc8OYrdrGmr4 for ; Fri, 25 May 2018 07:54:00 -0400 (EDT) Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (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 7D00624C57 for ; Fri, 25 May 2018 07:54:00 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH v7 5/7] sql: change sqlite3AddCheckConstraint signature References: <314e11a2-5b51-df44-e2b8-bd22c8fa66f1@tarantool.org> From: Kirill Shcherbatov Message-ID: Date: Fri, 25 May 2018 14:53:57 +0300 MIME-Version: 1.0 In-Reply-To: <314e11a2-5b51-df44-e2b8-bd22c8fa66f1@tarantool.org> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit 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: tarantool-patches@freelists.org Cc: "v.shpilevoy@tarantool.org" > 1. Renamed refactored? sql: change sqlite3AddCheckConstraint signature As we would store Check source expr in MsgPack we need span instead of parsed Expr in sqlite3AddCheckConstraint. Part of #3272.↵ > 2. This macro is not defined. You can remove it. > 3. != 0 > 4. If 'if' body is in {}, then else must be too. diff --git a/src/box/sql/build.c b/src/box/sql/build.c index afb1128..50e4985 100644 --- a/src/box/sql/build.c +++ b/src/box/sql/build.c @@ -1022,19 +1022,19 @@ sqlite3AddPrimaryKey(Parse * pParse, /* Parsing context */ void sql_add_check_constraint(Parse *parser, ExprSpan *span) { -#ifndef SQLITE_OMIT_CHECK struct Expr *expr = span->pExpr; Table *table = parser->pNewTable; if (table != NULL) { table->pCheck = sqlite3ExprListAppend(parser, table->pCheck, expr); - if (parser->constraintName.n) { + if (parser->constraintName.n != 0) { sqlite3ExprListSetName(parser, table->pCheck, &parser->constraintName, 1); } - } else -#endif + } else { sql_expr_delete(parser->db, expr, false); + + } } /* > 5. span parser? And the span is not parsed. You said it in the commit message: > "we need span instead of parsed Expr". - * @param span parser parsed expression object.. + * @param check expression span object. > 6. Wrap line after return type declaration. -void sql_add_check_constraint(Parse *parser, ExprSpan *span); +void +sql_add_check_constraint(Parse *parser, ExprSpan *span);