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 F377A29AC2 for ; Thu, 23 Aug 2018 06:51:34 -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 Fj-o4fzY6Dtb for ; Thu, 23 Aug 2018 06:51:34 -0400 (EDT) Received: from smtp3.mail.ru (smtp3.mail.ru [94.100.179.58]) (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 4A93E29AC1 for ; Thu, 23 Aug 2018 06:51:34 -0400 (EDT) From: imeevma@tarantool.org Subject: [tarantool-patches] [PATCH v1 1/1] box: replace schema_find_id by box_space_id_by_name Date: Thu, 23 Aug 2018 13:51:29 +0300 Message-Id: <203b3a49f33e1964efb7aa3c14aee1d34e2ae6dc.1535021399.git.imeevma@gmail.com> 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 In some cases it is useful to replace function schema_find_id by function box_space_id_by_name. Function box_space_id_by_name is more specialised and have some access right checks. Closes #3570 --- Branch: https://github.com/tarantool/tarantool/tree/imeevma/gh-3570-replace-schema_find_id Issue: https://github.com/tarantool/tarantool/issues/3570 src/box/alter.cc | 7 +++---- src/box/sql/trigger.c | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/box/alter.cc b/src/box/alter.cc index fe93174..b05869a 100644 --- a/src/box/alter.cc +++ b/src/box/alter.cc @@ -54,6 +54,7 @@ #include "version.h" #include "sequence.h" #include "sql.h" +#include "box.h" /** * chap-sha1 of empty string, i.e. @@ -1520,10 +1521,8 @@ update_view_references(struct Select *select, int update_value, const char *space_name = sql_select_from_table_name(select, i); if (space_name == NULL) continue; - uint32_t space_id; - if (schema_find_id(BOX_SPACE_ID, 2, space_name, - strlen(space_name), &space_id) != 0) - return -1; + uint32_t space_id = box_space_id_by_name(space_name, + strlen(space_name)); if (space_id == BOX_ID_NIL) { if (! suppress_error) { assert(not_found_space != NULL); diff --git a/src/box/sql/trigger.c b/src/box/sql/trigger.c index bd730c4..45c12bd 100644 --- a/src/box/sql/trigger.c +++ b/src/box/sql/trigger.c @@ -38,6 +38,7 @@ #include "tarantoolInt.h" #include "vdbeInt.h" #include "box/session.h" +#include "box/box.h" /* See comment in sqliteInt.h */ int sqlSubProgramsRemaining; @@ -101,10 +102,8 @@ sql_trigger_begin(struct Parse *parse, struct Token *name, int tr_tm, goto trigger_cleanup; const char *table_name = table->a[0].zName; - uint32_t space_id; - if (schema_find_id(BOX_SPACE_ID, 2, table_name, strlen(table_name), - &space_id) != 0) - goto set_tarantool_error_and_cleanup; + uint32_t space_id = box_space_id_by_name(table_name, + strlen(table_name)); if (space_id == BOX_ID_NIL) { diag_set(ClientError, ER_NO_SUCH_SPACE, table_name); goto set_tarantool_error_and_cleanup; -- 2.7.4