From: "n.pettik" <korablev@tarantool.org>
To: tarantool-patches@freelists.org
Cc: Imeev Mergen <imeevma@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH v2 4/6] sql: fix "PRAGMA case_sensitive_like" result
Date: Mon, 24 Dec 2018 16:01:54 +0200 [thread overview]
Message-ID: <23926231-FF7A-4562-A8BA-A3E96E422CAA@tarantool.org> (raw)
In-Reply-To: <cb761db4a695685eb6a826254ebdda4b52d0c543.1544871594.git.imeevma@gmail.com>
> diff --git a/src/box/sql/pragma.c b/src/box/sql/pragma.c
> index f34e7b8..9390f6f 100644
> --- a/src/box/sql/pragma.c
> +++ b/src/box/sql/pragma.c
> @@ -591,13 +591,20 @@ sqlite3Pragma(Parse * pParse, Token * pId, /* First part of [schema.]id field */
> * depending on the RHS.
> */
> case PragTyp_CASE_SENSITIVE_LIKE:{
> - if (zRight) {
> - int is_like_ci =
> - !(sqlite3GetBoolean(zRight, 0));
> - sqlite3RegisterLikeFunctions(db, is_like_ci);
> - }
> - break;
> + int mask = pPragma->iArg;
> + if (zRight == NULL) {
> + returnSingleInt(v,
> + (user_session->sql_flags & mask) != 0);
> + } else {
> + int is_like_ci = !(sqlite3GetBoolean(zRight, 0));
> + if (!is_like_ci)
> + user_session->sql_flags |= mask;
> + else
> + user_session->sql_flags &= ~mask;
> + sqlite3RegisterLikeFunctions(db, is_like_ci);
> }
Nit: since pragma is called ‘case_sensitive_like’, I would revert variable
meaning:
+++ b/src/box/sql/pragma.c
@@ -602,12 +602,12 @@ sqlite3Pragma(Parse * pParse, Token * pId, /* First part of [schema.]id field */
returnSingleInt(v,
(user_session->sql_flags & mask) != 0);
} else {
- int is_like_ci = !(sqlite3GetBoolean(zRight, 0));
- if (!is_like_ci)
+ bool is_like_cs = sqlite3GetBoolean(zRight, 0);
+ if (is_like_cs)
user_session->sql_flags |= mask;
else
user_session->sql_flags &= ~mask;
- sqlite3RegisterLikeFunctions(db, is_like_ci);
+ sqlite3RegisterLikeFunctions(db, ! is_like_cs);
Also, the same question here: why you didn’t make it be of
type ‘flag’? The only difference in additional call of sqlite3RegisterLikeFunctions.
> + break;
> + }
>
> case PragTyp_DEFAULT_ENGINE: {
> if (zRight == NULL) {
> diff --git a/src/box/sql/pragma.h b/src/box/sql/pragma.h
> index 59e0e1e..11a2e05 100644
> --- a/src/box/sql/pragma.h
> +++ b/src/box/sql/pragma.h
> @@ -94,9 +94,9 @@ static const PragmaName aPragmaName[] = {
> /* iArg: */ 0},
> { /* zName: */ "case_sensitive_like",
> /* ePragTyp: */ PragTyp_CASE_SENSITIVE_LIKE,
> - /* ePragFlg: */ PragFlg_NoColumns,
> + /* ePragFlg: */ PragFlg_Result0 | PragFlg_NoColumns1,
> /* ColNames: */ 0, 0,
> - /* iArg: */ 0},
> + /* iArg: */ SQLITE_LikeIsCaseSens},
Lets avoid using ’sqlite’ prefixes for added code.
next prev parent reply other threads:[~2018-12-24 14:01 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-15 11:51 [tarantool-patches] [PATCH v2 0/6] sql: set column types for EXPLAIN and PRAGMA imeevma
2018-12-15 11:54 ` [tarantool-patches] [PATCH v2 1/6] sql: remove unnecessary macros from pragma.* imeevma
2018-12-20 20:41 ` [tarantool-patches] " Vladislav Shpilevoy
2018-12-24 14:01 ` n.pettik
2018-12-15 11:56 ` [tarantool-patches] [PATCH v2 2/6] sql: fix "PRAGMA parser_trace" result imeevma
2018-12-24 14:01 ` [tarantool-patches] " n.pettik
2018-12-15 12:01 ` [tarantool-patches] [PATCH v2 3/6] sql: Show currently set sql_default_engine imeevma
2018-12-24 14:01 ` [tarantool-patches] " n.pettik
2018-12-15 12:03 ` [tarantool-patches] [PATCH v2 4/6] sql: fix "PRAGMA case_sensitive_like" result imeevma
2018-12-24 14:01 ` n.pettik [this message]
2018-12-15 12:05 ` [tarantool-patches] [PATCH v2 5/6] sql: 'PRAGMA' result in Tarantool format imeevma
2018-12-24 14:02 ` [tarantool-patches] " n.pettik
2018-12-15 12:08 ` [tarantool-patches] [PATCH v2 6/6] sql: set column types for EXPLAIN and PRAGMA imeevma
2018-12-24 14:02 ` [tarantool-patches] " n.pettik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=23926231-FF7A-4562-A8BA-A3E96E422CAA@tarantool.org \
--to=korablev@tarantool.org \
--cc=imeevma@tarantool.org \
--cc=tarantool-patches@freelists.org \
--subject='[tarantool-patches] Re: [PATCH v2 4/6] sql: fix "PRAGMA case_sensitive_like" result' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox