From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp53.i.mail.ru (smtp53.i.mail.ru [94.100.177.113]) (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 BA908469710 for ; Wed, 3 Jun 2020 21:56:16 +0300 (MSK) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3594.4.19\)) From: Roman Khabibov In-Reply-To: <20200518102648.GA17007@tarantool.org> Date: Wed, 3 Jun 2020 21:56:14 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <0B39C92C-DAAE-40E3-8102-F7182F8B18F8@tarantool.org> References: <20200417110925.31741-1-roman.habibov@tarantool.org> <20200518102648.GA17007@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH] sql: display collation in metadata for scalar List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Mergen Imeev Cc: tarantool-patches@dev.tarantool.org Hi! Thanks for the review. Nikita, could you, please, do a second = review. > On May 18, 2020, at 13:26, Mergen Imeev wrote: >=20 > Hi! Thank you for the fix. I have only one comment here, > you can see it below. Please send next version to Nikita. >=20 > On Fri, Apr 17, 2020 at 02:09:25PM +0300, Roman Khabibov wrote: >> Fix bug with the display of collation for scalar fields in >> >> when sql_full_metadata is enabled. >>=20 >> 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 >>=20 >> 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 =3D=3D TK_VARIABLE) >> var_pos[var_count++] =3D i; >> - vdbe_metadata_set_col_type(v, i, >> - = field_type_strs[sql_expr_type(p)]); >> - if (is_full_meta && sql_expr_type(p) =3D=3D = FIELD_TYPE_STRING) { >> + enum field_type type =3D sql_expr_type(p); >> + vdbe_metadata_set_col_type(v, i, field_type_strs[type]); >> + if (is_full_meta && (type =3D=3D FIELD_TYPE_STRING || >> + type =3D=3D FIELD_TYPE_SCALAR)) { >> bool unused; >> uint32_t id =3D 0; >> struct coll *coll =3D 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 =3D require('test_run') >> + | --- >> + | ... >> +test_run =3D 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" =3D true >> + WHERE "name" =3D '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" =3D false >> + WHERE "name" =3D '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 =3D require('test_run') >> +test_run =3D 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" =3D true >> + WHERE "name" =3D '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" =3D false >> + WHERE "name" =3D 'sql_full_metadata';]]); >> +box.execute("DROP TABLE test;"); >> --=20 >> 2.21.0 (Apple Git-122) commit d3733a4170f392e24db8d485c980d61130ce8a19 (HEAD -> = romanhabibov/gh-4755-scalar-collation, = origin/romanhabibov/gh-4755-scalar-collation) Author: Roman Khabibov Date: Fri Apr 17 10:04:44 2020 +0300 sql: display collation in metadata for scalar =20 Fix bug with the display of collation for scalar fields in