提交 744bc92f 编写于 作者: D dapan1121

modify TAOS as id addr

上级 c2a96b2c
...@@ -1100,10 +1100,12 @@ TAOS* taos_connect_auth(const char* ip, const char* user, const char* auth, cons ...@@ -1100,10 +1100,12 @@ TAOS* taos_connect_auth(const char* ip, const char* user, const char* auth, cons
STscObj* pObj = taos_connect_internal(ip, user, NULL, auth, db, port, CONN_TYPE__QUERY); STscObj* pObj = taos_connect_internal(ip, user, NULL, auth, db, port, CONN_TYPE__QUERY);
if (pObj) { if (pObj) {
return (TAOS*)pObj->id; uint64_t *id = taosMemoryMalloc(sizeof(uint64_t));
*id = pObj->id;
return (TAOS*)id;
} }
return (TAOS*)0; return NULL;
} }
TAOS* taos_connect_l(const char* ip, int ipLen, const char* user, int userLen, const char* pass, int passLen, TAOS* taos_connect_l(const char* ip, int ipLen, const char* user, int userLen, const char* pass, int passLen,
......
...@@ -99,10 +99,12 @@ TAOS *taos_connect(const char *ip, const char *user, const char *pass, const cha ...@@ -99,10 +99,12 @@ TAOS *taos_connect(const char *ip, const char *user, const char *pass, const cha
STscObj* pObj = taos_connect_internal(ip, user, pass, NULL, db, port, CONN_TYPE__QUERY); STscObj* pObj = taos_connect_internal(ip, user, pass, NULL, db, port, CONN_TYPE__QUERY);
if (pObj) { if (pObj) {
return (TAOS*)pObj->id; uint64_t *id = taosMemoryMalloc(sizeof(uint64_t));
*id = pObj->id;
return (TAOS*)id;
} }
return (TAOS*)0; return NULL;
} }
void taos_close_internal(void *taos) { void taos_close_internal(void *taos) {
...@@ -117,13 +119,14 @@ void taos_close_internal(void *taos) { ...@@ -117,13 +119,14 @@ void taos_close_internal(void *taos) {
} }
void taos_close(TAOS *taos) { void taos_close(TAOS *taos) {
STscObj* pObj = acquireTscObj((int64_t)taos); STscObj* pObj = acquireTscObj(*(int64_t*)taos);
if (NULL == pObj) { if (NULL == pObj) {
return; return;
} }
taos_close_internal(pObj); taos_close_internal(pObj);
releaseTscObj((int64_t)taos); releaseTscObj(*(int64_t*)taos);
taosMemoryFree(taos);
} }
...@@ -206,7 +209,7 @@ static void syncQueryFn(void *param, void *res, int32_t code) { ...@@ -206,7 +209,7 @@ static void syncQueryFn(void *param, void *res, int32_t code) {
} }
TAOS_RES *taos_query(TAOS *taos, const char *sql) { TAOS_RES *taos_query(TAOS *taos, const char *sql) {
STscObj* pTscObj = acquireTscObj((int64_t)taos); STscObj* pTscObj = acquireTscObj(*(int64_t*)taos);
if (pTscObj == NULL || sql == NULL) { if (pTscObj == NULL || sql == NULL) {
terrno = TSDB_CODE_TSC_DISCONNECTED; terrno = TSDB_CODE_TSC_DISCONNECTED;
return NULL; return NULL;
...@@ -219,13 +222,13 @@ TAOS_RES *taos_query(TAOS *taos, const char *sql) { ...@@ -219,13 +222,13 @@ TAOS_RES *taos_query(TAOS *taos, const char *sql) {
taos_query_a(taos, sql, syncQueryFn, param); taos_query_a(taos, sql, syncQueryFn, param);
tsem_wait(&param->sem); tsem_wait(&param->sem);
releaseTscObj((int64_t)taos); releaseTscObj(*(int64_t*)taos);
return param->pRequest; return param->pRequest;
#else #else
size_t sqlLen = strlen(sql); size_t sqlLen = strlen(sql);
if (sqlLen > (size_t)TSDB_MAX_ALLOWED_SQL_LEN) { if (sqlLen > (size_t)TSDB_MAX_ALLOWED_SQL_LEN) {
releaseTscObj((int64_t)taos); releaseTscObj(*(int64_t*)taos);
tscError("sql string exceeds max length:%d", TSDB_MAX_ALLOWED_SQL_LEN); tscError("sql string exceeds max length:%d", TSDB_MAX_ALLOWED_SQL_LEN);
terrno = TSDB_CODE_TSC_EXCEED_SQL_LIMIT; terrno = TSDB_CODE_TSC_EXCEED_SQL_LIMIT;
return NULL; return NULL;
...@@ -233,7 +236,7 @@ TAOS_RES *taos_query(TAOS *taos, const char *sql) { ...@@ -233,7 +236,7 @@ TAOS_RES *taos_query(TAOS *taos, const char *sql) {
TAOS_RES* pRes = execQuery(pTscObj, sql, sqlLen); TAOS_RES* pRes = execQuery(pTscObj, sql, sqlLen);
releaseTscObj((int64_t)taos); releaseTscObj(*(int64_t*)taos);
return pRes; return pRes;
#endif #endif
...@@ -453,15 +456,15 @@ int taos_result_precision(TAOS_RES *res) { ...@@ -453,15 +456,15 @@ int taos_result_precision(TAOS_RES *res) {
} }
int taos_select_db(TAOS *taos, const char *db) { int taos_select_db(TAOS *taos, const char *db) {
STscObj* pObj = acquireTscObj((int64_t)taos); STscObj* pObj = acquireTscObj(*(int64_t*)taos);
if (pObj == NULL) { if (pObj == NULL) {
releaseTscObj((int64_t)taos); releaseTscObj(*(int64_t*)taos);
terrno = TSDB_CODE_TSC_DISCONNECTED; terrno = TSDB_CODE_TSC_DISCONNECTED;
return TSDB_CODE_TSC_DISCONNECTED; return TSDB_CODE_TSC_DISCONNECTED;
} }
if (db == NULL || strlen(db) == 0) { if (db == NULL || strlen(db) == 0) {
releaseTscObj((int64_t)taos); releaseTscObj(*(int64_t*)taos);
terrno = TSDB_CODE_TSC_INVALID_INPUT; terrno = TSDB_CODE_TSC_INVALID_INPUT;
return terrno; return terrno;
} }
...@@ -473,7 +476,7 @@ int taos_select_db(TAOS *taos, const char *db) { ...@@ -473,7 +476,7 @@ int taos_select_db(TAOS *taos, const char *db) {
int32_t code = taos_errno(pRequest); int32_t code = taos_errno(pRequest);
taos_free_result(pRequest); taos_free_result(pRequest);
releaseTscObj((int64_t)taos); releaseTscObj(*(int64_t*)taos);
return code; return code;
} }
...@@ -626,7 +629,7 @@ int *taos_get_column_data_offset(TAOS_RES *res, int columnIndex) { ...@@ -626,7 +629,7 @@ int *taos_get_column_data_offset(TAOS_RES *res, int columnIndex) {
int taos_validate_sql(TAOS *taos, const char *sql) { return true; } int taos_validate_sql(TAOS *taos, const char *sql) { return true; }
void taos_reset_current_db(TAOS *taos) { void taos_reset_current_db(TAOS *taos) {
STscObj* pTscObj = acquireTscObj((int64_t)taos); STscObj* pTscObj = acquireTscObj(*(int64_t*)taos);
if (pTscObj == NULL) { if (pTscObj == NULL) {
terrno = TSDB_CODE_TSC_DISCONNECTED; terrno = TSDB_CODE_TSC_DISCONNECTED;
return; return;
...@@ -634,17 +637,17 @@ void taos_reset_current_db(TAOS *taos) { ...@@ -634,17 +637,17 @@ void taos_reset_current_db(TAOS *taos) {
resetConnectDB(pTscObj); resetConnectDB(pTscObj);
releaseTscObj((int64_t)taos); releaseTscObj(*(int64_t*)taos);
} }
const char *taos_get_server_info(TAOS *taos) { const char *taos_get_server_info(TAOS *taos) {
STscObj* pTscObj = acquireTscObj((int64_t)taos); STscObj* pTscObj = acquireTscObj(*(int64_t*)taos);
if (pTscObj == NULL) { if (pTscObj == NULL) {
terrno = TSDB_CODE_TSC_DISCONNECTED; terrno = TSDB_CODE_TSC_DISCONNECTED;
return NULL; return NULL;
} }
releaseTscObj((int64_t)taos); releaseTscObj(*(int64_t*)taos);
return pTscObj->ver; return pTscObj->ver;
} }
...@@ -711,11 +714,11 @@ void retrieveMetaCallback(SMetaData *pResultMeta, void *param, int32_t code) { ...@@ -711,11 +714,11 @@ void retrieveMetaCallback(SMetaData *pResultMeta, void *param, int32_t code) {
} }
void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param) { void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param) {
STscObj* pTscObj = acquireTscObj((int64_t)taos); STscObj* pTscObj = acquireTscObj(*(int64_t*)taos);
if (pTscObj == NULL || sql == NULL || NULL == fp) { if (pTscObj == NULL || sql == NULL || NULL == fp) {
terrno = TSDB_CODE_INVALID_PARA; terrno = TSDB_CODE_INVALID_PARA;
if (pTscObj) { if (pTscObj) {
releaseTscObj((int64_t)taos); releaseTscObj(*(int64_t*)taos);
} else { } else {
terrno = TSDB_CODE_TSC_DISCONNECTED; terrno = TSDB_CODE_TSC_DISCONNECTED;
} }
...@@ -936,7 +939,7 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) { ...@@ -936,7 +939,7 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
} }
TAOS_STMT *taos_stmt_init(TAOS *taos) { TAOS_STMT *taos_stmt_init(TAOS *taos) {
STscObj* pObj = acquireTscObj((int64_t)taos); STscObj* pObj = acquireTscObj(*(int64_t*)taos);
if (NULL == pObj) { if (NULL == pObj) {
tscError("invalid parameter for %s", __FUNCTION__); tscError("invalid parameter for %s", __FUNCTION__);
terrno = TSDB_CODE_TSC_DISCONNECTED; terrno = TSDB_CODE_TSC_DISCONNECTED;
...@@ -945,7 +948,7 @@ TAOS_STMT *taos_stmt_init(TAOS *taos) { ...@@ -945,7 +948,7 @@ TAOS_STMT *taos_stmt_init(TAOS *taos) {
TAOS_STMT* pStmt = stmtInit(pObj); TAOS_STMT* pStmt = stmtInit(pObj);
releaseTscObj((int64_t)taos); releaseTscObj(*(int64_t*)taos);
return pStmt; return pStmt;
} }
......
...@@ -2434,7 +2434,7 @@ static void smlInsertCallback(void *param, void *res, int32_t code) { ...@@ -2434,7 +2434,7 @@ static void smlInsertCallback(void *param, void *res, int32_t code) {
*/ */
TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int protocol, int precision) { TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int protocol, int precision) {
STscObj* pTscObj = acquireTscObj((int64_t)taos); STscObj* pTscObj = acquireTscObj(*(int64_t*)taos);
if (NULL == pTscObj) { if (NULL == pTscObj) {
terrno = TSDB_CODE_TSC_DISCONNECTED; terrno = TSDB_CODE_TSC_DISCONNECTED;
uError("SML:taos_schemaless_insert invalid taos"); uError("SML:taos_schemaless_insert invalid taos");
...@@ -2443,7 +2443,7 @@ TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int pr ...@@ -2443,7 +2443,7 @@ TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int pr
SRequestObj* request = (SRequestObj*)createRequest(pTscObj, TSDB_SQL_INSERT); SRequestObj* request = (SRequestObj*)createRequest(pTscObj, TSDB_SQL_INSERT);
if(!request){ if(!request){
releaseTscObj((int64_t)taos); releaseTscObj(*(int64_t*)taos);
uError("SML:taos_schemaless_insert error request is null"); uError("SML:taos_schemaless_insert error request is null");
return NULL; return NULL;
} }
...@@ -2531,6 +2531,6 @@ end: ...@@ -2531,6 +2531,6 @@ end:
// ((STscObj *)taos)->schemalessType = 0; // ((STscObj *)taos)->schemalessType = 0;
pTscObj->schemalessType = 1; pTscObj->schemalessType = 1;
uDebug("resultend:%s", request->msgBuf); uDebug("resultend:%s", request->msgBuf);
releaseTscObj((int64_t)taos); releaseTscObj(*(int64_t*)taos);
return (TAOS_RES*)request; return (TAOS_RES*)request;
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册