[Tarantool-patches] [PATCH v1 1/1] temporary: locate missing diag

imeevma at tarantool.org imeevma at tarantool.org
Wed Nov 25 13:14:15 MSK 2020


---
https://github.com/tarantool/tarantool/issues/5537
https://github.com/tarantool/tarantool/tree/imeevma/gh-5537-find-missing-diag

 src/box/errcode.h     | 1 +
 src/box/execute.c     | 9 ++++++++-
 test/box/error.result | 1 +
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/box/errcode.h b/src/box/errcode.h
index 938d41153..7d1703580 100644
--- a/src/box/errcode.h
+++ b/src/box/errcode.h
@@ -267,6 +267,7 @@ struct errcode_record {
 	/*212 */_(ER_SEQUENCE_NOT_STARTED,		"Sequence '%s' is not started") \
 	/*213 */_(ER_NO_SUCH_SESSION_SETTING,	"Session setting %s doesn't exist") \
 	/*214 */_(ER_TUPLE_METADATA_IS_TOO_BIG,	"Can't create tuple: metadata size %u is too big") \
+	/*215 */_(ER_DIAG_NOT_SET,		"Diag is not set: %s") \
 
 /*
  * !IMPORTANT! Please follow instructions at start of the file
diff --git a/src/box/execute.c b/src/box/execute.c
index 66eac9814..97fae1e42 100644
--- a/src/box/execute.c
+++ b/src/box/execute.c
@@ -724,6 +724,8 @@ sql_execute_prepared(uint32_t stmt_id, const struct sql_bind *bind,
 	if (sql_execute(stmt, port, region) != 0) {
 		port_destroy(port);
 		sql_stmt_reset(stmt);
+		if (diag_last_error(&fiber()->diag) == NULL)
+			diag_set(ClientError, ER_DIAG_NOT_SET, "VDBE");
 		return -1;
 	}
 	sql_stmt_reset(stmt);
@@ -737,8 +739,11 @@ sql_prepare_and_execute(const char *sql, int len, const struct sql_bind *bind,
 			struct region *region)
 {
 	struct sql_stmt *stmt;
-	if (sql_stmt_compile(sql, len, NULL, &stmt, NULL) != 0)
+	if (sql_stmt_compile(sql, len, NULL, &stmt, NULL) != 0) {
+		if (diag_last_error(&fiber()->diag) == NULL)
+			diag_set(ClientError, ER_DIAG_NOT_SET, "Parser");
 		return -1;
+	}
 	assert(stmt != NULL);
 	enum sql_serialization_format format = sql_column_count(stmt) > 0 ?
 					   DQL_EXECUTE : DML_EXECUTE;
@@ -747,5 +752,7 @@ sql_prepare_and_execute(const char *sql, int len, const struct sql_bind *bind,
 	    sql_execute(stmt, port, region) == 0)
 		return 0;
 	port_destroy(port);
+	if (diag_last_error(&fiber()->diag) == NULL)
+		diag_set(ClientError, ER_DIAG_NOT_SET, "VDBE");
 	return -1;
 }
diff --git a/test/box/error.result b/test/box/error.result
index a16682438..d05e66776 100644
--- a/test/box/error.result
+++ b/test/box/error.result
@@ -433,6 +433,7 @@ t;
  |   212: box.error.SEQUENCE_NOT_STARTED
  |   213: box.error.NO_SUCH_SESSION_SETTING
  |   214: box.error.TUPLE_METADATA_IS_TOO_BIG
+ |   215: box.error.DIAG_NOT_SET
  | ...
 
 test_run:cmd("setopt delimiter ''");
-- 
2.25.1



More information about the Tarantool-patches mailing list