[Tarantool-patches] [PATCH v1 03/21] sql: refactor HEX() function
Mergen Imeev
imeevma at tarantool.org
Mon Oct 25 11:19:31 MSK 2021
Thank you for the review! My answer and diff below. Also, I added a description
of the function.
On Fri, Oct 15, 2021 at 12:43:14AM +0200, Vladislav Shpilevoy wrote:
> Good job on the patch!
>
> > diff --git a/src/box/sql/func.c b/src/box/sql/func.c
> > index 7886f5f40..e5d763be1 100644
> > --- a/src/box/sql/func.c
> > +++ b/src/box/sql/func.c
> > @@ -800,6 +800,39 @@ func_greatest_least(struct sql_context *ctx, int argc, struct Mem *argv)
> > ctx->is_aborted = true;
> > }
> >
> > +/** Implementation of the HEX() function. */
> > +static const char hexdigits[] = {
> > + '0', '1', '2', '3', '4', '5', '6', '7',
> > + '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
> > +};
> > +
> > +static void
> > +func_hex(struct sql_context *ctx, int argc, struct Mem *argv)
> > +{
> > + assert(argc == 1);
> > + (void)argc;
> > + struct Mem *arg = &argv[0];
> > + if (mem_is_null(arg))
> > + return mem_set_null(ctx->pOut);
>
> Isn't pOut already null? I thought it is created as null.
True, fixed.
Diff:
diff --git a/src/box/sql/func.c b/src/box/sql/func.c
index 96525ed3a..2abf6811d 100644
--- a/src/box/sql/func.c
+++ b/src/box/sql/func.c
@@ -796,7 +796,11 @@ func_greatest_least(struct sql_context *ctx, int argc, struct Mem *argv)
ctx->is_aborted = true;
}
-/** Implementation of the HEX() function. */
+/**
+ * Implementation of the HEX() function.
+ *
+ * The HEX() function returns the hexadecimal representation of the argument.
+ */
static const char hexdigits[] = {
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
@@ -809,7 +813,7 @@ func_hex(struct sql_context *ctx, int argc, struct Mem *argv)
(void)argc;
struct Mem *arg = &argv[0];
if (mem_is_null(arg))
- return mem_set_null(ctx->pOut);
+ return;
assert(mem_is_bin(arg) && arg->n >= 0);
if (arg->n == 0)
More information about the Tarantool-patches
mailing list