Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@freelists.org, Nikita Pettik <korablev@tarantool.org>
Cc: kostja@tarantool.org
Subject: [tarantool-patches] Re: [PATCH 3/9] sql: use msgpack types instead of custom ones
Date: Tue, 16 Apr 2019 17:12:48 +0300	[thread overview]
Message-ID: <374916ec-2e49-643f-eccb-42f9d66e340e@tarantool.org> (raw)
In-Reply-To: <7d55169718d4bc193a41710da12cfd6a7d4edebc.1555252410.git.korablev@tarantool.org>

Thanks for the patch! See 4 comments below.

On 14/04/2019 18:04, Nikita Pettik wrote:
> This patch provides straightforward refactoring replacing enum sql_type
> with enum mp_type. Note that we use msgpack format instead of field_type
> since it is more suitable when dealing with NULLs.
> ---
>  src/box/bind.c          |  37 ++++++------------
>  src/box/execute.c       |  12 +++---
>  src/box/lua/execute.c   |   7 +---
>  src/box/lua/lua_sql.c   |  12 +++---
>  src/box/sql/date.c      |   2 +-
>  src/box/sql/func.c      | 100 ++++++++++++++++++++++++------------------------
>  src/box/sql/legacy.c    |   2 +-
>  src/box/sql/sqlInt.h    |  16 ++------
>  src/box/sql/vdbeapi.c   |  66 ++++++++++----------------------
>  src/box/sql/whereexpr.c |   2 +-
>  10 files changed, 102 insertions(+), 154 deletions(-)
> 
> diff --git a/src/box/bind.c b/src/box/bind.c
> index 4b57e23c8..5aa79751a 100644
> --- a/src/box/bind.c
> +++ b/src/box/bind.c
> @@ -138,6 +121,7 @@ sql_bind_decode(struct sql_bind *bind, int i, const char **packet)
>  	default:
>  		unreachable();
>  	}
> +	bind->type = type;

1. struct sql_bind.type still is uint8_t and commented as
'SQL type of the value.'. Please, change its type to enum mp_type
and say in the comment 'MessagePack type of the value.'

>  	return 0;
>  }
>  > diff --git a/src/box/sql/date.c b/src/box/sql/date.c
> index 5f5272ea3..ead0c01d0 100644
> --- a/src/box/sql/date.c
> +++ b/src/box/sql/date.c
> @@ -937,7 +937,7 @@ isDate(sql_context * context, int argc, sql_value ** argv, DateTime * p)
>  	if (argc == 0) {
>  		return setDateTimeToCurrent(context, p);
>  	}
> -	if ((eType = sql_value_type(argv[0])) == SQL_FLOAT
> +	if ((eType = sql_value_type(argv[0])) == MP_DOUBLE

2. Firstly, the code is commented out. Secondly, sql_value_type
does not exist anymore. Thirdly, eType is of type int, not
enum mp_type, and can not be compared with MP_DOUBLE.

Please, rename sql_value_mp_type to sql_value_type, because we
do not have 'not mp' type anymore. Then this hunk will be ok
except the third objection.

>  	    || eType == SQL_INTEGER) {
>  		setRawDateNumber(p, sql_value_double(argv[0]));
>  	} else {
> diff --git a/src/box/sql/func.c b/src/box/sql/func.c
> index 9adfeec67..3cdb119c8 100644
> --- a/src/box/sql/func.c
> +++ b/src/box/sql/func.c
> @@ -87,10 +87,10 @@ minmaxFunc(sql_context * context, int argc, sql_value ** argv)
>  	pColl = sqlGetFuncCollSeq(context);
>  	assert(mask == -1 || mask == 0);
>  	iBest = 0;
> -	if (sql_value_type(argv[0]) == SQL_NULL)
> +	if (sql_value_mp_type(argv[0]) == MP_NIL)

3. Please, move that check into a separate static inline
function in a header file. It appeared to be used often.
A possible name 'sql_value_is_null'.

>  		return;
>  	for (i = 1; i < argc; i++) {
> -		if (sql_value_type(argv[i]) == SQL_NULL)
> +		if (sql_value_mp_type(argv[i]) == MP_NIL)
>  			return;
>  		if ((sqlMemCompare(argv[iBest], argv[i], pColl) ^ mask) >=
>  		    0) {
> @@ -139,15 +139,15 @@ lengthFunc(sql_context * context, int argc, sql_value ** argv)
>  
>  	assert(argc == 1);
>  	UNUSED_PARAMETER(argc);
> -	switch (sql_value_type(argv[0])) {
> -	case SQL_BLOB:
> -	case SQL_INTEGER:
> -	case SQL_FLOAT:{
> +	switch (sql_value_mp_type(argv[0])) {
> +	case MP_BIN:
> +	case MP_INT:
> +	case MP_DOUBLE:{

4. Probably you could fix part of this:
https://github.com/tarantool/tarantool/issues/4159 in scope of
this commit, alongside.

>  			sql_result_int(context,
>  					   sql_value_bytes(argv[0]));
>  			break;
>  		}
> -	case SQL_TEXT:{
> +	case MP_STR:{
>  			const unsigned char *z = sql_value_text(argv[0]);
>  			if (z == 0)

  reply	other threads:[~2019-04-16 14:12 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
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   ` Vladislav Shpilevoy [this message]
2019-04-18 17:54     ` [tarantool-patches] " 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=374916ec-2e49-643f-eccb-42f9d66e340e@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=korablev@tarantool.org \
    --cc=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH 3/9] sql: use msgpack types instead of custom ones' \
    /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