TD-13757 bugfix
This commit is contained in:
parent
0025aed0d5
commit
25f2b374cc
|
@ -28,6 +28,13 @@
|
||||||
pSql += index; \
|
pSql += index; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#define NEXT_TOKEN_WITH_PREV(pSql, sToken) \
|
||||||
|
do { \
|
||||||
|
int32_t index = 0; \
|
||||||
|
sToken = tStrGetToken(pSql, &index, true); \
|
||||||
|
pSql += index; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define NEXT_TOKEN_KEEP_SQL(pSql, sToken, index) \
|
#define NEXT_TOKEN_KEEP_SQL(pSql, sToken, index) \
|
||||||
do { \
|
do { \
|
||||||
sToken = tStrGetToken(pSql, &index, false); \
|
sToken = tStrGetToken(pSql, &index, false); \
|
||||||
|
@ -352,7 +359,7 @@ static int parseTime(char **end, SToken *pToken, int16_t timePrec, int64_t *time
|
||||||
sToken = tStrGetToken(pTokenEnd, &index, false);
|
sToken = tStrGetToken(pTokenEnd, &index, false);
|
||||||
pTokenEnd += index;
|
pTokenEnd += index;
|
||||||
|
|
||||||
if (sToken.type == TK_MINUS || sToken.type == TK_NK_PLUS) {
|
if (sToken.type == TK_NK_MINUS || sToken.type == TK_NK_PLUS) {
|
||||||
index = 0;
|
index = 0;
|
||||||
valueToken = tStrGetToken(pTokenEnd, &index, false);
|
valueToken = tStrGetToken(pTokenEnd, &index, false);
|
||||||
pTokenEnd += index;
|
pTokenEnd += index;
|
||||||
|
@ -748,7 +755,7 @@ static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pTagsSchema,
|
||||||
SToken sToken;
|
SToken sToken;
|
||||||
char tmpTokenBuf[TSDB_MAX_BYTES_PER_ROW] = {0}; // used for deleting Escape character: \\, \', \"
|
char tmpTokenBuf[TSDB_MAX_BYTES_PER_ROW] = {0}; // used for deleting Escape character: \\, \', \"
|
||||||
for (int i = 0; i < pCxt->tags.numOfBound; ++i) {
|
for (int i = 0; i < pCxt->tags.numOfBound; ++i) {
|
||||||
NEXT_TOKEN(pCxt->pSql, sToken);
|
NEXT_TOKEN_WITH_PREV(pCxt->pSql, sToken);
|
||||||
SSchema* pSchema = &pTagsSchema[pCxt->tags.boundedColumns[i]];
|
SSchema* pSchema = &pTagsSchema[pCxt->tags.boundedColumns[i]];
|
||||||
param.schema = pSchema;
|
param.schema = pSchema;
|
||||||
CHECK_CODE(parseValueToken(&pCxt->pSql, &sToken, pSchema, precision, tmpTokenBuf, KvRowAppend, ¶m, &pCxt->msg));
|
CHECK_CODE(parseValueToken(&pCxt->pSql, &sToken, pSchema, precision, tmpTokenBuf, KvRowAppend, ¶m, &pCxt->msg));
|
||||||
|
@ -814,7 +821,7 @@ static int parseOneRow(SInsertParseContext* pCxt, STableDataBlocks* pDataBlocks,
|
||||||
SToken sToken = {0};
|
SToken sToken = {0};
|
||||||
// 1. set the parsed value from sql string
|
// 1. set the parsed value from sql string
|
||||||
for (int i = 0; i < spd->numOfBound; ++i) {
|
for (int i = 0; i < spd->numOfBound; ++i) {
|
||||||
NEXT_TOKEN(pCxt->pSql, sToken);
|
NEXT_TOKEN_WITH_PREV(pCxt->pSql, sToken);
|
||||||
SSchema *pSchema = &schema[spd->boundedColumns[i] - 1];
|
SSchema *pSchema = &schema[spd->boundedColumns[i] - 1];
|
||||||
param.schema = pSchema;
|
param.schema = pSchema;
|
||||||
getMemRowAppendInfo(schema, pBuilder->rowType, spd, i, ¶m.toffset, ¶m.colIdx);
|
getMemRowAppendInfo(schema, pBuilder->rowType, spd, i, ¶m.toffset, ¶m.colIdx);
|
||||||
|
|
|
@ -320,7 +320,7 @@ uint32_t tGetToken(const char* z, uint32_t* tokenId) {
|
||||||
*tokenId = TK_NK_COMMENT;
|
*tokenId = TK_NK_COMMENT;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
*tokenId = TK_MINUS;
|
*tokenId = TK_NK_MINUS;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
case '(': {
|
case '(': {
|
||||||
|
@ -674,7 +674,7 @@ SToken tStrGetToken(const char* str, int32_t* i, bool isPrevOptr) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// support parse the -/+number format
|
// support parse the -/+number format
|
||||||
if ((isPrevOptr) && (t0.type == TK_MINUS || t0.type == TK_NK_PLUS)) {
|
if ((isPrevOptr) && (t0.type == TK_NK_MINUS || t0.type == TK_NK_PLUS)) {
|
||||||
len = tGetToken(&str[*i + t0.n], &type);
|
len = tGetToken(&str[*i + t0.n], &type);
|
||||||
if (type == TK_NK_INTEGER || type == TK_NK_FLOAT) {
|
if (type == TK_NK_INTEGER || type == TK_NK_FLOAT) {
|
||||||
t0.type = type;
|
t0.type = type;
|
||||||
|
|
|
@ -873,12 +873,22 @@ static int32_t translateAlterDatabase(STranslateContext* pCxt, SAlterDatabaseStm
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t calcTypeBytes(SDataType dt) {
|
||||||
|
if (TSDB_DATA_TYPE_BINARY == dt.type) {
|
||||||
|
return dt.bytes + VARSTR_HEADER_SIZE;
|
||||||
|
} else if (TSDB_DATA_TYPE_NCHAR == dt.type) {
|
||||||
|
return dt.bytes * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE;
|
||||||
|
} else {
|
||||||
|
return dt.bytes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t columnNodeToField(SNodeList* pList, SArray** pArray) {
|
static int32_t columnNodeToField(SNodeList* pList, SArray** pArray) {
|
||||||
*pArray = taosArrayInit(LIST_LENGTH(pList), sizeof(SField));
|
*pArray = taosArrayInit(LIST_LENGTH(pList), sizeof(SField));
|
||||||
SNode* pNode;
|
SNode* pNode;
|
||||||
FOREACH(pNode, pList) {
|
FOREACH(pNode, pList) {
|
||||||
SColumnDefNode* pCol = (SColumnDefNode*)pNode;
|
SColumnDefNode* pCol = (SColumnDefNode*)pNode;
|
||||||
SField field = { .type = pCol->dataType.type, .bytes = pCol->dataType.bytes };
|
SField field = { .type = pCol->dataType.type, .bytes = calcTypeBytes(pCol->dataType) };
|
||||||
strcpy(field.name, pCol->colName);
|
strcpy(field.name, pCol->colName);
|
||||||
taosArrayPush(*pArray, &field);
|
taosArrayPush(*pArray, &field);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue