Tarantool development patches archive
 help / color / mirror / Atom feed
From: Alexander Turenko <alexander.turenko@tarantool.org>
To: Nikita Tatunov <n.tatunov@tarantool.org>
Cc: tarantool-patches@freelists.org, korablev@tarantool.org
Subject: [tarantool-patches] Re: [PATCH 2/2] sql: remove GLOB from Tarantool
Date: Sun, 21 Oct 2018 06:48:05 +0300	[thread overview]
Message-ID: <20181021034805.alwhmkpz3fbopqjz@tkn_work_nb> (raw)
In-Reply-To: <090683CD-6F88-492D-AF48-631220A24E36@tarantool.org>

I don't have objections re this commit in general. Please, fix minor
comments below and proceed with Nikita P.

WBR, Alexander Turenko.

> - * Providing there are symbols in string s this
> - * macro returns UTF-8 code of character and
> - * promotes pointer to the next symbol in the string.
> - * Otherwise return code is SQL_END_OF_STRING.
> + * Providing there are symbols in string s this macro returns
> + * UTF-8 code of character and promotes pointer to the next
> + * symbol in the string. If s points to an invalid UTF-8 symbol
> + * return code is SQL_INVALID_UTF8_SYMBOL. If there're no symbols
> + * left in string s return code is SQL_END_OF_STRING.

> -/*
> - * Possible error returns from sql_utf8_pattern_compare()
> +/**
> + * Possible error returns from sql_utf8_pattern_compare().
>   */

> - *      '%'       Matches any sequence of zero or more characters.
> + *      '%'       Matches any sequence of zero or more
> + *                characters.

> - *      Ec        Where E is the "esc" character and c is any other
> - *                character, including '%', '_', and esc, match
> - *                exactly c.
> + *      Ec        Where E is the "esc" character and c is any
> + *                other character, including '%', '_', and esc,
> + *                match exactly c.

> -       const char * pattern_end = pattern + strlen(pattern);
> -       const char * string_end = string + strlen(string);
> +       const char *pattern_end = pattern + strlen(pattern);
> +       const char *string_end = string + strlen(string);

Please, amend these hunks into the first patch. The first patch includes
code style fixes, so it would look more appropriate in it, eps. when you
already touch the code in it.

> +static const int case_insensitive_like = 1;
> +static const int case_sensitive_like = 0;

Are not they are mutually exclusive? Can we leave just one?

Why they are not defines?

/** .. */ inside functions should be /* */ (they are just comments and
they aren't documentation comments). It appears here ans there, so,
please, grep the intire patch for such things.

> -       return sql_utf8_pattern_compare(zGlobPattern, zString, &globInfo, '[');
> +       return sql_utf8_pattern_compare(zPattern, zStr, case_sensitive_like, esc);

> -       return sql_utf8_pattern_compare(zPattern, zStr, &likeInfoNorm, esc);
> +       return sql_utf8_pattern_compare(zPattern, zStr, case_insensitive_like, esc);

Exceeds 80 symbols

> + * @param is_case_sensitive whether like should be case sensitive
> + *                      or not.

Indent is strange.

> +       int *is_like_ci;
> +       if (is_case_sensitive)
> +               is_like_ci = (int *)&case_sensitive_like;
> +       else
> +               is_like_ci = (int *)&case_insensitive_like;

Discarding const qualifier? It seems not being right thing to do. It is
better to define is_like_ci pointer as const.

> -int sqlite3IsLikeFunction(sqlite3 *, Expr *, int *, char *);
> +int sql_is_like_func(sqlite3 *db, Expr *pExpr, int *is_case_insensitive);

The code around does not have parameter names, so here they are looks
strange.

> +       /* String on RHS of LIKE operator */
> +       const char *z = 0;
> +       /* Right and left size of LIKE operator */
> +       Expr *pRight, *pLeft;
> +       /* List of operands to the LIKE operator */
> +       ExprList *pList;
> +       /* One character in z[] */
> +       int c;
> +       /* Number of non-wildcard prefix characters */
> +       int cnt;
> +       /* Database connection */
> +       sqlite3 *db = pParse->db;
>         sqlite3_value *pVal = 0;
> -       int op;                 /* Opcode of pRight */
> -       int rc;                 /* Result code to return */
> +       /* Opcode of pRight */
> +       int op;
> +       /* Result code to return */
> +       int rc;

Our code style suggests to add a period at end of the comment. The same
in exprAnalyze() below.

> +        INSERT INTO t1 SELECT a+5,6,'six'||substr(c,4) FROM t1 WHERE c LIKE 'one-%';

Trailing whitespaces.

> --- NOTE: This test needs refactoring after deletion of GLOB &
> ---      type restrictions for LIKE. (See #3572)
>  -- Another NOTE: MATCH & REGEXP aren't supported in Tarantool &
> ---              are waiting for their hour, don't confuse them
> ---              being commented with ticket above.
> -    {"=", "==", "!=", "<>"}, --"LIKE", "GLOB"}, --"MATCH", "REGEXP"},
> +--               are waiting for their hour, don't confuse them
> +--               being commented with commenting of "LIKE".
> +    {"=", "==", "!=", "<>"}, --"MATCH", "REGEXP"},

Another NOTE -> NOTE.

'don't confuse them being commented with commenting of "LIKE"' -- can be
removed.

test/sql-tap/like3.test.lua cases can be rewritten with LIKE instead of
removing, right? I think it worth to do if it is so.

  reply	other threads:[~2018-10-21  3:48 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-16 17:00 [tarantool-patches] [PATCH v2 0/2] sql: pattern comparison fixes & GLOB removal N.Tatunov
2018-08-16 17:00 ` [tarantool-patches] [PATCH 1/2] sql: LIKE & GLOB pattern comparison issue N.Tatunov
2018-08-17  9:23   ` [tarantool-patches] " Alex Khatskevich
2018-08-17 11:17     ` Alexander Turenko
2018-08-17 11:42       ` Alex Khatskevich
2018-09-09 13:33         ` Nikita Tatunov
2018-09-10 22:20           ` Alex Khatskevich
2018-09-11  6:06             ` Nikita Tatunov
2018-09-11 10:06               ` Alex Khatskevich
2018-09-11 13:31                 ` Nikita Tatunov
2018-10-18 18:02                   ` Nikita Tatunov
2018-10-21  3:51                     ` Alexander Turenko
2018-10-26 15:19                       ` Nikita Tatunov
2018-10-29 13:01                         ` Alexander Turenko
2018-10-31  5:25                           ` Nikita Tatunov
2018-11-01 10:30                             ` Alexander Turenko
2018-11-14 14:16                               ` n.pettik
2018-11-14 17:06                                 ` Alexander Turenko
2018-08-16 17:00 ` [tarantool-patches] [PATCH 2/2] sql: remove GLOB from Tarantool N.Tatunov
2018-08-17  8:25   ` [tarantool-patches] " Alex Khatskevich
2018-08-17  8:49     ` n.pettik
2018-08-17  9:01       ` Alex Khatskevich
2018-08-17  9:20         ` n.pettik
2018-08-17  9:28           ` Alex Khatskevich
     [not found]     ` <04D02794-07A5-4146-9144-84EE720C8656@corp.mail.ru>
2018-08-17  8:53       ` Alex Khatskevich
2018-08-17 11:26     ` Alexander Turenko
2018-08-17 11:34       ` Alexander Turenko
2018-08-17 13:46     ` Nikita Tatunov
2018-09-09 14:57     ` Nikita Tatunov
2018-09-10 22:06       ` Alex Khatskevich
2018-09-11  7:38         ` Nikita Tatunov
2018-09-11 10:11           ` Alexander Turenko
2018-09-11 10:22             ` Alex Khatskevich
2018-09-11 12:03           ` Alex Khatskevich
2018-10-18 20:28             ` Nikita Tatunov
2018-10-21  3:48               ` Alexander Turenko [this message]
2018-10-26 15:21                 ` Nikita Tatunov
2018-10-29 12:15                   ` Alexander Turenko
2018-11-08 15:09                     ` Nikita Tatunov
2018-11-09 12:18                       ` Alexander Turenko
2018-11-10  3:38                         ` Nikita Tatunov
2018-11-13 19:23                           ` Alexander Turenko
2018-11-14 14:16                             ` n.pettik
2018-11-14 17:41                               ` Alexander Turenko
2018-11-14 21:48                                 ` n.pettik
2018-11-15  4:57 ` [tarantool-patches] Re: [PATCH v2 0/2] sql: pattern comparison fixes & GLOB removal Kirill Yukhin

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=20181021034805.alwhmkpz3fbopqjz@tkn_work_nb \
    --to=alexander.turenko@tarantool.org \
    --cc=korablev@tarantool.org \
    --cc=n.tatunov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH 2/2] sql: remove GLOB from Tarantool' \
    /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