From bfd31f8b0010d4427b784d4917e14de8dc43eb67 Mon Sep 17 00:00:00 2001 From: Ilya <markovilya197@gmail.com> Date: Thu, 28 Dec 2017 17:55:12 +0300 Subject: [PATCH] Error on wrong user on space creation Add error if user given in box.schema.space.create option was not found Closes #2068 --- src/box/lua/schema.lua | 8 ++++---- test/box/misc.result | 7 +++++++ test/box/misc.test.lua | 5 +++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/box/lua/schema.lua b/src/box/lua/schema.lua index 3321fd83d2..846d97b7c4 100644 --- a/src/box/lua/schema.lua +++ b/src/box/lua/schema.lua @@ -399,12 +399,12 @@ box.schema.space.create = function(name, options) end id = max_id[2] end - local uid = nil + local uid = session.uid() if options.user then uid = user_or_role_resolve(options.user) - end - if uid == nil then - uid = session.uid() + if uid == nil then + box.error(box.error.NO_SUCH_USER, options.user) + end end local format = options.format and options.format or {} check_param(format, 'format', 'table') diff --git a/test/box/misc.result b/test/box/misc.result index 287873fa27..4d27653fa3 100644 --- a/test/box/misc.result +++ b/test/box/misc.result @@ -1096,6 +1096,13 @@ not not s:create_index('test4', {parts = {{4, 'boolean', collation = 'unicode_ci s:drop() --- ... +-- +-- gh-2068 no error for invalid user during space creation +-- +s = box.schema.space.create('test', {user="no_such_user"}) +--- +- error: User 'no_such_user' is not found +... -- Too long WAL write warning (gh-2743). s = box.schema.space.create('test') --- diff --git a/test/box/misc.test.lua b/test/box/misc.test.lua index 9305a2b1e6..b7bf600c38 100644 --- a/test/box/misc.test.lua +++ b/test/box/misc.test.lua @@ -298,6 +298,11 @@ not not s:create_index('test3', {parts = {{3, 'integer', collation = 'unicode_ci not not s:create_index('test4', {parts = {{4, 'boolean', collation = 'unicode_ci'}}}) s:drop() +-- +-- gh-2068 no error for invalid user during space creation +-- +s = box.schema.space.create('test', {user="no_such_user"}) + -- Too long WAL write warning (gh-2743). s = box.schema.space.create('test') _ = s:create_index('pk') -- GitLab