[tarantool-patches] [PATCH 1/3] sql: remove redundant check of space format from QP

Nikita Pettik korablev at tarantool.org
Fri May 24 20:39:39 MSK 2019


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





More information about the Tarantool-patches mailing list