Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: imeevma@tarantool.org, tsafin@tarantool.org
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH v5 45/52] sql: introduce mem_get_int()
Date: Wed, 14 Apr 2021 01:01:02 +0200	[thread overview]
Message-ID: <57fdcb76-1935-ff3d-ca70-9edf3a4bd640@tarantool.org> (raw)
In-Reply-To: <921ae5a9b533bd897100dc2e7923347638719b13.1618000037.git.imeevma@gmail.com>

Nice fixes!

On 09.04.2021 22:53, Mergen Imeev via Tarantool-patches wrote:
> Thank you for the review! My answers and new patch below.
> 
> 
> On 30.03.2021 02:08, Vladislav Shpilevoy wrote:
>> Thanks for the patch!
>>
>>> diff --git a/src/box/sql/func.c b/src/box/sql/func.c
>>> index b644c39d8..0fa0f6ac7 100644
>>> --- a/src/box/sql/func.c
>>> +++ b/src/box/sql/func.c
>>> @@ -1532,10 +1543,11 @@ hexFunc(sql_context * context, int argc, sql_value ** argv)
>>>  static void
>>>  zeroblobFunc(sql_context * context, int argc, sql_value ** argv)
>>>  {
>>> -	i64 n;
>>> +	int64_t n;
>>>  	assert(argc == 1);
>>>  	UNUSED_PARAMETER(argc);
>>> -	n = sql_value_int64(argv[0]);
>>> +	bool unused;
>>> +	mem_get_integer(argv[0], &n, &unused);
>>
>> The flag is never used anywhere except one assertion where you can
>> check the integer value instead. I think you can drop this out
>> parameter. In future we could add mem_get_int_with_sign() or something
>> like that if necessary.
> I think the problem here mostly because most of built-in functions and bitwise
> operations cannot work with our INTEGER. They can only work with int64. I
> believe, if we fix this problem, there will be no problems with having this
> flag.

My complaint is about the flag. The third argument which is almost never
used. It makes the code ugly, and does not give a clue it is broken in fact.
When uint64_t is > INT64_MAX and is returned as int64_t and the flag is
ignored.

What about mem_get_int_unsafe()? It would return int64_t truncated like
before. Return as 'return', not out parameter. Because we also never check
for fail as I see. And no 'unused' flag. But we would clearly see that these
places are broken and need attention.

  reply	other threads:[~2021-04-13 23:01 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1618000036.git.imeevma@gmail.com>
2021-04-09 20:53 ` [Tarantool-patches] [PATCH v5 41/52] sql: introduce mem_to_number() Mergen Imeev via Tarantool-patches
2021-04-13 23:25   ` Mergen Imeev via Tarantool-patches
2021-04-09 20:53 ` [Tarantool-patches] [PATCH v5 42/52] sql: introduce mem_to_str() and mem_to_str0() Mergen Imeev via Tarantool-patches
2021-04-13 22:58   ` Vladislav Shpilevoy via Tarantool-patches
2021-04-13 23:41     ` Mergen Imeev via Tarantool-patches
2021-04-09 20:53 ` [Tarantool-patches] [PATCH v5 43/52] sql: introduce mem_cast_explicit() Mergen Imeev via Tarantool-patches
2021-04-13 22:59   ` Vladislav Shpilevoy via Tarantool-patches
2021-04-14  0:01     ` Mergen Imeev via Tarantool-patches
2021-04-09 20:53 ` [Tarantool-patches] [PATCH v5 44/52] sql: introduce mem_cast_implicit() Mergen Imeev via Tarantool-patches
2021-04-13 22:59   ` Vladislav Shpilevoy via Tarantool-patches
2021-04-14  0:05     ` Mergen Imeev via Tarantool-patches
2021-04-09 20:53 ` [Tarantool-patches] [PATCH v5 45/52] sql: introduce mem_get_int() Mergen Imeev via Tarantool-patches
2021-04-13 23:01   ` Vladislav Shpilevoy via Tarantool-patches [this message]
2021-04-14  0:28     ` Mergen Imeev via Tarantool-patches
2021-04-14  1:17       ` Mergen Imeev via Tarantool-patches
2021-04-09 21:08 ` [Tarantool-patches] [PATCH v5 46/52] sql: introduce mem_get_uint() Mergen Imeev via Tarantool-patches
2021-04-13 23:04   ` Vladislav Shpilevoy via Tarantool-patches
2021-04-14  0:39     ` Mergen Imeev via Tarantool-patches
2021-04-14  1:21       ` Mergen Imeev via Tarantool-patches
2021-04-09 21:08 ` [Tarantool-patches] [PATCH v5 47/52] sql: introduce mem_get_double() Mergen Imeev via Tarantool-patches
2021-04-13 23:04   ` Vladislav Shpilevoy via Tarantool-patches
2021-04-14  1:00     ` Mergen Imeev via Tarantool-patches
2021-04-15  0:17       ` Vladislav Shpilevoy via Tarantool-patches
2021-04-15  0:46         ` Mergen Imeev via Tarantool-patches
2021-04-09 21:08 ` [Tarantool-patches] [PATCH v5 48/52] sql: introduce mem_get_bool() Mergen Imeev via Tarantool-patches
2021-04-13 23:04   ` Vladislav Shpilevoy via Tarantool-patches
2021-04-14  1:29     ` Mergen Imeev via Tarantool-patches
2021-04-09 21:08 ` [Tarantool-patches] [PATCH v5 49/52] sql: introduce mem_get_str0() and mem_as_str0() Mergen Imeev via Tarantool-patches
2021-04-13 23:06   ` Vladislav Shpilevoy via Tarantool-patches
2021-04-14  1:43     ` Mergen Imeev via Tarantool-patches
2021-04-09 21:08 ` [Tarantool-patches] [PATCH v5 50/52] sql: introduce mem_get_bin() Mergen Imeev via Tarantool-patches
2021-04-09 21:08 ` [Tarantool-patches] [PATCH v5 51/52] sql: introduce mem_get_bytes_len() Mergen Imeev via Tarantool-patches
2021-04-13 23:06   ` Vladislav Shpilevoy via Tarantool-patches
2021-04-14  1:55     ` Mergen Imeev via Tarantool-patches
2021-04-15  0:21       ` Vladislav Shpilevoy via Tarantool-patches
2021-04-15  0:51         ` Mergen Imeev via Tarantool-patches
2021-04-09 21:08 ` [Tarantool-patches] [PATCH v5 52/52] sql: introduce mem_get_agg() 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=57fdcb76-1935-ff3d-ca70-9edf3a4bd640@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=imeevma@tarantool.org \
    --cc=tsafin@tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v5 45/52] sql: introduce mem_get_int()' \
    /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