From a823535f277cc9f32fc63ccae92ecd59f02cc282 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Wed, 13 Apr 2022 19:57:21 +0800 Subject: [PATCH] stmt --- source/client/inc/clientStmt.h | 33 ++++++++++++++++------ source/client/src/clientMain.c | 31 +++++++++++---------- source/client/src/clientStmt.c | 51 ++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+), 24 deletions(-) diff --git a/source/client/inc/clientStmt.h b/source/client/inc/clientStmt.h index e358ce37aa..c29361758d 100644 --- a/source/client/inc/clientStmt.h +++ b/source/client/inc/clientStmt.h @@ -28,18 +28,33 @@ typedef enum { typedef struct STscStmt { STMT_TYPE type; - int16_t last; - STscObj* taos; - SSqlObj* pSql; - SMultiTbStmt mtb; - SNormalStmt normal; + //int16_t last; + //STscObj* taos; + //SSqlObj* pSql; + //SMultiTbStmt mtb; + //SNormalStmt normal; - int numOfRows; + //int numOfRows; } STscStmt; -#define SCH_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0) -#define SCH_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0) -#define SCH_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0) +#define STMT_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0) +#define STMT_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0) +#define STMT_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0) + +TAOS_STMT *stmtInit(TAOS *taos); +int stmtClose(TAOS_STMT *stmt); +int stmtExec(TAOS_STMT *stmt); +char *stmtErrstr(TAOS_STMT *stmt); +int stmtAffectedRows(TAOS_STMT *stmt); +int stmtBind(TAOS_STMT *stmt, TAOS_BIND *bind); +int stmtPrepare(TAOS_STMT *stmt, const char *sql, unsigned long length); +int stmtSetTbNameTags(TAOS_STMT *stmt, const char *name, TAOS_BIND *tags); +int stmtIsInsert(TAOS_STMT *stmt, int *insert); +int stmtGetParamNum(TAOS_STMT *stmt, int *nums); +int stmtAddBatch(TAOS_STMT *stmt); +TAOS_RES *stmtUseResult(TAOS_STMT *stmt); +int stmtBindBatch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind); + #ifdef __cplusplus } diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index e9d1ca0d24..84f9c7ac30 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -16,6 +16,7 @@ #include "catalog.h" #include "scheduler.h" #include "clientInt.h" +#include "clientStmt.h" #include "clientLog.h" #include "os.h" #include "query.h" @@ -560,7 +561,7 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) { TAOS_STMT *taos_stmt_init(TAOS *taos) { if (taos == NULL) { - tscError("NULL parameter for %s", __FUNC__); + tscError("NULL parameter for %s", __FUNCTION__); terrno = TSDB_CODE_INVALID_PARA; return NULL; } @@ -570,7 +571,7 @@ TAOS_STMT *taos_stmt_init(TAOS *taos) { int taos_stmt_close(TAOS_STMT *stmt) { if (stmt == NULL) { - tscError("NULL parameter for %s", __FUNC__); + tscError("NULL parameter for %s", __FUNCTION__); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -580,7 +581,7 @@ int taos_stmt_close(TAOS_STMT *stmt) { int taos_stmt_execute(TAOS_STMT *stmt) { if (stmt == NULL) { - tscError("NULL parameter for %s", __FUNC__); + tscError("NULL parameter for %s", __FUNCTION__); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -590,7 +591,7 @@ int taos_stmt_execute(TAOS_STMT *stmt) { char *taos_stmt_errstr(TAOS_STMT *stmt) { if (stmt == NULL) { - tscError("NULL parameter for %s", __FUNC__); + tscError("NULL parameter for %s", __FUNCTION__); terrno = TSDB_CODE_INVALID_PARA; return NULL; } @@ -600,7 +601,7 @@ char *taos_stmt_errstr(TAOS_STMT *stmt) { int taos_stmt_affected_rows(TAOS_STMT *stmt) { if (stmt == NULL) { - tscError("NULL parameter for %s", __FUNC__); + tscError("NULL parameter for %s", __FUNCTION__); terrno = TSDB_CODE_INVALID_PARA; return 0; } @@ -610,7 +611,7 @@ int taos_stmt_affected_rows(TAOS_STMT *stmt) { int taos_stmt_bind_param(TAOS_STMT *stmt, TAOS_BIND *bind) { if (stmt == NULL || bind == NULL) { - tscError("NULL parameter for %s", __FUNC__); + tscError("NULL parameter for %s", __FUNCTION__); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -620,7 +621,7 @@ int taos_stmt_bind_param(TAOS_STMT *stmt, TAOS_BIND *bind) { int taos_stmt_prepare(TAOS_STMT *stmt, const char *sql, unsigned long length) { if (stmt == NULL || sql == NULL) { - tscError("NULL parameter for %s", __FUNC__); + tscError("NULL parameter for %s", __FUNCTION__); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -630,7 +631,7 @@ int taos_stmt_prepare(TAOS_STMT *stmt, const char *sql, unsigned long length) { int taos_stmt_set_tbname_tags(TAOS_STMT *stmt, const char *name, TAOS_BIND *tags) { if (stmt == NULL || name == NULL || tags == NULL) { - tscError("NULL parameter for %s", __FUNC__); + tscError("NULL parameter for %s", __FUNCTION__); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -640,7 +641,7 @@ int taos_stmt_set_tbname_tags(TAOS_STMT *stmt, const char *name, TAOS_BIND *tags int taos_stmt_set_tbname(TAOS_STMT *stmt, const char *name) { if (stmt == NULL || name == NULL) { - tscError("NULL parameter for %s", __FUNC__); + tscError("NULL parameter for %s", __FUNCTION__); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -650,7 +651,7 @@ int taos_stmt_set_tbname(TAOS_STMT *stmt, const char *name) { int taos_stmt_is_insert(TAOS_STMT *stmt, int *insert) { if (stmt == NULL || insert == NULL) { - tscError("NULL parameter for %s", __FUNC__); + tscError("NULL parameter for %s", __FUNCTION__); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -660,7 +661,7 @@ int taos_stmt_is_insert(TAOS_STMT *stmt, int *insert) { int taos_stmt_num_params(TAOS_STMT *stmt, int *nums) { if (stmt == NULL || nums == NULL) { - tscError("NULL parameter for %s", __FUNC__); + tscError("NULL parameter for %s", __FUNCTION__); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -670,7 +671,7 @@ int taos_stmt_num_params(TAOS_STMT *stmt, int *nums) { int taos_stmt_add_batch(TAOS_STMT *stmt) { if (stmt == NULL) { - tscError("NULL parameter for %s", __FUNC__); + tscError("NULL parameter for %s", __FUNCTION__); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -680,9 +681,9 @@ int taos_stmt_add_batch(TAOS_STMT *stmt) { TAOS_RES *taos_stmt_use_result(TAOS_STMT *stmt) { if (stmt == NULL) { - tscError("NULL parameter for %s", __FUNC__); + tscError("NULL parameter for %s", __FUNCTION__); terrno = TSDB_CODE_INVALID_PARA; - return terrno; + return NULL; } return stmtUseResult(stmt); @@ -690,7 +691,7 @@ TAOS_RES *taos_stmt_use_result(TAOS_STMT *stmt) { int taos_stmt_bind_param_batch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind) { if (stmt == NULL || bind == NULL) { - tscError("NULL parameter for %s", __FUNC__); + tscError("NULL parameter for %s", __FUNCTION__); terrno = TSDB_CODE_INVALID_PARA; return terrno; } diff --git a/source/client/src/clientStmt.c b/source/client/src/clientStmt.c index 2d8a489381..8c4cff9251 100644 --- a/source/client/src/clientStmt.c +++ b/source/client/src/clientStmt.c @@ -1,6 +1,7 @@ #include "clientInt.h" #include "clientLog.h" +#include "clientStmt.h" #include "tdef.h" TAOS_STMT *stmtInit(TAOS *taos) { @@ -46,3 +47,53 @@ TAOS_STMT *stmtInit(TAOS *taos) { return pStmt; } +int stmtClose(TAOS_STMT *stmt) { + return TSDB_CODE_SUCCESS; +} + +int stmtExec(TAOS_STMT *stmt) { + return TSDB_CODE_SUCCESS; +} + +char *stmtErrstr(TAOS_STMT *stmt) { + return NULL; +} + +int stmtAffectedRows(TAOS_STMT *stmt) { + return TSDB_CODE_SUCCESS; +} + +int stmtBind(TAOS_STMT *stmt, TAOS_BIND *bind) { + return TSDB_CODE_SUCCESS; +} + +int stmtPrepare(TAOS_STMT *stmt, const char *sql, unsigned long length) { + return TSDB_CODE_SUCCESS; +} + +int stmtSetTbNameTags(TAOS_STMT *stmt, const char *name, TAOS_BIND *tags) { + return TSDB_CODE_SUCCESS; +} + +int stmtIsInsert(TAOS_STMT *stmt, int *insert) { + return TSDB_CODE_SUCCESS; +} + +int stmtGetParamNum(TAOS_STMT *stmt, int *nums) { + return TSDB_CODE_SUCCESS; +} + +int stmtAddBatch(TAOS_STMT *stmt) { + return TSDB_CODE_SUCCESS; +} + +TAOS_RES *stmtUseResult(TAOS_STMT *stmt) { + return NULL; +} + +int stmtBindBatch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind) { + return TSDB_CODE_SUCCESS; +} + + +