From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id CD2EE31909 for ; Tue, 25 Jun 2019 13:54:53 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id m-z_3B2jspeK for ; Tue, 25 Jun 2019 13:54:53 -0400 (EDT) Received: from smtp38.i.mail.ru (smtp38.i.mail.ru [94.100.177.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 87AF231907 for ; Tue, 25 Jun 2019 13:54:53 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH 1/2 v2] test: check that collations isn't ignored in SELECTs References: <49f3a1279811efc66c580c6039cf1b890ff37889.1561372731.git.roman.habibov@tarantool.org> From: Vladislav Shpilevoy Message-ID: <01159864-ba96-a618-4d07-7f250994fcc1@tarantool.org> Date: Tue, 25 Jun 2019 19:55:39 +0200 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org, "n.pettik" Cc: Roman Khabibov On 25/06/2019 19:30, n.pettik wrote: > > >> On 24 Jun 2019, at 13:54, Roman Khabibov wrote: >> >> Add test to check that a new collation isn't ignored regardless >> of a name of a previous one in the following patterns of quries: > > Nit: quries -> queries > >> >> SELECT s COLLATE "unicode_ci" FROM a ORDER BY s COLLATE “unicode_ci" > > Why do you consider this kind of query? What can be wrong with it? That example works, but when the collations are different, according to the standard the last one should be applied, as I remember when I last time checked. Before the patch a wrong collation was used when there are several of them. If under `this kind of query` you mean why 'order by'? - it is just the only request where we can reproduce that. I've tried to find a simpler test, but did not manage. > Specifying collation for result set members doesn’t make much sense btw. > >> >> Also note: It is disallowed to compare strings with different >> collations: ISO/IEC JTC 1/SC 32, Part 2: Foundation, page 531 >> --- >> src/box/sql/resolve.c | 7 +++++++ >> test/sql-tap/collation.test.lua | 19 ++++++++++++++++++- >> 2 files changed, 25 insertions(+), 1 deletion(-) >> >> diff --git a/src/box/sql/resolve.c b/src/box/sql/resolve.c >> index fdf3703da..348b3ea9a 100644 >> --- a/src/box/sql/resolve.c >> +++ b/src/box/sql/resolve.c >> @@ -109,6 +109,13 @@ resolveAlias(Parse * pParse, /* Parsing context */ >> return; >> if (zType[0] != 'G') >> incrAggFunctionDepth(pDup, nSubquery); >> + /* >> + * If there was typed more than one explicit collations in >> + * query, it will be a sequence of left nodes with the >> + * collations in a tree. There is nothing special about >> + * keeping the sequence. Only one collation could be >> + * stored, but the present solution is simpler. >> + */ > > Do not understand how mentioned example is related to this code. > I suppose you might mean example like: > > SELECT s COLLATE “unicode” COLLATE “binary” COLLATE “unicode_ci” … > > Is this syntax allowed by ANSI? If so, which one (first or last) collation must be used? Yes, allowed, the last collation should be used. Probably, Roman, you should include in the commit message a reference to the standard (probably you did, I don't know - the first message in that thread is lost in my copy of our mailing list). > >> if (pExpr->op == TK_COLLATE) { >> pDup = >> sqlExprAddCollateString(pParse, pDup, pExpr->u.zToken);