Tarantool development patches archive
 help / color / mirror / Atom feed
From: Nikita Pettik <korablev@tarantool.org>
To: tarantool-patches@freelists.org
Cc: Nikita Pettik <korablev@tarantool.org>
Subject: [tarantool-patches] [PATCH 1/3] sql: remove redundant check of space format from QP
Date: Fri, 24 May 2019 20:39:39 +0300	[thread overview]
Message-ID: <feae9e26b0b3483056f84a7adb021b7679ec2ed5.1558700151.git.korablev@tarantool.org> (raw)
In-Reply-To: <cover.1558700151.git.korablev@tarantool.org>
In-Reply-To: <cover.1558700151.git.korablev@tarantool.org>

In SQL we are able to execute queries involving spaces only with formats.
Otherwise, at the very beginning of query compilation error is raised.
So, after that any checks of format existence are redundant.
---
 src/box/sql/wherecode.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/src/box/sql/wherecode.c b/src/box/sql/wherecode.c
index a453fe979..6f72506ad 100644
--- a/src/box/sql/wherecode.c
+++ b/src/box/sql/wherecode.c
@@ -967,7 +967,7 @@ sqlWhereCodeOneLoopStart(WhereInfo * pWInfo,	/* Complete information about the W
 		assert(idx_def != NULL);
 		struct space *space = space_by_id(idx_def->space_id);
 		assert(space != NULL);
-		bool is_format_set = space->def->field_count != 0;
+		assert(space->def->field_count != 0);
 		iIdxCur = pLevel->iIdxCur;
 		assert(nEq >= pLoop->nSkip);
 
@@ -996,8 +996,7 @@ sqlWhereCodeOneLoopStart(WhereInfo * pWInfo,	/* Complete information about the W
 			 * FYI: entries in an index are ordered as follows:
 			 *      NULL, ... NULL, min_value, ...
 			 */
-			if (is_format_set &&
-			    space->def->fields[j].is_nullable) {
+			if (space->def->fields[j].is_nullable) {
 				assert(pLoop->nSkip == 0);
 				bSeekPastNull = 1;
 				nExtraReg = 1;
@@ -1020,8 +1019,7 @@ sqlWhereCodeOneLoopStart(WhereInfo * pWInfo,	/* Complete information about the W
 			nExtraReg = MAX(nExtraReg, pLoop->nTop);
 			if (pRangeStart == 0) {
 				j = idx_def->key_def->parts[nEq].fieldno;
-				if (is_format_set &&
-				    space->def->fields[j].is_nullable)
+				if (space->def->fields[j].is_nullable)
 					bSeekPastNull = 1;
 			}
 		}
@@ -1099,12 +1097,10 @@ sqlWhereCodeOneLoopStart(WhereInfo * pWInfo,	/* Complete information about the W
 		}
 		struct index_def *idx_pk = space->index[0]->def;
 		int fieldno = idx_pk->key_def->parts[0].fieldno;
-		enum field_type fd_type = is_format_set ?
-					  space->def->fields[fieldno].type :
-					  FIELD_TYPE_SCALAR;
 
 		uint32_t pk_part_count = idx_pk->key_def->part_count;
-		if (pk_part_count == 1 && fd_type == FIELD_TYPE_INTEGER) {
+		if (pk_part_count == 1 &&
+		    space->def->fields[fieldno].type == FIELD_TYPE_INTEGER) {
 			/* Right now INTEGER PRIMARY KEY is the only option to
 			 * get Tarantool's INTEGER column type. Need special handling
 			 * here: try to loosely convert FLOAT to INT. If RHS type
-- 
2.15.1

  reply	other threads:[~2019-05-24 17:39 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-24 17:39 [tarantool-patches] [PATCH 0/3] Fix passing key with different from iterator's type Nikita Pettik
2019-05-24 17:39 ` Nikita Pettik [this message]
2019-05-24 17:39 ` [tarantool-patches] [PATCH 2/3] sql: remove redundant type derivation from QP Nikita Pettik
2019-05-27 21:49   ` [tarantool-patches] " Vladislav Shpilevoy
2019-05-28 19:58     ` n.pettik
2019-05-24 17:39 ` [tarantool-patches] [PATCH 3/3] sql: fix passing FP values to integer iterator Nikita Pettik
2019-05-25  5:51   ` [tarantool-patches] " Konstantin Osipov
2019-05-27 21:49     ` Vladislav Shpilevoy
2019-05-28  7:19       ` Konstantin Osipov
2019-05-28 11:31         ` Vladislav Shpilevoy
2019-05-29  7:02           ` Konstantin Osipov
2019-05-28 13:00         ` n.pettik
2019-05-29  9:14           ` Konstantin Osipov
2019-05-27 21:49   ` Vladislav Shpilevoy
2019-05-28 19:58     ` n.pettik
2019-06-02 18:11       ` Vladislav Shpilevoy
2019-06-06 13:51         ` n.pettik
2019-06-06 19:07           ` Vladislav Shpilevoy
2019-07-11  9:19 ` [tarantool-patches] Re: [PATCH 0/3] Fix passing key with different from iterator's type 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=feae9e26b0b3483056f84a7adb021b7679ec2ed5.1558700151.git.korablev@tarantool.org \
    --to=korablev@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH 1/3] sql: remove redundant check of space format from QP' \
    /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