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 507A12A893 for ; Tue, 26 Mar 2019 13:09:05 -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 nupQ0FxxQ5gQ for ; Tue, 26 Mar 2019 13:09:05 -0400 (EDT) Received: from smtp47.i.mail.ru (smtp47.i.mail.ru [94.100.177.107]) (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 23040236C6 for ; Tue, 26 Mar 2019 13:09:02 -0400 (EDT) From: Vladislav Shpilevoy Subject: [tarantool-patches] Re: [PATCH v2 0/7] sql: store regular identifiers in case-normal form References: Message-ID: Date: Tue, 26 Mar 2019 20:09:00 +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: tarantool-patches@freelists.org, Kirill Shcherbatov Hi! Thanks for the fixes! Please, look at the diff below and on the branch. ============================================================= commit d41b8abf83f31e8ce2ae1792a211c096e48e39e1 Author: Vladislav Shpilevoy Date: Mon Mar 25 15:49:09 2019 +0300 Review fix diff --git a/src/box/sql/build.c b/src/box/sql/build.c index dae582d1f..7bd99feb6 100644 --- a/src/box/sql/build.c +++ b/src/box/sql/build.c @@ -2521,21 +2521,18 @@ sql_id_list_append(struct sql *db, struct IdList *list, struct Token *name_token) { if (list == NULL && - (list = sqlDbMallocZero(db, sizeof(struct IdList))) == NULL) { - diag_set(OutOfMemory, sizeof(struct IdList), "sqlDbMallocZero", - "list"); + (list = sqlDbMallocZero(db, sizeof(*list))) == NULL) { + diag_set(OutOfMemory, sizeof(*list), "sqlDbMallocZero", "list"); return NULL; } int i; list->a = sqlArrayAllocate(db, list->a, sizeof(list->a[0]), &list->nId, &i); - if (i < 0) - goto error; - list->a[i].zName = sqlNameFromToken(db, name_token); - if (list->a[i].zName == NULL) - goto error; - return list; -error: + if (i >= 0) { + list->a[i].zName = sqlNameFromToken(db, name_token); + if (list->a[i].zName != NULL) + return list; + } sqlIdListDelete(db, list); return NULL; } diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h index 192929747..998a601c2 100644 --- a/src/box/sql/sqlInt.h +++ b/src/box/sql/sqlInt.h @@ -3419,8 +3419,8 @@ void *sqlArrayAllocate(sql *, void *, int, int *, int *); * @param db The database connection. * @param list The pointer to existent Id list if exists. * @param name_token The token containing name. - * @retval Not NULL IdList pointer is returned on success. - * @retval NULL Otherwise. Diag message is set. + * @retval Not NULL A new list or updated @a list. + * @retval NULL Error. Diag message is set. */ struct IdList * sql_id_list_append(struct sql *db, struct IdList *list,