From: imeevma@tarantool.org To: tarantool-patches@freelists.org Cc: v.shpilevoy@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 [thread overview] Message-ID: <203b3a49f33e1964efb7aa3c14aee1d34e2ae6dc.1535021399.git.imeevma@gmail.com> (raw) 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
next reply other threads:[~2018-08-23 10:51 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-08-23 10:51 imeevma [this message] 2018-08-27 16:36 ` [tarantool-patches] " Vladislav Shpilevoy
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=203b3a49f33e1964efb7aa3c14aee1d34e2ae6dc.1535021399.git.imeevma@gmail.com \ --to=imeevma@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [tarantool-patches] [PATCH v1 1/1] box: replace schema_find_id by box_space_id_by_name' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox