[Tarantool-patches] [PATCH v2 13/16] sql: introduce sql_stmt_query_str() method

Nikita Pettik korablev at tarantool.org
Thu Nov 21 00:28:12 MSK 2019


It is getter to fetch string of SQL query from prepared statement.

Needed for #2592
---
 src/box/execute.h     | 6 ++++++
 src/box/sql/vdbeapi.c | 7 +++++++
 2 files changed, 13 insertions(+)

diff --git a/src/box/execute.h b/src/box/execute.h
index d5b4d8421..16b424d36 100644
--- a/src/box/execute.h
+++ b/src/box/execute.h
@@ -124,6 +124,12 @@ sql_finalize(struct sql_stmt *stmt);
 size_t
 sql_stmt_sizeof(const struct sql_stmt *stmt);
 
+/**
+ * Return string of SQL query.
+ */
+const char *
+sql_stmt_query_str(const struct sql_stmt *stmt);
+
 /**
  * Prepare (compile into VDBE byte-code) statement.
  *
diff --git a/src/box/sql/vdbeapi.c b/src/box/sql/vdbeapi.c
index 10135bb68..0978e12fd 100644
--- a/src/box/sql/vdbeapi.c
+++ b/src/box/sql/vdbeapi.c
@@ -858,6 +858,13 @@ sql_stmt_sizeof(const sql_stmt *stmt)
 	return size;
 }
 
+const char *
+sql_stmt_query_str(const sql_stmt *stmt)
+{
+	struct Vdbe *v = (struct Vdbe *) stmt;
+	return v->zSql;
+}
+
 /******************************* sql_bind_  **************************
  *
  * Routines used to attach values to wildcards in a compiled SQL statement.
-- 
2.15.1



More information about the Tarantool-patches mailing list