From: imeevma@tarantool.org To: korablev@tarantool.org Cc: tarantool-patches@freelists.org Subject: [tarantool-patches] [PATCH v3 2/9] sql: save SQL parser errors in diag_set() Date: Sat, 2 Mar 2019 16:07:50 +0300 [thread overview] Message-ID: <438920c8d359811a86f30d3c55cf85d4584ed79b.1551530224.git.imeevma@gmail.com> (raw) In-Reply-To: <cover.1551530224.git.imeevma@gmail.com> After this patch all SQL parser errors will be saved in diag_set() instead of field zErrMsg of struct Parse. Part of #3965 --- src/box/errcode.h | 1 + src/box/sql/build.c | 3 ++- src/box/sql/util.c | 6 +++--- test/box/misc.result | 1 + test/sql-tap/check.test.lua | 2 +- test/sql/triggers.result | 4 ++-- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/box/errcode.h b/src/box/errcode.h index f2f47c0..d234d26 100644 --- a/src/box/errcode.h +++ b/src/box/errcode.h @@ -238,6 +238,7 @@ struct errcode_record { /*183 */_(ER_SQL_KEYWORD_IS_RESERVED, "Keyword '%.*s' is reserved. Please use double quotes if '%.*s' is an identifier.") \ /*184 */_(ER_SQL_UNRECOGNIZED_SYNTAX, "Syntax error near '%.*s'") \ /*185 */_(ER_SQL_UNKNOWN_TOKEN, "Syntax error: unrecognized token: '%.*s'") \ + /*186 */_(ER_SQL_PARSER_GENERIC, "%s") \ /* * !IMPORTANT! Please follow instructions at start of the file diff --git a/src/box/sql/build.c b/src/box/sql/build.c index f112c9f..deb5b89 100644 --- a/src/box/sql/build.c +++ b/src/box/sql/build.c @@ -194,7 +194,8 @@ sql_finish_coding(struct Parse *parse_context) sqlVdbeMakeReady(v, parse_context); parse_context->rc = SQL_DONE; } else { - parse_context->rc = SQL_ERROR; + if (parse_context->rc != SQL_TARANTOOL_ERROR) + parse_context->rc = SQL_ERROR; } } /** diff --git a/src/box/sql/util.c b/src/box/sql/util.c index c89e2e8..e4c93cb 100644 --- a/src/box/sql/util.c +++ b/src/box/sql/util.c @@ -236,10 +236,10 @@ sqlErrorMsg(Parse * pParse, const char *zFormat, ...) va_start(ap, zFormat); zMsg = sqlVMPrintf(db, zFormat, ap); va_end(ap); + diag_set(ClientError, ER_SQL_PARSER_GENERIC, zMsg); + sqlDbFree(db, zMsg); pParse->nErr++; - sqlDbFree(db, pParse->zErrMsg); - pParse->zErrMsg = zMsg; - pParse->rc = SQL_ERROR; + pParse->rc = SQL_TARANTOOL_ERROR; } void diff --git a/test/box/misc.result b/test/box/misc.result index 27579c6..9f0b2c7 100644 --- a/test/box/misc.result +++ b/test/box/misc.result @@ -514,6 +514,7 @@ t; 182: box.error.SQL_STATEMENT_EMPTY 184: box.error.SQL_UNRECOGNIZED_SYNTAX 185: box.error.SQL_UNKNOWN_TOKEN + 186: box.error.SQL_PARSER_GENERIC ... test_run:cmd("setopt delimiter ''"); --- diff --git a/test/sql-tap/check.test.lua b/test/sql-tap/check.test.lua index b6b7fc7..bab6493 100755 --- a/test/sql-tap/check.test.lua +++ b/test/sql-tap/check.test.lua @@ -319,7 +319,7 @@ test:do_catchsql_test( ); ]], { -- <check-3.1> - 1, "Failed to create space 'T3': SQL error: subqueries prohibited in CHECK constraints" + 1, "Failed to create space 'T3': subqueries prohibited in CHECK constraints" -- </check-3.1> }) diff --git a/test/sql/triggers.result b/test/sql/triggers.result index bbfff33..9ab169b 100644 --- a/test/sql/triggers.result +++ b/test/sql/triggers.result @@ -398,14 +398,14 @@ space_id = box.space.T1.id ... box.sql.execute("CREATE TRIGGER tr1 AFTER INSERT ON t1 WHEN new.a = ? BEGIN SELECT 1; END;") --- -- error: 'SQL error: bindings are not allowed in DDL' +- error: bindings are not allowed in DDL ... tuple = {"TR1", space_id, {sql = [[CREATE TRIGGER tr1 AFTER INSERT ON t1 WHEN new.a = ? BEGIN SELECT 1; END;]]}} --- ... box.space._trigger:insert(tuple) --- -- error: 'SQL error: bindings are not allowed in DDL' +- error: bindings are not allowed in DDL ... box.sql.execute("DROP TABLE t1;") --- -- 2.7.4
next prev parent reply other threads:[~2019-03-02 13:07 UTC|newest] Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-03-02 13:07 [tarantool-patches] [PATCH v3 0/9] sql: use diag_set() for errors in SQL imeevma 2019-03-02 13:07 ` [tarantool-patches] [PATCH v3 1/9] sql: rework syntax errors imeevma 2019-03-04 17:47 ` [tarantool-patches] " n.pettik 2019-03-05 8:31 ` Konstantin Osipov 2019-03-02 13:07 ` imeevma [this message] 2019-03-05 8:40 ` [tarantool-patches] Re: [PATCH v3 2/9] sql: save SQL parser errors in diag_set() Konstantin Osipov 2019-03-05 9:06 ` n.pettik 2019-03-02 13:07 ` [tarantool-patches] [PATCH v3 3/9] sql: remove field nErr of struct Parse imeevma 2019-03-05 8:41 ` [tarantool-patches] " Konstantin Osipov 2019-03-05 9:06 ` n.pettik 2019-03-02 13:07 ` [tarantool-patches] [PATCH v3 4/9] sql: remove field rc " imeevma 2019-03-05 8:42 ` [tarantool-patches] " Konstantin Osipov 2019-03-05 9:06 ` n.pettik 2019-03-02 13:07 ` [tarantool-patches] [PATCH v3 5/9] sql: remove field zErrMsg " imeevma 2019-03-05 8:43 ` [tarantool-patches] " Konstantin Osipov 2019-03-05 9:06 ` n.pettik 2019-03-02 13:07 ` [tarantool-patches] [PATCH v3 6/9] sql: rework six syntax errors imeevma 2019-03-05 8:45 ` [tarantool-patches] " Konstantin Osipov 2019-03-05 9:07 ` n.pettik 2019-03-02 13:08 ` [tarantool-patches] [PATCH v3 7/9] sql: rework four semantic errors imeevma 2019-03-05 8:46 ` [tarantool-patches] " Konstantin Osipov 2019-03-05 9:16 ` n.pettik 2019-03-02 13:08 ` [tarantool-patches] [PATCH v3 8/9] sql: rework three errors of "unsupported" type imeevma 2019-03-05 8:47 ` [tarantool-patches] " Konstantin Osipov 2019-03-05 9:34 ` n.pettik 2019-03-05 9:43 ` Konstantin Osipov 2019-03-02 13:08 ` [tarantool-patches] [PATCH v3 9/9] sql: remove sqlErrorMsg() imeevma 2019-03-05 8:48 ` [tarantool-patches] " Konstantin Osipov 2019-03-05 12:16 ` n.pettik 2019-03-05 15:44 ` Konstantin Osipov
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=438920c8d359811a86f30d3c55cf85d4584ed79b.1551530224.git.imeevma@gmail.com \ --to=imeevma@tarantool.org \ --cc=korablev@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [tarantool-patches] [PATCH v3 2/9] sql: save SQL parser errors in diag_set()' \ /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