Tarantool development patches archive
 help / color / mirror / Atom feed
* [tarantool-patches] [PATCH v1 1/1] box: replace schema_find_id by box_space_id_by_name
@ 2018-08-23 10:51 imeevma
  2018-08-27 16:36 ` [tarantool-patches] " Vladislav Shpilevoy
  0 siblings, 1 reply; 2+ messages in thread
From: imeevma @ 2018-08-23 10:51 UTC (permalink / raw)
  To: tarantool-patches; +Cc: v.shpilevoy

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-08-27 16:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-23 10:51 [tarantool-patches] [PATCH v1 1/1] box: replace schema_find_id by box_space_id_by_name imeevma
2018-08-27 16:36 ` [tarantool-patches] " Vladislav Shpilevoy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox