fix: adjust parsing of negative numbers
This commit is contained in:
parent
d223a6624b
commit
24d0fc4515
|
@ -385,6 +385,15 @@ SNode* createLogicConditionNode(SAstCreateContext* pCxt, ELogicConditionType typ
|
||||||
|
|
||||||
SNode* createOperatorNode(SAstCreateContext* pCxt, EOperatorType type, SNode* pLeft, SNode* pRight) {
|
SNode* createOperatorNode(SAstCreateContext* pCxt, EOperatorType type, SNode* pLeft, SNode* pRight) {
|
||||||
CHECK_PARSER_STATUS(pCxt);
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
|
if (OP_TYPE_MINUS == type && QUERY_NODE_VALUE == nodeType(pLeft)) {
|
||||||
|
SValueNode* pVal = (SValueNode*)pLeft;
|
||||||
|
char* pNewLiteral = taosMemoryCalloc(1, strlen(pVal->literal) + 1);
|
||||||
|
CHECK_OUT_OF_MEM(pNewLiteral);
|
||||||
|
sprintf(pNewLiteral, "-%s", pVal->literal);
|
||||||
|
taosMemoryFree(pVal->literal);
|
||||||
|
pVal->literal = pNewLiteral;
|
||||||
|
return pLeft;
|
||||||
|
}
|
||||||
SOperatorNode* op = (SOperatorNode*)nodesMakeNode(QUERY_NODE_OPERATOR);
|
SOperatorNode* op = (SOperatorNode*)nodesMakeNode(QUERY_NODE_OPERATOR);
|
||||||
CHECK_OUT_OF_MEM(op);
|
CHECK_OUT_OF_MEM(op);
|
||||||
op->opType = type;
|
op->opType = type;
|
||||||
|
|
|
@ -878,6 +878,9 @@ static EDealRes translateNormalValue(STranslateContext* pCxt, SValueNode* pVal,
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_VARCHAR:
|
case TSDB_DATA_TYPE_VARCHAR:
|
||||||
case TSDB_DATA_TYPE_VARBINARY: {
|
case TSDB_DATA_TYPE_VARBINARY: {
|
||||||
|
if (strict && (pVal->node.resType.bytes > targetDt.bytes - VARSTR_HEADER_SIZE)) {
|
||||||
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal);
|
||||||
|
}
|
||||||
pVal->datum.p = taosMemoryCalloc(1, targetDt.bytes + 1);
|
pVal->datum.p = taosMemoryCalloc(1, targetDt.bytes + 1);
|
||||||
if (NULL == pVal->datum.p) {
|
if (NULL == pVal->datum.p) {
|
||||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_OUT_OF_MEMORY);
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
@ -5829,10 +5832,6 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS
|
||||||
return pCxt->errCode;
|
return pCxt->errCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE(pSchema->type) && strlen(pStmt->pVal->literal) > pSchema->bytes) {
|
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pStmt->pVal->literal);
|
|
||||||
}
|
|
||||||
|
|
||||||
pReq->isNull = (TSDB_DATA_TYPE_NULL == pStmt->pVal->node.resType.type);
|
pReq->isNull = (TSDB_DATA_TYPE_NULL == pStmt->pVal->node.resType.type);
|
||||||
if (targetDt.type == TSDB_DATA_TYPE_JSON) {
|
if (targetDt.type == TSDB_DATA_TYPE_JSON) {
|
||||||
pReq->isNull = 0;
|
pReq->isNull = 0;
|
||||||
|
|
Loading…
Reference in New Issue