From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 930E03000B for ; Fri, 24 May 2019 13:39:50 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Cae7nD7HB-X5 for ; Fri, 24 May 2019 13:39:50 -0400 (EDT) Received: from smtp52.i.mail.ru (smtp52.i.mail.ru [94.100.177.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id CCF2D30035 for ; Fri, 24 May 2019 13:39:44 -0400 (EDT) From: Nikita Pettik Subject: [tarantool-patches] [PATCH 1/3] sql: remove redundant check of space format from QP Date: Fri, 24 May 2019 20:39:39 +0300 Message-Id: In-Reply-To: References: In-Reply-To: References: Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org Cc: Nikita Pettik 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