From: "n.pettik" <korablev@tarantool.org>
To: tarantool-patches@freelists.org
Cc: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH 2/9] sql: disallow text values participate in sum() aggregate
Date: Tue, 23 Apr 2019 22:58:07 +0300 [thread overview]
Message-ID: <EC5E066E-FCF3-4047-8745-C0A063CC78CC@tarantool.org> (raw)
In-Reply-To: <6484927f-90fc-666f-7516-f11005f09d2c@tarantool.org>
>> diff --git a/src/box/sql/func.c b/src/box/sql/func.c
>> index b86a95d9a..9adfeec67 100644
>> --- a/src/box/sql/func.c
>> +++ b/src/box/sql/func.c
>> @@ -1495,24 +1495,34 @@ static void
>> sumStep(sql_context * context, int argc, sql_value ** argv)
>> {
>> SumCtx *p;
>> - int type;
>> assert(argc == 1);
>> UNUSED_PARAMETER(argc);
>> p = sql_aggregate_context(context, sizeof(*p));
>> - type = sql_value_numeric_type(argv[0]);
>> - if (p && type != SQL_NULL) {
>> - p->cnt++;
>> - if (type == SQL_INTEGER) {
>> - i64 v = sql_value_int64(argv[0]);
>> - p->rSum += v;
>> - if ((p->approx | p->overflow) == 0
>> - && sqlAddInt64(&p->iSum, v)) {
>> - p->overflow = 1;
>> - }
>> - } else {
>> - p->rSum += sql_value_double(argv[0]);
>> - p->approx = 1;
>> + assert(p != NULL);
>
> Why are you sure, that p != NULL? sql_aggregate_context()
> on first invocation allocates memory, and it can fail.
Well, theoretically speaking - yes, it can. You’ve fixed that
in review fix, so skipped.
>> + int type = sql_value_type(argv[0]);
>> + if (type == SQL_NULL)
>> + return;
>
> I've fixed the comment above and also I see, that sumStep is
> rewritten almost completely, so it is time to convert it to
> Tarantool style. See the diff below and on the branch in a
> separate commit.
Thx. Diff is OK, applied.
next prev parent reply other threads:[~2019-04-23 19:58 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-14 15:03 [tarantool-patches] [PATCH 0/9] Introduce type BOOLEAN in SQL Nikita Pettik
2019-04-14 15:03 ` [tarantool-patches] [PATCH 1/9] sql: refactor mem_apply_numeric_type() Nikita Pettik
2019-04-14 15:04 ` [tarantool-patches] [PATCH 2/9] sql: disallow text values participate in sum() aggregate Nikita Pettik
2019-04-16 14:12 ` [tarantool-patches] " Vladislav Shpilevoy
2019-04-18 17:54 ` n.pettik
2019-04-22 18:02 ` Vladislav Shpilevoy
2019-04-23 19:58 ` n.pettik [this message]
2019-04-14 15:04 ` [tarantool-patches] [PATCH 3/9] sql: use msgpack types instead of custom ones Nikita Pettik
2019-04-16 14:12 ` [tarantool-patches] " Vladislav Shpilevoy
2019-04-18 17:54 ` n.pettik
2019-04-22 18:02 ` Vladislav Shpilevoy
2019-04-23 19:58 ` n.pettik
2019-04-14 15:04 ` [tarantool-patches] [PATCH 4/9] sql: introduce type boolean Nikita Pettik
2019-04-16 14:12 ` [tarantool-patches] " Vladislav Shpilevoy
2019-04-18 17:54 ` n.pettik
2019-04-22 18:02 ` Vladislav Shpilevoy
2019-04-23 19:58 ` n.pettik
2019-04-23 21:06 ` Vladislav Shpilevoy
2019-04-14 15:04 ` [tarantool-patches] [PATCH 5/9] sql: improve type determination for column meta Nikita Pettik
2019-04-16 14:12 ` [tarantool-patches] " Vladislav Shpilevoy
2019-04-18 17:54 ` n.pettik
2019-04-22 18:02 ` Vladislav Shpilevoy
2019-04-23 19:58 ` n.pettik
2019-04-14 15:04 ` [tarantool-patches] [PATCH 6/9] sql: make comparison predicate return boolean Nikita Pettik
2019-04-16 14:12 ` [tarantool-patches] " Vladislav Shpilevoy
2019-04-18 17:54 ` n.pettik
2019-04-14 15:04 ` [tarantool-patches] [PATCH 7/9] sql: make predicates accept and " Nikita Pettik
2019-04-16 14:12 ` [tarantool-patches] " Vladislav Shpilevoy
2019-04-18 17:55 ` n.pettik
2019-04-14 15:04 ` [tarantool-patches] [PATCH 9/9] sql: make <search condition> accept only boolean Nikita Pettik
2019-04-16 14:12 ` [tarantool-patches] " Vladislav Shpilevoy
2019-04-18 17:55 ` n.pettik
2019-04-22 18:02 ` Vladislav Shpilevoy
2019-04-23 19:59 ` n.pettik
2019-04-23 21:06 ` Vladislav Shpilevoy
2019-04-23 22:01 ` n.pettik
[not found] ` <b2a84f129c2343d3da3311469cbb7b20488a21c2.1555252410.git.korablev@tarantool.org>
2019-04-16 14:12 ` [tarantool-patches] Re: [PATCH 8/9] sql: make LIKE predicate return boolean result Vladislav Shpilevoy
2019-04-18 17:55 ` n.pettik
2019-04-22 18:02 ` Vladislav Shpilevoy
2019-04-23 19:58 ` n.pettik
2019-04-24 10:28 ` [tarantool-patches] Re: [PATCH 0/9] Introduce type BOOLEAN in SQL Vladislav Shpilevoy
2019-04-25 8:46 ` 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=EC5E066E-FCF3-4047-8745-C0A063CC78CC@tarantool.org \
--to=korablev@tarantool.org \
--cc=tarantool-patches@freelists.org \
--cc=v.shpilevoy@tarantool.org \
--subject='[tarantool-patches] Re: [PATCH 2/9] sql: disallow text values participate in sum() aggregate' \
/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