* [Tarantool-patches] [PATCH] sql: allow accessing list of collations via pragma
@ 2020-01-10 7:52 Chris Sosnin
2020-01-15 16:56 ` Nikita Pettik
0 siblings, 1 reply; 4+ messages in thread
From: Chris Sosnin @ 2020-01-10 7:52 UTC (permalink / raw)
To: tarantool-patches
'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)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Tarantool-patches] [PATCH] sql: allow accessing list of collations via pragma
2020-01-10 7:52 [Tarantool-patches] [PATCH] sql: allow accessing list of collations via pragma Chris Sosnin
@ 2020-01-15 16:56 ` Nikita Pettik
2020-01-16 8:41 ` Chris Sosnin
0 siblings, 1 reply; 4+ messages in thread
From: Nikita Pettik @ 2020-01-15 16:56 UTC (permalink / raw)
To: Chris Sosnin; +Cc: tarantool-patches
On 10 Jan 10:52, Chris Sosnin wrote:
> '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
Please, never truncate output of format-patch. At least when you
send patch for the first review iteration.
Content returned by 'pragma collation_list' is already verified in
sql-tap/collation.test.lua. So I guess it is enough to check that
box.execute("pragma collation_list") does not throw an error.
> 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)
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Tarantool-patches] [PATCH] sql: allow accessing list of collations via pragma
2020-01-15 16:56 ` Nikita Pettik
@ 2020-01-16 8:41 ` Chris Sosnin
2020-01-17 19:15 ` Nikita Pettik
0 siblings, 1 reply; 4+ messages in thread
From: Chris Sosnin @ 2020-01-16 8:41 UTC (permalink / raw)
To: korablev; +Cc: tarantool-patches
Hi! Thank you for the review!
> Content returned by 'pragma collation_list' is already verified in
> sql-tap/collation.test.lua. So I guess it is enough to check that
> box.execute("pragma collation_list") does not throw an error.
I'm sorry, didn't notice such test exists. I changed the patch so it only
checks for an error:
+-- gh-4713 "PRAGMA collation_list" is not accessible to all users
+_, err = box.execute('pragma collation_list')
+assert(err == nil)
See the whole patch below.
'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 | 10 ++++++----
test/sql/collation.test.lua | 5 +++--
3 files changed, 10 insertions(+), 7 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..4e4c27ef0 100644
--- a/test/sql/collation.result
+++ b/test/sql/collation.result
@@ -360,11 +360,13 @@ box.schema.user.create('tmp')
box.session.su('tmp')
---
...
--- Error: read access to space is denied.
-box.execute("pragma collation_list")
+-- gh-4713 "PRAGMA collation_list" is not accessible to all users
+_, err = box.execute('pragma collation_list')
---
-- null
-- Read access to space '_collation' is denied for user 'tmp'
+...
+assert(err == nil)
+---
+- true
...
box.session.su('admin')
---
diff --git a/test/sql/collation.test.lua b/test/sql/collation.test.lua
index 9a2042c09..407fc19dc 100644
--- a/test/sql/collation.test.lua
+++ b/test/sql/collation.test.lua
@@ -103,8 +103,9 @@ 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")
+-- gh-4713 "PRAGMA collation_list" is not accessible to all users
+_, err = box.execute('pragma collation_list')
+assert(err == nil)
box.session.su('admin')
box.schema.user.drop('tmp')
--
2.21.0 (Apple Git-122.2)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Tarantool-patches] [PATCH] sql: allow accessing list of collations via pragma
2020-01-16 8:41 ` Chris Sosnin
@ 2020-01-17 19:15 ` Nikita Pettik
0 siblings, 0 replies; 4+ messages in thread
From: Nikita Pettik @ 2020-01-17 19:15 UTC (permalink / raw)
To: Chris Sosnin; +Cc: tarantool-patches
On 16 Jan 11:41, Chris Sosnin wrote:
> Hi! Thank you for the review!
>
> > Content returned by 'pragma collation_list' is already verified in
> > sql-tap/collation.test.lua. So I guess it is enough to check that
> > box.execute("pragma collation_list") does not throw an error.
>
> I'm sorry, didn't notice such test exists. I changed the patch so it only
> checks for an error:
> +-- gh-4713 "PRAGMA collation_list" is not accessible to all users
> +_, err = box.execute('pragma collation_list')
> +assert(err == nil)
>
> See the whole patch below.
>
> '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
Pushed to master, 2.2 and 2.3 branches. Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-01-17 19:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-10 7:52 [Tarantool-patches] [PATCH] sql: allow accessing list of collations via pragma Chris Sosnin
2020-01-15 16:56 ` Nikita Pettik
2020-01-16 8:41 ` Chris Sosnin
2020-01-17 19:15 ` Nikita Pettik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox