[tarantool-patches] Re: [PATCH] sql: LIKE & GLOB pattern comparison issue
Nikita Tatunov
hollow653 at gmail.com
Thu Jul 19 14:14:20 MSK 2018
ср, 18 июл. 2018 г. в 20:10, Alexander Turenko <
alexander.turenko at tarantool.org>:
> Two minor comments are below.
>
> WBR, Alexander Turenko.
>
> On Wed, Jul 18, 2018 at 06:57:39PM +0300, Nikita Tatunov wrote:
> > ср, 18 июл. 2018 г. в 18:53, Alex Khatskevich
> > <[1]avkhatskevich at tarantool.org>:
> >
> > Once you have fixed comments, please apply a new full diff at the end
> > of email, to
> > continue review process.
> > Answer with a full diff to this email please (just paste as a plain
> > text output of `git diff` command)
> > On 18.07.2018 18:24, Nikita Tatunov wrote:
> >
> > -/*
> > - * For LIKE and GLOB matching on EBCDIC machines, assume that every
> > - * character is exactly one byte in size. Also, provde the
> Utf8Read()
> > - * macro for fast reading of the next character in the common case
> > where
> > - * the next character is ASCII.
> > +/**
> > + * Providing there are symbols in string s this macro returns
> > + * UTF-8 code of character and pushes pointer to the next symbol
> > + * in the string. Otherwise return code is SQL_END_OF_STRING.
>
> Nitpicking: pushes -> promotes?
>
>
Both should be fine, I guess. But ok, changed it.
> > */
> > -#define Utf8Read(s, e) ucnv_getNextUChar(pUtf8conv, &s, e,
> &status)
> > +#define Utf8Read(s, e) (s < e ?\
> > + ucnv_getNextUChar(pUtf8conv, &s, e, &status) : 0)
> > +
> > +#define SQL_END_OF_STRING 0
>
> Always wrap argument usages of a function-like macro within its body
> with parenthesis (consider example I give in the previous email). It is
> usual way to handle the fact that a macros works as text replacement,
> so, say
>
> #define SUB(x, y) x - y
>
> will give the wrong result for the expression SUB(10, 5 - 3), while
>
> #define SUB(x, y) ((x) - (y))
>
> will produce the correct result.
>
Fixed.
Also made few minor codestyle fixes in tests compared to prev. patch.
diff --git a/src/box/sql/func.c b/src/box/sql/func.c
index c06e3bd..a9784cc 100644
--- a/src/box/sql/func.c
+++ b/src/box/sql/func.c
@@ -617,13 +617,16 @@ struct compareInfo {
u8 noCase; /* true to ignore case differences */
};
-/*
- * For LIKE and GLOB matching on EBCDIC machines, assume that every
- * character is exactly one byte in size. Also, provde the Utf8Read()
- * macro for fast reading of the next character in the common case where
- * the next character is ASCII.
+/**
+ * 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.
*/
-#define Utf8Read(s, e) ucnv_getNextUChar(pUtf8conv, &s, e, &status)
+#define Utf8Read(s, e) (((s) < (e)) ?\
+ ucnv_getNextUChar(pUtf8conv, &s, e, &status) : 0)
+
+#define SQL_END_OF_STRING 0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.tarantool.org/pipermail/tarantool-patches/attachments/20180719/b3de3577/attachment.html>
More information about the Tarantool-patches
mailing list