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 746D925197 for ; Fri, 15 Feb 2019 07:50:11 -0500 (EST) 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 34Pjm8_k_VzQ for ; Fri, 15 Feb 2019 07:50:11 -0500 (EST) Received: from smtp51.i.mail.ru (smtp51.i.mail.ru [94.100.177.111]) (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 08D7D25182 for ; Fri, 15 Feb 2019 07:50:09 -0500 (EST) Date: Fri, 15 Feb 2019 15:50:07 +0300 From: Konstantin Osipov Subject: [tarantool-patches] Re: [PATCH v1 1/1] sql: rework "no such object" and "object exists" errors Message-ID: <20190215125007.GB14894@chai> References: <168FF7F0-A4AA-42DD-AF9A-FA95098ADBBA@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <168FF7F0-A4AA-42DD-AF9A-FA95098ADBBA@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, Imeev Mergen * n.pettik [19/02/15 15:46]: > > + /*148 */_(ER_NO_SUCH_INDEX_NAME, "No index '%s' is defined in space '%s'") \ > > I’d better say ’No index with name …’. > But it is to be discussed. It's a copycat of the INDEX_ID message. > > + /*153 */_(ER_NO_SUCH_FIELD_NAME, "Field '%s' doesn't exist") \ > > Mb it is better to split this error into two: > “Space %s doesn’t feature field with name %s” and > “Unresolved column name %s” > > Again, I’m neither SQL expert nor technical writer, so it is not up to me. In a separate patch. > > /** > > + * Increment error counter if error suppression isn't set. > > + * > > + * @param parse_context Current parsing context. > > + */ > > +void > > +sql_parser_error(struct Parse *parse_context); > > I suggest to incapsulate call of diag set inside this > function. To achieve this, lets make function take > variadic params. It would allow us to reduce size > of refactored code, at least. Nikita, I agree in general but given this entire function is temporary, I think it's good enough. > > } > > > > +void > > +sql_parser_error(struct Parse *parse_context) > > +{ > > + if (parse_context->db->suppressErr) > > + return; > > As Konstantin pointed out, seems like we don’t need > taking into consideration suppressErr here. > > > + parse_context->nErr++; > > + parse_context->rc = SQL_TARANTOOL_ERROR; > > +} > > + > > + > > Extra blank line. Good point, I agree! > > -- > > box.sql.execute("CREATE TABLE w2 (s1 INT PRIMARY KEY, CHECK ((SELECT COUNT(*) FROM w2) = 0));") > > --- > > -- error: 'Failed to create space ''W2'': SQL error: no such table: W2' > > +- error: 'Failed to create space ''W2'': Space ''W2'' does not exist’ > > Hm, IMHO looks a bit misleading. > Could we improve error reporting in this case? > It would be nice to see smth like “name cannot be resolved” or > “Misuse of space forward declaration”. In a separate patch, please. > -- Konstantin Osipov, Moscow, Russia, +7 903 626 22 32 http://tarantool.io - www.twitter.com/kostja_osipov