提交 12e3633f 编写于 作者: Y yihaoDeng

TD-1611

上级 21d754c4
...@@ -3727,9 +3727,6 @@ int32_t handleExprInDelCond(SSqlCmd* pCmd, SQueryInfo *pQueryInfo, tSQLExpr* pEx ...@@ -3727,9 +3727,6 @@ int32_t handleExprInDelCond(SSqlCmd* pCmd, SQueryInfo *pQueryInfo, tSQLExpr* pEx
} }
int32_t getDelCond(SSqlCmd* pCmd, SQueryInfo *pQueryInfo, tSQLExpr* pExpr, int64_t **tsBuf, int32_t *sz) { int32_t getDelCond(SSqlCmd* pCmd, SQueryInfo *pQueryInfo, tSQLExpr* pExpr, int64_t **tsBuf, int32_t *sz) {
if (pExpr == NULL) {
return TSDB_CODE_SUCCESS;
}
const char* msg1 = "invalid time stamp"; const char* msg1 = "invalid time stamp";
const char* msg2 = "illegal column name"; const char* msg2 = "illegal column name";
...@@ -3758,10 +3755,10 @@ int32_t getDelCond(SSqlCmd* pCmd, SQueryInfo *pQueryInfo, tSQLExpr* pExpr, int64 ...@@ -3758,10 +3755,10 @@ int32_t getDelCond(SSqlCmd* pCmd, SQueryInfo *pQueryInfo, tSQLExpr* pExpr, int64
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
} }
nParam = pRight->pParam->nExpr; nParam = pRight->pParam->nExpr;
*tsBuf = malloc(sizeof(int64_t) * nParam); if ((*tsBuf = malloc(sizeof(int64_t) * nParam)) == NULL) {
if (*tsBuf == NULL) {
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
for (int i = 0; i < nParam; i++) { for (int i = 0; i < nParam; i++) {
int64_t ts; int64_t ts;
if (getTimeFromExpr(pRight->pParam->a[i].pNode, timePrecision, &ts) != TSDB_CODE_SUCCESS) { if (getTimeFromExpr(pRight->pParam->a[i].pNode, timePrecision, &ts) != TSDB_CODE_SUCCESS) {
...@@ -3774,10 +3771,10 @@ int32_t getDelCond(SSqlCmd* pCmd, SQueryInfo *pQueryInfo, tSQLExpr* pExpr, int64 ...@@ -3774,10 +3771,10 @@ int32_t getDelCond(SSqlCmd* pCmd, SQueryInfo *pQueryInfo, tSQLExpr* pExpr, int64
*sz = nParam; *sz = nParam;
} else if (pExpr->nSQLOptr == TK_EQ) { } else if (pExpr->nSQLOptr == TK_EQ) {
nParam = 1; nParam = 1;
*tsBuf = malloc(sizeof(int64_t) * nParam); if ((*tsBuf = malloc(sizeof(int64_t) * nParam)) == NULL) {
if (*tsBuf == NULL) {
return TSDB_CODE_TSC_OUT_OF_MEMORY; return TSDB_CODE_TSC_OUT_OF_MEMORY;
} }
int64_t ts; int64_t ts;
if (getTimeFromExpr(pRight, timePrecision, &ts) != TSDB_CODE_SUCCESS) { if (getTimeFromExpr(pRight, timePrecision, &ts) != TSDB_CODE_SUCCESS) {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
...@@ -4662,9 +4659,8 @@ int32_t parseOrderbyClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQu ...@@ -4662,9 +4659,8 @@ int32_t parseOrderbyClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQu
int32_t setDelInfo(SSqlObj *pSql, struct SSqlInfo* pInfo) { int32_t setDelInfo(SSqlObj *pSql, struct SSqlInfo* pInfo) {
const char* msg1 = "invalid table name"; const char* msg1 = "invalid table name";
const char* msg2 = "invalid delete sql"; const char* msg2 = "data deletion is not supported on super table";
const char* msg3 = "data deletion is not supported on super table"; const char* msg3 = "Only data deletion by timestamp is supported ";
const char* msg4 = "Only data deletion by timestamp is supported ";
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
...@@ -4699,21 +4695,23 @@ int32_t setDelInfo(SSqlObj *pSql, struct SSqlInfo* pInfo) { ...@@ -4699,21 +4695,23 @@ int32_t setDelInfo(SSqlObj *pSql, struct SSqlInfo* pInfo) {
STableMeta* pTableMeta = pTableMetaInfo->pTableMeta; STableMeta* pTableMeta = pTableMetaInfo->pTableMeta;
if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3); return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
} }
int64_t *tsBuf = NULL; int64_t *tsBuf = NULL;
int32_t sz = 0; int32_t sz = 0;
if (pDelSql->pWhere != NULL) { if (pDelSql->pWhere != NULL) {
if (getDelCond(pCmd, pQueryInfo, pDelSql->pWhere, &tsBuf, &sz) != TSDB_CODE_SUCCESS) { code = getDelCond(pCmd, pQueryInfo, pDelSql->pWhere, &tsBuf, &sz);
if (code != TSDB_CODE_SUCCESS) {
free(tsBuf); free(tsBuf);
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2); return code;
} }
} else { } else {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg4); return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3);
} }
if ((code = tscAllocPayload(pCmd, sizeof(SDeleteMsg) + sz * sizeof(tsBuf[0]) + 64)) != TSDB_CODE_SUCCESS) { if ((code = tscAllocPayload(pCmd, sizeof(SDeleteMsg) + sz * sizeof(tsBuf[0]) + 64)) != TSDB_CODE_SUCCESS) {
free(tsBuf);
return code; return code;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册