提交 98fc185e 编写于 作者: X Xiaoyu Wang

fix: escape character problem in auto create table insert

上级 0383ff3d
...@@ -105,7 +105,7 @@ typedef enum ENodeType { ...@@ -105,7 +105,7 @@ typedef enum ENodeType {
QUERY_NODE_COLUMN_REF, QUERY_NODE_COLUMN_REF,
// Statement nodes are used in parser and planner module. // Statement nodes are used in parser and planner module.
QUERY_NODE_SET_OPERATOR, QUERY_NODE_SET_OPERATOR = 100,
QUERY_NODE_SELECT_STMT, QUERY_NODE_SELECT_STMT,
QUERY_NODE_VNODE_MODIF_STMT, QUERY_NODE_VNODE_MODIF_STMT,
QUERY_NODE_CREATE_DATABASE_STMT, QUERY_NODE_CREATE_DATABASE_STMT,
...@@ -198,7 +198,7 @@ typedef enum ENodeType { ...@@ -198,7 +198,7 @@ typedef enum ENodeType {
QUERY_NODE_QUERY, QUERY_NODE_QUERY,
// logic plan node // logic plan node
QUERY_NODE_LOGIC_PLAN_SCAN, QUERY_NODE_LOGIC_PLAN_SCAN = 1000,
QUERY_NODE_LOGIC_PLAN_JOIN, QUERY_NODE_LOGIC_PLAN_JOIN,
QUERY_NODE_LOGIC_PLAN_AGG, QUERY_NODE_LOGIC_PLAN_AGG,
QUERY_NODE_LOGIC_PLAN_PROJECT, QUERY_NODE_LOGIC_PLAN_PROJECT,
...@@ -215,7 +215,7 @@ typedef enum ENodeType { ...@@ -215,7 +215,7 @@ typedef enum ENodeType {
QUERY_NODE_LOGIC_PLAN, QUERY_NODE_LOGIC_PLAN,
// physical plan node // physical plan node
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN, QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN = 1100,
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN, QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN,
QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN, QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN,
QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN, QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN,
......
...@@ -133,7 +133,6 @@ typedef enum EOperatorType { ...@@ -133,7 +133,6 @@ typedef enum EOperatorType {
OP_TYPE_REM, OP_TYPE_REM,
// unary arithmetic operator // unary arithmetic operator
OP_TYPE_MINUS, OP_TYPE_MINUS,
OP_TYPE_ASSIGN,
// bitwise operator // bitwise operator
OP_TYPE_BIT_AND, OP_TYPE_BIT_AND,
...@@ -164,7 +163,10 @@ typedef enum EOperatorType { ...@@ -164,7 +163,10 @@ typedef enum EOperatorType {
// json operator // json operator
OP_TYPE_JSON_GET_VALUE, OP_TYPE_JSON_GET_VALUE,
OP_TYPE_JSON_CONTAINS OP_TYPE_JSON_CONTAINS,
// internal operator
OP_TYPE_ASSIGN
} EOperatorType; } EOperatorType;
#define OP_TYPE_CALC_MAX OP_TYPE_BIT_OR #define OP_TYPE_CALC_MAX OP_TYPE_BIT_OR
......
...@@ -88,7 +88,7 @@ static const SSysDbTableSchema userDBSchema[] = { ...@@ -88,7 +88,7 @@ static const SSysDbTableSchema userDBSchema[] = {
{.name = "comp", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT}, {.name = "comp", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
{.name = "precision", .bytes = 2 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "precision", .bytes = 2 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
{.name = "status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
{.name = "retention", .bytes = 60 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "retentions", .bytes = 60 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
{.name = "single_stable", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL}, {.name = "single_stable", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL},
{.name = "cachemodel", .bytes = TSDB_CACHE_MODEL_STR_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "cachemodel", .bytes = TSDB_CACHE_MODEL_STR_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
{.name = "cachesize", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "cachesize", .bytes = 4, .type = TSDB_DATA_TYPE_INT},
......
...@@ -205,7 +205,7 @@ typedef struct SExprSupp { ...@@ -205,7 +205,7 @@ typedef struct SExprSupp {
} SExprSupp; } SExprSupp;
typedef struct SOperatorInfo { typedef struct SOperatorInfo {
uint8_t operatorType; uint16_t operatorType;
bool blocking; // block operator or not bool blocking; // block operator or not
uint8_t status; // denote if current operator is completed uint8_t status; // denote if current operator is completed
char* name; // name, for debug purpose char* name; // name, for debug purpose
...@@ -434,7 +434,7 @@ typedef struct SStreamAggSupporter { ...@@ -434,7 +434,7 @@ typedef struct SStreamAggSupporter {
typedef struct SessionWindowSupporter { typedef struct SessionWindowSupporter {
SStreamAggSupporter* pStreamAggSup; SStreamAggSupporter* pStreamAggSup;
int64_t gap; int64_t gap;
uint8_t parentType; uint16_t parentType;
SAggSupporter* pIntervalAggSup; SAggSupporter* pIntervalAggSup;
} SessionWindowSupporter; } SessionWindowSupporter;
......
...@@ -1780,7 +1780,7 @@ void increaseTs(SqlFunctionCtx* pCtx) { ...@@ -1780,7 +1780,7 @@ void increaseTs(SqlFunctionCtx* pCtx) {
} }
} }
void initIntervalDownStream(SOperatorInfo* downstream, uint8_t type, SAggSupporter* pSup) { void initIntervalDownStream(SOperatorInfo* downstream, uint16_t type, SAggSupporter* pSup) {
if (downstream->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) { if (downstream->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) {
// Todo(liuyao) support partition by column // Todo(liuyao) support partition by column
return; return;
...@@ -2644,7 +2644,6 @@ void destroyTimeSliceOperatorInfo(void* param, int32_t numOfOutput) { ...@@ -2644,7 +2644,6 @@ void destroyTimeSliceOperatorInfo(void* param, int32_t numOfOutput) {
taosMemoryFreeClear(param); taosMemoryFreeClear(param);
} }
SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo) { SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo) {
STimeSliceOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(STimeSliceOperatorInfo)); STimeSliceOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(STimeSliceOperatorInfo));
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
......
...@@ -21,36 +21,89 @@ ...@@ -21,36 +21,89 @@
#include "taoserror.h" #include "taoserror.h"
#include "thash.h" #include "thash.h"
char *gOperatorStr[] = {NULL, static const char *operatorTypeStr(EOperatorType type) {
"+", switch (type) {
"-", case OP_TYPE_ADD:
"*", return "+";
"/", case OP_TYPE_SUB:
"%", return "-";
"-", case OP_TYPE_MULTI:
"&", return "*";
"|", case OP_TYPE_DIV:
">", return "/";
">=", case OP_TYPE_REM:
"<", return "%";
"<=", case OP_TYPE_MINUS:
"=", return "-";
"<>", case OP_TYPE_BIT_AND:
"IN", return "&";
"NOT IN", case OP_TYPE_BIT_OR:
"LIKE", return "|";
"NOT LIKE", case OP_TYPE_GREATER_THAN:
"MATCH", return ">";
"NMATCH", case OP_TYPE_GREATER_EQUAL:
"IS NULL", return ">=";
"IS NOT NULL", case OP_TYPE_LOWER_THAN:
"IS TRUE", return "<";
"IS FALSE", case OP_TYPE_LOWER_EQUAL:
"IS UNKNOWN", return "<=";
"IS NOT TRUE", case OP_TYPE_EQUAL:
"IS NOT FALSE", return "=";
"IS NOT UNKNOWN"}; case OP_TYPE_NOT_EQUAL:
char *gLogicConditionStr[] = {"AND", "OR", "NOT"}; return "<>";
case OP_TYPE_IN:
return "IN";
case OP_TYPE_NOT_IN:
return "NOT IN";
case OP_TYPE_LIKE:
return "LIKE";
case OP_TYPE_NOT_LIKE:
return "NOT LIKE";
case OP_TYPE_MATCH:
return "MATCH";
case OP_TYPE_NMATCH:
return "NMATCH";
case OP_TYPE_IS_NULL:
return "IS NULL";
case OP_TYPE_IS_NOT_NULL:
return "IS NOT NULL";
case OP_TYPE_IS_TRUE:
return "IS TRUE";
case OP_TYPE_IS_FALSE:
return "IS FALSE";
case OP_TYPE_IS_UNKNOWN:
return "IS UNKNOWN";
case OP_TYPE_IS_NOT_TRUE:
return "IS NOT TRUE";
case OP_TYPE_IS_NOT_FALSE:
return "IS NOT FALSE";
case OP_TYPE_IS_NOT_UNKNOWN:
return "IS NOT UNKNOWN";
case OP_TYPE_JSON_GET_VALUE:
return "=>";
case OP_TYPE_JSON_CONTAINS:
return "CONTAINS";
case OP_TYPE_ASSIGN:
return "=";
default:
break;
}
return "UNKNOWN";
}
static const char *logicConditionTypeStr(ELogicConditionType type) {
switch (type) {
case LOGIC_COND_TYPE_AND:
return "AND";
case LOGIC_COND_TYPE_OR:
return "OR";
case LOGIC_COND_TYPE_NOT:
return "NOT";
default:
break;
}
return "UNKNOWN";
}
int32_t nodesNodeToSQL(SNode *pNode, char *buf, int32_t bufSize, int32_t *len) { int32_t nodesNodeToSQL(SNode *pNode, char *buf, int32_t bufSize, int32_t *len) {
switch (pNode->type) { switch (pNode->type) {
...@@ -94,12 +147,7 @@ int32_t nodesNodeToSQL(SNode *pNode, char *buf, int32_t bufSize, int32_t *len) { ...@@ -94,12 +147,7 @@ int32_t nodesNodeToSQL(SNode *pNode, char *buf, int32_t bufSize, int32_t *len) {
NODES_ERR_RET(nodesNodeToSQL(pOpNode->pLeft, buf, bufSize, len)); NODES_ERR_RET(nodesNodeToSQL(pOpNode->pLeft, buf, bufSize, len));
} }
if (pOpNode->opType >= (sizeof(gOperatorStr) / sizeof(gOperatorStr[0]))) { *len += snprintf(buf + *len, bufSize - *len, " %s ", operatorTypeStr(pOpNode->opType));
nodesError("unknown operation type:%d", pOpNode->opType);
NODES_ERR_RET(TSDB_CODE_QRY_APP_ERROR);
}
*len += snprintf(buf + *len, bufSize - *len, " %s ", gOperatorStr[pOpNode->opType]);
if (pOpNode->pRight) { if (pOpNode->pRight) {
NODES_ERR_RET(nodesNodeToSQL(pOpNode->pRight, buf, bufSize, len)); NODES_ERR_RET(nodesNodeToSQL(pOpNode->pRight, buf, bufSize, len));
...@@ -118,7 +166,7 @@ int32_t nodesNodeToSQL(SNode *pNode, char *buf, int32_t bufSize, int32_t *len) { ...@@ -118,7 +166,7 @@ int32_t nodesNodeToSQL(SNode *pNode, char *buf, int32_t bufSize, int32_t *len) {
FOREACH(node, pLogicNode->pParameterList) { FOREACH(node, pLogicNode->pParameterList) {
if (!first) { if (!first) {
*len += snprintf(buf + *len, bufSize - *len, " %s ", gLogicConditionStr[pLogicNode->condType]); *len += snprintf(buf + *len, bufSize - *len, " %s ", logicConditionTypeStr(pLogicNode->condType));
} }
NODES_ERR_RET(nodesNodeToSQL(node, buf, bufSize, len)); NODES_ERR_RET(nodesNodeToSQL(node, buf, bufSize, len));
first = false; first = false;
......
...@@ -143,9 +143,9 @@ static int32_t createSName(SName* pName, SToken* pTableName, int32_t acctId, con ...@@ -143,9 +143,9 @@ static int32_t createSName(SName* pName, SToken* pTableName, int32_t acctId, con
} }
char name[TSDB_DB_FNAME_LEN] = {0}; char name[TSDB_DB_FNAME_LEN] = {0};
strncpy(name, pTableName->z, dbLen); strncpy(name, pTableName->z, dbLen);
dbLen = strdequote(name); int32_t actualDbLen = strdequote(name);
code = tNameSetDbName(pName, acctId, name, dbLen); code = tNameSetDbName(pName, acctId, name, actualDbLen);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
return buildInvalidOperationMsg(pMsgBuf, msg1); return buildInvalidOperationMsg(pMsgBuf, msg1);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册