提交 29d290d5 编写于 作者: S slguan

fix issue #469

上级 0bb41e5b
......@@ -35,6 +35,7 @@ extern const char *httpRespTemplate[];
void httpSendErrorResp(HttpContext *pContext, int errNo);
void httpSendErrorRespWithDesc(HttpContext *pContext, int errNo, char *desc);
void httpSendTaosdErrorResp(HttpContext *pContext, int errCode);
void httpSendTaosdInvalidSqlErrorResp(HttpContext *pContext, char* errMsg);
void httpSendSuccResp(HttpContext *pContext, char *desc);
void httpSendOptionResp(HttpContext *pContext, char *desc);
......
......@@ -18,6 +18,7 @@
#include <string.h>
#include "httpCode.h"
#include "httpJson.h"
#include "taosmsg.h"
extern char *tsError[];
......@@ -186,6 +187,22 @@ void httpSendTaosdErrorResp(HttpContext *pContext, int errCode) {
httpSendErrResp(pContext, httpCode, "Bad Request", errCode, tsError[errCode]);
}
void httpSendTaosdInvalidSqlErrorResp(HttpContext *pContext, char* errMsg) {
int httpCode = 400;
char temp[512] = {0};
int len = sprintf(temp, "invalid SQL: %s", errMsg);
for (int i = 0; i < len; ++i) {
if (temp[i] == '\"') {
temp[i] = '\'';
} else if (temp[i] == '\n') {
temp[i] = ' ';
} else {}
}
httpSendErrResp(pContext, httpCode, "Bad Request", TSDB_CODE_INVALID_SQL, temp);
}
void httpSendSuccResp(HttpContext *pContext, char *desc) {
char head[1024] = {0};
char body[1024] = {0};
......
......@@ -238,10 +238,15 @@ void httpProcessSingleSqlCallBack(void *param, TAOS_RES *result, int code) {
if (code < 0) {
SSqlObj *pObj = (SSqlObj *)result;
httpError("context:%p, fd:%d, ip:%s, user:%s, query error, taos:%p, code:%d, sqlObj:%p",
pContext, pContext->fd, pContext->ipstr, pContext->user, pContext->session->taos, -code, pObj);
httpSendTaosdErrorResp(pContext, -code);
if (-code == TSDB_CODE_INVALID_SQL) {
httpError("context:%p, fd:%d, ip:%s, user:%s, query error, taos:%p, code:%d:invalidsql, sqlObj:%p, error:%s",
pContext, pContext->fd, pContext->ipstr, pContext->user, pContext->session->taos, -code, pObj, pObj->cmd.payload);
httpSendTaosdInvalidSqlErrorResp(pContext, pObj->cmd.payload);
} else {
httpError("context:%p, fd:%d, ip:%s, user:%s, query error, taos:%p, code:%d, sqlObj:%p",
pContext, pContext->fd, pContext->ipstr, pContext->user, pContext->session->taos, -code, pObj);
httpSendTaosdErrorResp(pContext, -code);
}
return;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册