提交 e5da9167 编写于 作者: X Xiaoyu Wang

fix: escape character problem in auto create table insert

上级 09cb5753
...@@ -428,6 +428,9 @@ void nodesValueNodeToVariant(const SValueNode* pNode, SVariant* pVal); ...@@ -428,6 +428,9 @@ void nodesValueNodeToVariant(const SValueNode* pNode, SVariant* pVal);
char* nodesGetFillModeString(EFillMode mode); char* nodesGetFillModeString(EFillMode mode);
int32_t nodesMergeConds(SNode** pDst, SNodeList** pSrc); int32_t nodesMergeConds(SNode** pDst, SNodeList** pSrc);
const char* operatorTypeStr(EOperatorType type);
const char* logicConditionTypeStr(ELogicConditionType type);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -166,7 +166,7 @@ typedef enum EOperatorType { ...@@ -166,7 +166,7 @@ typedef enum EOperatorType {
OP_TYPE_JSON_CONTAINS, OP_TYPE_JSON_CONTAINS,
// internal operator // internal operator
OP_TYPE_ASSIGN = 250 OP_TYPE_ASSIGN = 200
} EOperatorType; } EOperatorType;
#define OP_TYPE_CALC_MAX OP_TYPE_BIT_OR #define OP_TYPE_CALC_MAX OP_TYPE_BIT_OR
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include "taoserror.h" #include "taoserror.h"
#include "thash.h" #include "thash.h"
static const char *operatorTypeStr(EOperatorType type) { const char *operatorTypeStr(EOperatorType type) {
switch (type) { switch (type) {
case OP_TYPE_ADD: case OP_TYPE_ADD:
return "+"; return "+";
...@@ -91,7 +91,7 @@ static const char *operatorTypeStr(EOperatorType type) { ...@@ -91,7 +91,7 @@ static const char *operatorTypeStr(EOperatorType type) {
return "UNKNOWN"; return "UNKNOWN";
} }
static const char *logicConditionTypeStr(ELogicConditionType type) { const char *logicConditionTypeStr(ELogicConditionType type) {
switch (type) { switch (type) {
case LOGIC_COND_TYPE_AND: case LOGIC_COND_TYPE_AND:
return "AND"; return "AND";
......
...@@ -350,7 +350,6 @@ struct SFilterInfo { ...@@ -350,7 +350,6 @@ struct SFilterInfo {
extern bool filterDoCompare(__compar_fn_t func, uint8_t optr, void *left, void *right); extern bool filterDoCompare(__compar_fn_t func, uint8_t optr, void *left, void *right);
extern __compar_fn_t filterGetCompFunc(int32_t type, int32_t optr); extern __compar_fn_t filterGetCompFunc(int32_t type, int32_t optr);
extern OptrStr gOptrStr[];
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -24,46 +24,6 @@ ...@@ -24,46 +24,6 @@
#include "ttime.h" #include "ttime.h"
#include "functionMgt.h" #include "functionMgt.h"
OptrStr gOptrStr[] = {
{0, "invalid"},
{OP_TYPE_ADD, "+"},
{OP_TYPE_SUB, "-"},
{OP_TYPE_MULTI, "*"},
{OP_TYPE_DIV, "/"},
{OP_TYPE_REM, "%"},
{OP_TYPE_MINUS, "minus"},
{OP_TYPE_ASSIGN, "assign"},
// bit operator
{OP_TYPE_BIT_AND, "&"},
{OP_TYPE_BIT_OR, "|"},
// comparison operator
{OP_TYPE_GREATER_THAN, ">"},
{OP_TYPE_GREATER_EQUAL, ">="},
{OP_TYPE_LOWER_THAN, "<"},
{OP_TYPE_LOWER_EQUAL, "<="},
{OP_TYPE_EQUAL, "=="},
{OP_TYPE_NOT_EQUAL, "!="},
{OP_TYPE_IN, "in"},
{OP_TYPE_NOT_IN, "not in"},
{OP_TYPE_LIKE, "like"},
{OP_TYPE_NOT_LIKE, "not like"},
{OP_TYPE_MATCH, "match"},
{OP_TYPE_NMATCH, "nmatch"},
{OP_TYPE_IS_NULL, "is null"},
{OP_TYPE_IS_NOT_NULL, "not null"},
{OP_TYPE_IS_TRUE, "is true"},
{OP_TYPE_IS_FALSE, "is false"},
{OP_TYPE_IS_UNKNOWN, "is unknown"},
{OP_TYPE_IS_NOT_TRUE, "not true"},
{OP_TYPE_IS_NOT_FALSE, "not false"},
{OP_TYPE_IS_NOT_UNKNOWN, "not unknown"},
// json operator
{OP_TYPE_JSON_GET_VALUE, "->"},
{OP_TYPE_JSON_CONTAINS, "json contains"}
};
bool filterRangeCompGi (const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) { bool filterRangeCompGi (const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) {
int32_t result = cfunc(maxv, minr); int32_t result = cfunc(maxv, minr);
return result >= 0; return result >= 0;
...@@ -986,7 +946,7 @@ int32_t filterAddUnit(SFilterInfo *info, uint8_t optr, SFilterFieldId *left, SFi ...@@ -986,7 +946,7 @@ int32_t filterAddUnit(SFilterInfo *info, uint8_t optr, SFilterFieldId *left, SFi
} else { } else {
int32_t paramNum = scalarGetOperatorParamNum(optr); int32_t paramNum = scalarGetOperatorParamNum(optr);
if (1 != paramNum) { if (1 != paramNum) {
fltError("invalid right field in unit, operator:%s, rightType:%d", gOptrStr[optr].str, u->right.type); fltError("invalid right field in unit, operator:%s, rightType:%d", operatorTypeStr(optr), u->right.type);
return TSDB_CODE_QRY_APP_ERROR; return TSDB_CODE_QRY_APP_ERROR;
} }
} }
...@@ -1517,7 +1477,7 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options) ...@@ -1517,7 +1477,7 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options)
SFilterField *left = FILTER_UNIT_LEFT_FIELD(info, unit); SFilterField *left = FILTER_UNIT_LEFT_FIELD(info, unit);
SColumnNode *refNode = (SColumnNode *)left->desc; SColumnNode *refNode = (SColumnNode *)left->desc;
if (unit->compare.optr >= 0 && unit->compare.optr <= OP_TYPE_JSON_CONTAINS){ if (unit->compare.optr >= 0 && unit->compare.optr <= OP_TYPE_JSON_CONTAINS){
len = sprintf(str, "UNIT[%d] => [%d][%d] %s [", i, refNode->dataBlockId, refNode->slotId, gOptrStr[unit->compare.optr].str); len = sprintf(str, "UNIT[%d] => [%d][%d] %s [", i, refNode->dataBlockId, refNode->slotId, operatorTypeStr(unit->compare.optr));
} }
if (unit->right.type == FLD_TYPE_VALUE && FILTER_UNIT_OPTR(unit) != OP_TYPE_IN) { if (unit->right.type == FLD_TYPE_VALUE && FILTER_UNIT_OPTR(unit) != OP_TYPE_IN) {
...@@ -1536,7 +1496,7 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options) ...@@ -1536,7 +1496,7 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options)
if (unit->compare.optr2) { if (unit->compare.optr2) {
strcat(str, " && "); strcat(str, " && ");
if (unit->compare.optr2 >= 0 && unit->compare.optr2 <= OP_TYPE_JSON_CONTAINS){ if (unit->compare.optr2 >= 0 && unit->compare.optr2 <= OP_TYPE_JSON_CONTAINS){
sprintf(str + strlen(str), "[%d][%d] %s [", refNode->dataBlockId, refNode->slotId, gOptrStr[unit->compare.optr2].str); sprintf(str + strlen(str), "[%d][%d] %s [", refNode->dataBlockId, refNode->slotId, operatorTypeStr(unit->compare.optr2));
} }
if (unit->right2.type == FLD_TYPE_VALUE && FILTER_UNIT_OPTR(unit) != OP_TYPE_IN) { if (unit->right2.type == FLD_TYPE_VALUE && FILTER_UNIT_OPTR(unit) != OP_TYPE_IN) {
......
...@@ -1089,16 +1089,16 @@ void makeCalculate(void *json, void *key, int32_t rightType, void *rightData, do ...@@ -1089,16 +1089,16 @@ void makeCalculate(void *json, void *key, int32_t rightType, void *rightData, do
}else if(opType == OP_TYPE_ADD || opType == OP_TYPE_SUB || opType == OP_TYPE_MULTI || opType == OP_TYPE_DIV || }else if(opType == OP_TYPE_ADD || opType == OP_TYPE_SUB || opType == OP_TYPE_MULTI || opType == OP_TYPE_DIV ||
opType == OP_TYPE_REM || opType == OP_TYPE_MINUS){ opType == OP_TYPE_REM || opType == OP_TYPE_MINUS){
printf("op:%s,1result:%f,except:%f\n", gOptrStr[opType].str, *((double *)colDataGetData(column, 0)), exceptValue); printf("op:%s,1result:%f,except:%f\n", operatorTypeStr(opType), *((double *)colDataGetData(column, 0)), exceptValue);
ASSERT_TRUE(fabs(*((double *)colDataGetData(column, 0)) - exceptValue) < 0.0001); ASSERT_TRUE(fabs(*((double *)colDataGetData(column, 0)) - exceptValue) < 0.0001);
}else if(opType == OP_TYPE_BIT_AND || opType == OP_TYPE_BIT_OR){ }else if(opType == OP_TYPE_BIT_AND || opType == OP_TYPE_BIT_OR){
printf("op:%s,2result:%" PRId64 ",except:%f\n", gOptrStr[opType].str, *((int64_t *)colDataGetData(column, 0)), exceptValue); printf("op:%s,2result:%" PRId64 ",except:%f\n", operatorTypeStr(opType), *((int64_t *)colDataGetData(column, 0)), exceptValue);
ASSERT_EQ(*((int64_t *)colDataGetData(column, 0)), exceptValue); ASSERT_EQ(*((int64_t *)colDataGetData(column, 0)), exceptValue);
}else if(opType == OP_TYPE_GREATER_THAN || opType == OP_TYPE_GREATER_EQUAL || opType == OP_TYPE_LOWER_THAN || }else if(opType == OP_TYPE_GREATER_THAN || opType == OP_TYPE_GREATER_EQUAL || opType == OP_TYPE_LOWER_THAN ||
opType == OP_TYPE_LOWER_EQUAL || opType == OP_TYPE_EQUAL || opType == OP_TYPE_NOT_EQUAL || opType == OP_TYPE_LOWER_EQUAL || opType == OP_TYPE_EQUAL || opType == OP_TYPE_NOT_EQUAL ||
opType == OP_TYPE_IS_NULL || opType == OP_TYPE_IS_NOT_NULL || opType == OP_TYPE_IS_TRUE || opType == OP_TYPE_IS_NULL || opType == OP_TYPE_IS_NOT_NULL || opType == OP_TYPE_IS_TRUE ||
opType == OP_TYPE_LIKE || opType == OP_TYPE_NOT_LIKE || opType == OP_TYPE_MATCH || opType == OP_TYPE_NMATCH){ opType == OP_TYPE_LIKE || opType == OP_TYPE_NOT_LIKE || opType == OP_TYPE_MATCH || opType == OP_TYPE_NMATCH){
printf("op:%s,3result:%d,except:%f\n", gOptrStr[opType].str, *((bool *)colDataGetData(column, 0)), exceptValue); printf("op:%s,3result:%d,except:%f\n", operatorTypeStr(opType), *((bool *)colDataGetData(column, 0)), exceptValue);
ASSERT_EQ(*((bool *)colDataGetData(column, 0)), exceptValue); ASSERT_EQ(*((bool *)colDataGetData(column, 0)), exceptValue);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册