Tarantool development patches archive
 help / color / mirror / Atom feed
From: Mergen Imeev via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH v2 1/3] sql: initialize MEM used in aggregate functions
Date: Mon, 17 May 2021 14:38:28 +0300
Message-ID: <20210517113828.GA177059@tarantool.org> (raw)
In-Reply-To: <4b765060-a56e-e5d7-2b3a-5adb3a4bd40c@tarantool.org>

Hi! Thank you for the review! My answer and diff below.

On Thu, Apr 29, 2021 at 11:02:06PM +0200, Vladislav Shpilevoy wrote:
> Hi! Thanks for the patch!
> 
> > diff --git a/src/box/sql/func.c b/src/box/sql/func.c
> > index 9c28d5122..d282b2cea 100644
> > --- a/src/box/sql/func.c
> > +++ b/src/box/sql/func.c
> > @@ -1798,14 +1798,13 @@ minmaxStep(sql_context * context, int NotUsed, sql_value ** argv)
> >  static void
> >  minMaxFinalize(sql_context * context)
> >  {
> > -	sql_value *pRes;
> > -	pRes = (sql_value *) sql_aggregate_context(context, 0);
> > -	if (pRes) {
> > -		if (pRes->flags) {
> > -			sql_result_value(context, pRes);
> > -		}
> > -		mem_destroy(pRes);
> > -	}
> > +	struct Mem *mem = context->pMem;
> > +	struct Mem *res;
> > +	if (!mem_is_agg(mem) || mem_get_agg(mem, (void **)&res) != 0)
> 
> You don't need `is_agg` check. `get` does the same already.
> 
Fixed.

> > +		return;
> > +	if (!mem_is_null(res))
> > +		sql_result_value(context, res);
> > +	mem_destroy(res);
> >  }

Diff:


diff --git a/src/box/sql/func.c b/src/box/sql/func.c
index d282b2cea..94302cc56 100644
--- a/src/box/sql/func.c
+++ b/src/box/sql/func.c
@@ -1800,7 +1800,7 @@ minMaxFinalize(sql_context * context)
 {
 	struct Mem *mem = context->pMem;
 	struct Mem *res;
-	if (!mem_is_agg(mem) || mem_get_agg(mem, (void **)&res) != 0)
+	if (mem_get_agg(mem, (void **)&res) != 0)
 		return;
 	if (!mem_is_null(res))
 		sql_result_value(context, res);

  reply	other threads:[~2021-05-17 11:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1619542456.git.imeevma@gmail.com>
2021-04-27 16:55 ` Mergen Imeev via Tarantool-patches
2021-04-29 21:02   ` Vladislav Shpilevoy via Tarantool-patches
2021-05-17 11:38     ` Mergen Imeev via Tarantool-patches [this message]
2021-04-27 16:55 ` [Tarantool-patches] [PATCH v2 2/3] sql: make mem_is_bin() to check only for VARBINARY Mergen Imeev via Tarantool-patches
2021-04-29 21:05   ` Vladislav Shpilevoy via Tarantool-patches
2021-05-17 12:05     ` Mergen Imeev via Tarantool-patches

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=20210517113828.GA177059@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=imeevma@tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    /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

Tarantool development patches archive

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://lists.tarantool.org/tarantool-patches/0 tarantool-patches/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 tarantool-patches tarantool-patches/ https://lists.tarantool.org/tarantool-patches \
		tarantool-patches@dev.tarantool.org.
	public-inbox-index tarantool-patches

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git