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 E81B12C098 for ; Mon, 12 Nov 2018 19:07:36 -0500 (EST) 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 hPgte-WWKFNs for ; Mon, 12 Nov 2018 19:07:36 -0500 (EST) Received: from smtp20.mail.ru (smtp20.mail.ru [94.100.179.251]) (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 9C3EB2B6EC for ; Mon, 12 Nov 2018 19:07:36 -0500 (EST) From: Nikita Pettik Subject: [tarantool-patches] [PATCH v2 1/3] sql: do not add explicit clause Date: Tue, 13 Nov 2018 03:07:24 +0300 Message-Id: <9582cd3146ee8717fd249bca78b8132641ff4bb1.1542066357.git.korablev@tarantool.org> In-Reply-To: References: In-Reply-To: References: 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 Cc: v.shpilevoy@tarantool.org, Nikita Pettik We don't need to add explicit COLLATE "BINARY" clause since binary collation is anyway default. On the other hand, it may confuse due to ambiugty when comparing two terms. Needed for #3185 --- src/box/sql/fkey.c | 2 -- src/box/sql/select.c | 4 ---- src/box/sql/whereexpr.c | 25 ++++++++++++------------- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/box/sql/fkey.c b/src/box/sql/fkey.c index fc39c879e..4e3270f0c 100644 --- a/src/box/sql/fkey.c +++ b/src/box/sql/fkey.c @@ -313,8 +313,6 @@ exprTableRegister(Parse * pParse, /* Parsing and code generating context */ pExpr->iTable = regBase + iCol + 1; char affinity = pTab->def->fields[iCol].affinity; pExpr->affinity = affinity; - pExpr = sqlite3ExprAddCollateString(pParse, pExpr, - "binary"); } else { pExpr->iTable = regBase; pExpr->affinity = AFFINITY_INTEGER; diff --git a/src/box/sql/select.c b/src/box/sql/select.c index 16b1044d6..dfa6ed8e0 100644 --- a/src/box/sql/select.c +++ b/src/box/sql/select.c @@ -2238,10 +2238,6 @@ sql_multiselect_orderby_to_key_info(struct Parse *parse, struct Select *s, order_by->a[i].pExpr = sqlite3ExprAddCollateString(parse, term, name); - } else { - order_by->a[i].pExpr = - sqlite3ExprAddCollateString(parse, term, - "BINARY"); } } part->coll_id = id; diff --git a/src/box/sql/whereexpr.c b/src/box/sql/whereexpr.c index 612868695..9fa6ce15d 100644 --- a/src/box/sql/whereexpr.c +++ b/src/box/sql/whereexpr.c @@ -1133,7 +1133,6 @@ exprAnalyze(SrcList * pSrc, /* the FROM clause */ Expr *pNewExpr2; int idxNew1; int idxNew2; - const char *zCollSeqName; /* Name of collating sequence */ const u16 wtFlags = TERM_LIKEOPT | TERM_VIRTUAL | TERM_DYNAMIC; pLeft = pExpr->x.pList->a[1].pExpr; @@ -1171,24 +1170,24 @@ exprAnalyze(SrcList * pSrc, /* the FROM clause */ } *pC = c + 1; } - /* Support only for unicode_ci indexes by now */ - zCollSeqName = noCase ? "unicode_ci" : "BINARY"; pNewExpr1 = sqlite3ExprDup(db, pLeft, 0); - pNewExpr1 = sqlite3PExpr(pParse, TK_GE, - sqlite3ExprAddCollateString(pParse, - pNewExpr1, - zCollSeqName), - pStr1); + if (noCase) { + pNewExpr1 = + sqlite3ExprAddCollateString(pParse, pNewExpr1, + "unicode_ci"); + } + pNewExpr1 = sqlite3PExpr(pParse, TK_GE, pNewExpr1, pStr1); transferJoinMarkings(pNewExpr1, pExpr); idxNew1 = whereClauseInsert(pWC, pNewExpr1, wtFlags); testcase(idxNew1 == 0); exprAnalyze(pSrc, pWC, idxNew1); pNewExpr2 = sqlite3ExprDup(db, pLeft, 0); - pNewExpr2 = sqlite3PExpr(pParse, TK_LT, - sqlite3ExprAddCollateString(pParse, - pNewExpr2, - zCollSeqName), - pStr2); + if (noCase) { + pNewExpr2 = + sqlite3ExprAddCollateString(pParse, pNewExpr2, + "unicode_ci"); + } + pNewExpr2 = sqlite3PExpr(pParse, TK_LT, pNewExpr2, pStr2); transferJoinMarkings(pNewExpr2, pExpr); idxNew2 = whereClauseInsert(pWC, pNewExpr2, wtFlags); testcase(idxNew2 == 0); -- 2.15.1