提交 d2941c06 编写于 作者: X xywang

[TD-5169]<enhance>: simplified function implementation

上级 cf76ed44
...@@ -395,6 +395,8 @@ int32_t* taosGetErrno(); ...@@ -395,6 +395,8 @@ int32_t* taosGetErrno();
#define TSDB_CODE_HTTP_OP_VALUE_NULL TAOS_DEF_ERROR_CODE(0, 0x11A5) //"value not find") #define TSDB_CODE_HTTP_OP_VALUE_NULL TAOS_DEF_ERROR_CODE(0, 0x11A5) //"value not find")
#define TSDB_CODE_HTTP_OP_VALUE_TYPE TAOS_DEF_ERROR_CODE(0, 0x11A6) //"value type should be boolean number or string") #define TSDB_CODE_HTTP_OP_VALUE_TYPE TAOS_DEF_ERROR_CODE(0, 0x11A6) //"value type should be boolean number or string")
#define TSDB_CODE_HTTP_REQUEST_JSON_ERROR TAOS_DEF_ERROR_CODE(0, 0x1F00) //"http request json error")
// odbc // odbc
#define TSDB_CODE_ODBC_OOM TAOS_DEF_ERROR_CODE(0, 0x2100) //"out of memory") #define TSDB_CODE_ODBC_OOM TAOS_DEF_ERROR_CODE(0, 0x2100) //"out of memory")
#define TSDB_CODE_ODBC_CONV_CHAR_NOT_NUM TAOS_DEF_ERROR_CODE(0, 0x2101) //"convertion not a valid literal input") #define TSDB_CODE_ODBC_CONV_CHAR_NOT_NUM TAOS_DEF_ERROR_CODE(0, 0x2101) //"convertion not a valid literal input")
......
...@@ -178,12 +178,8 @@ bool gcProcessQueryRequest(HttpContext* pContext) { ...@@ -178,12 +178,8 @@ bool gcProcessQueryRequest(HttpContext* pContext) {
#define ESCAPE_ERROR_PROC(code, context, root) \ #define ESCAPE_ERROR_PROC(code, context, root) \
do { \ do { \
if (code != 0) { \ if (code != TSDB_CODE_SUCCESS) { \
if (code == 1) { \ httpSendErrorResp(context, code); \
httpSendErrorResp(context, TSDB_CODE_HTTP_GC_REQ_PARSE_ERROR); \
} else { \
httpSendErrorResp(context, TSDB_CODE_HTTP_NO_ENOUGH_MEMORY); \
} \
\ \
cJSON_Delete(root); \ cJSON_Delete(root); \
return false; \ return false; \
......
...@@ -429,27 +429,27 @@ int32_t httpCheckAllocEscapeSql(char *oldSql, char **newSql) ...@@ -429,27 +429,27 @@ int32_t httpCheckAllocEscapeSql(char *oldSql, char **newSql)
char *pos; char *pos;
if (oldSql == NULL || newSql == NULL) { if (oldSql == NULL || newSql == NULL) {
return 0; return TSDB_CODE_SUCCESS;
} }
/* bad sql clause */ /* bad sql clause */
pos = strstr(oldSql, "%%"); pos = strstr(oldSql, "%%");
if (pos) { if (pos) {
httpError("bad sql:%s", oldSql); httpError("bad sql:%s", oldSql);
return 1; return TSDB_CODE_HTTP_REQUEST_JSON_ERROR;
} }
pos = strchr(oldSql, '%'); pos = strchr(oldSql, '%');
if (pos == NULL) { if (pos == NULL) {
httpDebug("sql:%s", oldSql); httpDebug("sql:%s", oldSql);
*newSql = oldSql; *newSql = oldSql;
return 0; return TSDB_CODE_SUCCESS;
} }
*newSql = (char *) calloc(1, (strlen(oldSql) << 1) + 1); *newSql = (char *) calloc(1, (strlen(oldSql) << 1) + 1);
if (newSql == NULL) { if (newSql == NULL) {
httpError("failed to allocate for new sql, old sql:%s", oldSql); httpError("failed to allocate for new sql, old sql:%s", oldSql);
return -1; return TSDB_CODE_HTTP_NO_ENOUGH_MEMORY;
} }
char *src = oldSql; char *src = oldSql;
...@@ -473,7 +473,7 @@ int32_t httpCheckAllocEscapeSql(char *oldSql, char **newSql) ...@@ -473,7 +473,7 @@ int32_t httpCheckAllocEscapeSql(char *oldSql, char **newSql)
} }
} }
return 0; return TSDB_CODE_SUCCESS;
} }
void httpCheckFreeEscapedSql(char *oldSql, char *newSql) void httpCheckFreeEscapedSql(char *oldSql, char *newSql)
......
...@@ -613,12 +613,8 @@ bool tgProcessSingleMetric(HttpContext *pContext, cJSON *metric, char *db) { ...@@ -613,12 +613,8 @@ bool tgProcessSingleMetric(HttpContext *pContext, cJSON *metric, char *db) {
char *tagStr = NULL; char *tagStr = NULL;
int32_t retCode = httpCheckAllocEscapeSql(tag->string, &tagStr); int32_t retCode = httpCheckAllocEscapeSql(tag->string, &tagStr);
if (retCode != 0) { if (retCode != TSDB_CODE_SUCCESS) {
if (retCode == 1) { httpSendErrorResp(pContext, retCode);
httpSendErrorResp(pContext, TSDB_CODE_HTTP_TG_INVALID_JSON);
} else {
httpSendErrorResp(pContext, TSDB_CODE_HTTP_NO_ENOUGH_MEMORY);
}
return false; return false;
} }
......
...@@ -403,6 +403,8 @@ TAOS_DEFINE_ERROR(TSDB_CODE_HTTP_OP_TAG_VALUE_TOO_LONG, "tag value can not mor ...@@ -403,6 +403,8 @@ TAOS_DEFINE_ERROR(TSDB_CODE_HTTP_OP_TAG_VALUE_TOO_LONG, "tag value can not mor
TAOS_DEFINE_ERROR(TSDB_CODE_HTTP_OP_VALUE_NULL, "value not find") TAOS_DEFINE_ERROR(TSDB_CODE_HTTP_OP_VALUE_NULL, "value not find")
TAOS_DEFINE_ERROR(TSDB_CODE_HTTP_OP_VALUE_TYPE, "value type should be boolean, number or string") TAOS_DEFINE_ERROR(TSDB_CODE_HTTP_OP_VALUE_TYPE, "value type should be boolean, number or string")
TAOS_DEFINE_ERROR(TSDB_CODE_HTTP_REQUEST_JSON_ERROR, "http request json error")
// odbc // odbc
TAOS_DEFINE_ERROR(TSDB_CODE_ODBC_OOM, "out of memory") TAOS_DEFINE_ERROR(TSDB_CODE_ODBC_OOM, "out of memory")
TAOS_DEFINE_ERROR(TSDB_CODE_ODBC_CONV_CHAR_NOT_NUM, "convertion not a valid literal input") TAOS_DEFINE_ERROR(TSDB_CODE_ODBC_CONV_CHAR_NOT_NUM, "convertion not a valid literal input")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册