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 E149D2760F for ; Tue, 26 Mar 2019 15:20:25 -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 5XffZKaHucno for ; Tue, 26 Mar 2019 15:20:25 -0400 (EDT) Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (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 1C619253DC for ; Tue, 26 Mar 2019 15:20:24 -0400 (EDT) Date: Tue, 26 Mar 2019 22:20:21 +0300 From: Mergen Imeev Subject: [tarantool-patches] Re: [PATCH v4 7/8] sql: rework semantic errors Message-ID: <20190326192021.GA30904@tarantool.org> References: <6dca562ff5163f5579f45d175b6cf188db52a09f.1552494059.git.imeevma@gmail.com> <53DBABF2-8730-4FF6-9C23-64BF3F9986D1@tarantool.org> <20190322124822.GA7890@tarantool.org> <08DAB5A5-C5B9-4D0F-B3C3-D3B29505B2D0@tarantool.org> <20190326165653.GA3149@tarantool.org> <9EFBE722-AEB3-4592-AD43-BEC564893529@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <9EFBE722-AEB3-4592-AD43-BEC564893529@tarantool.org> 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: "n.pettik" Cc: tarantool-patches@freelists.org On Tue, Mar 26, 2019 at 09:16:08PM +0300, n.pettik wrote: > > > #if SQL_MAX_COLUMN > > if (pOrderBy->nExpr > db->aLimit[SQL_LIMIT_COLUMN]) { > > - const char *err_msg = > > - is_order_by ? "The number of terms in ORDER BY clause" : > > - "The number of terms in GROUP BY clause"; > > + const char *err_msg; > > + if (zType[0] != 'G') > > + err_msg = "The number of terms in ORDER BY clause"; > > + else > > + err_msg = "The number of terms in GROUP BY clauseā€¯; > > Just use format string and sprintf - it allows to remove branching > (like it was in original SQLite code). > Fixed: diff --git a/src/box/sql/resolve.c b/src/box/sql/resolve.c index 30a6b5f..747e4c4 100644 --- a/src/box/sql/resolve.c +++ b/src/box/sql/resolve.c @@ -1055,12 +1055,9 @@ sqlResolveOrderGroupBy(Parse * pParse, /* Parsing context. Leave error messages return 0; #if SQL_MAX_COLUMN if (pOrderBy->nExpr > db->aLimit[SQL_LIMIT_COLUMN]) { - const char *err_msg; - if (zType[0] != 'G') - err_msg = "The number of terms in ORDER BY clause"; - else - err_msg = "The number of terms in GROUP BY clause"; - diag_set(ClientError, ER_SQL_PARSER_LIMIT, err_msg, + const char *err = tt_sprintf("The number of terms in %s BY "\ + "clause", zType); + diag_set(ClientError, ER_SQL_PARSER_LIMIT, err, pOrderBy->nExpr, db->aLimit[SQL_LIMIT_COLUMN]); pParse->is_aborted = true; return 1;