From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 3DB666EC40; Mon, 27 Sep 2021 09:41:56 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 3DB666EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1632724916; bh=jh7pFWiB7kInIrWlwQV5U9wExxt6Es16wxmxEt9yQZ8=; h=To:Cc:References:Date:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=jviU+QWVquTeHepTq+mP0AfxwT+SH/U8pqYtr3G9ZeNfMZAur48WZw0tWqRTYWDli GyqoXF61kfpRTyIV9VXJWwjmatmgvrBKwdtBFSzMmoAJ69LLqcwtjXHHoc6WsdlJK5 XlwgblqwV9KbwJxCIlwb5hk+2J4W2/mOQfIKrhug= Received: from smtpng1.i.mail.ru (smtpng1.i.mail.ru [94.100.181.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 1927A6EC40 for ; Mon, 27 Sep 2021 09:41:55 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 1927A6EC40 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1mUkKo-0001hH-9B; Mon, 27 Sep 2021 09:41:54 +0300 To: Vladislav Shpilevoy Cc: tarantool-patches@dev.tarantool.org References: <38ac1b8d1ecae3352b8fe748def9e8a451239b9a.1630915850.git.imeevma@gmail.com> <4e091d79-84c5-9ba1-f624-185cfced6591@tarantool.org> <20210909110754.GA51222@tarantool.org> Message-ID: <6849d9f6-c34b-db33-ee64-a20f9201b01d@tarantool.org> Date: Mon, 27 Sep 2021 09:41:54 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20210909110754.GA51222@tarantool.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-4EC0790: 10 X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD96A58C36AA2E996490107B6E0C80113C20C85D07D51133CB8182A05F5380850408D0AD0E5AF4ED6970C1410A39C4978FE177AE65D359B4999DA2C52DB2F3C88E2 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE763424119D34F5CBFEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F790063707C4856229E8E7E48638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D89481EC99BBC8E40AF34F0839EA3971F4117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAA867293B0326636D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8BF1175FABE1C0F9B6A471835C12D1D977C4224003CC8364762BB6847A3DEAEFB0F43C7A68FF6260569E8FC8737B5C2249EC8D19AE6D49635B68655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7CD1D040B6C1ECEA3F43847C11F186F3C59DAA53EE0834AAEE X-C1DE0DAB: 0D63561A33F958A58C48B1BC73124B22FE93CD25A3CDEB5F71E494FA4C6004F6D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75BFC02AB3DF06BA5A410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D344EF254DC71474AA346547F19D86EB3BC3B84DE3ADFCB368703E063C93CAFCEBEF68F7DC3364D8D8B1D7E09C32AA3244C01E9AE8C86CD562A6897653F86A5B0DF795D98D676DD64D0729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojnnOrOlyI/jMzVnwCdf2ztQ== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5DEC53A7F4D0002819DC080DA079F7188983D72C36FC87018B9F80AB2734326CD2FB559BB5D741EB96352A0ABBE4FDA4210A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v1 1/1] schema: remove assert on wrong insert into _priv X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Mergen Imeev via Tarantool-patches Reply-To: Mergen Imeev Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi! On 09.09.2021 14:07, Mergen Imeev wrote: > Hi! Thank you for the review! My answers, diff and new patch below. > > On Tue, Sep 07, 2021 at 11:59:58PM +0200, Vladislav Shpilevoy wrote: >> Hi! Thanks for the patch! >> >> See 4 comments below. >> >> On 06.09.2021 10:11, imeevma@tarantool.org wrote: >>> Prior to this patch, an assertion was throwed if a tuple with an >> 1. throwed -> thrown. >> > Fixed. > >>> 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 >> 2. Could you please add a changelog? >> > Added. > >>> 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") >> 3. Shouldn't the message be like a comment? Describing the correct >> behaviour. It is printed always along with ok/no ok in the tap output. >> So it should be about what is expected. >> > Thanks, fixed. > >>> 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 >> 4. Why? The test does not pass in release? >> > It does, however in release build nothing will change. At least at the first > glance. > >>> config = suite.cfg >>> fragile = { >>> "retries": 10, >>> > > Diff: > > > diff --git a/changelogs/unreleased/gh-6295-assert-on-wrong-insert-into-_priv.md b/changelogs/unreleased/gh-6295-assert-on-wrong-insert-into-_priv.md > new file mode 100644 > index 000000000..058d218d7 > --- /dev/null > +++ b/changelogs/unreleased/gh-6295-assert-on-wrong-insert-into-_priv.md > @@ -0,0 +1,5 @@ > +## bugfix/sql > + > +* Now inserting a tuple with the wrong "id" field into the \_priv space will > + return the correct error (gh-6295). > + > 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 > index e4822f395..add2df429 100755 > --- a/test/box-tap/gh-6295-assert-on-wrong-id.test.lua > +++ b/test/box-tap/gh-6295-assert-on-wrong-id.test.lua > @@ -13,22 +13,22 @@ box.cfg{} > 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") > +test:is_deeply({ok, tostring(res)}, {false, errmsg}, "Proper error is returned") > > 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") > +test:is_deeply({ok, tostring(res)}, {false, errmsg}, "Proper error is returned") > > 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") > +test:is_deeply({ok, tostring(res)}, {false, errmsg}, "Proper error is returned") > > 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") > +test:is_deeply({ok, tostring(res)}, {false, errmsg}, "Proper error is returned") > > 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") > +test:is_deeply({ok, tostring(res)}, {false, errmsg}, "Proper error is returned") > > os.exit(test:check() and 0 or 1) > diff --git a/test/box-tap/suite.ini b/test/box-tap/suite.ini > index fd55d5d24..b09d7db4f 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, gh-6295-assert-on-wrong-id.test.lua > +release_disabled = errinj_set_with_enviroment_vars.test.lua > config = suite.cfg > fragile = { > "retries": 10, > > > New patch: > > > commit a3542e0082c480f166796281d3996f6edfffcaf7 > Author: Mergen Imeev > Date: Sat Aug 7 13:11:12 2021 +0300 > > schema: remove assert on wrong insert into _priv > > Prior to this patch, an assertion was thrown if a tuple with an invalid > id was inserted into the _priv system space. This bug appeared only in > the debug build. > > Closes #6295 > > diff --git a/changelogs/unreleased/gh-6295-assert-on-wrong-insert-into-_priv.md b/changelogs/unreleased/gh-6295-assert-on-wrong-insert-into-_priv.md > new file mode 100644 > index 000000000..058d218d7 > --- /dev/null > +++ b/changelogs/unreleased/gh-6295-assert-on-wrong-insert-into-_priv.md > @@ -0,0 +1,5 @@ > +## bugfix/sql > + > +* Now inserting a tuple with the wrong "id" field into the \_priv space will > + return the correct error (gh-6295). > + > diff --git a/src/box/alter.cc b/src/box/alter.cc > index 3bd56feb9..e87fbb847 100644 > --- a/src/box/alter.cc > +++ b/src/box/alter.cc > @@ -3954,6 +3954,8 @@ priv_def_check(struct priv_def *priv, enum priv_type priv_type) > return -1; > } > const char *name = schema_find_name(priv->object_type, priv->object_id); > + if (name == NULL) > + return -1; > if (access_check_ddl(name, priv->object_id, grantor->def->uid, > priv->object_type, priv_type) != 0) > return -1; > diff --git a/src/box/schema.cc b/src/box/schema.cc > index 1970871cc..cf1e531e3 100644 > --- a/src/box/schema.cc > +++ b/src/box/schema.cc > @@ -701,36 +701,51 @@ schema_find_name(enum schema_object_type type, uint32_t object_id) > case SC_SPACE: > { > struct space *space = space_by_id(object_id); > - if (space == NULL) > - break; > - return space->def->name; > + if (space != NULL) > + return space->def->name; > + diag_set(ClientError, ER_NO_SUCH_SPACE, > + tt_sprintf("%d", object_id)); > + break; > } > case SC_FUNCTION: > { > struct func *func = func_by_id(object_id); > - if (func == NULL) > - break; > - return func->def->name; > + if (func != NULL) > + return func->def->name; > + diag_set(ClientError, ER_NO_SUCH_FUNCTION, > + tt_sprintf("%d", object_id)); > + break; > } > case SC_SEQUENCE: > { > struct sequence *seq = sequence_by_id(object_id); > - if (seq == NULL) > - break; > - return seq->def->name; > + if (seq != NULL) > + return seq->def->name; > + diag_set(ClientError, ER_NO_SUCH_SEQUENCE, > + tt_sprintf("%d", object_id)); > + break; > } > case SC_ROLE: > - case SC_USER: > { > struct user *role = user_by_id(object_id); > - if (role == NULL) > - break; > - return role->def->name; > + if (role != NULL) > + return role->def->name; > + diag_set(ClientError, ER_NO_SUCH_ROLE, > + tt_sprintf("%d", object_id)); > + break; > + } > + case SC_USER: > + { > + struct user *user = user_by_id(object_id); > + if (user != NULL) > + return user->def->name; > + diag_set(ClientError, ER_NO_SUCH_USER, > + tt_sprintf("%d", object_id)); > + break; > } > default: > - break; > + unreachable(); > } > - assert(false); > - return "(nil)"; > + return NULL; > } > > 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..add2df429 > --- /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}, "Proper error is returned") > + > +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}, "Proper error is returned") > + > +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}, "Proper error is returned") > + > +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}, "Proper error is returned") > + > +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}, "Proper error is returned") > + > +os.exit(test:check() and 0 or 1)