* [tarantool-patches] [PATCH v1 1/1] sql: remove legacy.c
@ 2019-03-30 14:19 imeevma
0 siblings, 0 replies; only message in thread
From: imeevma @ 2019-03-30 14:19 UTC (permalink / raw)
To: korablev; +Cc: tarantool-patches
The module legacy.c is not used and should be removed.
---
https://github.com/tarantool/tarantool/tree/imeevma/small-patches
src/box/sql/CMakeLists.txt | 1 -
src/box/sql/analyze.c | 9 ++-
src/box/sql/legacy.c | 187 ---------------------------------------------
src/box/sql/sqlInt.h | 7 --
4 files changed, 5 insertions(+), 199 deletions(-)
delete mode 100644 src/box/sql/legacy.c
diff --git a/src/box/sql/CMakeLists.txt b/src/box/sql/CMakeLists.txt
index 87fb833..2573431 100644
--- a/src/box/sql/CMakeLists.txt
+++ b/src/box/sql/CMakeLists.txt
@@ -38,7 +38,6 @@ add_library(sql STATIC
global.c
hash.c
insert.c
- legacy.c
main.c
malloc.c
os.c
diff --git a/src/box/sql/analyze.c b/src/box/sql/analyze.c
index 0663c66..0d26db9 100644
--- a/src/box/sql/analyze.c
+++ b/src/box/sql/analyze.c
@@ -1217,7 +1217,7 @@ decode_stat_string(const char *stat_string, int stat_size, tRowcnt *stat_exact,
* @param argv Callback arguments.
* @retval 0 on success, -1 otherwise.
*/
-static int
+int
analysis_loader(void *data, int argc, char **argv, char **unused)
{
assert(argc == 3);
@@ -1699,11 +1699,12 @@ sql_analysis_load(struct sql *db)
info.db = db;
info.stats = stats;
info.index_count = 0;
- const char *load_stat1 =
+ MAYBE_UNUSED const char *load_stat1 =
"SELECT \"tbl\",\"idx\",\"stat\" FROM \"_sql_stat1\"";
/* Load new statistics out of the _sql_stat1 table. */
- if (sql_exec(db, load_stat1, analysis_loader, &info, 0) != 0)
- goto fail;
+ /* This part was commented due to removing of sql_exec(). */
+ // if (sql_exec(db, load_stat1, analysis_loader, &info, 0) != 0)
+ // goto fail;
if (info.index_count == 0) {
box_txn_commit();
return SQL_OK;
diff --git a/src/box/sql/legacy.c b/src/box/sql/legacy.c
deleted file mode 100644
index 599fba0..0000000
--- a/src/box/sql/legacy.c
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Copyright 2010-2017, Tarantool AUTHORS, please see AUTHORS file.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the
- * following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * <COPYRIGHT HOLDER> OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * Main file for the sql library. The routines in this file
- * implement the programmer interface to the library. Routines in
- * other files are for internal use by sql and should not be
- * accessed by users of the library.
- */
-
-#include "sqlInt.h"
-#include "box/session.h"
-
-/*
- * Execute SQL code. Return one of the SQL_ success/failure
- * codes. Also write an error message into memory obtained from
- * malloc() and make *pzErrMsg point to that message.
- *
- * If the SQL is a query, then for each row in the query result
- * the xCallback() function is called. pArg becomes the first
- * argument to xCallback(). If xCallback=NULL then no callback
- * is invoked, even for queries.
- */
-int
-sql_exec(sql * db, /* The database on which the SQL executes */
- const char *zSql, /* The SQL to be executed */
- sql_callback xCallback, /* Invoke this callback routine */
- void *pArg, /* First argument to xCallback() */
- char **pzErrMsg /* Write error messages here */
- )
-{
- int rc = SQL_OK; /* Return code */
- const char *zLeftover; /* Tail of unprocessed SQL */
- sql_stmt *pStmt = 0; /* The current SQL statement */
- char **azCols = 0; /* Names of result columns */
- int callbackIsInit; /* True if callback data is initialized */
- struct session *user_session = current_session();
-
- if (!sqlSafetyCheckOk(db))
- return SQL_MISUSE;
- if (zSql == 0)
- zSql = "";
-
- sqlError(db, SQL_OK);
- while (rc == SQL_OK && zSql[0]) {
- int nCol;
- char **azVals = 0;
-
- pStmt = 0;
- rc = sql_prepare_v2(db, zSql, -1, &pStmt, &zLeftover);
- assert(rc == SQL_OK || pStmt == 0);
- if (rc != SQL_OK) {
- continue;
- }
- if (!pStmt) {
- /* this happens for a comment or white-space */
- zSql = zLeftover;
- continue;
- }
-
- callbackIsInit = 0;
- nCol = sql_column_count(pStmt);
-
- while (1) {
- int i;
- rc = sql_step(pStmt);
- /* Invoke the callback function if required */
- if (xCallback && (SQL_ROW == rc ||
- (SQL_DONE == rc && !callbackIsInit
- && user_session->
- sql_flags & SQL_NullCallback))) {
- if (!callbackIsInit) {
- azCols =
- sqlDbMallocZero(db,
- 2 * nCol *
- sizeof(const
- char *) +
- 1);
- if (azCols == 0) {
- goto exec_out;
- }
- for (i = 0; i < nCol; i++) {
- azCols[i] =
- (char *)
- sql_column_name(pStmt,
- i);
- /* sqlVdbeSetColName() installs column names as UTF8
- * strings so there is no way for sql_column_name() to fail.
- */
- assert(azCols[i] != 0);
- }
- callbackIsInit = 1;
- }
- if (rc == SQL_ROW) {
- azVals = &azCols[nCol];
- for (i = 0; i < nCol; i++) {
- azVals[i] =
- (char *)
- sql_column_text(pStmt,
- i);
- if (!azVals[i]
- &&
- sql_column_type(pStmt,
- i) !=
- SQL_NULL) {
- sqlOomFault(db);
- goto exec_out;
- }
- }
- }
- if (xCallback(pArg, nCol, azVals, azCols)) {
- /* EVIDENCE-OF: R-38229-40159 If the callback function to
- * sql_exec() returns non-zero, then sql_exec() will
- * return SQL_ABORT.
- */
- rc = SQL_ABORT;
- sqlVdbeFinalize((Vdbe *) pStmt);
- pStmt = 0;
- sqlError(db, SQL_ABORT);
- goto exec_out;
- }
- }
-
- if (rc != SQL_ROW) {
- rc = sqlVdbeFinalize((Vdbe *) pStmt);
- pStmt = 0;
- zSql = zLeftover;
- while (sqlIsspace(zSql[0]))
- zSql++;
- break;
- }
- }
-
- sqlDbFree(db, azCols);
- azCols = 0;
- }
-
- exec_out:
- if (pStmt)
- sqlVdbeFinalize((Vdbe *) pStmt);
- sqlDbFree(db, azCols);
-
- rc = sqlApiExit(db, rc);
- if (rc != SQL_OK && pzErrMsg) {
- int nErrMsg = 1 + sqlStrlen30(sql_errmsg(db));
- *pzErrMsg = sqlMalloc(nErrMsg);
- if (*pzErrMsg) {
- memcpy(*pzErrMsg, sql_errmsg(db), nErrMsg);
- } else {
- rc = SQL_NOMEM;
- sqlError(db, SQL_NOMEM);
- }
- } else if (pzErrMsg) {
- *pzErrMsg = 0;
- }
-
- assert((rc & db->errMask) == rc);
- return rc;
-}
diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h
index 72bd4ee..5c0257c 100644
--- a/src/box/sql/sqlInt.h
+++ b/src/box/sql/sqlInt.h
@@ -592,13 +592,6 @@ sql_column_value(sql_stmt *,
int
sql_finalize(sql_stmt * pStmt);
-int
-sql_exec(sql *, /* An open database */
- const char *sql, /* SQL to be evaluated */
- int (*callback) (void *, int, char **, char **), /* Callback function */
- void *, /* 1st argument to callback */
- char **errmsg /* Error msg written here */
- );
#define SQL_IOERR_READ (SQL_IOERR | (1<<8))
#define SQL_IOERR_SHORT_READ (SQL_IOERR | (2<<8))
#define SQL_IOERR_WRITE (SQL_IOERR | (3<<8))
--
2.7.4
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-03-30 14:19 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-30 14:19 [tarantool-patches] [PATCH v1 1/1] sql: remove legacy.c imeevma
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox