From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (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 3DCC246970E for ; Fri, 10 Jan 2020 10:52:18 +0300 (MSK) Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1ipp5d-0003zI-OD for tarantool-patches@dev.tarantool.org; Fri, 10 Jan 2020 10:52:17 +0300 From: Chris Sosnin Date: Fri, 10 Jan 2020 10:52:17 +0300 Message-Id: <20200110075217.68276-1-k.sosnin@tarantool.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH] sql: allow accessing list of collations via pragma List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tarantool-patches@dev.tarantool.org 'pragma collation_list' uses _collation space, although user may have no access to it. Thus, we replace it with the corresponding view. Closes #4713 --- branch: https://github.com/tarantool/tarantool/tree/ksosnin/gh-4713-pragma-collation-list issue: https://github.com/tarantool/tarantool/issues/4713 src/box/sql/pragma.c | 2 +- test/sql/collation.result | 286 +++++++++++++++++++++++++++++++++++- test/sql/collation.test.lua | 1 - 3 files changed, 284 insertions(+), 5 deletions(-) diff --git a/src/box/sql/pragma.c b/src/box/sql/pragma.c index 28ba64500..636f519ef 100644 --- a/src/box/sql/pragma.c +++ b/src/box/sql/pragma.c @@ -241,7 +241,7 @@ sql_pragma_collation_list(struct Parse *parse_context) char key_buf[16]; char *key_end = mp_encode_array(key_buf, 0); box_tuple_t *tuple; - box_iterator_t *it = box_index_iterator(BOX_COLLATION_ID, 0, ITER_ALL, + box_iterator_t *it = box_index_iterator(BOX_VCOLLATION_ID, 0, ITER_ALL, key_buf, key_end); if (it == NULL) { parse_context->is_aborted = true; diff --git a/test/sql/collation.result b/test/sql/collation.result index 4e43a7cb7..924ac424c 100644 --- a/test/sql/collation.result +++ b/test/sql/collation.result @@ -360,11 +360,291 @@ box.schema.user.create('tmp') box.session.su('tmp') --- ... --- Error: read access to space is denied. box.execute("pragma collation_list") --- -- null -- Read access to space '_collation' is denied for user 'tmp' +- metadata: + - name: seq + type: integer + - name: name + type: text + rows: //snipped 276 rows --- diff --git a/test/sql/collation.test.lua b/test/sql/collation.test.lua index 9a2042c09..cbe6e7799 100644 --- a/test/sql/collation.test.lua +++ b/test/sql/collation.test.lua @@ -103,7 +103,6 @@ box.schema.user.revoke('guest', 'read,write,execute', 'universe') -- gh-3857 "PRAGMA collation_list" invokes segmentation fault. box.schema.user.create('tmp') box.session.su('tmp') --- Error: read access to space is denied. box.execute("pragma collation_list") box.session.su('admin') box.schema.user.drop('tmp') -- 2.21.0 (Apple Git-122.2)