Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH] sql: display collation in metadata for scalar
@ 2020-06-10 12:47 Roman Khabibov
  2020-06-10 14:00 ` Kirill Yukhin
  2020-06-15 15:01 ` Kirill Yukhin
  0 siblings, 2 replies; 7+ messages in thread
From: Roman Khabibov @ 2020-06-10 12:47 UTC (permalink / raw)
  To: tarantool-patches

Fix bug with the  display of collation for scalar fields in
<SELECT> result, when sql_full_metadata is enabled.

Closes #4755
---

Branch: https://github.com/tarantool/tarantool/tree/romanhabibov/gh-4755-scalar-collation
Issue: https://github.com/tarantool/tarantool/issues/4755

 src/box/sql/select.c                          |  7 +--
 .../gh-4755-scalar-collation-metadata.result  | 52 +++++++++++++++++++
 ...gh-4755-scalar-collation-metadata.test.lua | 18 +++++++
 3 files changed, 74 insertions(+), 3 deletions(-)
 create mode 100644 test/sql/gh-4755-scalar-collation-metadata.result
 create mode 100755 test/sql/gh-4755-scalar-collation-metadata.test.lua

diff --git a/src/box/sql/select.c b/src/box/sql/select.c
index f39484013..92d20e992 100644
--- a/src/box/sql/select.c
+++ b/src/box/sql/select.c
@@ -1792,9 +1792,10 @@ generate_column_metadata(struct Parse *pParse, struct SrcList *pTabList,
 			continue;
 		if (p->op == TK_VARIABLE)
 			var_pos[var_count++] = i;
-		vdbe_metadata_set_col_type(v, i,
-					   field_type_strs[sql_expr_type(p)]);
-		if (is_full_meta && sql_expr_type(p) == FIELD_TYPE_STRING) {
+		enum field_type type = sql_expr_type(p);
+		vdbe_metadata_set_col_type(v, i, field_type_strs[type]);
+		if (is_full_meta && (type == FIELD_TYPE_STRING ||
+		    type == FIELD_TYPE_SCALAR)) {
 			bool unused;
 			uint32_t id = 0;
 			struct coll *coll = NULL;
diff --git a/test/sql/gh-4755-scalar-collation-metadata.result b/test/sql/gh-4755-scalar-collation-metadata.result
new file mode 100644
index 000000000..eef2d86ad
--- /dev/null
+++ b/test/sql/gh-4755-scalar-collation-metadata.result
@@ -0,0 +1,52 @@
+-- test-run result file version 2
+env = require('test_run')
+ | ---
+ | ...
+test_run = env.new()
+ | ---
+ | ...
+
+--
+-- gh-4755: Collation in metadata must be displayed as for string
+-- filed as for scalar field.
+--
+test_run:cmd("setopt delimiter ';'");
+ | ---
+ | - true
+ | ...
+box.execute([[SET SESSION "sql_full_metadata" = true;]]);
+ | ---
+ | - row_count: 1
+ | ...
+box.execute([[CREATE TABLE test (a SCALAR COLLATE "unicode_ci" PRIMARY KEY,
+                                 b STRING COLLATE "unicode_ci");]]);
+ | ---
+ | - row_count: 1
+ | ...
+box.execute("SELECT * FROM test;");
+ | ---
+ | - metadata:
+ |   - span: A
+ |     type: scalar
+ |     is_nullable: false
+ |     name: A
+ |     collation: unicode_ci
+ |   - span: B
+ |     type: string
+ |     is_nullable: true
+ |     name: B
+ |     collation: unicode_ci
+ |   rows: []
+ | ...
+
+--
+-- Cleanup.
+--
+box.execute([[SET SESSION "sql_full_metadata" = false;]]);
+ | ---
+ | - row_count: 1
+ | ...
+box.execute("DROP TABLE test;");
+ | ---
+ | - row_count: 1
+ | ...
diff --git a/test/sql/gh-4755-scalar-collation-metadata.test.lua b/test/sql/gh-4755-scalar-collation-metadata.test.lua
new file mode 100755
index 000000000..cc883794f
--- /dev/null
+++ b/test/sql/gh-4755-scalar-collation-metadata.test.lua
@@ -0,0 +1,18 @@
+env = require('test_run')
+test_run = env.new()
+
+--
+-- gh-4755: Collation in metadata must be displayed as for string
+-- filed as for scalar field.
+--
+test_run:cmd("setopt delimiter ';'");
+box.execute([[SET SESSION "sql_full_metadata" = true;]]);
+box.execute([[CREATE TABLE test (a SCALAR COLLATE "unicode_ci" PRIMARY KEY,
+                                 b STRING COLLATE "unicode_ci");]]);
+box.execute("SELECT * FROM test;");
+
+--
+-- Cleanup.
+--
+box.execute([[SET SESSION "sql_full_metadata" = false;]]);
+box.execute("DROP TABLE test;");
-- 
2.21.0 (Apple Git-122)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Tarantool-patches] [PATCH] sql: display collation in metadata for scalar
  2020-06-10 12:47 [Tarantool-patches] [PATCH] sql: display collation in metadata for scalar Roman Khabibov
@ 2020-06-10 14:00 ` Kirill Yukhin
  2020-06-11 21:03   ` Roman Khabibov
  2020-06-15 15:01 ` Kirill Yukhin
  1 sibling, 1 reply; 7+ messages in thread
From: Kirill Yukhin @ 2020-06-10 14:00 UTC (permalink / raw)
  To: Roman Khabibov; +Cc: tarantool-patches

Hello,

Thanks for the patch. Few nits inlined.

Where is ChangeLog entry?

Fix it and it will be LGTM.

On 10 июн 15:47, Roman Khabibov wrote:
> Fix bug with the  display of collation for scalar fields in

Double space.

> <SELECT> result, when sql_full_metadata is enabled.
> 
> Closes #4755
> ---
> 
> Branch: https://github.com/tarantool/tarantool/tree/romanhabibov/gh-4755-scalar-collation
> Issue: https://github.com/tarantool/tarantool/issues/4755
> 
>  src/box/sql/select.c                          |  7 +--
>  .../gh-4755-scalar-collation-metadata.result  | 52 +++++++++++++++++++
>  ...gh-4755-scalar-collation-metadata.test.lua | 18 +++++++
>  3 files changed, 74 insertions(+), 3 deletions(-)
>  create mode 100644 test/sql/gh-4755-scalar-collation-metadata.result
>  create mode 100755 test/sql/gh-4755-scalar-collation-metadata.test.lua
> 
> diff --git a/test/sql/gh-4755-scalar-collation-metadata.result b/test/sql/gh-4755-scalar-collation-metadata.result
> new file mode 100644
> index 000000000..eef2d86ad
> --- /dev/null
> +++ b/test/sql/gh-4755-scalar-collation-metadata.result
> @@ -0,0 +1,52 @@
> +-- test-run result file version 2
> +env = require('test_run')
> + | ---
> + | ...
> +test_run = env.new()
> + | ---
> + | ...
> +
> +--
> +-- gh-4755: Collation in metadata must be displayed as for string
> +-- filed as for scalar field.

Start with lowercase, please. Re-phrase it: "... for both string and scalar field types ..."

--
Regards, Kirill Yukhin

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Tarantool-patches] [PATCH] sql: display collation in metadata for scalar
  2020-06-10 14:00 ` Kirill Yukhin
@ 2020-06-11 21:03   ` Roman Khabibov
  0 siblings, 0 replies; 7+ messages in thread
From: Roman Khabibov @ 2020-06-11 21:03 UTC (permalink / raw)
  To: Kirill Yukhin; +Cc: tarantool-patches

Hi! Thanks for the review.

@ChangeLog
- Fix bug with the display of collation for scalar fields in
<SELECT> result, when sql_full_metadata is enabled.

> On Jun 10, 2020, at 17:00, Kirill Yukhin <kyukhin@tarantool.org> wrote:
> 
> Hello,
> 
> Thanks for the patch. Few nits inlined.
> 
> Where is ChangeLog entry?
Done.

> Fix it and it will be LGTM.
> 
> On 10 июн 15:47, Roman Khabibov wrote:
>> Fix bug with the  display of collation for scalar fields in
> 
> Double space.
Fixed.

>> <SELECT> result, when sql_full_metadata is enabled.
>> 
>> Closes #4755
>> ---
>> 
>> Branch: https://github.com/tarantool/tarantool/tree/romanhabibov/gh-4755-scalar-collation
>> Issue: https://github.com/tarantool/tarantool/issues/4755
>> 
>> src/box/sql/select.c                          |  7 +--
>> .../gh-4755-scalar-collation-metadata.result  | 52 +++++++++++++++++++
>> ...gh-4755-scalar-collation-metadata.test.lua | 18 +++++++
>> 3 files changed, 74 insertions(+), 3 deletions(-)
>> create mode 100644 test/sql/gh-4755-scalar-collation-metadata.result
>> create mode 100755 test/sql/gh-4755-scalar-collation-metadata.test.lua
>> 
>> diff --git a/test/sql/gh-4755-scalar-collation-metadata.result b/test/sql/gh-4755-scalar-collation-metadata.result
>> new file mode 100644
>> index 000000000..eef2d86ad
>> --- /dev/null
>> +++ b/test/sql/gh-4755-scalar-collation-metadata.result
>> @@ -0,0 +1,52 @@
>> +-- test-run result file version 2
>> +env = require('test_run')
>> + | ---
>> + | ...
>> +test_run = env.new()
>> + | ---
>> + | ...
>> +
>> +--
>> +-- gh-4755: Collation in metadata must be displayed as for string
>> +-- filed as for scalar field.
> 
> Start with lowercase, please. Re-phrase it: "... for both string and scalar field types …”
+-- gh-4755: collation in metadata must be displayed for both
+-- string and scalar field types.

> --
> Regards, Kirill Yukhin

commit 8e398297beb216e6267797a6b929513156f76f36
Author: Roman Khabibov <roman.habibov@tarantool.org>
Date:   Fri Apr 17 10:04:44 2020 +0300

    sql: display collation in metadata for scalar
    
    Fix bug with the display of collation for scalar fields in
    <SELECT> result, when sql_full_metadata is enabled.
    
    Closes #4755

diff --git a/src/box/sql/select.c b/src/box/sql/select.c
index f39484013..92d20e992 100644
--- a/src/box/sql/select.c
+++ b/src/box/sql/select.c
@@ -1792,9 +1792,10 @@ generate_column_metadata(struct Parse *pParse, struct SrcList *pTabList,
 			continue;
 		if (p->op == TK_VARIABLE)
 			var_pos[var_count++] = i;
-		vdbe_metadata_set_col_type(v, i,
-					   field_type_strs[sql_expr_type(p)]);
-		if (is_full_meta && sql_expr_type(p) == FIELD_TYPE_STRING) {
+		enum field_type type = sql_expr_type(p);
+		vdbe_metadata_set_col_type(v, i, field_type_strs[type]);
+		if (is_full_meta && (type == FIELD_TYPE_STRING ||
+		    type == FIELD_TYPE_SCALAR)) {
 			bool unused;
 			uint32_t id = 0;
 			struct coll *coll = NULL;
diff --git a/test/sql/gh-4755-scalar-collation-metadata.result b/test/sql/gh-4755-scalar-collation-metadata.result
new file mode 100644
index 000000000..cccc4aae8
--- /dev/null
+++ b/test/sql/gh-4755-scalar-collation-metadata.result
@@ -0,0 +1,52 @@
+-- test-run result file version 2
+env = require('test_run')
+ | ---
+ | ...
+test_run = env.new()
+ | ---
+ | ...
+
+--
+-- gh-4755: collation in metadata must be displayed for both
+-- string and scalar field types.
+--
+test_run:cmd("setopt delimiter ';'");
+ | ---
+ | - true
+ | ...
+box.execute([[SET SESSION "sql_full_metadata" = true;]]);
+ | ---
+ | - row_count: 1
+ | ...
+box.execute([[CREATE TABLE test (a SCALAR COLLATE "unicode_ci" PRIMARY KEY,
+                                 b STRING COLLATE "unicode_ci");]]);
+ | ---
+ | - row_count: 1
+ | ...
+box.execute("SELECT * FROM test;");
+ | ---
+ | - metadata:
+ |   - span: A
+ |     type: scalar
+ |     is_nullable: false
+ |     name: A
+ |     collation: unicode_ci
+ |   - span: B
+ |     type: string
+ |     is_nullable: true
+ |     name: B
+ |     collation: unicode_ci
+ |   rows: []
+ | ...
+
+--
+-- Cleanup.
+--
+box.execute([[SET SESSION "sql_full_metadata" = false;]]);
+ | ---
+ | - row_count: 1
+ | ...
+box.execute("DROP TABLE test;");
+ | ---
+ | - row_count: 1
+ | ...
diff --git a/test/sql/gh-4755-scalar-collation-metadata.test.lua b/test/sql/gh-4755-scalar-collation-metadata.test.lua
new file mode 100755
index 000000000..20158662e
--- /dev/null
+++ b/test/sql/gh-4755-scalar-collation-metadata.test.lua
@@ -0,0 +1,18 @@
+env = require('test_run')
+test_run = env.new()
+
+--
+-- gh-4755: collation in metadata must be displayed for both
+-- string and scalar field types.
+--
+test_run:cmd("setopt delimiter ';'");
+box.execute([[SET SESSION "sql_full_metadata" = true;]]);
+box.execute([[CREATE TABLE test (a SCALAR COLLATE "unicode_ci" PRIMARY KEY,
+                                 b STRING COLLATE "unicode_ci");]]);
+box.execute("SELECT * FROM test;");
+
+--
+-- Cleanup.
+--
+box.execute([[SET SESSION "sql_full_metadata" = false;]]);
+box.execute("DROP TABLE test;");

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Tarantool-patches] [PATCH] sql: display collation in metadata for scalar
  2020-06-10 12:47 [Tarantool-patches] [PATCH] sql: display collation in metadata for scalar Roman Khabibov
  2020-06-10 14:00 ` Kirill Yukhin
@ 2020-06-15 15:01 ` Kirill Yukhin
  1 sibling, 0 replies; 7+ messages in thread
From: Kirill Yukhin @ 2020-06-15 15:01 UTC (permalink / raw)
  To: Roman Khabibov; +Cc: tarantool-patches

Hello,

On 10 июн 15:47, Roman Khabibov wrote:
> Fix bug with the  display of collation for scalar fields in
> <SELECT> result, when sql_full_metadata is enabled.
> 
> Closes #4755
> ---
> 
> Branch: https://github.com/tarantool/tarantool/tree/romanhabibov/gh-4755-scalar-collation
> Issue: https://github.com/tarantool/tarantool/issues/4755

I've checked your patch into 2.3, 2.4 and master.

--
Regards, Kirill Yukhin

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Tarantool-patches] [PATCH] sql: display collation in metadata for scalar
  2020-05-18 10:26 ` Mergen Imeev
@ 2020-06-03 18:56   ` Roman Khabibov
  0 siblings, 0 replies; 7+ messages in thread
From: Roman Khabibov @ 2020-06-03 18:56 UTC (permalink / raw)
  To: Mergen Imeev; +Cc: tarantool-patches

Hi! Thanks for the review. Nikita, could you, please, do a second review.

> On May 18, 2020, at 13:26, Mergen Imeev <imeevma@tarantool.org> wrote:
> 
> Hi! Thank you for the fix. I have only one comment here,
> you can see it below. Please send next version to Nikita.
> 
> On Fri, Apr 17, 2020 at 02:09:25PM +0300, Roman Khabibov wrote:
>> Fix bug with the  display of collation for scalar fields in
>> <SELECT> result, when sql_full_metadata is enabled.
>> 
>> Closes #4755
>> ---
>> Branch: https://github.com/tarantool/tarantool/tree/romanhabibov/gh-4755-scalar-collation
>> Issue: https://github.com/tarantool/tarantool/issues/4755
>> 
>> @ChangeLog
>> - Fix bug with no collation display for scalar fields in <SELECT>
>> when sql_full_metadata is enabled.
>> 
>> src/box/sql/select.c                          |  7 ++-
>> .../gh-4755-scalar-collation-metadata.result  | 56 +++++++++++++++++++
>> ...gh-4755-scalar-collation-metadata.test.lua | 22 ++++++++
>> 3 files changed, 82 insertions(+), 3 deletions(-)
>> create mode 100644 test/sql/gh-4755-scalar-collation-metadata.result
>> create mode 100755 test/sql/gh-4755-scalar-collation-metadata.test.lua
>> 
>> diff --git a/src/box/sql/select.c b/src/box/sql/select.c
>> index f39484013..92d20e992 100644
>> --- a/src/box/sql/select.c
>> +++ b/src/box/sql/select.c
>> @@ -1792,9 +1792,10 @@ generate_column_metadata(struct Parse *pParse, struct SrcList *pTabList,
>> 			continue;
>> 		if (p->op == TK_VARIABLE)
>> 			var_pos[var_count++] = i;
>> -		vdbe_metadata_set_col_type(v, i,
>> -					   field_type_strs[sql_expr_type(p)]);
>> -		if (is_full_meta && sql_expr_type(p) == FIELD_TYPE_STRING) {
>> +		enum field_type type = sql_expr_type(p);
>> +		vdbe_metadata_set_col_type(v, i, field_type_strs[type]);
>> +		if (is_full_meta && (type == FIELD_TYPE_STRING ||
>> +		    type == FIELD_TYPE_SCALAR)) {
>> 			bool unused;
>> 			uint32_t id = 0;
>> 			struct coll *coll = NULL;
>> diff --git a/test/sql/gh-4755-scalar-collation-metadata.result b/test/sql/gh-4755-scalar-collation-metadata.result
>> new file mode 100644
>> index 000000000..2ffcc79f3
>> --- /dev/null
>> +++ b/test/sql/gh-4755-scalar-collation-metadata.result
>> @@ -0,0 +1,56 @@
>> +-- test-run result file version 2
>> +env = require('test_run')
>> + | ---
>> + | ...
>> +test_run = env.new()
>> + | ---
>> + | ...
>> +
>> +--
>> +-- gh-4755: Collation in metadata must be displayed as for string
>> +-- filed as for scalar field.
>> +--
>> +test_run:cmd("setopt delimiter ';'");
>> + | ---
>> + | - true
>> + | ...
>> +box.execute([[UPDATE "_session_settings"
>> +                  SET "value" = true
>> +                  WHERE "name" = 'sql_full_metadata';]]);
>> + | ---
>> + | - row_count: 1
>> + | ...
>> +box.execute([[CREATE TABLE test (a SCALAR COLLATE "unicode_ci" PRIMARY KEY,
>> +                                 b STRING COLLATE "unicode_ci");]]);
>> + | ---
>> + | - row_count: 1
>> + | ...
>> +box.execute("SELECT * FROM test;");
>> + | ---
>> + | - metadata:
>> + |   - span: A
>> + |     type: scalar
>> + |     is_nullable: false
>> + |     name: A
>> + |     collation: unicode_ci
>> + |   - span: B
>> + |     type: string
>> + |     is_nullable: true
>> + |     name: B
>> + |     collation: unicode_ci
>> + |   rows: []
>> + | ...
>> +
>> +--
>> +-- Cleanup.
>> +--
>> +box.execute([[UPDATE "_session_settings"
>> +                  SET "value" = false
>> +                  WHERE "name" = 'sql_full_metadata';]]);
>> + | ---
>> + | - row_count: 1
>> + | ...
>> +box.execute("DROP TABLE test;");
>> + | ---
>> + | - row_count: 1
>> + | ...
>> diff --git a/test/sql/gh-4755-scalar-collation-metadata.test.lua b/test/sql/gh-4755-scalar-collation-metadata.test.lua
>> new file mode 100755
>> index 000000000..197b06891
>> --- /dev/null
>> +++ b/test/sql/gh-4755-scalar-collation-metadata.test.lua
>> @@ -0,0 +1,22 @@
>> +env = require('test_run')
>> +test_run = env.new()
>> +
>> +--
>> +-- gh-4755: Collation in metadata must be displayed as for string
>> +-- filed as for scalar field.
>> +--
>> +test_run:cmd("setopt delimiter ';'");
>> +box.execute([[UPDATE "_session_settings"
>> +                  SET "value" = true
>> +                  WHERE "name" = 'sql_full_metadata';]]);
> I think it make sense to use  new interface here.
Done.

>> +box.execute([[CREATE TABLE test (a SCALAR COLLATE "unicode_ci" PRIMARY KEY,
>> +                                 b STRING COLLATE "unicode_ci");]]);
>> +box.execute("SELECT * FROM test;");
>> +
>> +--
>> +-- Cleanup.
>> +--
>> +box.execute([[UPDATE "_session_settings"
>> +                  SET "value" = false
>> +                  WHERE "name" = 'sql_full_metadata';]]);
>> +box.execute("DROP TABLE test;");
>> -- 
>> 2.21.0 (Apple Git-122)

commit d3733a4170f392e24db8d485c980d61130ce8a19 (HEAD -> romanhabibov/gh-4755-scalar-collation, origin/romanhabibov/gh-4755-scalar-collation)
Author: Roman Khabibov <roman.habibov@tarantool.org>
Date:   Fri Apr 17 10:04:44 2020 +0300

    sql: display collation in metadata for scalar
    
    Fix bug with the  display of collation for scalar fields in
    <SELECT> result, when sql_full_metadata is enabled.
    
    Closes #4755

diff --git a/src/box/sql/select.c b/src/box/sql/select.c
index f39484013..92d20e992 100644
--- a/src/box/sql/select.c
+++ b/src/box/sql/select.c
@@ -1792,9 +1792,10 @@ generate_column_metadata(struct Parse *pParse, struct SrcList *pTabList,
 			continue;
 		if (p->op == TK_VARIABLE)
 			var_pos[var_count++] = i;
-		vdbe_metadata_set_col_type(v, i,
-					   field_type_strs[sql_expr_type(p)]);
-		if (is_full_meta && sql_expr_type(p) == FIELD_TYPE_STRING) {
+		enum field_type type = sql_expr_type(p);
+		vdbe_metadata_set_col_type(v, i, field_type_strs[type]);
+		if (is_full_meta && (type == FIELD_TYPE_STRING ||
+		    type == FIELD_TYPE_SCALAR)) {
 			bool unused;
 			uint32_t id = 0;
 			struct coll *coll = NULL;
diff --git a/test/sql/gh-4755-scalar-collation-metadata.result b/test/sql/gh-4755-scalar-collation-metadata.result
new file mode 100644
index 000000000..eef2d86ad
--- /dev/null
+++ b/test/sql/gh-4755-scalar-collation-metadata.result
@@ -0,0 +1,52 @@
+-- test-run result file version 2
+env = require('test_run')
+ | ---
+ | ...
+test_run = env.new()
+ | ---
+ | ...
+
+--
+-- gh-4755: Collation in metadata must be displayed as for string
+-- filed as for scalar field.
+--
+test_run:cmd("setopt delimiter ';'");
+ | ---
+ | - true
+ | ...
+box.execute([[SET SESSION "sql_full_metadata" = true;]]);
+ | ---
+ | - row_count: 1
+ | ...
+box.execute([[CREATE TABLE test (a SCALAR COLLATE "unicode_ci" PRIMARY KEY,
+                                 b STRING COLLATE "unicode_ci");]]);
+ | ---
+ | - row_count: 1
+ | ...
+box.execute("SELECT * FROM test;");
+ | ---
+ | - metadata:
+ |   - span: A
+ |     type: scalar
+ |     is_nullable: false
+ |     name: A
+ |     collation: unicode_ci
+ |   - span: B
+ |     type: string
+ |     is_nullable: true
+ |     name: B
+ |     collation: unicode_ci
+ |   rows: []
+ | ...
+
+--
+-- Cleanup.
+--
+box.execute([[SET SESSION "sql_full_metadata" = false;]]);
+ | ---
+ | - row_count: 1
+ | ...
+box.execute("DROP TABLE test;");
+ | ---
+ | - row_count: 1
+ | ...
diff --git a/test/sql/gh-4755-scalar-collation-metadata.test.lua b/test/sql/gh-4755-scalar-collation-metadata.test.lua
new file mode 100755
index 000000000..cc883794f
--- /dev/null
+++ b/test/sql/gh-4755-scalar-collation-metadata.test.lua
@@ -0,0 +1,18 @@
+env = require('test_run')
+test_run = env.new()
+
+--
+-- gh-4755: Collation in metadata must be displayed as for string
+-- filed as for scalar field.
+--
+test_run:cmd("setopt delimiter ';'");
+box.execute([[SET SESSION "sql_full_metadata" = true;]]);
+box.execute([[CREATE TABLE test (a SCALAR COLLATE "unicode_ci" PRIMARY KEY,
+                                 b STRING COLLATE "unicode_ci");]]);
+box.execute("SELECT * FROM test;");
+
+--
+-- Cleanup.
+--
+box.execute([[SET SESSION "sql_full_metadata" = false;]]);
+box.execute("DROP TABLE test;”);

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Tarantool-patches] [PATCH] sql: display collation in metadata for scalar
  2020-04-17 11:09 Roman Khabibov
@ 2020-05-18 10:26 ` Mergen Imeev
  2020-06-03 18:56   ` Roman Khabibov
  0 siblings, 1 reply; 7+ messages in thread
From: Mergen Imeev @ 2020-05-18 10:26 UTC (permalink / raw)
  To: Roman Khabibov; +Cc: tarantool-patches

Hi! Thank you for the fix. I have only one comment here,
you can see it below. Please send next version to Nikita.

On Fri, Apr 17, 2020 at 02:09:25PM +0300, Roman Khabibov wrote:
> Fix bug with the  display of collation for scalar fields in
> <SELECT> result, when sql_full_metadata is enabled.
> 
> Closes #4755
> ---
> Branch: https://github.com/tarantool/tarantool/tree/romanhabibov/gh-4755-scalar-collation
> Issue: https://github.com/tarantool/tarantool/issues/4755
> 
> @ChangeLog
> - Fix bug with no collation display for scalar fields in <SELECT>
> when sql_full_metadata is enabled.
> 
>  src/box/sql/select.c                          |  7 ++-
>  .../gh-4755-scalar-collation-metadata.result  | 56 +++++++++++++++++++
>  ...gh-4755-scalar-collation-metadata.test.lua | 22 ++++++++
>  3 files changed, 82 insertions(+), 3 deletions(-)
>  create mode 100644 test/sql/gh-4755-scalar-collation-metadata.result
>  create mode 100755 test/sql/gh-4755-scalar-collation-metadata.test.lua
> 
> diff --git a/src/box/sql/select.c b/src/box/sql/select.c
> index f39484013..92d20e992 100644
> --- a/src/box/sql/select.c
> +++ b/src/box/sql/select.c
> @@ -1792,9 +1792,10 @@ generate_column_metadata(struct Parse *pParse, struct SrcList *pTabList,
>  			continue;
>  		if (p->op == TK_VARIABLE)
>  			var_pos[var_count++] = i;
> -		vdbe_metadata_set_col_type(v, i,
> -					   field_type_strs[sql_expr_type(p)]);
> -		if (is_full_meta && sql_expr_type(p) == FIELD_TYPE_STRING) {
> +		enum field_type type = sql_expr_type(p);
> +		vdbe_metadata_set_col_type(v, i, field_type_strs[type]);
> +		if (is_full_meta && (type == FIELD_TYPE_STRING ||
> +		    type == FIELD_TYPE_SCALAR)) {
>  			bool unused;
>  			uint32_t id = 0;
>  			struct coll *coll = NULL;
> diff --git a/test/sql/gh-4755-scalar-collation-metadata.result b/test/sql/gh-4755-scalar-collation-metadata.result
> new file mode 100644
> index 000000000..2ffcc79f3
> --- /dev/null
> +++ b/test/sql/gh-4755-scalar-collation-metadata.result
> @@ -0,0 +1,56 @@
> +-- test-run result file version 2
> +env = require('test_run')
> + | ---
> + | ...
> +test_run = env.new()
> + | ---
> + | ...
> +
> +--
> +-- gh-4755: Collation in metadata must be displayed as for string
> +-- filed as for scalar field.
> +--
> +test_run:cmd("setopt delimiter ';'");
> + | ---
> + | - true
> + | ...
> +box.execute([[UPDATE "_session_settings"
> +                  SET "value" = true
> +                  WHERE "name" = 'sql_full_metadata';]]);
> + | ---
> + | - row_count: 1
> + | ...
> +box.execute([[CREATE TABLE test (a SCALAR COLLATE "unicode_ci" PRIMARY KEY,
> +                                 b STRING COLLATE "unicode_ci");]]);
> + | ---
> + | - row_count: 1
> + | ...
> +box.execute("SELECT * FROM test;");
> + | ---
> + | - metadata:
> + |   - span: A
> + |     type: scalar
> + |     is_nullable: false
> + |     name: A
> + |     collation: unicode_ci
> + |   - span: B
> + |     type: string
> + |     is_nullable: true
> + |     name: B
> + |     collation: unicode_ci
> + |   rows: []
> + | ...
> +
> +--
> +-- Cleanup.
> +--
> +box.execute([[UPDATE "_session_settings"
> +                  SET "value" = false
> +                  WHERE "name" = 'sql_full_metadata';]]);
> + | ---
> + | - row_count: 1
> + | ...
> +box.execute("DROP TABLE test;");
> + | ---
> + | - row_count: 1
> + | ...
> diff --git a/test/sql/gh-4755-scalar-collation-metadata.test.lua b/test/sql/gh-4755-scalar-collation-metadata.test.lua
> new file mode 100755
> index 000000000..197b06891
> --- /dev/null
> +++ b/test/sql/gh-4755-scalar-collation-metadata.test.lua
> @@ -0,0 +1,22 @@
> +env = require('test_run')
> +test_run = env.new()
> +
> +--
> +-- gh-4755: Collation in metadata must be displayed as for string
> +-- filed as for scalar field.
> +--
> +test_run:cmd("setopt delimiter ';'");
> +box.execute([[UPDATE "_session_settings"
> +                  SET "value" = true
> +                  WHERE "name" = 'sql_full_metadata';]]);
I think it make sense to use  new interface here.

> +box.execute([[CREATE TABLE test (a SCALAR COLLATE "unicode_ci" PRIMARY KEY,
> +                                 b STRING COLLATE "unicode_ci");]]);
> +box.execute("SELECT * FROM test;");
> +
> +--
> +-- Cleanup.
> +--
> +box.execute([[UPDATE "_session_settings"
> +                  SET "value" = false
> +                  WHERE "name" = 'sql_full_metadata';]]);
> +box.execute("DROP TABLE test;");
> -- 
> 2.21.0 (Apple Git-122)
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Tarantool-patches] [PATCH] sql: display collation in metadata for scalar
@ 2020-04-17 11:09 Roman Khabibov
  2020-05-18 10:26 ` Mergen Imeev
  0 siblings, 1 reply; 7+ messages in thread
From: Roman Khabibov @ 2020-04-17 11:09 UTC (permalink / raw)
  To: tarantool-patches

Fix bug with the  display of collation for scalar fields in
<SELECT> result, when sql_full_metadata is enabled.

Closes #4755
---
Branch: https://github.com/tarantool/tarantool/tree/romanhabibov/gh-4755-scalar-collation
Issue: https://github.com/tarantool/tarantool/issues/4755

@ChangeLog
- Fix bug with no collation display for scalar fields in <SELECT>
when sql_full_metadata is enabled.

 src/box/sql/select.c                          |  7 ++-
 .../gh-4755-scalar-collation-metadata.result  | 56 +++++++++++++++++++
 ...gh-4755-scalar-collation-metadata.test.lua | 22 ++++++++
 3 files changed, 82 insertions(+), 3 deletions(-)
 create mode 100644 test/sql/gh-4755-scalar-collation-metadata.result
 create mode 100755 test/sql/gh-4755-scalar-collation-metadata.test.lua

diff --git a/src/box/sql/select.c b/src/box/sql/select.c
index f39484013..92d20e992 100644
--- a/src/box/sql/select.c
+++ b/src/box/sql/select.c
@@ -1792,9 +1792,10 @@ generate_column_metadata(struct Parse *pParse, struct SrcList *pTabList,
 			continue;
 		if (p->op == TK_VARIABLE)
 			var_pos[var_count++] = i;
-		vdbe_metadata_set_col_type(v, i,
-					   field_type_strs[sql_expr_type(p)]);
-		if (is_full_meta && sql_expr_type(p) == FIELD_TYPE_STRING) {
+		enum field_type type = sql_expr_type(p);
+		vdbe_metadata_set_col_type(v, i, field_type_strs[type]);
+		if (is_full_meta && (type == FIELD_TYPE_STRING ||
+		    type == FIELD_TYPE_SCALAR)) {
 			bool unused;
 			uint32_t id = 0;
 			struct coll *coll = NULL;
diff --git a/test/sql/gh-4755-scalar-collation-metadata.result b/test/sql/gh-4755-scalar-collation-metadata.result
new file mode 100644
index 000000000..2ffcc79f3
--- /dev/null
+++ b/test/sql/gh-4755-scalar-collation-metadata.result
@@ -0,0 +1,56 @@
+-- test-run result file version 2
+env = require('test_run')
+ | ---
+ | ...
+test_run = env.new()
+ | ---
+ | ...
+
+--
+-- gh-4755: Collation in metadata must be displayed as for string
+-- filed as for scalar field.
+--
+test_run:cmd("setopt delimiter ';'");
+ | ---
+ | - true
+ | ...
+box.execute([[UPDATE "_session_settings"
+                  SET "value" = true
+                  WHERE "name" = 'sql_full_metadata';]]);
+ | ---
+ | - row_count: 1
+ | ...
+box.execute([[CREATE TABLE test (a SCALAR COLLATE "unicode_ci" PRIMARY KEY,
+                                 b STRING COLLATE "unicode_ci");]]);
+ | ---
+ | - row_count: 1
+ | ...
+box.execute("SELECT * FROM test;");
+ | ---
+ | - metadata:
+ |   - span: A
+ |     type: scalar
+ |     is_nullable: false
+ |     name: A
+ |     collation: unicode_ci
+ |   - span: B
+ |     type: string
+ |     is_nullable: true
+ |     name: B
+ |     collation: unicode_ci
+ |   rows: []
+ | ...
+
+--
+-- Cleanup.
+--
+box.execute([[UPDATE "_session_settings"
+                  SET "value" = false
+                  WHERE "name" = 'sql_full_metadata';]]);
+ | ---
+ | - row_count: 1
+ | ...
+box.execute("DROP TABLE test;");
+ | ---
+ | - row_count: 1
+ | ...
diff --git a/test/sql/gh-4755-scalar-collation-metadata.test.lua b/test/sql/gh-4755-scalar-collation-metadata.test.lua
new file mode 100755
index 000000000..197b06891
--- /dev/null
+++ b/test/sql/gh-4755-scalar-collation-metadata.test.lua
@@ -0,0 +1,22 @@
+env = require('test_run')
+test_run = env.new()
+
+--
+-- gh-4755: Collation in metadata must be displayed as for string
+-- filed as for scalar field.
+--
+test_run:cmd("setopt delimiter ';'");
+box.execute([[UPDATE "_session_settings"
+                  SET "value" = true
+                  WHERE "name" = 'sql_full_metadata';]]);
+box.execute([[CREATE TABLE test (a SCALAR COLLATE "unicode_ci" PRIMARY KEY,
+                                 b STRING COLLATE "unicode_ci");]]);
+box.execute("SELECT * FROM test;");
+
+--
+-- Cleanup.
+--
+box.execute([[UPDATE "_session_settings"
+                  SET "value" = false
+                  WHERE "name" = 'sql_full_metadata';]]);
+box.execute("DROP TABLE test;");
-- 
2.21.0 (Apple Git-122)

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-06-15 15:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-10 12:47 [Tarantool-patches] [PATCH] sql: display collation in metadata for scalar Roman Khabibov
2020-06-10 14:00 ` Kirill Yukhin
2020-06-11 21:03   ` Roman Khabibov
2020-06-15 15:01 ` Kirill Yukhin
  -- strict thread matches above, loose matches on Subject: below --
2020-04-17 11:09 Roman Khabibov
2020-05-18 10:26 ` Mergen Imeev
2020-06-03 18:56   ` Roman Khabibov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox