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>
Subject: [tarantool-patches] Re: [PATCH 7/8] sql: clean-up affinity from SQL source code
Date: Sat, 29 Dec 2018 20:42:24 +0300	[thread overview]
Message-ID: <d1138550-6c27-d993-9848-c8e7788aea61@tarantool.org> (raw)
In-Reply-To: <a53fd0f893ee7eef9f8ac12b2e3adfea59030097.1545987214.git.korablev@tarantool.org>

Thanks for the patch! See 5 comments below.

On 28/12/2018 12:34, Nikita Pettik wrote:
> Replace remains of affinity usage in SQL parser, query optimizer and
> VDBE. Don't add affinity to field definition when table is encoded into
> msgpack.  Remove field type <-> affinity converters, since now we can
> operate directly on field type.
> 
> Part of #3698
> ---
>   src/box/sql.c           |  6 +-----
>   src/box/sql/build.c     | 52 ------------------------------------------------
>   src/box/sql/expr.c      | 11 +++++-----
>   src/box/sql/insert.c    | 39 ++++++------------------------------
>   src/box/sql/select.c    | 17 +++++-----------
>   src/box/sql/sqliteInt.h | 53 -------------------------------------------------
>   src/box/sql/vdbe.c      |  4 ++--
>   src/box/sql/where.c     | 10 ----------
>   src/box/sql/wherecode.c | 29 ++++++++++-----------------
>   src/box/sql/whereexpr.c |  3 ++-
>   test/sql/types.result   | 15 +++++++-------
>   test/sql/upgrade.result |  6 +++---
>   12 files changed, 42 insertions(+), 203 deletions(-)
> 
> diff --git a/src/box/sql/expr.c b/src/box/sql/expr.c
> index 32606dac3..22b64b526 100644
> --- a/src/box/sql/expr.c
> +++ b/src/box/sql/expr.c
> @@ -311,8 +311,7 @@ binaryCompareP5(Expr * pExpr1, Expr * pExpr2, int jumpIfNull)
>   {
>   	enum field_type lhs = sql_expr_type(pExpr2);
>   	enum field_type rhs = sql_expr_type(pExpr1);
> -	u8 type_mask = sql_field_type_to_affinity(sql_type_result(rhs, lhs)) |
> -		       (u8) jumpIfNull;
> +	u8 type_mask = sql_type_result(rhs, lhs) | (u8) jumpIfNull;

1. Are you sure that we can | jumpIfNull with enum field_type? Look at
this code:

	#define SQLITE_KEEPNULL     0x08	/* Used by vector == or <> */
	#define SQLITE_JUMPIFNULL   0x10	/* jumps if either operand is NULL */
	#define SQLITE_STOREP2      0x20	/* Store result in reg[P2] rather than jump */
	#define SQLITE_NULLEQ       0x80	/* NULL=NULL */
	#define SQLITE_NOTNULL      0x90	/* Assert that operands are never NULL */

SQLite states that these values can be safely ORed with type, but
SQLITE_KEEPNULL == FIELD_TYPE_MAP - mess.

>   	return type_mask;
>   }
> diff --git a/src/box/sql/select.c b/src/box/sql/select.c
> index cc3e2f2fd..f3008094b 100644
> --- a/src/box/sql/select.c
> +++ b/src/box/sql/select.c
> @@ -3067,10 +3061,9 @@ generateOutputSubroutine(struct Parse *parse, struct Select *p,
>   			int r1;
>   			testcase(in->nSdst > 1);
>   			r1 = sqlite3GetTempReg(parse);
> -			const char *type_str =
> -				sql_affinity_str_to_field_type_str(dest->zAffSdst);
>   			sqlite3VdbeAddOp4(v, OP_MakeRecord, in->iSdst,
> -					  in->nSdst, r1, type_str, P4_DYNAMIC);
> +					  in->nSdst, r1, dest->zAffSdst,
> +					  in->nSdst);

2. As we learned from the previous patch, p4 here is not
a length. It is a type of memory - static or dynamic.

>   			sqlite3ExprCacheAffinityChange(parse, in->iSdst,
>   						       in->nSdst);
>   			sqlite3VdbeAddOp2(v, OP_IdxInsert, r1, dest->reg_eph);
> diff --git a/src/box/sql/where.c b/src/box/sql/where.c
> index ac5390f92..88c45aaa3 100644
> --- a/src/box/sql/where.c
> +++ b/src/box/sql/where.c
> @@ -701,7 +701,6 @@ termCanDriveIndex(WhereTerm * pTerm,	/* WHERE clause term to check */
>   		return 0;
>   	if (pTerm->u.leftColumn < 0)
>   		return 0;
> -	aff = pSrc->pTab->aCol[pTerm->u.leftColumn].affinity;
>   	if (!sqlite3IndexAffinityOk(pTerm->pExpr, aff))

3. This function does not exist since the previous commit. Looks
like this code is not even compiled.

>   		return 0;
>   	return 1;

4. AFFINITY_MASK still exists.

5. wherecode.c and vdbeaux.c still use AFFINITY_BLOB in comments.

  reply	other threads:[~2018-12-29 17:42 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-28  9:34 [tarantool-patches] [PATCH 0/8] Eliminate affinity from " Nikita Pettik
2018-12-28  9:34 ` [tarantool-patches] [PATCH 1/8] sql: remove SQLITE_ENABLE_UPDATE_DELETE_LIMIT define Nikita Pettik
2018-12-29 17:42   ` [tarantool-patches] " Vladislav Shpilevoy
2019-01-16 14:25     ` n.pettik
2018-12-28  9:34 ` [tarantool-patches] [PATCH 2/8] sql: use field type instead of affinity for type_def Nikita Pettik
2018-12-29 17:42   ` [tarantool-patches] " Vladislav Shpilevoy
2019-01-16 14:26     ` n.pettik
2018-12-28  9:34 ` [tarantool-patches] [PATCH 3/8] sql: remove numeric affinity Nikita Pettik
2018-12-29  9:01   ` [tarantool-patches] " Konstantin Osipov
2018-12-29 17:42   ` Vladislav Shpilevoy
2019-01-09  8:26     ` Konstantin Osipov
2019-01-16 14:26     ` n.pettik
2019-01-22 15:41       ` Vladislav Shpilevoy
2019-01-28 16:39         ` n.pettik
2019-01-30 13:04           ` Vladislav Shpilevoy
2019-02-01 16:39             ` n.pettik
2019-01-09  8:20   ` Konstantin Osipov
2018-12-28  9:34 ` [tarantool-patches] [PATCH 4/8] sql: replace affinity with field type for func Nikita Pettik
2018-12-28  9:34 ` [tarantool-patches] [PATCH 5/8] sql: replace field type with affinity for VDBE runtime Nikita Pettik
2018-12-29 17:42   ` [tarantool-patches] " Vladislav Shpilevoy
2019-01-16 14:26     ` n.pettik
2019-01-22 15:41       ` Vladislav Shpilevoy
2019-01-28 16:39         ` n.pettik
2019-01-30 13:04           ` Vladislav Shpilevoy
2019-02-01 16:39             ` n.pettik
2019-02-05 15:08               ` Vladislav Shpilevoy
2019-02-05 17:46                 ` n.pettik
2018-12-28  9:34 ` [tarantool-patches] [PATCH 6/8] sql: replace affinity with field type in struct Expr Nikita Pettik
2018-12-29 17:42   ` [tarantool-patches] " Vladislav Shpilevoy
2019-01-16 14:26     ` n.pettik
2019-01-22 15:41       ` Vladislav Shpilevoy
2019-01-28 16:39         ` n.pettik
2019-01-30 13:04           ` Vladislav Shpilevoy
2019-02-01 16:39             ` n.pettik
2019-02-05 15:08               ` Vladislav Shpilevoy
2019-02-05 17:46                 ` n.pettik
2018-12-28  9:34 ` [tarantool-patches] [PATCH 7/8] sql: clean-up affinity from SQL source code Nikita Pettik
2018-12-29 17:42   ` Vladislav Shpilevoy [this message]
2019-01-16 14:26     ` [tarantool-patches] " n.pettik
2019-01-22 15:41       ` Vladislav Shpilevoy
2019-01-28 16:40         ` n.pettik
2019-01-30 13:04           ` Vladislav Shpilevoy
2019-02-01 16:39             ` n.pettik
2019-02-05 15:08               ` Vladislav Shpilevoy
2019-02-05 17:46                 ` n.pettik
2018-12-28  9:34 ` [tarantool-patches] [PATCH 8/8] Remove affinity from field definition Nikita Pettik
2019-02-05 19:41 ` [tarantool-patches] Re: [PATCH 0/8] Eliminate affinity from source code Vladislav Shpilevoy
2019-02-08 13:37 ` 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=d1138550-6c27-d993-9848-c8e7788aea61@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=korablev@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH 7/8] sql: clean-up affinity from SQL source code' \
    /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