[Tarantool-patches] [PATCH v1 1/1] schema: remove assert on wrong insert into _priv

imeevma at tarantool.org imeevma at tarantool.org
Mon Aug 16 19:13:34 MSK 2021


Prior to this patch, an assertion was throwed if a tuple with an
incorrect id was inserted into the _priv system space. This bug
appeared only in the debug build.

Closes #6295
---
https://github.com/tarantool/tarantool/issues/6295
https://github.com/tarantool/tarantool/tree/imeevma/gh-6295-assert-on-insert-with-wrong-id

 src/box/schema.cc                             |  1 -
 .../gh-6295-assert-on-wrong-id.test.lua       | 34 +++++++++++++++++++
 test/box-tap/suite.ini                        |  2 +-
 3 files changed, 35 insertions(+), 2 deletions(-)
 create mode 100755 test/box-tap/gh-6295-assert-on-wrong-id.test.lua

diff --git a/src/box/schema.cc b/src/box/schema.cc
index 1970871cc..ac19a2b1e 100644
--- a/src/box/schema.cc
+++ b/src/box/schema.cc
@@ -730,7 +730,6 @@ schema_find_name(enum schema_object_type type, uint32_t object_id)
 	default:
 		break;
 	}
-	assert(false);
 	return "(nil)";
 }
 
diff --git a/test/box-tap/gh-6295-assert-on-wrong-id.test.lua b/test/box-tap/gh-6295-assert-on-wrong-id.test.lua
new file mode 100755
index 000000000..e4822f395
--- /dev/null
+++ b/test/box-tap/gh-6295-assert-on-wrong-id.test.lua
@@ -0,0 +1,34 @@
+#!/usr/bin/env tarantool
+
+local tap = require('tap')
+local test = tap.test('gh-6295-assert-on-wrong-id')
+
+test:plan(5)
+
+local ok, res
+
+box.cfg{}
+
+-- Should be an error, not an assertion.
+local _priv = box.space._priv
+local errmsg = "Function '1000000' does not exist"
+ok, res = pcall(_priv.replace, _priv, {1, 2, 'function', 1000000, box.priv.A})
+test:is_deeply({ok, tostring(res)}, {false, errmsg}, "Function exists")
+
+errmsg = "Sequence '1000000' does not exist"
+ok, res = pcall(_priv.replace, _priv, {1, 2, 'sequence', 1000000, box.priv.A})
+test:is_deeply({ok, tostring(res)}, {false, errmsg}, "Sequence exists")
+
+errmsg = "Space '1000000' does not exist"
+ok, res = pcall(_priv.replace, _priv, {1, 2, 'space', 1000000, box.priv.A})
+test:is_deeply({ok, tostring(res)}, {false, errmsg}, "Space exists")
+
+errmsg = "User '1000000' is not found"
+ok, res = pcall(_priv.replace, _priv, {1, 2, 'user', 1000000, box.priv.A})
+test:is_deeply({ok, tostring(res)}, {false, errmsg}, "User exists")
+
+errmsg = "Role '1000000' is not found"
+ok, res = pcall(_priv.replace, _priv, {1, 2, 'role', 1000000, box.priv.A})
+test:is_deeply({ok, tostring(res)}, {false, errmsg}, "Role exists")
+
+os.exit(test:check() and 0 or 1)
diff --git a/test/box-tap/suite.ini b/test/box-tap/suite.ini
index b09d7db4f..fd55d5d24 100644
--- a/test/box-tap/suite.ini
+++ b/test/box-tap/suite.ini
@@ -3,7 +3,7 @@ core = app
 description = Database tests with #! using TAP
 is_parallel = True
 use_unix_sockets_iproto = True
-release_disabled = errinj_set_with_enviroment_vars.test.lua
+release_disabled = errinj_set_with_enviroment_vars.test.lua, gh-6295-assert-on-wrong-id.test.lua
 config = suite.cfg
 fragile = {
     "retries": 10,
-- 
2.25.1



More information about the Tarantool-patches mailing list