diff --git a/src/client/inc/tscUtil.h b/src/client/inc/tscUtil.h index b183598fcceff926cfba235e42d8634546b36a48..aeac129bd93c9ac634929173137121a3d069f3c9 100644 --- a/src/client/inc/tscUtil.h +++ b/src/client/inc/tscUtil.h @@ -35,12 +35,12 @@ extern "C" { #define UTIL_TABLE_IS_CHILD_TABLE(metaInfo) \ (((metaInfo)->pTableMeta != NULL) && ((metaInfo)->pTableMeta->tableType == TSDB_CHILD_TABLE)) -#define UTIL_TABLE_IS_NORMAL_TABLE(metaInfo) \ - (!(UTIL_TABLE_IS_SUPER_TABLE(metaInfo) || UTIL_TABLE_IS_CHILD_TABLE(metaInfo))) - #define UTIL_TABLE_IS_TMP_TABLE(metaInfo) \ (((metaInfo)->pTableMeta != NULL) && ((metaInfo)->pTableMeta->tableType == TSDB_TEMP_TABLE)) +#define UTIL_TABLE_IS_NORMAL_TABLE(metaInfo) \ + (!(UTIL_TABLE_IS_SUPER_TABLE(metaInfo) || UTIL_TABLE_IS_CHILD_TABLE(metaInfo) || UTIL_TABLE_IS_TMP_TABLE(metaInfo))) + #define UTIL_GET_VGROUPMAP(pSql) \ (pSql->pTscObj->pClusterInfo->vgroupMap) diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index 7f35cf0ea5080cbb49db3a78b7d53df58cb9724c..97cc3383c9b5609a2a7064ae247d074b15374751 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -499,6 +499,8 @@ bool tscHasReachLimitation(SQueryInfo *pQueryInfo, SSqlRes *pRes); void tscSetBoundColumnInfo(SParsedDataColInfo *pColInfo, SSchema *pSchema, int32_t numOfCols); char *tscGetErrorMsgPayload(SSqlCmd *pCmd); +int32_t tscGetErrorMsgLength(SSqlCmd* pCmd); + int32_t tscErrorMsgWithCode(int32_t code, char* dstBuffer, const char* errMsg, const char* sql); int32_t tscInvalidOperationMsg(char *msg, const char *additionalInfo, const char *sql); diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 921adf1a5fd72f65b370185089917179de67eaf4..c8f9fc7821c86e0533552bada84b4248c27fc60e 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -1806,6 +1806,10 @@ static int32_t handleScalarTypeExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32 if (ret != TSDB_CODE_SUCCESS) { taosArrayDestroy(colList); tExprTreeDestroy(pNode, NULL); + if (tscGetErrorMsgLength(pCmd) > 0) { + return ret; + } + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); } @@ -1816,15 +1820,19 @@ static int32_t handleScalarTypeExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32 if (TSDB_COL_IS_TAG(pIndex->flag)) { tExprTreeDestroy(pNode, NULL); taosArrayDestroy(colList); - + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); } } - ret = exprTreeValidateTree(pNode); + ret = exprTreeValidateTree(tscGetErrorMsgPayload(pCmd), pNode); if (ret != TSDB_CODE_SUCCESS) { taosArrayDestroy(colList); tExprTreeDestroy(pNode, NULL); + if (tscGetErrorMsgLength(pCmd) > 0) { + return ret; + } + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); } @@ -1885,7 +1893,7 @@ static int32_t handleAggTypeExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), "invalid expression in select clause"); } - ret = exprTreeValidateTree(pExpr); + ret = exprTreeValidateTree(tscGetErrorMsgPayload(pCmd), pExpr); if (ret != TSDB_CODE_SUCCESS) { tExprTreeDestroy(pExpr, NULL); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); @@ -1932,17 +1940,16 @@ static int32_t handleAggTypeExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t } static int32_t handleSQLExprItem(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t exprIndex, tSqlExprItem* pItem) { - const char* msg1 = "invalid column name, illegal column type, illegal function combination or columns in expression from two tables"; - SColumnList columnList = {0}; int32_t sqlExprType = SQLEXPR_TYPE_UNASSIGNED; uint64_t uid; - if (validateSQLExprItem(pCmd, pItem->pNode, pQueryInfo, &columnList, &sqlExprType, &uid) != TSDB_CODE_SUCCESS) { - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); + int32_t code = validateSQLExprItem(pCmd, pItem->pNode, pQueryInfo, &columnList, &sqlExprType, &uid); + + if (code != TSDB_CODE_SUCCESS) { + return code; } - int32_t code = TSDB_CODE_SUCCESS; if (sqlExprType == SQLEXPR_TYPE_SCALAR) { code = handleScalarTypeExpr(pCmd, pQueryInfo, exprIndex, pItem, &columnList, true); } else { @@ -3781,7 +3788,6 @@ static bool functionCompatibleCheck(SQueryInfo* pQueryInfo, bool joinQuery, bool } } - aggNum = (int32_t)size - prjNum - scalarFuncNum - aggUdf - scalarUdf - countTbname; assert(aggNum >= 0); @@ -4351,6 +4357,9 @@ static int32_t getJoinCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr* static int32_t validateSQLExprItemSQLFunc(SSqlCmd* pCmd, tSqlExpr* pExpr, SQueryInfo* pQueryInfo, SColumnList* pList, int32_t* type, uint64_t *uid) { int32_t code = TSDB_CODE_SUCCESS; + const char* msg1 = "invalid function parameters"; + const char* msg2 = "not supported functions in arithmetic expression"; + int32_t functionId = isValidFunction(pExpr->Expr.operand.z, pExpr->Expr.operand.n); pExpr->functionId = functionId; @@ -4369,7 +4378,7 @@ static int32_t validateSQLExprItemSQLFunc(SSqlCmd* pCmd, tSqlExpr* pExpr, if (!TSDB_FUNC_IS_SCALAR(functionId) && (pParamElem->pNode->type == SQL_NODE_EXPR || pParamElem->pNode->type == SQL_NODE_SQLFUNCTION)) { - return TSDB_CODE_TSC_INVALID_OPERATION; + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); } } @@ -4383,7 +4392,7 @@ static int32_t validateSQLExprItemSQLFunc(SSqlCmd* pCmd, tSqlExpr* pExpr, anyChildAgg = anyChildAgg || (childrenTypes[i] == SQLEXPR_TYPE_AGG); } if (anyChildAgg && anyChildScalar) { - return TSDB_CODE_TSC_INVALID_OPERATION; + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); } if (anyChildAgg) { *type = SQLEXPR_TYPE_AGG; @@ -4427,7 +4436,7 @@ static int32_t validateSQLExprItemSQLFunc(SSqlCmd* pCmd, tSqlExpr* pExpr, // It is invalid in case of more than one sqlExpr, such as first(ts, k) - last(ts, k) int32_t inc = (int32_t)tscNumOfExprs(pQueryInfo) - outputIndex; if (inc > 1) { - return TSDB_CODE_TSC_INVALID_OPERATION; + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); } // Not supported data type in arithmetic expression @@ -4462,6 +4471,9 @@ static int32_t validateSQLExprItemArithmeticExpr(SSqlCmd* pCmd, tSqlExpr* pExpr, uint64_t uidRight = 0; int32_t leftType = SQLEXPR_TYPE_UNASSIGNED; int32_t rightType = SQLEXPR_TYPE_UNASSIGNED; + const char* msg1 = "arithmetic expression composed with columns from different tables"; + const char* msg2 = "arithmetic expression composed with functions/columns of different types"; + int32_t ret = validateSQLExprItem(pCmd, pExpr->pLeft, pQueryInfo, pList, &leftType, &uidLeft); if (ret != TSDB_CODE_SUCCESS) { return ret; @@ -4472,7 +4484,7 @@ static int32_t validateSQLExprItemArithmeticExpr(SSqlCmd* pCmd, tSqlExpr* pExpr, } if (uidLeft != uidRight && uidLeft != 0 && uidRight != 0) { - return TSDB_CODE_TSC_INVALID_OPERATION; + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); } *uid = uidLeft; @@ -4480,11 +4492,8 @@ static int32_t validateSQLExprItemArithmeticExpr(SSqlCmd* pCmd, tSqlExpr* pExpr, assert(leftType != SQLEXPR_TYPE_UNASSIGNED && rightType != SQLEXPR_TYPE_UNASSIGNED); // return invalid operation when one child aggregate and the other child scalar or column - if (leftType == SQLEXPR_TYPE_AGG && rightType == SQLEXPR_TYPE_SCALAR) { - return TSDB_CODE_TSC_INVALID_OPERATION; - } - if (rightType == SQLEXPR_TYPE_AGG && leftType == SQLEXPR_TYPE_SCALAR) { - return TSDB_CODE_TSC_INVALID_OPERATION; + if ((leftType == SQLEXPR_TYPE_AGG && rightType == SQLEXPR_TYPE_SCALAR) || (rightType == SQLEXPR_TYPE_AGG && leftType == SQLEXPR_TYPE_SCALAR)) { + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); } if (leftType == SQLEXPR_TYPE_AGG || rightType == SQLEXPR_TYPE_AGG) { @@ -4500,6 +4509,10 @@ static int32_t validateSQLExprItemArithmeticExpr(SSqlCmd* pCmd, tSqlExpr* pExpr, static int32_t validateSQLExprItem(SSqlCmd* pCmd, tSqlExpr* pExpr, SQueryInfo* pQueryInfo, SColumnList* pList, int32_t* type, uint64_t* uid) { + const char* msg1 = "invalid column name in select clause"; + const char* msg2 = "invalid data type in select clause"; + const char* msg3 = "invalid select clause"; + if (pExpr == NULL) { return TSDB_CODE_SUCCESS; } @@ -4518,16 +4531,26 @@ static int32_t validateSQLExprItem(SSqlCmd* pCmd, tSqlExpr* pExpr, SColumnIndex index = COLUMN_INDEX_INITIALIZER; if (getColumnIndexByName(&pExpr->columnName, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) { - return TSDB_CODE_TSC_INVALID_OPERATION; + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); } pList->ids[pList->num++] = index; *type = SQLEXPR_TYPE_SCALAR; + } else if (pExpr->type == SQL_NODE_DATA_TYPE) { + if (pExpr->dataType.type < 0 || pExpr->dataType.bytes <= 0) { + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); + } + *type = SQLEXPR_TYPE_SCALAR; } else { if ((pExpr->tokenId == TK_FLOAT && (isnan(pExpr->value.dKey) || isinf(pExpr->value.dKey))) || pExpr->tokenId == TK_NULL) { - return TSDB_CODE_TSC_INVALID_OPERATION; + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); + } + + if (pExpr->value.nType == (uint32_t)-1) { + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); } + if (pExpr->type == SQL_NODE_VALUE) { *type = SQLEXPR_TYPE_VALUE; } @@ -6292,6 +6315,27 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq return invalidOperationMsg(pMsgBuf, msg11); } + if (tscIsProjectionQuery(pQueryInfo)) { + bool found = false; + for (int32_t i = 0; i < tscNumOfExprs(pQueryInfo); ++i) { + SExprInfo* pExpr = tscExprGet(pQueryInfo, i); + if (pExpr->base.functionId == TSDB_FUNC_PRJ && pExpr->base.colInfo.colId == pSchema[index.columnIndex].colId) { + found = true; + break; + } + } + + if (!found) { + int32_t numOfCols = (int32_t)tscNumOfFields(pQueryInfo); + tscAddFuncInSelectClause(pQueryInfo, numOfCols, TSDB_FUNC_PRJ, &index, pSchema, TSDB_COL_NORMAL, getNewResColId(pCmd)); + + SInternalField* pSupInfo = tscFieldInfoGetInternalField(&pQueryInfo->fieldsInfo, numOfCols); + pSupInfo->visible = false; + + pQueryInfo->type |= TSDB_QUERY_TYPE_PROJECTION_QUERY; + } + } + tVariantListItem* pItem = taosArrayGet(pSqlNode->pSortOrder, 0); pQueryInfo->order.order = pItem->sortOrder; pQueryInfo->order.orderColId = pSchema[index.columnIndex].colId; @@ -9686,6 +9730,14 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS taosArrayPush(pCols, &colIndex); } + return TSDB_CODE_SUCCESS; + } else if (pSqlExpr->type == SQL_NODE_DATA_TYPE) { + *pExpr = calloc(1, sizeof(tExprNode)); + (*pExpr)->nodeType = TSQL_NODE_TYPE; + (*pExpr)->pType = calloc(1, sizeof(TAOS_FIELD)); + + *(*pExpr)->pType = pSqlExpr->dataType; + return TSDB_CODE_SUCCESS; } else if (pSqlExpr->tokenId == TK_SET) { int32_t colType = -1; @@ -9873,3 +9925,4 @@ void normalizeSqlNode(SSqlNode* pSqlNode, const char* dbName) { #endif + diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index fb2f3d5da5c507e4048b42c2d1de3d41eb9ab085..62167d9fedbdc67e3422374f4c1e1fc55684681d 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -4409,6 +4409,8 @@ bool tscHasReachLimitation(SQueryInfo* pQueryInfo, SSqlRes* pRes) { char* tscGetErrorMsgPayload(SSqlCmd* pCmd) { return pCmd->payload; } +int32_t tscGetErrorMsgLength(SSqlCmd* pCmd) { return (int32_t)strlen(pCmd->payload); } + /** * If current vnode query does not return results anymore (pRes->numOfRows == 0), try the next vnode if exists, * while multi-vnode super table projection query and the result does not reach the limitation. diff --git a/src/common/inc/texpr.h b/src/common/inc/texpr.h index aa6057c668a155461a3128e93b1f71eb8b1164f5..311f65073367e2b2a2c5e436b4655cf12ef4c02a 100644 --- a/src/common/inc/texpr.h +++ b/src/common/inc/texpr.h @@ -64,7 +64,8 @@ struct SSchema; #define TSDB_FUNC_SCALAR_LENGTH (TSDB_FUNC_FLAG_SCALAR | 0x000E) #define TSDB_FUNC_SCALAR_CONCAT_WS (TSDB_FUNC_FLAG_SCALAR | 0x000F) #define TSDB_FUNC_SCALAR_CHAR_LENGTH (TSDB_FUNC_FLAG_SCALAR | 0x0010) -#define TSDB_FUNC_SCALAR_MAX_NUM 17 +#define TSDB_FUNC_SCALAR_CAST (TSDB_FUNC_FLAG_SCALAR | 0x0011) +#define TSDB_FUNC_SCALAR_MAX_NUM 18 #define TSDB_FUNC_SCALAR_NAME_MAX_LEN 16 @@ -97,7 +98,8 @@ enum { TSQL_NODE_EXPR = 0x1, TSQL_NODE_COL = 0x2, TSQL_NODE_VALUE = 0x4, - TSQL_NODE_FUNC = 0x8 + TSQL_NODE_FUNC = 0x8, + TSQL_NODE_TYPE = 0x10 }; /** @@ -131,6 +133,8 @@ typedef struct tExprNode { int32_t numChildren; struct tExprNode **pChildren; } _func; + + TAOS_FIELD *pType; }; int16_t resultType; int16_t resultBytes; @@ -144,7 +148,7 @@ typedef struct SExprTraverseSupp { void tExprTreeDestroy(tExprNode *pNode, void (*fp)(void *)); -int32_t exprTreeValidateTree(tExprNode *pExpr); +int32_t exprTreeValidateTree(char* msgbuf, tExprNode *pExpr); void exprTreeToBinary(SBufferWriter* bw, tExprNode* pExprTree); tExprNode* exprTreeFromBinary(const void* data, size_t size); diff --git a/src/common/src/texpr.c b/src/common/src/texpr.c index 0fe99ac540bd246cedaccc64cad6ee271a6e7c7c..bac2eb4cdf2f6b19c11d63e423ef0ceb8b3a6074 100644 --- a/src/common/src/texpr.c +++ b/src/common/src/texpr.c @@ -32,8 +32,19 @@ static int32_t exprValidateMathNode(tExprNode *pExpr); static int32_t exprValidateStringConcatNode(tExprNode *pExpr); static int32_t exprValidateStringConcatWsNode(tExprNode *pExpr); static int32_t exprValidateStringLengthNode(tExprNode *pExpr); +static int32_t exprValidateCastNode(char* msgbuf, tExprNode *pExpr); -int32_t exprTreeValidateFunctionNode(tExprNode *pExpr) { +static int32_t exprInvalidOperationMsg(char *msgbuf, const char *msg) { + const char* msgFormat = "invalid operation: %s"; + + sprintf(msgbuf, msgFormat, msg); + + return TSDB_CODE_TSC_INVALID_OPERATION; +} + + + +int32_t exprTreeValidateFunctionNode(char* msgbuf, tExprNode *pExpr) { int32_t code = TSDB_CODE_SUCCESS; //TODO: check childs for every function switch (pExpr->_func.functionId) { @@ -59,6 +70,9 @@ int32_t exprTreeValidateFunctionNode(tExprNode *pExpr) { case TSDB_FUNC_SCALAR_CHAR_LENGTH: { return exprValidateStringLengthNode(pExpr); } + case TSDB_FUNC_SCALAR_CAST: { + return exprValidateCastNode(msgbuf, pExpr); + } case TSDB_FUNC_SCALAR_CONCAT_WS: { return exprValidateStringConcatWsNode(pExpr); } @@ -86,7 +100,7 @@ int32_t exprTreeValidateExprNode(tExprNode *pExpr) { } } -int32_t exprTreeValidateTree(tExprNode *pExpr) { +int32_t exprTreeValidateTree(char* msgbuf, tExprNode *pExpr) { int32_t code = TSDB_CODE_SUCCESS; if (pExpr == NULL) { return TSDB_CODE_SUCCESS; @@ -106,11 +120,11 @@ int32_t exprTreeValidateTree(tExprNode *pExpr) { pExpr->resultBytes = tGetTbnameColumnSchema()->bytes; } } else if (pExpr->nodeType == TSQL_NODE_EXPR) { - code = exprTreeValidateTree(pExpr->_node.pLeft); + code = exprTreeValidateTree(msgbuf, pExpr->_node.pLeft); if (code != TSDB_CODE_SUCCESS) { return code; } - code = exprTreeValidateTree(pExpr->_node.pRight); + code = exprTreeValidateTree(msgbuf, pExpr->_node.pRight); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -120,15 +134,18 @@ int32_t exprTreeValidateTree(tExprNode *pExpr) { } } else if (pExpr->nodeType == TSQL_NODE_FUNC) { for (int32_t i = 0; i < pExpr->_func.numChildren; ++i) { - code = exprTreeValidateTree(pExpr->_func.pChildren[i]); + code = exprTreeValidateTree(msgbuf, pExpr->_func.pChildren[i]); if (code != TSDB_CODE_SUCCESS) { return code; } } - code = exprTreeValidateFunctionNode(pExpr); + code = exprTreeValidateFunctionNode(msgbuf, pExpr); if (code != TSDB_CODE_SUCCESS) { return code; } + } else if (pExpr->nodeType == TSQL_NODE_TYPE) { + pExpr->resultType = pExpr->pType->type; + pExpr->resultBytes = pExpr->pType->bytes; } return TSDB_CODE_SUCCESS; @@ -147,7 +164,7 @@ static uint8_t UNUSED_FUNC isQueryOnPrimaryKey(const char *primaryColumnName, co } } -static void reverseCopy(char* dest, const char* src, int16_t type, int32_t numOfRows) { +static void reverseCopy(char* dest, const char* src, int16_t type, int32_t numOfRows, int16_t colSize) { switch(type) { case TSDB_DATA_TYPE_TINYINT: case TSDB_DATA_TYPE_UTINYINT:{ @@ -208,6 +225,13 @@ static void reverseCopy(char* dest, const char* src, int16_t type, int32_t numOf } return; } + case TSDB_DATA_TYPE_BINARY: + case TSDB_DATA_TYPE_NCHAR:{ + for(int32_t i = 0; i < numOfRows; ++i) { + memcpy(dest + i * colSize, src + (numOfRows - i - 1) * colSize, colSize); + } + return; + } default: assert(0); } } @@ -227,6 +251,8 @@ void tExprTreeDestroy(tExprNode *pNode, void (*fp)(void *)) { tfree(pNode->pSchema); } else if (pNode->nodeType == TSQL_NODE_FUNC) { doExprTreeDestroy(&pNode, fp); + } else if (pNode->nodeType == TSQL_NODE_TYPE) { + tfree(pNode->pType); } free(pNode); @@ -254,6 +280,8 @@ static void doExprTreeDestroy(tExprNode **pExpr, void (*fp)(void *)) { doExprTreeDestroy((*pExpr)->_func.pChildren + i, fp); } free((*pExpr)->_func.pChildren); + } else if ((*pExpr)->nodeType == TSQL_NODE_TYPE) { + tfree((*pExpr)->pType); } free(*pExpr); @@ -303,7 +331,7 @@ void exprTreeNodeTraverse(tExprNode *pExpr, int32_t numOfRows, tExprOperandInfo } else if (pExpr->nodeType == TSQL_NODE_COL) { char *pInputData = getSourceDataBlock(param, pExpr->pSchema->name, pExpr->pSchema->colId); if (order == TSDB_ORDER_DESC) { - reverseCopy(pOutput, pInputData, pExpr->pSchema->type, numOfRows); + reverseCopy(pOutput, pInputData, pExpr->pSchema->type, numOfRows, pExpr->pSchema->bytes); } else { memcpy(pOutput, pInputData, pExpr->pSchema->bytes*numOfRows); } @@ -359,7 +387,7 @@ void exprTreeFunctionNodeTraverse(tExprNode *pExpr, int32_t numOfRows, tExprOper char *pInputData = getSourceDataBlock(param, pChild->pSchema->name, pChild->pSchema->colId); if (order == TSDB_ORDER_DESC) { pChildrenOutput[i] = malloc(pChild->pSchema->bytes * numOfRows); - reverseCopy(pChildrenOutput[i], pInputData, pChild->pSchema->type, numOfRows); + reverseCopy(pChildrenOutput[i], pInputData, pChild->pSchema->type, numOfRows, pChild->pSchema->bytes); pInputs[i].data = pChildrenOutput[i]; } else { pInputs[i].data = pInputData; @@ -392,115 +420,79 @@ void exprTreeExprNodeTraverse(tExprNode *pExpr, int32_t numOfRows, tExprOperandI tExprNode *pLeft = pExpr->_node.pLeft; tExprNode *pRight = pExpr->_node.pRight; - - /* the left output has result from the left child syntax tree */ - char *pLeftOutput = (char*)malloc(sizeof(int64_t) * numOfRows); - tExprOperandInfo left; - left.type = TSDB_DATA_TYPE_DOUBLE; - left.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes; - left.data = pLeftOutput; + char *ltmp = NULL, *rtmp = NULL; + char *leftIn = NULL, *rightIn = NULL; + int32_t leftNum = 0, rightNum = 0; + int32_t leftType = 0, rightType = 0; + int32_t fnOrder = TSDB_ORDER_ASC; + if (pLeft->nodeType == TSQL_NODE_EXPR || pLeft->nodeType == TSQL_NODE_FUNC) { + ltmp = (char*)malloc(sizeof(int64_t) * numOfRows); + tExprOperandInfo left; + left.data = ltmp; exprTreeInternalNodeTraverse(pLeft, numOfRows, &left, param, order, getSourceDataBlock); - } - - /* the right output has result from the right child syntax tree */ - char *pRightOutput = malloc(sizeof(int64_t) * numOfRows); - tExprOperandInfo right; - right.type = TSDB_DATA_TYPE_DOUBLE; - right.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes; - right.data = pRightOutput; + + leftIn = ltmp; + leftType = left.type; + leftNum = left.numOfRows; + } else if (pLeft->nodeType == TSQL_NODE_COL) { + char *pInputData = getSourceDataBlock(param, pLeft->pSchema->name, pLeft->pSchema->colId); + if (order == TSDB_ORDER_DESC && (pRight->nodeType != TSQL_NODE_COL)) { + ltmp = malloc(sizeof(int64_t) * numOfRows); + reverseCopy(ltmp, pInputData, pLeft->pSchema->type, numOfRows, pLeft->pSchema->bytes); + leftIn = ltmp; + } else { + leftIn = pInputData; + fnOrder = order; + } - char *pData = malloc(sizeof(int64_t) * numOfRows); + leftType = pLeft->pSchema->type; + leftNum = numOfRows; + } else { + assert(pLeft->nodeType == TSQL_NODE_VALUE); + leftIn = (char *)&pLeft->pVal->i64; + leftType = pLeft->pVal->nType; + leftNum = 1; + } if (pRight->nodeType == TSQL_NODE_EXPR || pRight->nodeType == TSQL_NODE_FUNC) { + rtmp = (char*)malloc(sizeof(int64_t) * numOfRows); + tExprOperandInfo right; + right.data = rtmp; exprTreeInternalNodeTraverse(pRight, numOfRows, &right, param, order, getSourceDataBlock); - } - - if (pLeft->nodeType == TSQL_NODE_EXPR || pLeft->nodeType == TSQL_NODE_FUNC) { - if (pRight->nodeType == TSQL_NODE_EXPR || pRight->nodeType == TSQL_NODE_FUNC) { - /* - * exprLeft + exprRight - * the type of returned value of one expression is always double float precious - */ - _arithmetic_operator_fn_t OperatorFn = getArithmeticOperatorFn(pExpr->_node.optr); - OperatorFn(pLeftOutput, numOfRows, TSDB_DATA_TYPE_DOUBLE, pRightOutput, numOfRows, TSDB_DATA_TYPE_DOUBLE, output->data, TSDB_ORDER_ASC); - output->numOfRows = MAX(left.numOfRows, right.numOfRows); - } else if (pRight->nodeType == TSQL_NODE_COL) { // exprLeft + columnRight - _arithmetic_operator_fn_t OperatorFn = getArithmeticOperatorFn(pExpr->_node.optr); - - // set input buffer - char *pInputData = getSourceDataBlock(param, pRight->pSchema->name, pRight->pSchema->colId); - if (order == TSDB_ORDER_DESC) { - reverseCopy(pData, pInputData, pRight->pSchema->type, numOfRows); - OperatorFn(pLeftOutput, numOfRows, TSDB_DATA_TYPE_DOUBLE, pData, numOfRows, pRight->pSchema->type, output->data, TSDB_ORDER_ASC); - } else { - OperatorFn(pLeftOutput, numOfRows, TSDB_DATA_TYPE_DOUBLE, pInputData, numOfRows, pRight->pSchema->type, output->data, TSDB_ORDER_ASC); - } - output->numOfRows = numOfRows; - } else if (pRight->nodeType == TSQL_NODE_VALUE) { // exprLeft + 12 - _arithmetic_operator_fn_t OperatorFn = getArithmeticOperatorFn(pExpr->_node.optr); - OperatorFn(pLeftOutput, numOfRows, TSDB_DATA_TYPE_DOUBLE, &pRight->pVal->i64, 1, pRight->pVal->nType, output->data, TSDB_ORDER_ASC); - output->numOfRows = numOfRows; + + rightIn = rtmp; + rightType = right.type; + rightNum = right.numOfRows; + } else if (pRight->nodeType == TSQL_NODE_COL) { + char *pInputData = getSourceDataBlock(param, pRight->pSchema->name, pRight->pSchema->colId); + if (order == TSDB_ORDER_DESC && (pLeft->nodeType != TSQL_NODE_COL)) { + rtmp = malloc(sizeof(int64_t) * numOfRows); + reverseCopy(rtmp, pInputData, pRight->pSchema->type, numOfRows, pRight->pSchema->bytes); + rightIn = rtmp; + } else { + rightIn = pInputData; + fnOrder = order; } - } else if (pLeft->nodeType == TSQL_NODE_COL) { - // column data specified on left-hand-side - char *pLeftInputData = getSourceDataBlock(param, pLeft->pSchema->name, pLeft->pSchema->colId); - if (pRight->nodeType == TSQL_NODE_EXPR || pRight->nodeType == TSQL_NODE_FUNC) { // columnLeft + expr2 - _arithmetic_operator_fn_t OperatorFn = getArithmeticOperatorFn(pExpr->_node.optr); - - if (order == TSDB_ORDER_DESC) { - reverseCopy(pData, pLeftInputData, pLeft->pSchema->type, numOfRows); - OperatorFn(pData, numOfRows, pLeft->pSchema->type, pRightOutput, numOfRows, TSDB_DATA_TYPE_DOUBLE, output->data, TSDB_ORDER_ASC); - } else { - OperatorFn(pLeftInputData, numOfRows, pLeft->pSchema->type, pRightOutput, numOfRows, TSDB_DATA_TYPE_DOUBLE, output->data, TSDB_ORDER_ASC); - } - } else if (pRight->nodeType == TSQL_NODE_COL) { // columnLeft + columnRight - // column data specified on right-hand-side - char *pRightInputData = getSourceDataBlock(param, pRight->pSchema->name, pRight->pSchema->colId); - _arithmetic_operator_fn_t OperatorFn = getArithmeticOperatorFn(pExpr->_node.optr); - - // both columns are descending order, do not reverse the source data - OperatorFn(pLeftInputData, numOfRows, pLeft->pSchema->type, pRightInputData, numOfRows, pRight->pSchema->type, output->data, order); - } else if (pRight->nodeType == TSQL_NODE_VALUE) { // columnLeft + 12 - _arithmetic_operator_fn_t OperatorFn = getArithmeticOperatorFn(pExpr->_node.optr); - - if (order == TSDB_ORDER_DESC) { - reverseCopy(pData, pLeftInputData, pLeft->pSchema->type, numOfRows); - OperatorFn(pData, numOfRows, pLeft->pSchema->type, &pRight->pVal->i64, 1, pRight->pVal->nType, output->data, TSDB_ORDER_ASC); - } else { - OperatorFn(pLeftInputData, numOfRows, pLeft->pSchema->type, &pRight->pVal->i64, 1, pRight->pVal->nType, output->data, TSDB_ORDER_ASC); - } - } - output->numOfRows = numOfRows; + rightType = pRight->pSchema->type; + rightNum = numOfRows; } else { - // column data specified on left-hand-side - if (pRight->nodeType == TSQL_NODE_EXPR || pRight->nodeType == TSQL_NODE_FUNC) { // 12 + expr2 - _arithmetic_operator_fn_t OperatorFn = getArithmeticOperatorFn(pExpr->_node.optr); - OperatorFn(&pLeft->pVal->i64, 1, pLeft->pVal->nType, pRightOutput, numOfRows, TSDB_DATA_TYPE_DOUBLE, output->data, TSDB_ORDER_ASC); - output->numOfRows = right.numOfRows; - } else if (pRight->nodeType == TSQL_NODE_COL) { // 12 + columnRight - // column data specified on right-hand-side - char *pRightInputData = getSourceDataBlock(param, pRight->pSchema->name, pRight->pSchema->colId); - _arithmetic_operator_fn_t OperatorFn = getArithmeticOperatorFn(pExpr->_node.optr); - - if (order == TSDB_ORDER_DESC) { - reverseCopy(pData, pRightInputData, pRight->pSchema->type, numOfRows); - OperatorFn(&pLeft->pVal->i64, 1, pLeft->pVal->nType, pData, numOfRows, pRight->pSchema->type, output->data, TSDB_ORDER_ASC); - } else { - OperatorFn(&pLeft->pVal->i64, 1, pLeft->pVal->nType, pRightInputData, numOfRows, pRight->pSchema->type, output->data, TSDB_ORDER_ASC); - } - output->numOfRows = numOfRows; - } else if (pRight->nodeType == TSQL_NODE_VALUE) { // 12 + 12 - _arithmetic_operator_fn_t OperatorFn = getArithmeticOperatorFn(pExpr->_node.optr); - OperatorFn(&pLeft->pVal->i64, 1, pLeft->pVal->nType, &pRight->pVal->i64, 1, pRight->pVal->nType, output->data, TSDB_ORDER_ASC); - output->numOfRows = 1; - } + assert(pRight->nodeType == TSQL_NODE_VALUE); + rightIn = (char *)&pRight->pVal->i64; + rightType = pRight->pVal->nType; + rightNum = 1; } - tfree(pData); - tfree(pLeftOutput); - tfree(pRightOutput); + _arithmetic_operator_fn_t OperatorFn = getArithmeticOperatorFn(pExpr->_node.optr); + OperatorFn(leftIn, leftNum, leftType, rightIn, rightNum, rightType, output->data, fnOrder); + + output->numOfRows = MAX(leftNum, rightNum); + output->type = TSDB_DATA_TYPE_DOUBLE; + output->bytes = tDataTypes[output->type].bytes; + + tfree(ltmp); + tfree(rtmp); } static void exprTreeToBinaryImpl(SBufferWriter* bw, tExprNode* expr) { @@ -865,8 +857,11 @@ tExprNode* exprdup(tExprNode* pNode) { for (int i = 0; i < pNode->_func.numChildren; ++i) { pCloned->_func.pChildren[i] = exprdup(pNode->_func.pChildren[i]); } - } - + } else if (pNode->nodeType == TSQL_NODE_TYPE) { + pCloned->pType = calloc(1, sizeof(TAOS_FIELD)); + *pCloned->pType = *pNode->pType; + } + pCloned->nodeType = pNode->nodeType; pCloned->resultType = pNode->resultType; pCloned->resultBytes = pNode->resultBytes; @@ -1045,6 +1040,45 @@ int32_t exprValidateStringLengthNode(tExprNode *pExpr) { return TSDB_CODE_SUCCESS; } +int32_t exprValidateCastNode(char* msgbuf, tExprNode *pExpr) { + const char* msg1 = "invalid param num for cast function"; + const char* msg2 = "the second param should be a valid type name for cast function"; + const char* msg3 = "target type is not supported for cast function"; + const char* msg4 = "not supported type convertion for cast function"; + + if (pExpr->_func.numChildren != 2) { + return exprInvalidOperationMsg(msgbuf, msg1); + } + + tExprNode* child0 = pExpr->_func.pChildren[0]; + tExprNode* child1 = pExpr->_func.pChildren[1]; + + if (child1->nodeType != TSQL_NODE_TYPE) { + return exprInvalidOperationMsg(msgbuf, msg2); + } + + if (child1->resultType != TSDB_DATA_TYPE_BIGINT && child1->resultType != TSDB_DATA_TYPE_UBIGINT + && child1->resultType != TSDB_DATA_TYPE_TIMESTAMP && child1->resultType != TSDB_DATA_TYPE_BINARY + && child1->resultType != TSDB_DATA_TYPE_NCHAR) { + return exprInvalidOperationMsg(msgbuf, msg3); + } + + if ((child0->resultType == TSDB_DATA_TYPE_BINARY && child1->resultType == TSDB_DATA_TYPE_TIMESTAMP) + || (child0->resultType == TSDB_DATA_TYPE_TIMESTAMP && (child1->resultType == TSDB_DATA_TYPE_BINARY || child1->resultType == TSDB_DATA_TYPE_NCHAR)) + || (child0->resultType == TSDB_DATA_TYPE_NCHAR && (child1->resultType == TSDB_DATA_TYPE_BINARY || child1->resultType == TSDB_DATA_TYPE_TIMESTAMP))) { + return exprInvalidOperationMsg(msgbuf, msg4); + } + + pExpr->resultType = child1->resultType; + pExpr->resultBytes = child1->resultBytes; + + doExprTreeDestroy(&pExpr->_func.pChildren[1], NULL); + pExpr->_func.numChildren = 1; + + return TSDB_CODE_SUCCESS; +} + + int32_t exprValidateMathNode(tExprNode *pExpr) { switch (pExpr->_func.functionId) { case TSDB_FUNC_SCALAR_POW: @@ -1227,6 +1261,103 @@ void vectorLength(int16_t functionId, tExprOperandInfo *pInputs, int32_t numInpu } } +void castConvert(int16_t inputType, int16_t inputBytes, char *input, int16_t OutputType, int16_t outputBytes, char *output) { + switch (OutputType) { + case TSDB_DATA_TYPE_BIGINT: + if (inputType == TSDB_DATA_TYPE_BINARY) { + char *tmp = malloc(varDataLen(input) + 1); + memcpy(tmp, varDataVal(input), varDataLen(input)); + tmp[varDataLen(input)] = 0; + *(int64_t *)output = strtoll(tmp, NULL, 10); + free(tmp); + } else if (inputType == TSDB_DATA_TYPE_NCHAR) { + char *newColData = calloc(1, outputBytes * TSDB_NCHAR_SIZE + 1); + int len = taosUcs4ToMbs(varDataVal(input), varDataLen(input), newColData); + newColData[len] = 0; + *(int64_t *)output = strtoll(newColData, NULL, 10); + tfree(newColData); + } else { + GET_TYPED_DATA(*(int64_t *)output, int64_t, inputType, input); + } + break; + case TSDB_DATA_TYPE_UBIGINT: + if (inputType == TSDB_DATA_TYPE_BINARY) { + char *tmp = malloc(varDataLen(input) + 1); + memcpy(tmp, varDataVal(input), varDataLen(input)); + tmp[varDataLen(input)] = 0; + *(uint64_t *)output = strtoull(tmp, NULL, 10); + free(tmp); + } else if (inputType == TSDB_DATA_TYPE_NCHAR) { + char *newColData = calloc(1, outputBytes * TSDB_NCHAR_SIZE + 1); + int len = taosUcs4ToMbs(varDataVal(input), varDataLen(input), newColData); + newColData[len] = 0; + *(int64_t *)output = strtoull(newColData, NULL, 10); + tfree(newColData); + } else { + GET_TYPED_DATA(*(uint64_t *)output, uint64_t, inputType, input); + } + break; + case TSDB_DATA_TYPE_TIMESTAMP: + if (inputType == TSDB_DATA_TYPE_BINARY || inputType == TSDB_DATA_TYPE_NCHAR) { + assert(0); + } else { + GET_TYPED_DATA(*(int64_t *)output, int64_t, inputType, input); + } + break; + case TSDB_DATA_TYPE_BINARY: + if (inputType == TSDB_DATA_TYPE_BOOL) { + int32_t len = sprintf(varDataVal(output), "%.*s", (int32_t)(outputBytes - VARSTR_HEADER_SIZE), *(int8_t*)input ? "true" : "false"); + varDataSetLen(output, len); + } else if (inputType == TSDB_DATA_TYPE_BINARY) { + char *tmp = malloc(varDataLen(input) + 1); + memcpy(tmp, varDataVal(input), varDataLen(input)); + tmp[varDataLen(input)] = 0; + int32_t len = sprintf(varDataVal(output), "%.*s", (int32_t)(outputBytes - VARSTR_HEADER_SIZE), tmp); + varDataSetLen(output, len); + free(tmp); + } else if (inputType == TSDB_DATA_TYPE_TIMESTAMP || inputType == TSDB_DATA_TYPE_NCHAR) { + assert(0); + } else { + char tmp[400] = {0}; + NUM_TO_STRING(inputType, input, sizeof(tmp), tmp); + int32_t len = (int32_t)strlen(tmp); + len = (outputBytes - VARSTR_HEADER_SIZE) > len ? len : (outputBytes - VARSTR_HEADER_SIZE); + memcpy(varDataVal(output), tmp, len); + varDataSetLen(output, len); + } + break; + case TSDB_DATA_TYPE_NCHAR: { + int32_t ncharSize = (outputBytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE; + if (inputType == TSDB_DATA_TYPE_BOOL) { + char tmp[8] = {0}; + int32_t len = sprintf(tmp, "%.*s", ncharSize, *(int8_t*)input ? "true" : "false"); + taosMbsToUcs4(tmp, len, varDataVal(output), outputBytes - VARSTR_HEADER_SIZE, &len); + varDataSetLen(output, len); + } else if (inputType == TSDB_DATA_TYPE_BINARY) { + int32_t len = ncharSize > varDataLen(input) ? varDataLen(input) : ncharSize; + taosMbsToUcs4(input + VARSTR_HEADER_SIZE, len, varDataVal(output), outputBytes - VARSTR_HEADER_SIZE, &len); + varDataSetLen(output, len); + } else if (inputType == TSDB_DATA_TYPE_TIMESTAMP) { + assert(0); + } else if (inputType == TSDB_DATA_TYPE_NCHAR) { + int32_t len = (inputBytes > outputBytes) ? outputBytes : inputBytes; + memcpy(output, input, len); + varDataSetLen(output, len - VARSTR_HEADER_SIZE); + } else { + char tmp[400] = {0}; + NUM_TO_STRING(inputType, input, sizeof(tmp), tmp); + int32_t len = (int32_t)(ncharSize > strlen(tmp) ? strlen(tmp) : ncharSize); + taosMbsToUcs4(tmp, len, varDataVal(output), outputBytes - VARSTR_HEADER_SIZE, &len); + varDataSetLen(output, len); + } + break; + } + default: + assert(0); + break; + } +} + void vectorCharLength(int16_t functionId, tExprOperandInfo *pInputs, int32_t numInputs, tExprOperandInfo* pOutput, int32_t order) { assert(functionId == TSDB_FUNC_SCALAR_CHAR_LENGTH && numInputs == 1 && order == TSDB_ORDER_ASC); assert(IS_VAR_DATA_TYPE(pInputs[0].type)); @@ -1255,7 +1386,6 @@ void vectorCharLength(int16_t functionId, tExprOperandInfo *pInputs, int32_t num } void vectorMathFunc(int16_t functionId, tExprOperandInfo *pInputs, int32_t numInputs, tExprOperandInfo* pOutput, int32_t order) { - for (int i = 0; i < numInputs; ++i) { assert(pInputs[i].numOfRows == 1 || pInputs[i].numOfRows == pOutput->numOfRows); } @@ -1458,6 +1588,10 @@ void vectorMathFunc(int16_t functionId, tExprOperandInfo *pInputs, int32_t numIn } break; } + case TSDB_FUNC_SCALAR_CAST: { + castConvert(pInputs[0].type, pInputs[0].bytes, inputData[0], pOutput->type, pOutput->bytes, outputData); + break; + } default: { assert(false); break; @@ -1551,6 +1685,11 @@ tScalarFunctionInfo aScalarFunctions[] = { "length", vectorLength }, + { + TSDB_FUNC_SCALAR_CAST, + "cast", + vectorMathFunc + }, { TSDB_FUNC_SCALAR_CONCAT_WS, "concat_ws", diff --git a/src/inc/ttokendef.h b/src/inc/ttokendef.h index 1eb0a8bd60dee65ebe81ecf1e6523c5e2b767e91..d97bc943a9ade49f629dfce8e0b71860ab5905a6 100644 --- a/src/inc/ttokendef.h +++ b/src/inc/ttokendef.h @@ -218,6 +218,10 @@ + + + + #define TK_SPACE 300 #define TK_COMMENT 301 #define TK_ILLEGAL 302 diff --git a/src/inc/ttype.h b/src/inc/ttype.h index 095b593ab7d1fb74effd7991feeeb60f54cbc1b8..0ac382ca603263a7ae20e2029d3b9543126ccbdb 100644 --- a/src/inc/ttype.h +++ b/src/inc/ttype.h @@ -166,6 +166,42 @@ typedef struct { } \ } while (0) +#define NUM_TO_STRING(_inputType, _input, _outputBytes, _output) \ + do { \ + switch (_inputType) { \ + case TSDB_DATA_TYPE_TINYINT: \ + snprintf(_output, (int32_t)(_outputBytes), "%d", *(int8_t *)(_input)); \ + break; \ + case TSDB_DATA_TYPE_UTINYINT: \ + snprintf(_output, (int32_t)(_outputBytes), "%d", *(uint8_t *)(_input)); \ + break; \ + case TSDB_DATA_TYPE_SMALLINT: \ + snprintf(_output, (int32_t)(_outputBytes), "%d", *(int16_t *)(_input)); \ + break; \ + case TSDB_DATA_TYPE_USMALLINT: \ + snprintf(_output, (int32_t)(_outputBytes), "%d", *(uint16_t *)(_input)); \ + break; \ + case TSDB_DATA_TYPE_BIGINT: \ + snprintf(_output, (int32_t)(_outputBytes), "%" PRId64, *(int64_t *)(_input)); \ + break; \ + case TSDB_DATA_TYPE_UBIGINT: \ + snprintf(_output, (int32_t)(_outputBytes), "%" PRIu64, *(uint64_t *)(_input)); \ + break; \ + case TSDB_DATA_TYPE_FLOAT: \ + snprintf(_output, (int32_t)(_outputBytes), "%f", *(float *)(_input)); \ + break; \ + case TSDB_DATA_TYPE_DOUBLE: \ + snprintf(_output, (int32_t)(_outputBytes), "%f", *(double *)(_input)); \ + break; \ + case TSDB_DATA_TYPE_UINT: \ + snprintf(_output, (int32_t)(_outputBytes), "%u", *(uint32_t *)(_input)); \ + break; \ + default: \ + snprintf(_output, (int32_t)(_outputBytes), "%d", *(int32_t *)(_input)); \ + break; \ + } \ + } while (0) + #define IS_SIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_TINYINT && (_t) <= TSDB_DATA_TYPE_BIGINT) #define IS_UNSIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_UTINYINT && (_t) <= TSDB_DATA_TYPE_UBIGINT) #define IS_FLOAT_TYPE(_t) ((_t) == TSDB_DATA_TYPE_FLOAT || (_t) == TSDB_DATA_TYPE_DOUBLE) diff --git a/src/kit/shell/src/shellEngine.c b/src/kit/shell/src/shellEngine.c index e3e86e518690c8c4f773471b93bdb381a5bb8dc1..2f054cb913fd947af38c21476768c147681a22ab 100644 --- a/src/kit/shell/src/shellEngine.c +++ b/src/kit/shell/src/shellEngine.c @@ -645,7 +645,7 @@ static void shellPrintNChar(const char *str, int length, int width) { static void printField(const char* val, TAOS_FIELD* field, int width, int32_t length, int precision) { if (val == NULL) { int w = width; - if (field->type < TSDB_DATA_TYPE_TINYINT || field->type > TSDB_DATA_TYPE_DOUBLE) { + if (field->type == TSDB_DATA_TYPE_BINARY || field->type == TSDB_DATA_TYPE_NCHAR || field->type == TSDB_DATA_TYPE_TIMESTAMP) { w = 0; } w = printf("%*s", w, TSDB_DATA_NULL_STR); diff --git a/src/query/inc/qAggMain.h b/src/query/inc/qAggMain.h index a23a2a6d11a51e7639e7e138c5e533443b537130..217efffe2b539c7d1ad56704c9572ff1eb8227ff 100644 --- a/src/query/inc/qAggMain.h +++ b/src/query/inc/qAggMain.h @@ -251,7 +251,7 @@ void blockDistInfoToBinary(STableBlockDist* pDist, struct SBufferWriter* bw); void blockDistInfoFromBinary(const char* data, int32_t len, STableBlockDist* pDist); /* global sql function array */ -extern struct SAggFunctionInfo aAggs[]; +extern struct SAggFunctionInfo aAggs[40]; extern int32_t functionCompatList[]; // compatible check array list diff --git a/src/query/inc/qSqlparser.h b/src/query/inc/qSqlparser.h index 804c80780af8856559aa82a7e21456c97a79e882..142ebe31ad994ae8021f66dcd701658bc55a2e65 100644 --- a/src/query/inc/qSqlparser.h +++ b/src/query/inc/qSqlparser.h @@ -38,6 +38,7 @@ enum SQL_NODE_TYPE { SQL_NODE_SQLFUNCTION = 2, SQL_NODE_VALUE = 3, SQL_NODE_EXPR = 4, + SQL_NODE_DATA_TYPE = 5, }; enum SQL_NODE_FROM_TYPE { @@ -264,6 +265,7 @@ typedef struct tSqlExpr { int32_t functionId; // function id, todo remove it SStrToken columnName; // table column info + TAOS_FIELD dataType; // data type tVariant value; // the use input value SStrToken exprToken; // original sql expr string uint32_t flags; // todo remove it @@ -292,6 +294,7 @@ SRelationInfo *addSubqueryElem(SRelationInfo* pRelationInfo, SArray* pSub, SStrT tSqlExpr *tSqlExprCreateTimestamp(SStrToken *pToken, int32_t optrType); tSqlExpr *tSqlExprCreateIdValue(SSqlInfo* pInfo, SStrToken *pToken, int32_t optrType); tSqlExpr *tSqlExprCreateFunction(SArray *pParam, SStrToken *pFuncToken, SStrToken *endToken, int32_t optType); +tSqlExpr *tSqlExprCreateFuncWithParams(SSqlInfo *pInfo, tSqlExpr* col, TAOS_FIELD *colType, SStrToken *pFuncToken, SStrToken *endToken, int32_t optType); SArray *tStrTokenAppend(SArray *pList, SStrToken *pToken); tSqlExpr *tSqlExprCreate(tSqlExpr *pLeft, tSqlExpr *pRight, int32_t optrType); diff --git a/src/query/inc/sql.y b/src/query/inc/sql.y index e21e9e9baa2eac75a91cd2b576c736a49e2cc90c..6aa5ad7b9a48f638d8a3854bcb007c823bf7bd8a 100644 --- a/src/query/inc/sql.y +++ b/src/query/inc/sql.y @@ -733,6 +733,9 @@ expr(A) ::= ID(X) LP exprlist(Y) RP(E). { tStrTokenAppend(pInfo->funcs, &X); A = // for parsing sql functions with wildcard for parameters. e.g., count(*)/first(*)/last(*) operation expr(A) ::= ID(X) LP STAR RP(Y). { tStrTokenAppend(pInfo->funcs, &X); A = tSqlExprCreateFunction(NULL, &X, &Y, X.type); } +// for parsing sql function CAST(column as typename) +expr(A) ::= ID(X) LP expr(B) AS typename(C) RP(Y). { tStrTokenAppend(pInfo->funcs, &X); A = tSqlExprCreateFuncWithParams(pInfo, B, &C, &X, &Y, X.type); } + // is (not) null expression expr(A) ::= expr(X) IS NULL. {A = tSqlExprCreate(X, NULL, TK_ISNULL);} expr(A) ::= expr(X) IS NOT NULL. {A = tSqlExprCreate(X, NULL, TK_NOTNULL);} diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index a8ce33c0cee75bc59bc094b9fa768ed688b818f8..9fe775c40a7e66d2523c4deb02396953af307765 100644 --- a/src/query/src/qAggMain.c +++ b/src/query/src/qAggMain.c @@ -492,7 +492,7 @@ int32_t isValidFunction(const char* name, int32_t len) { } } - for(int32_t i = 0; i <= TSDB_FUNC_BLKINFO; ++i) { + for(int32_t i = 0; i <= tListLen(aAggs); ++i) { int32_t nameLen = (int32_t) strlen(aAggs[i].name); if (len != nameLen) { continue; @@ -4779,7 +4779,7 @@ int32_t functionCompatList[] = { 7 }; -SAggFunctionInfo aAggs[] = {{ +SAggFunctionInfo aAggs[40] = {{ // 0, count function does not invoke the finalize function "count", TSDB_FUNC_COUNT, @@ -5226,4 +5226,4 @@ SAggFunctionInfo aAggs[] = {{ block_func_merge, dataBlockRequired, }, -}; \ No newline at end of file +}; diff --git a/src/query/src/qSqlParser.c b/src/query/src/qSqlParser.c index 1f6de550cfe195b15aafe970dc900681939546e4..d388fc43e5b098e4dfd06b5a1e39877bbd6c6e87 100644 --- a/src/query/src/qSqlParser.c +++ b/src/query/src/qSqlParser.c @@ -178,6 +178,14 @@ tSqlExpr *tSqlExprCreateIdValue(SSqlInfo* pInfo, SStrToken *pToken, int32_t optr pSqlExpr->value.nType = TSDB_DATA_TYPE_BIGINT; pSqlExpr->tokenId = TK_TIMESTAMP; pSqlExpr->type = SQL_NODE_VALUE; + } else if (optrType == TK_AS) { + // Here it must be column type + if (pToken != NULL) { + pSqlExpr->dataType = *(TAOS_FIELD *)pToken; + } + + pSqlExpr->tokenId = optrType; + pSqlExpr->type = SQL_NODE_DATA_TYPE; } else { // Here it must be the column name (tk_id) if it is not a number or string. assert(optrType == TK_ID || optrType == TK_ALL); @@ -275,6 +283,25 @@ tSqlExpr *tSqlExprCreateFunction(SArray *pParam, SStrToken *pFuncToken, SStrToke return pExpr; } +tSqlExpr *tSqlExprCreateFuncWithParams(SSqlInfo *pInfo, tSqlExpr* col, TAOS_FIELD *colType, SStrToken *pFuncToken, SStrToken *endToken, int32_t optType) { + if (colType == NULL || col == NULL) { + return NULL; + } + + if (NULL == col) { + return NULL; + } + + tSqlExpr* ctype = tSqlExprCreateIdValue(pInfo, (SStrToken *)colType, TK_AS); + + SArray *exprList = tSqlExprListAppend(0,col,0, 0); + + tSqlExprListAppend(exprList,ctype,0, 0); + + return tSqlExprCreateFunction(exprList, pFuncToken, endToken, optType); +} + + /* * create binary expression in this procedure * if the expr is arithmetic, calculate the result and set it to tSqlExpr Object @@ -801,6 +828,10 @@ void tSetColumnType(TAOS_FIELD *pField, SStrToken *type) { pField->bytes = (int16_t)bytes; } + } else { + if (type->type > 0) { + pField->type = -1; + } } } diff --git a/src/query/src/sql.c b/src/query/src/sql.c index 3e56222723519064a3a2549712524af3ad7834c2..7be015626df1d448dc3645dbeebb2b4d280e041f 100644 --- a/src/query/src/sql.c +++ b/src/query/src/sql.c @@ -1,5 +1,3 @@ -/* This file is automatically generated by Lemon from input grammar -** source file "sql.y". */ /* ** 2000-05-29 ** @@ -24,7 +22,10 @@ ** The following is the concatenation of all %include directives from the ** input grammar file: */ +#include +#include /************ Begin %include sections from the grammar ************************/ + #include #include #include @@ -37,208 +38,11 @@ #include "tutil.h" #include "tvariant.h" /**************** End of %include directives **********************************/ -/* These constants specify the various numeric values for terminal symbols. -***************** Begin token definitions *************************************/ -#ifndef TK_ID -#define TK_ID 1 -#define TK_BOOL 2 -#define TK_TINYINT 3 -#define TK_SMALLINT 4 -#define TK_INTEGER 5 -#define TK_BIGINT 6 -#define TK_FLOAT 7 -#define TK_DOUBLE 8 -#define TK_STRING 9 -#define TK_TIMESTAMP 10 -#define TK_BINARY 11 -#define TK_NCHAR 12 -#define TK_OR 13 -#define TK_AND 14 -#define TK_NOT 15 -#define TK_EQ 16 -#define TK_NE 17 -#define TK_ISNULL 18 -#define TK_NOTNULL 19 -#define TK_IS 20 -#define TK_LIKE 21 -#define TK_MATCH 22 -#define TK_NMATCH 23 -#define TK_GLOB 24 -#define TK_BETWEEN 25 -#define TK_IN 26 -#define TK_GT 27 -#define TK_GE 28 -#define TK_LT 29 -#define TK_LE 30 -#define TK_BITAND 31 -#define TK_BITOR 32 -#define TK_LSHIFT 33 -#define TK_RSHIFT 34 -#define TK_PLUS 35 -#define TK_MINUS 36 -#define TK_DIVIDE 37 -#define TK_TIMES 38 -#define TK_STAR 39 -#define TK_SLASH 40 -#define TK_REM 41 -#define TK_UMINUS 42 -#define TK_UPLUS 43 -#define TK_BITNOT 44 -#define TK_SHOW 45 -#define TK_DATABASES 46 -#define TK_TOPICS 47 -#define TK_FUNCTIONS 48 -#define TK_MNODES 49 -#define TK_DNODES 50 -#define TK_ACCOUNTS 51 -#define TK_USERS 52 -#define TK_MODULES 53 -#define TK_QUERIES 54 -#define TK_CONNECTIONS 55 -#define TK_STREAMS 56 -#define TK_VARIABLES 57 -#define TK_SCORES 58 -#define TK_GRANTS 59 -#define TK_VNODES 60 -#define TK_DOT 61 -#define TK_CREATE 62 -#define TK_TABLE 63 -#define TK_STABLE 64 -#define TK_DATABASE 65 -#define TK_TABLES 66 -#define TK_STABLES 67 -#define TK_VGROUPS 68 -#define TK_DROP 69 -#define TK_TOPIC 70 -#define TK_FUNCTION 71 -#define TK_DNODE 72 -#define TK_USER 73 -#define TK_ACCOUNT 74 -#define TK_USE 75 -#define TK_DESCRIBE 76 -#define TK_DESC 77 -#define TK_ALTER 78 -#define TK_PASS 79 -#define TK_PRIVILEGE 80 -#define TK_LOCAL 81 -#define TK_COMPACT 82 -#define TK_LP 83 -#define TK_RP 84 -#define TK_IF 85 -#define TK_EXISTS 86 -#define TK_AS 87 -#define TK_OUTPUTTYPE 88 -#define TK_AGGREGATE 89 -#define TK_BUFSIZE 90 -#define TK_PPS 91 -#define TK_TSERIES 92 -#define TK_DBS 93 -#define TK_STORAGE 94 -#define TK_QTIME 95 -#define TK_CONNS 96 -#define TK_STATE 97 -#define TK_COMMA 98 -#define TK_KEEP 99 -#define TK_CACHE 100 -#define TK_REPLICA 101 -#define TK_QUORUM 102 -#define TK_DAYS 103 -#define TK_MINROWS 104 -#define TK_MAXROWS 105 -#define TK_BLOCKS 106 -#define TK_CTIME 107 -#define TK_WAL 108 -#define TK_FSYNC 109 -#define TK_COMP 110 -#define TK_PRECISION 111 -#define TK_UPDATE 112 -#define TK_CACHELAST 113 -#define TK_PARTITIONS 114 -#define TK_UNSIGNED 115 -#define TK_TAGS 116 -#define TK_USING 117 -#define TK_NULL 118 -#define TK_NOW 119 -#define TK_SELECT 120 -#define TK_UNION 121 -#define TK_ALL 122 -#define TK_DISTINCT 123 -#define TK_FROM 124 -#define TK_VARIABLE 125 -#define TK_RANGE 126 -#define TK_INTERVAL 127 -#define TK_EVERY 128 -#define TK_SESSION 129 -#define TK_STATE_WINDOW 130 -#define TK_FILL 131 -#define TK_SLIDING 132 -#define TK_ORDER 133 -#define TK_BY 134 -#define TK_ASC 135 -#define TK_GROUP 136 -#define TK_HAVING 137 -#define TK_LIMIT 138 -#define TK_OFFSET 139 -#define TK_SLIMIT 140 -#define TK_SOFFSET 141 -#define TK_WHERE 142 -#define TK_RESET 143 -#define TK_QUERY 144 -#define TK_SYNCDB 145 -#define TK_ADD 146 -#define TK_COLUMN 147 -#define TK_MODIFY 148 -#define TK_TAG 149 -#define TK_CHANGE 150 -#define TK_SET 151 -#define TK_KILL 152 -#define TK_CONNECTION 153 -#define TK_STREAM 154 -#define TK_COLON 155 -#define TK_ABORT 156 -#define TK_AFTER 157 -#define TK_ATTACH 158 -#define TK_BEFORE 159 -#define TK_BEGIN 160 -#define TK_CASCADE 161 -#define TK_CLUSTER 162 -#define TK_CONFLICT 163 -#define TK_COPY 164 -#define TK_DEFERRED 165 -#define TK_DELIMITERS 166 -#define TK_DETACH 167 -#define TK_EACH 168 -#define TK_END 169 -#define TK_EXPLAIN 170 -#define TK_FAIL 171 -#define TK_FOR 172 -#define TK_IGNORE 173 -#define TK_IMMEDIATE 174 -#define TK_INITIALLY 175 -#define TK_INSTEAD 176 -#define TK_KEY 177 -#define TK_OF 178 -#define TK_RAISE 179 -#define TK_REPLACE 180 -#define TK_RESTRICT 181 -#define TK_ROW 182 -#define TK_STATEMENT 183 -#define TK_TRIGGER 184 -#define TK_VIEW 185 -#define TK_IPTOKEN 186 -#define TK_SEMI 187 -#define TK_NONE 188 -#define TK_PREV 189 -#define TK_LINEAR 190 -#define TK_IMPORT 191 -#define TK_TBNAME 192 -#define TK_JOIN 193 -#define TK_INSERT 194 -#define TK_INTO 195 -#define TK_VALUES 196 -#define TK_FILE 197 -#endif -/**************** End token definitions ***************************************/ +/* These constants specify the various numeric values for terminal symbols +** in a format understandable to "makeheaders". This section is blank unless +** "lemon" is run with the "-m" command-line option. +***************** Begin makeheaders token definitions *************************/ +/**************** End makeheaders token definitions ***************************/ /* The next sections is a series of control #defines. ** various aspects of the generated parser. @@ -335,18 +139,18 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 378 -#define YYNRULE 302 -#define YYNRULE_WITH_ACTION 302 +#define YYNSTATE 381 +#define YYNRULE 303 +#define YYNRULE_WITH_ACTION 303 #define YYNTOKEN 198 -#define YY_MAX_SHIFT 377 -#define YY_MIN_SHIFTREDUCE 593 -#define YY_MAX_SHIFTREDUCE 894 -#define YY_ERROR_ACTION 895 -#define YY_ACCEPT_ACTION 896 -#define YY_NO_ACTION 897 -#define YY_MIN_REDUCE 898 -#define YY_MAX_REDUCE 1199 +#define YY_MAX_SHIFT 380 +#define YY_MIN_SHIFTREDUCE 597 +#define YY_MAX_SHIFTREDUCE 899 +#define YY_ERROR_ACTION 900 +#define YY_ACCEPT_ACTION 901 +#define YY_NO_ACTION 902 +#define YY_MIN_REDUCE 903 +#define YY_MAX_REDUCE 1205 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -413,171 +217,174 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (790) +#define YY_ACTTAB_COUNT (813) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 165, 644, 23, 1075, 376, 237, 213, 165, 1039, 645, - /* 10 */ 83, 896, 377, 59, 60, 244, 63, 64, 1175, 1053, - /* 20 */ 258, 53, 52, 51, 644, 62, 334, 67, 65, 68, - /* 30 */ 66, 158, 645, 250, 252, 58, 57, 1053, 1053, 56, - /* 40 */ 55, 54, 59, 60, 1038, 63, 64, 174, 768, 258, - /* 50 */ 53, 52, 51, 680, 62, 334, 67, 65, 68, 66, - /* 60 */ 1023, 1066, 1021, 1022, 58, 57, 296, 1024, 56, 55, - /* 70 */ 54, 1025, 1072, 1026, 1027, 58, 57, 1122, 280, 56, - /* 80 */ 55, 54, 59, 60, 96, 63, 64, 84, 97, 258, - /* 90 */ 53, 52, 51, 332, 62, 334, 67, 65, 68, 66, - /* 100 */ 1066, 287, 286, 85, 58, 57, 29, 332, 56, 55, - /* 110 */ 54, 59, 61, 831, 63, 64, 765, 240, 258, 53, - /* 120 */ 52, 51, 644, 62, 334, 67, 65, 68, 66, 813, - /* 130 */ 645, 728, 772, 58, 57, 644, 127, 56, 55, 54, - /* 140 */ 63, 64, 9, 645, 258, 53, 52, 51, 364, 62, - /* 150 */ 334, 67, 65, 68, 66, 56, 55, 54, 364, 58, - /* 160 */ 57, 354, 353, 56, 55, 54, 99, 594, 595, 596, - /* 170 */ 597, 598, 599, 600, 601, 602, 603, 604, 605, 606, - /* 180 */ 607, 156, 60, 238, 63, 64, 255, 812, 258, 53, - /* 190 */ 52, 51, 254, 62, 334, 67, 65, 68, 66, 1036, - /* 200 */ 1037, 35, 1040, 58, 57, 102, 90, 56, 55, 54, - /* 210 */ 44, 330, 371, 370, 329, 328, 327, 369, 326, 325, - /* 220 */ 324, 368, 323, 367, 366, 24, 1015, 1003, 1004, 1005, - /* 230 */ 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1016, - /* 240 */ 1017, 1041, 216, 45, 257, 846, 1047, 213, 835, 224, - /* 250 */ 838, 259, 841, 213, 210, 141, 140, 139, 223, 1176, - /* 260 */ 257, 846, 339, 90, 835, 1176, 838, 211, 841, 796, - /* 270 */ 797, 38, 67, 65, 68, 66, 165, 256, 235, 236, - /* 280 */ 58, 57, 335, 217, 56, 55, 54, 14, 784, 218, - /* 290 */ 261, 98, 787, 251, 235, 236, 5, 41, 184, 6, - /* 300 */ 45, 219, 165, 183, 108, 113, 104, 112, 266, 837, - /* 310 */ 752, 840, 213, 749, 1052, 750, 239, 751, 292, 293, - /* 320 */ 1050, 101, 319, 279, 1176, 82, 69, 125, 119, 130, - /* 330 */ 1170, 38, 231, 836, 129, 839, 135, 138, 128, 204, - /* 340 */ 202, 200, 69, 263, 264, 132, 199, 145, 144, 143, - /* 350 */ 142, 308, 44, 95, 371, 370, 155, 153, 152, 369, - /* 360 */ 38, 847, 842, 368, 38, 367, 366, 262, 843, 260, - /* 370 */ 38, 342, 341, 38, 1169, 38, 248, 847, 842, 1123, - /* 380 */ 1050, 306, 1168, 38, 843, 268, 38, 265, 233, 349, - /* 390 */ 348, 38, 38, 38, 272, 375, 374, 621, 234, 1066, - /* 400 */ 267, 267, 242, 276, 275, 249, 267, 372, 984, 1050, - /* 410 */ 87, 180, 181, 1049, 946, 343, 241, 1051, 344, 1050, - /* 420 */ 345, 194, 1050, 956, 1050, 281, 753, 754, 346, 844, - /* 430 */ 194, 350, 1050, 1, 182, 1050, 351, 352, 356, 39, - /* 440 */ 1050, 1050, 1050, 947, 3, 195, 88, 283, 291, 290, - /* 450 */ 194, 793, 803, 845, 804, 75, 78, 738, 311, 336, - /* 460 */ 740, 313, 739, 34, 833, 160, 70, 16, 26, 15, - /* 470 */ 869, 39, 39, 81, 70, 100, 70, 848, 643, 118, - /* 480 */ 18, 117, 17, 283, 25, 757, 755, 758, 756, 137, - /* 490 */ 136, 25, 25, 20, 214, 19, 314, 79, 76, 124, - /* 500 */ 215, 123, 834, 220, 212, 727, 22, 1195, 21, 221, - /* 510 */ 222, 1187, 226, 1133, 227, 228, 225, 209, 1132, 246, - /* 520 */ 1129, 1128, 247, 277, 288, 289, 355, 157, 154, 48, - /* 530 */ 1074, 1085, 1067, 284, 1082, 1083, 1087, 159, 164, 302, - /* 540 */ 176, 1115, 1048, 1114, 177, 1046, 295, 178, 179, 961, - /* 550 */ 316, 317, 783, 318, 321, 322, 46, 170, 168, 243, - /* 560 */ 207, 42, 850, 333, 955, 340, 1194, 297, 299, 115, - /* 570 */ 80, 1193, 1190, 1064, 77, 185, 166, 167, 309, 347, - /* 580 */ 50, 1186, 121, 1185, 1182, 186, 307, 981, 43, 40, - /* 590 */ 305, 47, 208, 298, 303, 943, 131, 941, 133, 134, - /* 600 */ 939, 938, 269, 197, 198, 935, 934, 933, 932, 931, - /* 610 */ 49, 930, 929, 301, 201, 203, 925, 923, 921, 205, - /* 620 */ 918, 206, 914, 294, 320, 282, 86, 91, 300, 365, - /* 630 */ 1116, 358, 126, 357, 359, 360, 361, 232, 253, 362, - /* 640 */ 315, 363, 373, 894, 270, 271, 893, 273, 274, 892, - /* 650 */ 229, 230, 960, 959, 109, 110, 875, 278, 874, 283, - /* 660 */ 310, 10, 285, 92, 937, 89, 760, 30, 936, 189, - /* 670 */ 792, 188, 982, 187, 190, 192, 191, 146, 147, 193, - /* 680 */ 983, 1019, 148, 73, 928, 927, 2, 173, 171, 169, - /* 690 */ 172, 33, 175, 149, 1029, 920, 919, 790, 789, 4, - /* 700 */ 786, 785, 74, 163, 794, 161, 245, 805, 162, 31, - /* 710 */ 799, 93, 32, 801, 94, 304, 13, 11, 27, 312, - /* 720 */ 28, 12, 36, 101, 103, 106, 105, 658, 693, 691, - /* 730 */ 37, 690, 689, 107, 687, 686, 685, 682, 648, 111, - /* 740 */ 331, 7, 851, 849, 8, 338, 337, 114, 116, 71, - /* 750 */ 72, 39, 730, 120, 729, 726, 122, 674, 672, 664, - /* 760 */ 670, 666, 668, 662, 660, 696, 695, 694, 692, 688, - /* 770 */ 684, 683, 196, 646, 611, 898, 897, 897, 897, 897, - /* 780 */ 897, 897, 897, 897, 897, 897, 897, 897, 150, 151, + /* 0 */ 166, 648, 23, 1080, 379, 239, 214, 732, 1044, 649, + /* 10 */ 684, 901, 380, 60, 61, 246, 64, 65, 1181, 1058, + /* 20 */ 260, 54, 53, 52, 648, 63, 336, 68, 66, 69, + /* 30 */ 67, 159, 649, 375, 989, 59, 58, 357, 356, 57, + /* 40 */ 56, 55, 60, 61, 252, 64, 65, 175, 1058, 260, + /* 50 */ 54, 53, 52, 166, 63, 336, 68, 66, 69, 67, + /* 60 */ 1028, 1071, 1026, 1027, 59, 58, 298, 1029, 57, 56, + /* 70 */ 55, 1030, 1077, 1031, 1032, 59, 58, 1127, 282, 57, + /* 80 */ 56, 55, 60, 61, 254, 64, 65, 85, 1058, 260, + /* 90 */ 54, 53, 52, 334, 63, 336, 68, 66, 69, 67, + /* 100 */ 951, 289, 288, 166, 59, 58, 257, 195, 57, 56, + /* 110 */ 55, 60, 61, 14, 64, 65, 38, 99, 260, 54, + /* 120 */ 53, 52, 769, 63, 336, 68, 66, 69, 67, 128, + /* 130 */ 1128, 788, 308, 59, 58, 791, 648, 57, 56, 55, + /* 140 */ 100, 367, 60, 62, 649, 64, 65, 102, 9, 260, + /* 150 */ 54, 53, 52, 835, 63, 336, 68, 66, 69, 67, + /* 160 */ 1071, 294, 295, 91, 59, 58, 256, 210, 57, 56, + /* 170 */ 55, 39, 334, 1041, 1042, 35, 1045, 242, 310, 1182, + /* 180 */ 96, 598, 599, 600, 601, 602, 603, 604, 605, 606, + /* 190 */ 607, 608, 609, 610, 611, 157, 61, 240, 64, 65, + /* 200 */ 46, 367, 260, 54, 53, 52, 648, 63, 336, 68, + /* 210 */ 66, 69, 67, 263, 649, 269, 241, 59, 58, 166, + /* 220 */ 1055, 57, 56, 55, 64, 65, 181, 214, 260, 54, + /* 230 */ 53, 52, 274, 63, 336, 68, 66, 69, 67, 1182, + /* 240 */ 817, 278, 277, 59, 58, 244, 1052, 57, 56, 55, + /* 250 */ 45, 332, 374, 373, 331, 330, 329, 372, 328, 327, + /* 260 */ 326, 371, 325, 370, 369, 1020, 1008, 1009, 1010, 1011, + /* 270 */ 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1021, 1022, + /* 280 */ 24, 259, 850, 39, 261, 839, 212, 842, 29, 845, + /* 290 */ 264, 1071, 262, 253, 345, 344, 97, 218, 816, 259, + /* 300 */ 850, 800, 801, 839, 226, 842, 34, 845, 243, 1057, + /* 310 */ 142, 141, 140, 225, 1201, 237, 238, 342, 91, 338, + /* 320 */ 5, 42, 185, 103, 57, 56, 55, 184, 109, 114, + /* 330 */ 105, 113, 1054, 237, 238, 68, 66, 69, 67, 316, + /* 340 */ 841, 39, 844, 59, 58, 214, 321, 57, 56, 55, + /* 350 */ 268, 756, 1, 183, 753, 46, 754, 1182, 755, 1046, + /* 360 */ 840, 269, 843, 70, 126, 120, 131, 156, 154, 153, + /* 370 */ 39, 130, 182, 136, 139, 129, 3, 196, 281, 339, + /* 380 */ 83, 70, 133, 1193, 265, 266, 250, 233, 39, 39, + /* 390 */ 1055, 39, 84, 205, 203, 201, 39, 39, 851, 846, + /* 400 */ 200, 146, 145, 144, 143, 847, 39, 39, 772, 39, + /* 410 */ 269, 45, 79, 374, 373, 251, 851, 846, 372, 1055, + /* 420 */ 98, 337, 371, 847, 370, 369, 1043, 270, 269, 267, + /* 430 */ 283, 352, 351, 346, 347, 86, 348, 1055, 1055, 1056, + /* 440 */ 1055, 349, 353, 961, 40, 1055, 1055, 378, 377, 625, + /* 450 */ 195, 354, 355, 80, 359, 1055, 1055, 952, 1055, 88, + /* 460 */ 848, 89, 293, 292, 195, 76, 837, 757, 758, 797, + /* 470 */ 807, 808, 742, 313, 744, 315, 743, 874, 258, 852, + /* 480 */ 849, 647, 855, 161, 71, 26, 40, 40, 71, 101, + /* 490 */ 71, 25, 776, 25, 82, 25, 285, 16, 285, 15, + /* 500 */ 6, 119, 213, 118, 838, 18, 219, 17, 77, 761, + /* 510 */ 759, 762, 760, 20, 220, 19, 221, 125, 22, 124, + /* 520 */ 21, 138, 137, 1176, 1175, 290, 731, 1174, 235, 236, + /* 530 */ 216, 217, 222, 215, 223, 224, 228, 229, 230, 227, + /* 540 */ 211, 279, 1138, 1137, 158, 248, 291, 1134, 1079, 1133, + /* 550 */ 249, 358, 1090, 49, 1072, 1120, 1087, 1088, 155, 1092, + /* 560 */ 160, 286, 165, 304, 1053, 1119, 297, 177, 178, 245, + /* 570 */ 322, 299, 1051, 179, 180, 787, 966, 172, 318, 319, + /* 580 */ 320, 167, 323, 324, 47, 1069, 168, 311, 169, 301, + /* 590 */ 307, 81, 170, 51, 208, 78, 43, 309, 335, 960, + /* 600 */ 343, 1200, 116, 1199, 1196, 186, 350, 1192, 122, 1191, + /* 610 */ 1188, 305, 187, 986, 44, 41, 48, 303, 209, 948, + /* 620 */ 132, 946, 134, 135, 944, 943, 271, 300, 198, 199, + /* 630 */ 940, 939, 938, 937, 936, 935, 934, 202, 204, 930, + /* 640 */ 928, 926, 296, 206, 923, 207, 919, 368, 50, 284, + /* 650 */ 87, 92, 127, 302, 1121, 360, 361, 362, 363, 364, + /* 660 */ 365, 366, 376, 899, 273, 234, 272, 898, 255, 317, + /* 670 */ 276, 897, 275, 880, 231, 232, 879, 285, 280, 110, + /* 680 */ 965, 964, 111, 312, 10, 287, 764, 90, 942, 941, + /* 690 */ 30, 93, 933, 190, 147, 189, 987, 188, 932, 192, + /* 700 */ 191, 193, 988, 194, 148, 149, 150, 2, 796, 1024, + /* 710 */ 925, 924, 74, 794, 33, 173, 171, 176, 174, 4, + /* 720 */ 793, 790, 789, 75, 1034, 798, 162, 164, 809, 163, + /* 730 */ 247, 803, 94, 31, 805, 95, 306, 32, 13, 11, + /* 740 */ 12, 314, 104, 27, 28, 102, 107, 662, 697, 695, + /* 750 */ 694, 693, 36, 691, 106, 690, 37, 108, 689, 686, + /* 760 */ 652, 112, 333, 7, 340, 854, 856, 853, 8, 341, + /* 770 */ 115, 72, 117, 73, 40, 121, 123, 734, 733, 730, + /* 780 */ 678, 676, 668, 674, 670, 672, 666, 664, 700, 699, + /* 790 */ 698, 696, 692, 688, 687, 197, 650, 615, 903, 902, + /* 800 */ 902, 902, 902, 902, 902, 902, 902, 902, 902, 902, + /* 810 */ 902, 151, 152, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 200, 1, 268, 200, 200, 201, 268, 200, 0, 9, - /* 10 */ 208, 198, 199, 13, 14, 246, 16, 17, 280, 250, + /* 0 */ 200, 1, 268, 200, 200, 201, 268, 5, 0, 9, + /* 10 */ 5, 198, 199, 13, 14, 246, 16, 17, 280, 250, /* 20 */ 20, 21, 22, 23, 1, 25, 26, 27, 28, 29, - /* 30 */ 30, 200, 9, 246, 246, 35, 36, 250, 250, 39, - /* 40 */ 40, 41, 13, 14, 242, 16, 17, 255, 39, 20, - /* 50 */ 21, 22, 23, 5, 25, 26, 27, 28, 29, 30, + /* 30 */ 30, 200, 9, 222, 223, 35, 36, 35, 36, 39, + /* 40 */ 40, 41, 13, 14, 246, 16, 17, 255, 250, 20, + /* 50 */ 21, 22, 23, 200, 25, 26, 27, 28, 29, 30, /* 60 */ 224, 248, 226, 227, 35, 36, 274, 231, 39, 40, /* 70 */ 41, 235, 269, 237, 238, 35, 36, 277, 265, 39, - /* 80 */ 40, 41, 13, 14, 277, 16, 17, 87, 251, 20, + /* 80 */ 40, 41, 13, 14, 246, 16, 17, 87, 250, 20, /* 90 */ 21, 22, 23, 85, 25, 26, 27, 28, 29, 30, - /* 100 */ 248, 270, 271, 266, 35, 36, 83, 85, 39, 40, - /* 110 */ 41, 13, 14, 84, 16, 17, 98, 265, 20, 21, - /* 120 */ 22, 23, 1, 25, 26, 27, 28, 29, 30, 77, - /* 130 */ 9, 5, 123, 35, 36, 1, 79, 39, 40, 41, - /* 140 */ 16, 17, 124, 9, 20, 21, 22, 23, 91, 25, - /* 150 */ 26, 27, 28, 29, 30, 39, 40, 41, 91, 35, - /* 160 */ 36, 35, 36, 39, 40, 41, 208, 46, 47, 48, - /* 170 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, - /* 180 */ 59, 60, 14, 62, 16, 17, 207, 135, 20, 21, - /* 190 */ 22, 23, 207, 25, 26, 27, 28, 29, 30, 241, - /* 200 */ 242, 243, 244, 35, 36, 208, 83, 39, 40, 41, - /* 210 */ 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, - /* 220 */ 109, 110, 111, 112, 113, 45, 224, 225, 226, 227, - /* 230 */ 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, - /* 240 */ 238, 244, 62, 120, 1, 2, 200, 268, 5, 69, - /* 250 */ 7, 207, 9, 268, 268, 75, 76, 77, 78, 280, - /* 260 */ 1, 2, 82, 83, 5, 280, 7, 268, 9, 127, - /* 270 */ 128, 200, 27, 28, 29, 30, 200, 61, 35, 36, - /* 280 */ 35, 36, 39, 268, 39, 40, 41, 83, 5, 268, - /* 290 */ 69, 87, 9, 247, 35, 36, 63, 64, 65, 83, - /* 300 */ 120, 268, 200, 70, 71, 72, 73, 74, 69, 5, - /* 310 */ 2, 7, 268, 5, 250, 7, 245, 9, 35, 36, - /* 320 */ 249, 117, 89, 143, 280, 145, 83, 63, 64, 65, - /* 330 */ 268, 200, 152, 5, 70, 7, 72, 73, 74, 63, - /* 340 */ 64, 65, 83, 35, 36, 81, 70, 71, 72, 73, - /* 350 */ 74, 275, 99, 277, 101, 102, 63, 64, 65, 106, - /* 360 */ 200, 118, 119, 110, 200, 112, 113, 146, 125, 148, - /* 370 */ 200, 150, 151, 200, 268, 200, 245, 118, 119, 277, - /* 380 */ 249, 279, 268, 200, 125, 146, 200, 148, 268, 150, - /* 390 */ 151, 200, 200, 200, 144, 66, 67, 68, 268, 248, - /* 400 */ 200, 200, 119, 153, 154, 245, 200, 222, 223, 249, - /* 410 */ 84, 211, 211, 249, 206, 245, 265, 211, 245, 249, - /* 420 */ 245, 213, 249, 206, 249, 84, 118, 119, 245, 125, - /* 430 */ 213, 245, 249, 209, 210, 249, 245, 245, 245, 98, - /* 440 */ 249, 249, 249, 206, 204, 205, 84, 121, 35, 36, - /* 450 */ 213, 84, 84, 125, 84, 98, 98, 84, 84, 15, - /* 460 */ 84, 84, 84, 83, 1, 98, 98, 147, 98, 149, - /* 470 */ 84, 98, 98, 83, 98, 98, 98, 84, 84, 147, - /* 480 */ 147, 149, 149, 121, 98, 5, 5, 7, 7, 79, - /* 490 */ 80, 98, 98, 147, 268, 149, 116, 139, 141, 147, - /* 500 */ 268, 149, 39, 268, 268, 115, 147, 250, 149, 268, - /* 510 */ 268, 250, 268, 240, 268, 268, 268, 268, 240, 240, - /* 520 */ 240, 240, 240, 200, 273, 273, 240, 200, 61, 267, - /* 530 */ 200, 200, 248, 248, 200, 200, 200, 200, 200, 200, - /* 540 */ 252, 278, 248, 278, 200, 200, 272, 200, 200, 200, - /* 550 */ 200, 200, 125, 200, 200, 200, 200, 259, 261, 272, - /* 560 */ 200, 200, 118, 200, 200, 200, 200, 272, 272, 200, - /* 570 */ 138, 200, 200, 264, 140, 200, 263, 262, 133, 200, - /* 580 */ 137, 200, 200, 200, 200, 200, 136, 200, 200, 200, - /* 590 */ 131, 200, 200, 132, 130, 200, 200, 200, 200, 200, + /* 100 */ 206, 270, 271, 200, 35, 36, 207, 213, 39, 40, + /* 110 */ 41, 13, 14, 83, 16, 17, 87, 87, 20, 21, + /* 120 */ 22, 23, 98, 25, 26, 27, 28, 29, 30, 79, + /* 130 */ 277, 5, 279, 35, 36, 9, 1, 39, 40, 41, + /* 140 */ 208, 91, 13, 14, 9, 16, 17, 117, 124, 20, + /* 150 */ 21, 22, 23, 84, 25, 26, 27, 28, 29, 30, + /* 160 */ 248, 35, 36, 83, 35, 36, 207, 268, 39, 40, + /* 170 */ 41, 200, 85, 241, 242, 243, 244, 265, 275, 280, + /* 180 */ 277, 46, 47, 48, 49, 50, 51, 52, 53, 54, + /* 190 */ 55, 56, 57, 58, 59, 60, 14, 62, 16, 17, + /* 200 */ 120, 91, 20, 21, 22, 23, 1, 25, 26, 27, + /* 210 */ 28, 29, 30, 69, 9, 200, 245, 35, 36, 200, + /* 220 */ 249, 39, 40, 41, 16, 17, 211, 268, 20, 21, + /* 230 */ 22, 23, 144, 25, 26, 27, 28, 29, 30, 280, + /* 240 */ 77, 153, 154, 35, 36, 119, 200, 39, 40, 41, + /* 250 */ 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, + /* 260 */ 109, 110, 111, 112, 113, 224, 225, 226, 227, 228, + /* 270 */ 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, + /* 280 */ 45, 1, 2, 200, 207, 5, 268, 7, 83, 9, + /* 290 */ 146, 248, 148, 247, 150, 151, 277, 62, 135, 1, + /* 300 */ 2, 127, 128, 5, 69, 7, 83, 9, 265, 250, + /* 310 */ 75, 76, 77, 78, 250, 35, 36, 82, 83, 39, + /* 320 */ 63, 64, 65, 208, 39, 40, 41, 70, 71, 72, + /* 330 */ 73, 74, 249, 35, 36, 27, 28, 29, 30, 116, + /* 340 */ 5, 200, 7, 35, 36, 268, 89, 39, 40, 41, + /* 350 */ 69, 2, 209, 210, 5, 120, 7, 280, 9, 244, + /* 360 */ 5, 200, 7, 83, 63, 64, 65, 63, 64, 65, + /* 370 */ 200, 70, 211, 72, 73, 74, 204, 205, 143, 15, + /* 380 */ 145, 83, 81, 250, 35, 36, 245, 152, 200, 200, + /* 390 */ 249, 200, 208, 63, 64, 65, 200, 200, 118, 119, + /* 400 */ 70, 71, 72, 73, 74, 125, 200, 200, 39, 200, + /* 410 */ 200, 99, 98, 101, 102, 245, 118, 119, 106, 249, + /* 420 */ 251, 211, 110, 125, 112, 113, 242, 146, 200, 148, + /* 430 */ 84, 150, 151, 245, 245, 266, 245, 249, 249, 211, + /* 440 */ 249, 245, 245, 206, 98, 249, 249, 66, 67, 68, + /* 450 */ 213, 245, 245, 139, 245, 249, 249, 206, 249, 84, + /* 460 */ 125, 84, 35, 36, 213, 98, 1, 118, 119, 84, + /* 470 */ 84, 84, 84, 84, 84, 84, 84, 84, 61, 84, + /* 480 */ 125, 84, 118, 98, 98, 98, 98, 98, 98, 98, + /* 490 */ 98, 98, 123, 98, 83, 98, 121, 147, 121, 149, + /* 500 */ 83, 147, 268, 149, 39, 147, 268, 149, 141, 5, + /* 510 */ 5, 7, 7, 147, 268, 149, 268, 147, 147, 149, + /* 520 */ 149, 79, 80, 268, 268, 273, 115, 268, 268, 268, + /* 530 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 540 */ 268, 200, 240, 240, 200, 240, 273, 240, 200, 240, + /* 550 */ 240, 240, 200, 267, 248, 278, 200, 200, 61, 200, + /* 560 */ 200, 248, 200, 200, 248, 278, 272, 252, 200, 272, + /* 570 */ 90, 272, 200, 200, 200, 125, 200, 258, 200, 200, + /* 580 */ 200, 263, 200, 200, 200, 264, 262, 133, 261, 272, + /* 590 */ 131, 138, 260, 137, 200, 140, 200, 136, 200, 200, /* 600 */ 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, - /* 610 */ 142, 200, 200, 129, 200, 200, 200, 200, 200, 200, - /* 620 */ 200, 200, 200, 126, 90, 202, 202, 202, 202, 114, - /* 630 */ 202, 52, 97, 96, 93, 95, 56, 202, 202, 94, - /* 640 */ 202, 92, 85, 5, 155, 5, 5, 155, 5, 5, - /* 650 */ 202, 202, 212, 212, 208, 208, 101, 144, 100, 121, - /* 660 */ 116, 83, 98, 98, 202, 122, 84, 83, 202, 215, - /* 670 */ 84, 219, 221, 220, 218, 217, 216, 203, 203, 214, - /* 680 */ 223, 239, 203, 98, 202, 202, 209, 256, 258, 260, - /* 690 */ 257, 254, 253, 203, 239, 202, 202, 125, 125, 204, - /* 700 */ 5, 5, 83, 98, 84, 83, 1, 84, 83, 98, - /* 710 */ 84, 83, 98, 84, 83, 83, 83, 134, 83, 116, - /* 720 */ 83, 134, 88, 117, 79, 71, 87, 5, 9, 5, - /* 730 */ 88, 5, 5, 87, 5, 5, 5, 5, 86, 79, - /* 740 */ 15, 83, 118, 84, 83, 60, 26, 149, 149, 16, - /* 750 */ 16, 98, 5, 149, 5, 84, 149, 5, 5, 5, - /* 760 */ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - /* 770 */ 5, 5, 98, 86, 61, 0, 281, 281, 281, 281, - /* 780 */ 281, 281, 281, 281, 281, 281, 281, 281, 21, 21, - /* 790 */ 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, + /* 610 */ 200, 130, 200, 200, 200, 200, 200, 129, 200, 200, + /* 620 */ 200, 200, 200, 200, 200, 200, 200, 132, 200, 200, + /* 630 */ 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, + /* 640 */ 200, 200, 126, 200, 200, 200, 200, 114, 142, 202, + /* 650 */ 202, 202, 97, 202, 202, 96, 52, 93, 95, 56, + /* 660 */ 94, 92, 85, 5, 5, 202, 155, 5, 202, 202, + /* 670 */ 5, 5, 155, 101, 202, 202, 100, 121, 144, 208, + /* 680 */ 212, 212, 208, 116, 83, 98, 84, 122, 202, 202, + /* 690 */ 83, 98, 202, 215, 203, 219, 221, 220, 202, 216, + /* 700 */ 218, 217, 223, 214, 203, 203, 203, 209, 84, 239, + /* 710 */ 202, 202, 98, 125, 254, 257, 259, 253, 256, 204, + /* 720 */ 125, 5, 5, 83, 239, 84, 83, 98, 84, 83, + /* 730 */ 1, 84, 83, 98, 84, 83, 83, 98, 83, 134, + /* 740 */ 134, 116, 79, 83, 83, 117, 71, 5, 9, 5, + /* 750 */ 5, 5, 88, 5, 87, 5, 88, 87, 5, 5, + /* 760 */ 86, 79, 15, 83, 26, 84, 118, 84, 83, 60, + /* 770 */ 149, 16, 149, 16, 98, 149, 149, 5, 5, 84, + /* 780 */ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + /* 790 */ 5, 5, 5, 5, 5, 98, 86, 61, 0, 281, /* 800 */ 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, - /* 810 */ 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, + /* 810 */ 281, 21, 21, 281, 281, 281, 281, 281, 281, 281, /* 820 */ 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, /* 830 */ 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, /* 840 */ 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, @@ -594,116 +401,121 @@ static const YYCODETYPE yy_lookahead[] = { /* 950 */ 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, /* 960 */ 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, /* 970 */ 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, - /* 980 */ 281, 281, 281, 281, 281, 281, 281, 281, + /* 980 */ 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, + /* 990 */ 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, + /* 1000 */ 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, + /* 1010 */ 281, }; -#define YY_SHIFT_COUNT (377) +#define YY_SHIFT_COUNT (380) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (775) +#define YY_SHIFT_MAX (798) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 180, 111, 111, 253, 253, 22, 243, 259, 259, 23, - /* 10 */ 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, - /* 20 */ 134, 134, 134, 0, 121, 259, 308, 308, 308, 123, - /* 30 */ 123, 134, 134, 142, 134, 8, 134, 134, 134, 134, - /* 40 */ 57, 22, 67, 67, 48, 790, 790, 790, 259, 259, - /* 50 */ 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, - /* 60 */ 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, - /* 70 */ 308, 308, 308, 283, 283, 126, 126, 126, 126, 126, - /* 80 */ 126, 126, 134, 134, 134, 9, 134, 134, 134, 123, - /* 90 */ 123, 134, 134, 134, 134, 52, 52, 18, 123, 134, - /* 100 */ 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, - /* 110 */ 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, - /* 120 */ 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, - /* 130 */ 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, - /* 140 */ 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, - /* 150 */ 134, 134, 134, 134, 134, 134, 134, 467, 467, 467, - /* 160 */ 427, 427, 427, 427, 467, 467, 432, 434, 445, 443, - /* 170 */ 450, 459, 464, 484, 461, 497, 468, 467, 467, 467, - /* 180 */ 534, 534, 515, 22, 22, 467, 467, 535, 537, 579, - /* 190 */ 541, 540, 580, 545, 549, 515, 48, 467, 467, 557, - /* 200 */ 557, 467, 557, 467, 557, 467, 467, 790, 790, 29, - /* 210 */ 69, 69, 98, 69, 168, 124, 233, 245, 245, 245, - /* 220 */ 245, 245, 245, 264, 276, 40, 40, 40, 40, 221, - /* 230 */ 239, 250, 204, 116, 116, 304, 328, 329, 293, 341, - /* 240 */ 326, 362, 413, 367, 368, 370, 357, 358, 373, 374, - /* 250 */ 376, 377, 378, 380, 386, 393, 463, 216, 444, 394, - /* 260 */ 320, 332, 333, 480, 481, 346, 352, 390, 359, 410, - /* 270 */ 638, 489, 640, 641, 492, 643, 644, 555, 558, 513, - /* 280 */ 538, 544, 578, 543, 582, 584, 564, 565, 586, 585, - /* 290 */ 572, 573, 695, 696, 619, 620, 622, 623, 625, 626, - /* 300 */ 605, 628, 629, 631, 705, 632, 611, 583, 614, 587, - /* 310 */ 633, 544, 635, 603, 637, 606, 645, 634, 639, 654, - /* 320 */ 722, 642, 646, 719, 724, 726, 727, 729, 730, 731, - /* 330 */ 732, 652, 725, 660, 658, 659, 624, 661, 720, 685, - /* 340 */ 733, 598, 599, 653, 653, 653, 653, 734, 604, 607, - /* 350 */ 653, 653, 653, 747, 749, 671, 653, 752, 753, 754, - /* 360 */ 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, - /* 370 */ 765, 766, 674, 687, 767, 768, 713, 775, + /* 0 */ 235, 151, 151, 312, 312, 87, 280, 298, 298, 205, + /* 10 */ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + /* 20 */ 23, 23, 23, 0, 135, 298, 349, 349, 349, 80, + /* 30 */ 80, 23, 23, 174, 23, 8, 23, 23, 23, 23, + /* 40 */ 23, 50, 87, 110, 110, 5, 813, 813, 813, 298, + /* 50 */ 298, 298, 298, 298, 298, 298, 298, 298, 298, 298, + /* 60 */ 298, 298, 298, 298, 298, 298, 298, 298, 298, 298, + /* 70 */ 298, 349, 349, 349, 126, 126, 2, 2, 2, 2, + /* 80 */ 2, 2, 2, 23, 23, 23, 369, 23, 23, 23, + /* 90 */ 80, 80, 23, 23, 23, 23, 163, 163, 24, 80, + /* 100 */ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + /* 110 */ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + /* 120 */ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + /* 130 */ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + /* 140 */ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + /* 150 */ 23, 23, 23, 23, 23, 23, 23, 23, 497, 497, + /* 160 */ 497, 450, 450, 450, 450, 497, 497, 453, 455, 454, + /* 170 */ 456, 461, 459, 481, 488, 495, 516, 506, 497, 497, + /* 180 */ 497, 480, 480, 533, 87, 87, 497, 497, 555, 559, + /* 190 */ 604, 564, 563, 603, 566, 569, 533, 5, 497, 497, + /* 200 */ 577, 577, 497, 577, 497, 577, 497, 497, 813, 813, + /* 210 */ 29, 69, 98, 98, 98, 129, 182, 208, 257, 308, + /* 220 */ 308, 308, 308, 308, 308, 301, 330, 40, 40, 40, + /* 230 */ 40, 144, 281, 88, 30, 285, 285, 335, 355, 381, + /* 240 */ 304, 346, 375, 377, 427, 385, 386, 387, 367, 314, + /* 250 */ 388, 389, 390, 391, 392, 223, 393, 395, 465, 417, + /* 260 */ 364, 397, 350, 354, 358, 504, 505, 366, 370, 411, + /* 270 */ 371, 442, 658, 511, 659, 662, 517, 665, 666, 572, + /* 280 */ 576, 534, 556, 567, 601, 565, 602, 607, 587, 593, + /* 290 */ 624, 614, 588, 595, 716, 717, 640, 641, 643, 644, + /* 300 */ 646, 647, 629, 649, 650, 652, 729, 653, 635, 605, + /* 310 */ 639, 606, 655, 567, 660, 625, 661, 628, 663, 664, + /* 320 */ 667, 675, 742, 668, 670, 739, 744, 745, 746, 748, + /* 330 */ 750, 753, 754, 674, 747, 682, 680, 681, 683, 648, + /* 340 */ 685, 738, 709, 755, 621, 623, 676, 676, 676, 676, + /* 350 */ 757, 626, 627, 676, 676, 676, 772, 773, 695, 676, + /* 360 */ 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, + /* 370 */ 785, 786, 787, 788, 789, 697, 710, 790, 791, 736, + /* 380 */ 798, }; -#define YY_REDUCE_COUNT (208) +#define YY_REDUCE_COUNT (209) #define YY_REDUCE_MIN (-266) -#define YY_REDUCE_MAX (495) +#define YY_REDUCE_MAX (515) static const short yy_reduce_ofst[] = { - /* 0 */ -187, 2, 2, -164, -164, -42, -21, -15, 44, -169, - /* 10 */ 71, 102, 76, 131, 160, 170, 173, 175, 183, 186, - /* 20 */ 191, 192, 193, -197, -196, -262, -231, -213, -212, -148, - /* 30 */ 151, -200, -193, -208, 46, -3, 200, 201, 206, 164, - /* 40 */ 208, -198, 217, 237, 185, -163, 224, 240, -266, -14, - /* 50 */ -1, 15, 21, 33, 62, 106, 114, 120, 130, 226, - /* 60 */ 232, 235, 236, 241, 242, 244, 246, 247, 248, 249, - /* 70 */ 64, 257, 261, 251, 252, 273, 278, 279, 280, 281, - /* 80 */ 282, 286, 323, 327, 330, 262, 331, 334, 335, 284, - /* 90 */ 285, 336, 337, 338, 339, 263, 265, 288, 294, 344, - /* 100 */ 345, 347, 348, 349, 350, 351, 353, 354, 355, 356, - /* 110 */ 360, 361, 363, 364, 365, 366, 369, 371, 372, 375, - /* 120 */ 379, 381, 382, 383, 384, 385, 387, 388, 389, 391, - /* 130 */ 392, 395, 396, 397, 398, 399, 400, 401, 402, 403, - /* 140 */ 404, 405, 406, 407, 408, 409, 411, 412, 414, 415, - /* 150 */ 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, - /* 160 */ 274, 287, 295, 296, 426, 428, 309, 313, 315, 297, - /* 170 */ 429, 298, 430, 433, 431, 437, 439, 435, 436, 438, - /* 180 */ 440, 441, 442, 446, 447, 448, 449, 451, 453, 452, - /* 190 */ 454, 456, 460, 458, 465, 455, 457, 462, 466, 474, - /* 200 */ 475, 482, 479, 483, 490, 493, 494, 477, 495, + /* 0 */ -187, 41, 41, -164, -164, -68, -101, -41, 77, -169, + /* 10 */ -29, -147, -97, 141, 170, 188, 189, 191, 196, 197, + /* 20 */ 206, 207, 209, -197, -196, -262, -231, -202, -162, -88, + /* 30 */ 43, -200, 19, -208, 46, 115, 15, 161, 210, 228, + /* 40 */ 83, -106, 184, 237, 251, -189, 169, 143, 172, -266, + /* 50 */ 18, 234, 238, 246, 248, 255, 256, 259, 260, 261, + /* 60 */ 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, + /* 70 */ 272, 59, 64, 133, 252, 273, 302, 303, 305, 307, + /* 80 */ 309, 310, 311, 341, 344, 348, 286, 352, 356, 357, + /* 90 */ 306, 313, 359, 360, 362, 363, 277, 287, 315, 316, + /* 100 */ 368, 372, 373, 374, 376, 378, 379, 380, 382, 383, + /* 110 */ 384, 394, 396, 398, 399, 400, 401, 402, 403, 404, + /* 120 */ 405, 406, 407, 408, 409, 410, 412, 413, 414, 415, + /* 130 */ 416, 418, 419, 420, 421, 422, 423, 424, 425, 426, + /* 140 */ 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, + /* 150 */ 438, 439, 440, 441, 443, 444, 445, 446, 447, 448, + /* 160 */ 449, 294, 297, 299, 317, 451, 452, 321, 318, 324, + /* 170 */ 327, 332, 457, 319, 458, 462, 460, 464, 463, 466, + /* 180 */ 467, 468, 469, 470, 471, 474, 472, 473, 475, 477, + /* 190 */ 476, 478, 482, 483, 484, 489, 485, 479, 486, 487, + /* 200 */ 491, 501, 490, 502, 496, 503, 508, 509, 498, 515, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 895, 1018, 957, 1028, 944, 954, 1178, 1178, 1178, 895, - /* 10 */ 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, - /* 20 */ 895, 895, 895, 1076, 915, 1178, 895, 895, 895, 895, - /* 30 */ 895, 895, 895, 1100, 895, 954, 895, 895, 895, 895, - /* 40 */ 964, 954, 964, 964, 895, 1071, 1002, 1020, 895, 895, - /* 50 */ 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, - /* 60 */ 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, - /* 70 */ 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, - /* 80 */ 895, 895, 895, 895, 895, 1078, 1084, 1081, 895, 895, - /* 90 */ 895, 1086, 895, 895, 895, 1119, 1119, 1069, 895, 895, - /* 100 */ 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, - /* 110 */ 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, - /* 120 */ 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, - /* 130 */ 895, 942, 895, 940, 895, 895, 895, 895, 895, 895, - /* 140 */ 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, - /* 150 */ 895, 895, 895, 895, 895, 895, 913, 917, 917, 917, - /* 160 */ 895, 895, 895, 895, 917, 917, 1126, 1130, 1112, 1124, - /* 170 */ 1120, 1107, 1105, 1103, 1111, 1096, 1134, 917, 917, 917, - /* 180 */ 962, 962, 958, 954, 954, 917, 917, 980, 978, 976, - /* 190 */ 968, 974, 970, 972, 966, 945, 895, 917, 917, 952, - /* 200 */ 952, 917, 952, 917, 952, 917, 917, 1002, 1020, 895, - /* 210 */ 1135, 1125, 895, 1177, 1165, 1164, 895, 1173, 1172, 1171, - /* 220 */ 1163, 1162, 1161, 895, 895, 1157, 1160, 1159, 1158, 895, - /* 230 */ 895, 895, 895, 1167, 1166, 895, 895, 895, 895, 895, - /* 240 */ 895, 895, 1093, 895, 895, 895, 1131, 1127, 895, 895, - /* 250 */ 895, 895, 895, 895, 895, 895, 895, 1137, 895, 895, - /* 260 */ 895, 895, 895, 895, 895, 895, 895, 1030, 895, 895, - /* 270 */ 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, - /* 280 */ 1068, 895, 895, 895, 895, 895, 1080, 1079, 895, 895, - /* 290 */ 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, - /* 300 */ 895, 895, 895, 895, 895, 895, 1121, 895, 1113, 895, - /* 310 */ 895, 1042, 895, 895, 895, 895, 895, 895, 895, 895, - /* 320 */ 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, - /* 330 */ 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, - /* 340 */ 895, 895, 895, 1196, 1191, 1192, 1189, 895, 895, 895, - /* 350 */ 1188, 1183, 1184, 895, 895, 895, 1181, 895, 895, 895, - /* 360 */ 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, - /* 370 */ 895, 895, 986, 895, 924, 922, 895, 895, + /* 0 */ 900, 1023, 962, 1033, 949, 959, 1184, 1184, 1184, 900, + /* 10 */ 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, + /* 20 */ 900, 900, 900, 1081, 920, 1184, 900, 900, 900, 900, + /* 30 */ 900, 900, 900, 1105, 900, 959, 900, 900, 900, 900, + /* 40 */ 900, 969, 959, 969, 969, 900, 1076, 1007, 1025, 900, + /* 50 */ 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, + /* 60 */ 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, + /* 70 */ 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, + /* 80 */ 900, 900, 900, 900, 900, 900, 1083, 1089, 1086, 900, + /* 90 */ 900, 900, 1091, 900, 900, 900, 1124, 1124, 1074, 900, + /* 100 */ 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, + /* 110 */ 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, + /* 120 */ 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, + /* 130 */ 900, 900, 947, 900, 945, 900, 900, 900, 900, 900, + /* 140 */ 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, + /* 150 */ 900, 900, 900, 900, 900, 900, 900, 918, 922, 922, + /* 160 */ 922, 900, 900, 900, 900, 922, 922, 1131, 1135, 1117, + /* 170 */ 1129, 1125, 1112, 1110, 1108, 1116, 1101, 1139, 922, 922, + /* 180 */ 922, 967, 967, 963, 959, 959, 922, 922, 985, 983, + /* 190 */ 981, 973, 979, 975, 977, 971, 950, 900, 922, 922, + /* 200 */ 957, 957, 922, 957, 922, 957, 922, 922, 1007, 1025, + /* 210 */ 1183, 900, 1140, 1130, 1183, 900, 1171, 1170, 900, 1179, + /* 220 */ 1178, 1177, 1169, 1168, 1167, 900, 900, 1163, 1166, 1165, + /* 230 */ 1164, 900, 900, 900, 900, 1173, 1172, 900, 900, 900, + /* 240 */ 900, 900, 900, 900, 1098, 900, 900, 900, 1136, 1132, + /* 250 */ 900, 900, 900, 900, 900, 900, 900, 900, 900, 1142, + /* 260 */ 900, 900, 900, 900, 900, 900, 900, 900, 900, 1035, + /* 270 */ 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, + /* 280 */ 900, 900, 1073, 900, 900, 900, 900, 900, 1085, 1084, + /* 290 */ 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, + /* 300 */ 900, 900, 900, 900, 900, 900, 900, 900, 1126, 900, + /* 310 */ 1118, 900, 900, 1047, 900, 900, 900, 900, 900, 900, + /* 320 */ 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, + /* 330 */ 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, + /* 340 */ 900, 900, 900, 900, 900, 900, 1202, 1197, 1198, 1195, + /* 350 */ 900, 900, 900, 1194, 1189, 1190, 900, 900, 900, 1187, + /* 360 */ 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, + /* 370 */ 900, 900, 900, 900, 900, 991, 900, 929, 927, 900, + /* 380 */ 900, }; /********** End of lemon-generated parsing tables *****************************/ @@ -974,7 +786,6 @@ typedef struct yyParser yyParser; #ifndef NDEBUG #include -#include static FILE *yyTraceFILE = 0; static char *yyTracePrompt = 0; #endif /* NDEBUG */ @@ -1554,51 +1365,52 @@ static const char *const yyRuleName[] = { /* 254 */ "expr ::= NULL", /* 255 */ "expr ::= ID LP exprlist RP", /* 256 */ "expr ::= ID LP STAR RP", - /* 257 */ "expr ::= expr IS NULL", - /* 258 */ "expr ::= expr IS NOT NULL", - /* 259 */ "expr ::= expr LT expr", - /* 260 */ "expr ::= expr GT expr", - /* 261 */ "expr ::= expr LE expr", - /* 262 */ "expr ::= expr GE expr", - /* 263 */ "expr ::= expr NE expr", - /* 264 */ "expr ::= expr EQ expr", - /* 265 */ "expr ::= expr BETWEEN expr AND expr", - /* 266 */ "expr ::= expr AND expr", - /* 267 */ "expr ::= expr OR expr", - /* 268 */ "expr ::= expr PLUS expr", - /* 269 */ "expr ::= expr MINUS expr", - /* 270 */ "expr ::= expr STAR expr", - /* 271 */ "expr ::= expr SLASH expr", - /* 272 */ "expr ::= expr REM expr", - /* 273 */ "expr ::= expr LIKE expr", - /* 274 */ "expr ::= expr MATCH expr", - /* 275 */ "expr ::= expr NMATCH expr", - /* 276 */ "expr ::= expr IN LP exprlist RP", - /* 277 */ "exprlist ::= exprlist COMMA expritem", - /* 278 */ "exprlist ::= expritem", - /* 279 */ "expritem ::= expr", - /* 280 */ "expritem ::=", - /* 281 */ "cmd ::= RESET QUERY CACHE", - /* 282 */ "cmd ::= SYNCDB ids REPLICA", - /* 283 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", - /* 284 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", - /* 285 */ "cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist", - /* 286 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", - /* 287 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", - /* 288 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", - /* 289 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", - /* 290 */ "cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist", - /* 291 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist", - /* 292 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids", - /* 293 */ "cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist", - /* 294 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist", - /* 295 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids", - /* 296 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids", - /* 297 */ "cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem", - /* 298 */ "cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist", - /* 299 */ "cmd ::= KILL CONNECTION INTEGER", - /* 300 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", - /* 301 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", + /* 257 */ "expr ::= ID LP expr AS typename RP", + /* 258 */ "expr ::= expr IS NULL", + /* 259 */ "expr ::= expr IS NOT NULL", + /* 260 */ "expr ::= expr LT expr", + /* 261 */ "expr ::= expr GT expr", + /* 262 */ "expr ::= expr LE expr", + /* 263 */ "expr ::= expr GE expr", + /* 264 */ "expr ::= expr NE expr", + /* 265 */ "expr ::= expr EQ expr", + /* 266 */ "expr ::= expr BETWEEN expr AND expr", + /* 267 */ "expr ::= expr AND expr", + /* 268 */ "expr ::= expr OR expr", + /* 269 */ "expr ::= expr PLUS expr", + /* 270 */ "expr ::= expr MINUS expr", + /* 271 */ "expr ::= expr STAR expr", + /* 272 */ "expr ::= expr SLASH expr", + /* 273 */ "expr ::= expr REM expr", + /* 274 */ "expr ::= expr LIKE expr", + /* 275 */ "expr ::= expr MATCH expr", + /* 276 */ "expr ::= expr NMATCH expr", + /* 277 */ "expr ::= expr IN LP exprlist RP", + /* 278 */ "exprlist ::= exprlist COMMA expritem", + /* 279 */ "exprlist ::= expritem", + /* 280 */ "expritem ::= expr", + /* 281 */ "expritem ::=", + /* 282 */ "cmd ::= RESET QUERY CACHE", + /* 283 */ "cmd ::= SYNCDB ids REPLICA", + /* 284 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", + /* 285 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", + /* 286 */ "cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist", + /* 287 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", + /* 288 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", + /* 289 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", + /* 290 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", + /* 291 */ "cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist", + /* 292 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist", + /* 293 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids", + /* 294 */ "cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist", + /* 295 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist", + /* 296 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids", + /* 297 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids", + /* 298 */ "cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem", + /* 299 */ "cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist", + /* 300 */ "cmd ::= KILL CONNECTION INTEGER", + /* 301 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", + /* 302 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", }; #endif /* NDEBUG */ @@ -1945,7 +1757,7 @@ static YYACTIONTYPE yy_find_shift_action( #endif /* YYWILDCARD */ return yy_default[stateno]; }else{ - assert( i>=0 && i<(int)(sizeof(yy_action)/sizeof(yy_action[0])) ); + assert( i>=0 && iyytos; +#ifndef NDEBUG + if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ + yysize = yyRuleInfoNRhs[yyruleno]; + if( yysize ){ + fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", + yyTracePrompt, + yyruleno, yyRuleName[yyruleno], + yyrulenoyytos - yypParser->yystack)>yypParser->yyhwm ){ + yypParser->yyhwm++; + assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack)); + } +#endif +#if YYSTACKDEPTH>0 + if( yypParser->yytos>=yypParser->yystackEnd ){ + yyStackOverflow(yypParser); + /* The call to yyStackOverflow() above pops the stack until it is + ** empty, causing the main parser loop to exit. So the return value + ** is never used and does not matter. */ + return 0; + } +#else + if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){ + if( yyGrowStack(yypParser) ){ + yyStackOverflow(yypParser); + /* The call to yyStackOverflow() above pops the stack until it is + ** empty, causing the main parser loop to exit. So the return value + ** is never used and does not matter. */ + return 0; + } + yymsp = yypParser->yytos; + } +#endif + } switch( yyruleno ){ /* Beginning here are the reduction cases. A typical example @@ -3488,7 +3350,7 @@ static YYACTIONTYPE yy_reduce( break; case 226: /* having_opt ::= */ case 236: /* where_opt ::= */ yytestcase(yyruleno==236); - case 280: /* expritem ::= */ yytestcase(yyruleno==280); + case 281: /* expritem ::= */ yytestcase(yyruleno==281); {yymsp[1].minor.yy44 = 0;} break; case 227: /* having_opt ::= HAVING expr */ @@ -3582,112 +3444,116 @@ static YYACTIONTYPE yy_reduce( { tStrTokenAppend(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy44 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } yymsp[-3].minor.yy44 = yylhsminor.yy44; break; - case 257: /* expr ::= expr IS NULL */ + case 257: /* expr ::= ID LP expr AS typename RP */ +{ tStrTokenAppend(pInfo->funcs, &yymsp[-5].minor.yy0); yylhsminor.yy44 = tSqlExprCreateFuncWithParams(pInfo, yymsp[-3].minor.yy44, &yymsp[-1].minor.yy179, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, yymsp[-5].minor.yy0.type); } + yymsp[-5].minor.yy44 = yylhsminor.yy44; + break; + case 258: /* expr ::= expr IS NULL */ {yylhsminor.yy44 = tSqlExprCreate(yymsp[-2].minor.yy44, NULL, TK_ISNULL);} yymsp[-2].minor.yy44 = yylhsminor.yy44; break; - case 258: /* expr ::= expr IS NOT NULL */ + case 259: /* expr ::= expr IS NOT NULL */ {yylhsminor.yy44 = tSqlExprCreate(yymsp[-3].minor.yy44, NULL, TK_NOTNULL);} yymsp[-3].minor.yy44 = yylhsminor.yy44; break; - case 259: /* expr ::= expr LT expr */ + case 260: /* expr ::= expr LT expr */ {yylhsminor.yy44 = tSqlExprCreate(yymsp[-2].minor.yy44, yymsp[0].minor.yy44, TK_LT);} yymsp[-2].minor.yy44 = yylhsminor.yy44; break; - case 260: /* expr ::= expr GT expr */ + case 261: /* expr ::= expr GT expr */ {yylhsminor.yy44 = tSqlExprCreate(yymsp[-2].minor.yy44, yymsp[0].minor.yy44, TK_GT);} yymsp[-2].minor.yy44 = yylhsminor.yy44; break; - case 261: /* expr ::= expr LE expr */ + case 262: /* expr ::= expr LE expr */ {yylhsminor.yy44 = tSqlExprCreate(yymsp[-2].minor.yy44, yymsp[0].minor.yy44, TK_LE);} yymsp[-2].minor.yy44 = yylhsminor.yy44; break; - case 262: /* expr ::= expr GE expr */ + case 263: /* expr ::= expr GE expr */ {yylhsminor.yy44 = tSqlExprCreate(yymsp[-2].minor.yy44, yymsp[0].minor.yy44, TK_GE);} yymsp[-2].minor.yy44 = yylhsminor.yy44; break; - case 263: /* expr ::= expr NE expr */ + case 264: /* expr ::= expr NE expr */ {yylhsminor.yy44 = tSqlExprCreate(yymsp[-2].minor.yy44, yymsp[0].minor.yy44, TK_NE);} yymsp[-2].minor.yy44 = yylhsminor.yy44; break; - case 264: /* expr ::= expr EQ expr */ + case 265: /* expr ::= expr EQ expr */ {yylhsminor.yy44 = tSqlExprCreate(yymsp[-2].minor.yy44, yymsp[0].minor.yy44, TK_EQ);} yymsp[-2].minor.yy44 = yylhsminor.yy44; break; - case 265: /* expr ::= expr BETWEEN expr AND expr */ + case 266: /* expr ::= expr BETWEEN expr AND expr */ { tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy44); yylhsminor.yy44 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy44, yymsp[-2].minor.yy44, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy44, TK_LE), TK_AND);} yymsp[-4].minor.yy44 = yylhsminor.yy44; break; - case 266: /* expr ::= expr AND expr */ + case 267: /* expr ::= expr AND expr */ {yylhsminor.yy44 = tSqlExprCreate(yymsp[-2].minor.yy44, yymsp[0].minor.yy44, TK_AND);} yymsp[-2].minor.yy44 = yylhsminor.yy44; break; - case 267: /* expr ::= expr OR expr */ + case 268: /* expr ::= expr OR expr */ {yylhsminor.yy44 = tSqlExprCreate(yymsp[-2].minor.yy44, yymsp[0].minor.yy44, TK_OR); } yymsp[-2].minor.yy44 = yylhsminor.yy44; break; - case 268: /* expr ::= expr PLUS expr */ + case 269: /* expr ::= expr PLUS expr */ {yylhsminor.yy44 = tSqlExprCreate(yymsp[-2].minor.yy44, yymsp[0].minor.yy44, TK_PLUS); } yymsp[-2].minor.yy44 = yylhsminor.yy44; break; - case 269: /* expr ::= expr MINUS expr */ + case 270: /* expr ::= expr MINUS expr */ {yylhsminor.yy44 = tSqlExprCreate(yymsp[-2].minor.yy44, yymsp[0].minor.yy44, TK_MINUS); } yymsp[-2].minor.yy44 = yylhsminor.yy44; break; - case 270: /* expr ::= expr STAR expr */ + case 271: /* expr ::= expr STAR expr */ {yylhsminor.yy44 = tSqlExprCreate(yymsp[-2].minor.yy44, yymsp[0].minor.yy44, TK_STAR); } yymsp[-2].minor.yy44 = yylhsminor.yy44; break; - case 271: /* expr ::= expr SLASH expr */ + case 272: /* expr ::= expr SLASH expr */ {yylhsminor.yy44 = tSqlExprCreate(yymsp[-2].minor.yy44, yymsp[0].minor.yy44, TK_DIVIDE);} yymsp[-2].minor.yy44 = yylhsminor.yy44; break; - case 272: /* expr ::= expr REM expr */ + case 273: /* expr ::= expr REM expr */ {yylhsminor.yy44 = tSqlExprCreate(yymsp[-2].minor.yy44, yymsp[0].minor.yy44, TK_REM); } yymsp[-2].minor.yy44 = yylhsminor.yy44; break; - case 273: /* expr ::= expr LIKE expr */ + case 274: /* expr ::= expr LIKE expr */ {yylhsminor.yy44 = tSqlExprCreate(yymsp[-2].minor.yy44, yymsp[0].minor.yy44, TK_LIKE); } yymsp[-2].minor.yy44 = yylhsminor.yy44; break; - case 274: /* expr ::= expr MATCH expr */ + case 275: /* expr ::= expr MATCH expr */ {yylhsminor.yy44 = tSqlExprCreate(yymsp[-2].minor.yy44, yymsp[0].minor.yy44, TK_MATCH); } yymsp[-2].minor.yy44 = yylhsminor.yy44; break; - case 275: /* expr ::= expr NMATCH expr */ + case 276: /* expr ::= expr NMATCH expr */ {yylhsminor.yy44 = tSqlExprCreate(yymsp[-2].minor.yy44, yymsp[0].minor.yy44, TK_NMATCH); } yymsp[-2].minor.yy44 = yylhsminor.yy44; break; - case 276: /* expr ::= expr IN LP exprlist RP */ + case 277: /* expr ::= expr IN LP exprlist RP */ {yylhsminor.yy44 = tSqlExprCreate(yymsp[-4].minor.yy44, (tSqlExpr*)yymsp[-1].minor.yy247, TK_IN); } yymsp[-4].minor.yy44 = yylhsminor.yy44; break; - case 277: /* exprlist ::= exprlist COMMA expritem */ + case 278: /* exprlist ::= exprlist COMMA expritem */ {yylhsminor.yy247 = tSqlExprListAppend(yymsp[-2].minor.yy247,yymsp[0].minor.yy44,0, 0);} yymsp[-2].minor.yy247 = yylhsminor.yy247; break; - case 278: /* exprlist ::= expritem */ + case 279: /* exprlist ::= expritem */ {yylhsminor.yy247 = tSqlExprListAppend(0,yymsp[0].minor.yy44,0, 0);} yymsp[0].minor.yy247 = yylhsminor.yy247; break; - case 279: /* expritem ::= expr */ + case 280: /* expritem ::= expr */ {yylhsminor.yy44 = yymsp[0].minor.yy44;} yymsp[0].minor.yy44 = yylhsminor.yy44; break; - case 281: /* cmd ::= RESET QUERY CACHE */ + case 282: /* cmd ::= RESET QUERY CACHE */ { setDCLSqlElems(pInfo, TSDB_SQL_RESET_CACHE, 0);} break; - case 282: /* cmd ::= SYNCDB ids REPLICA */ + case 283: /* cmd ::= SYNCDB ids REPLICA */ { setDCLSqlElems(pInfo, TSDB_SQL_SYNC_DB_REPLICA, 1, &yymsp[-1].minor.yy0);} break; - case 283: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + case 284: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy247, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 284: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + case 285: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3698,21 +3564,21 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 285: /* cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ + case 286: /* cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy247, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 286: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + case 287: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy247, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 287: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + case 288: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3723,7 +3589,7 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 288: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + case 289: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; @@ -3737,7 +3603,7 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 289: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + case 290: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ { yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n; @@ -3749,21 +3615,21 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 290: /* cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ + case 291: /* cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy247, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 291: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ + case 292: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy247, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 292: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ + case 293: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3774,21 +3640,21 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 293: /* cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ + case 294: /* cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy247, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 294: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ + case 295: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy247, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 295: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ + case 296: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3799,7 +3665,7 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 296: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ + case 297: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; @@ -3813,7 +3679,7 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 297: /* cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ + case 298: /* cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ { yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n; @@ -3825,20 +3691,20 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 298: /* cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ + case 299: /* cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy247, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 299: /* cmd ::= KILL CONNECTION INTEGER */ + case 300: /* cmd ::= KILL CONNECTION INTEGER */ {setKillSql(pInfo, TSDB_SQL_KILL_CONNECTION, &yymsp[0].minor.yy0);} break; - case 300: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */ + case 301: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */ {yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setKillSql(pInfo, TSDB_SQL_KILL_STREAM, &yymsp[-2].minor.yy0);} break; - case 301: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */ + case 302: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */ {yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setKillSql(pInfo, TSDB_SQL_KILL_QUERY, &yymsp[-2].minor.yy0);} break; default: @@ -4009,56 +3875,12 @@ void Parse( } #endif - while(1){ /* Exit by "break" */ - assert( yypParser->yytos>=yypParser->yystack ); + do{ assert( yyact==yypParser->yytos->stateno ); yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact); if( yyact >= YY_MIN_REDUCE ){ - unsigned int yyruleno = yyact - YY_MIN_REDUCE; /* Reduce by this rule */ - assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ); -#ifndef NDEBUG - if( yyTraceFILE ){ - int yysize = yyRuleInfoNRhs[yyruleno]; - if( yysize ){ - fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", - yyTracePrompt, - yyruleno, yyRuleName[yyruleno], - yyrulenoyytos[yysize].stateno); - }else{ - fprintf(yyTraceFILE, "%sReduce %d [%s]%s.\n", - yyTracePrompt, yyruleno, yyRuleName[yyruleno], - yyrulenoyytos - yypParser->yystack)>yypParser->yyhwm ){ - yypParser->yyhwm++; - assert( yypParser->yyhwm == - (int)(yypParser->yytos - yypParser->yystack)); - } -#endif -#if YYSTACKDEPTH>0 - if( yypParser->yytos>=yypParser->yystackEnd ){ - yyStackOverflow(yypParser); - break; - } -#else - if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){ - if( yyGrowStack(yypParser) ){ - yyStackOverflow(yypParser); - break; - } - } -#endif - } - yyact = yy_reduce(yypParser,yyruleno,yymajor,yyminor ParseCTX_PARAM); + yyact = yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor, + yyminor ParseCTX_PARAM); }else if( yyact <= YY_MAX_SHIFTREDUCE ){ yy_shift(yypParser,yyact,(YYCODETYPE)yymajor,yyminor); #ifndef YYNOERRORRECOVERY @@ -4171,7 +3993,7 @@ void Parse( break; #endif } - } + }while( yypParser->yytos>yypParser->yystack ); #ifndef NDEBUG if( yyTraceFILE ){ yyStackEntry *i; diff --git a/tests/pytest/tag_lite/alter_tag.py b/tests/pytest/tag_lite/alter_tag.py index 9e5abb6c134840ecb4ab52c7d3a6ab623885e12b..c4d738e4cf0d9bd63f7813e9d267080f9f045fac 100644 --- a/tests/pytest/tag_lite/alter_tag.py +++ b/tests/pytest/tag_lite/alter_tag.py @@ -30,7 +30,7 @@ class TDTestCase: print("==============step1") tdSql.execute( - "CREATE TABLE IF NOT EXISTS ampere (ts TIMESTAMP(8),ampere DOUBLE(8)) TAGS (device_name BINARY(50),build_id BINARY(50),project_id BINARY(50),alias BINARY(50))") + "CREATE TABLE IF NOT EXISTS ampere (ts TIMESTAMP,ampere DOUBLE) TAGS (device_name BINARY(50),build_id BINARY(50),project_id BINARY(50),alias BINARY(50))") tdSql.execute("insert into d1001 using ampere tags('test', '2', '2', '2') VALUES (now, 123)") tdSql.execute("ALTER TABLE ampere ADD TAG variable_id BINARY(50)") diff --git a/tests/script/general/compute/cast.sim b/tests/script/general/compute/cast.sim new file mode 100644 index 0000000000000000000000000000000000000000..729d6808a53e8db4ee17eb1e38ed94aca91ac1ef --- /dev/null +++ b/tests/script/general/compute/cast.sim @@ -0,0 +1,106 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 6 +system sh/cfg.sh -n dnode1 -c cache -v 1 +system sh/cfg.sh -n dnode1 -c minRows -v 10 +system sh/exec.sh -n dnode1 -s start + +sleep 100 +sql connect + +sql drop database if exists db +sql create database if not exists db +sql use db +sql create table stb1 (ts timestamp, c1 bool, c2 tinyint, c3 smallint, c4 int, c5 bigint, c6 float, c7 double, c8 binary(10), c9 nchar(10), c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned) TAGS(t1 int, t2 binary(10), t3 double); + +sql create table tb1 using stb1 tags(1,'1',1.0); +sql create table tb2 using stb1 tags(2,'2',2.0); +sql create table tb3 using stb1 tags(3,'3',3.0); + +sql insert into tb1 values ('2021-11-11 09:00:00',true,1,1,1,1,1,1,"123","1234",1,1,1,1); +sql insert into tb1 values ('2021-11-11 09:00:01',true,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); +sql insert into tb1 values ('2021-11-11 09:00:02',true,2,NULL,2,NULL,2,NULL,"234",NULL,2,NULL,2,NULL); +sql insert into tb1 values ('2021-11-11 09:00:03',false,NULL,3,NULL,3,NULL,3,NULL,"3456",NULL,3,NULL,3); +sql insert into tb1 values ('2021-11-11 09:00:04',true,4,4,4,4,4,4,"456","4567",4,4,4,4); +sql insert into tb1 values ('2021-11-11 09:00:05',true,127,32767,2147483647,9223372036854775807,3.402823466e+38,1.79769e+308,"567","5678",254,65534,4294967294,9223372036854775807); +sql insert into tb1 values ('2021-11-11 09:00:06',true,-127,-32767,-2147483647,-9223372036854775807,-3.402823466e+38,-1.79769e+308,"678","6789",0,0,0,0); + +sql insert into tb2 values ('2021-11-11 09:00:00',true,1,1,1,1,1,1,"111","1111",1,1,1,1); +sql insert into tb2 values ('2021-11-11 09:00:01',true,2,2,2,2,2,2,"222","2222",2,2,2,2); +sql insert into tb2 values ('2021-11-11 09:00:02',true,3,3,2,3,3,3,"333","3333",3,3,3,3); +sql insert into tb2 values ('2021-11-11 09:00:03',false,4,4,4,4,4,4,"444","4444",4,4,4,4); +sql insert into tb2 values ('2021-11-11 09:00:04',true,5,5,5,5,5,5,"555","5555",5,5,5,5); +sql insert into tb2 values ('2021-11-11 09:00:05',true,6,6,6,6,6,6,"666","6666",6,6,6,6); +sql insert into tb2 values ('2021-11-11 09:00:06',true,7,7,7,7,7,7,"777","7777",7,7,7,7); + +sql create table tbn (ts timestamp, c1 bool, c2 tinyint, c3 smallint, c4 int, c5 bigint, c6 float, c7 double, c8 binary(10), c9 nchar(10), c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned); + +sql insert into tbn values ('2021-11-11 09:00:00',true,1,1,1,1,1,1,"111","1111",1,1,1,1); +sql insert into tbn values ('2021-11-11 09:00:01',true,2,2,2,2,2,2,"222","2222",2,2,2,2); +sql insert into tbn values ('2021-11-11 09:00:02',true,3,3,2,3,3,3,"333","3333",3,3,3,3); +sql insert into tbn values ('2021-11-11 09:00:03',false,4,4,4,4,4,4,"444","4444",4,4,4,4); +sql insert into tbn values ('2021-11-11 09:00:04',true,5,5,5,5,5,5,"555","5555",5,5,5,5); +sql insert into tbn values ('2021-11-11 09:00:05',true,6,6,6,6,6,6,"666","6666",6,6,6,6); +sql insert into tbn values ('2021-11-11 09:00:06',true,7,7,7,7,7,7,"777","7777",7,7,7,7); + +run general/compute/cast_query1.sim +run general/compute/cast_query2.sim + + +sql create table stba (ts timestamp, c1 bool, c2 tinyint, c3 smallint, c4 int, c5 bigint, c6 float, c7 double, c8 binary(10), c9 nchar(10), c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned) TAGS(t1 int, t2 binary(10), t3 double); + +sql create table tba1 using stba tags(1,'1',1.0); + +sql insert into tba1 values ('2021-11-11 09:00:00',true, 1,1,1,1,1,1,"111","1111",1,1,1,1); +sql insert into tba1 values ('2021-11-11 09:00:01',true, 2,2,2,2,2,2,"222","2222",2,2,2,2); +sql insert into tba1 values ('2021-11-11 09:00:02',true, 3,3,2,3,3,3,"333","3333",3,3,3,3); +sql insert into tba1 values ('2021-11-11 09:00:03',false,4,4,4,4,4,4,"444","4444",4,4,4,4); +sql insert into tba1 values ('2021-11-11 09:00:04',true, 5,5,5,5,5,5,"555","5555",5,5,5,5); +sql insert into tba1 values ('2021-11-11 09:00:05',true, 6,6,6,6,6,6,"666","6666",6,6,6,6); +sql insert into tba1 values ('2021-11-11 09:00:06',true, 7,7,7,7,7,7,"777","7777",7,7,7,7); +sql insert into tba1 values ('2021-11-11 09:00:07',true, 8,8,8,8,8,8,"888","8888",8,8,8,8); +sql insert into tba1 values ('2021-11-11 09:00:08',true, 9,9,9,9,9,9,"999","9999",9,9,9,9); +sql insert into tba1 values ('2021-11-11 09:00:09',true, 0,0,0,0,0,0,"000","0000",0,0,0,0); + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 500 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed + +sql insert into tba1 values ('2021-11-11 09:00:10',true, 1,1,1,1,1,1,"111","1111",1,1,1,1); +sql insert into tba1 values ('2021-11-11 09:00:11',true, 2,2,2,2,2,2,"222","2222",2,2,2,2); +sql insert into tba1 values ('2021-11-11 09:00:12',true, 3,3,2,3,3,3,"333","3333",3,3,3,3); +sql insert into tba1 values ('2021-11-11 09:00:13',false,4,4,4,4,4,4,"444","4444",4,4,4,4); +sql insert into tba1 values ('2021-11-11 09:00:14',true, 5,5,5,5,5,5,"555","5555",5,5,5,5); +sql insert into tba1 values ('2021-11-11 09:00:15',true, 6,6,6,6,6,6,"666","6666",6,6,6,6); +sql insert into tba1 values ('2021-11-11 09:00:16',true, 7,7,7,7,7,7,"777","7777",7,7,7,7); +sql insert into tba1 values ('2021-11-11 09:00:17',true, 8,8,8,8,8,8,"888","8888",8,8,8,8); +sql insert into tba1 values ('2021-11-11 09:00:18',true, 9,9,9,9,9,9,"999","9999",9,9,9,9); +sql insert into tba1 values ('2021-11-11 09:00:19',true, 0,0,0,0,0,0,"000","0000",0,0,0,0); + +print ================== restart server to commit data into disk +system sh/exec.sh -n dnode1 -s stop -x SIGINT +sleep 500 +system sh/exec.sh -n dnode1 -s start +print ================== server restart completed + +sql insert into tba1 values ('2021-11-11 09:00:20',true, 1,1,1,1,1,1,"111","1111",1,1,1,1); +sql insert into tba1 values ('2021-11-11 09:00:21',true, 2,2,2,2,2,2,"222","2222",2,2,2,2); +sql insert into tba1 values ('2021-11-11 09:00:22',true, 3,3,2,3,3,3,"333","3333",3,3,3,3); +sql insert into tba1 values ('2021-11-11 09:00:23',false,4,4,4,4,4,4,"444","4444",4,4,4,4); +sql insert into tba1 values ('2021-11-11 09:00:24',true, 5,5,5,5,5,5,"555","5555",5,5,5,5); +sql insert into tba1 values ('2021-11-11 09:00:25',true, 6,6,6,6,6,6,"666","6666",6,6,6,6); +sql insert into tba1 values ('2021-11-11 09:00:26',true, 7,7,7,7,7,7,"777","7777",7,7,7,7); +sql insert into tba1 values ('2021-11-11 09:00:27',true, 8,8,8,8,8,8,"888","8888",8,8,8,8); +sql insert into tba1 values ('2021-11-11 09:00:28',true, 9,9,9,9,9,9,"999","9999",9,9,9,9); +sql insert into tba1 values ('2021-11-11 09:00:29',true, 0,0,0,0,0,0,"000","0000",0,0,0,0); + +run general/compute/cast_query1.sim +run general/compute/cast_query2.sim +run general/compute/cast_query3.sim + +#system sh/exec.sh -n dnode1 -s stop -x SIGINT + diff --git a/tests/script/general/compute/cast_query1.sim b/tests/script/general/compute/cast_query1.sim new file mode 100644 index 0000000000000000000000000000000000000000..de0722bcd8c3911d94b4558c302c22bbc607defd --- /dev/null +++ b/tests/script/general/compute/cast_query1.sim @@ -0,0 +1,2454 @@ +sleep 100 +sql connect + +sql use db; + +print "test negative cases" + +sql_error select cast(* as tinyint) from tb1; +sql_error select cast(* as smallint) from tb1; +sql_error select cast(* as int) from tb1; +sql_error select cast(* as bool) from tb1; +sql_error select cast(* as bigint) as a from tb1; +sql_error select cast(* as bigint) + 1 as a from tb1; +sql_error select cast(tb1.* as bigint) + 1 as a from tb1; +sql_error select cast(* as bigint) from tb1; +sql_error select cast(c1 as binary(16384)) from tb1; +sql_error select cast(c1 as nchar(16384)) from tb1; +sql_error select cast(c1 + c2 as bigint) from tb1; +sql_error select cast(13 as binary(0)) from tb1; +sql_error select cast(12 as binary(-1)) from tb1; +sql_error select cast(11 as nchar(0)) from tb1; +sql_error select cast(10 as nchar(-1)) from tb1; +sql_error select cast(11 as tinyint) from tb1; +sql_error select cast(11 as bool) from tb1; +sql_error select cast(11 as smallint) from tb1; +sql_error select cast(11 as int) from tb1; +sql_error select cast(11 as float) from tb1; +sql_error select cast(11 as double) from tb1; +sql_error select cast(11 as tinyint unsigned) from tb1; +sql_error select cast(11 as smallint unsigned) from tb1; +sql_error select cast(11 as int unsigned) from tb1; +sql_error select cast(c1 as binary(0)) from tb1; +sql_error select cast(c1 as binary(-1)) from tb1; +sql_error select cast(c1 as nchar(0)) from tb1; +sql_error select cast(c1 as nchar(-1)) from tb1; +sql_error select cast(c1 as tinyint) from tb1; +sql_error select cast(c1 as bool) from tb1; +sql_error select cast(c1 as smallint) from tb1; +sql_error select cast(c1 as int) from tb1; +sql_error select cast(c1 as float) from tb1; +sql_error select cast(c1 as double) from tb1; +sql_error select cast(c1 as tinyint unsigned) from tb1; +sql_error select cast(c1 as smallint unsigned) from tb1; +sql_error select cast(c1 as int unsigned) from tb1; +sql_error select cast(c2 as binary(0)) from tb1; +sql_error select cast(c2 as binary(-1)) from tb1; +sql_error select cast(c2 as nchar(0)) from tb1; +sql_error select cast(c2 as nchar(-1)) from tb1; +sql_error select cast(c2 as tinyint) from tb1; +sql_error select cast(c2 as bool) from tb1; +sql_error select cast(c2 as smallint) from tb1; +sql_error select cast(c2 as int) from tb1; +sql_error select cast(c2 as float) from tb1; +sql_error select cast(c2 as double) from tb1; +sql_error select cast(c2 as tinyint unsigned) from tb1; +sql_error select cast(c2 as smallint unsigned) from tb1; +sql_error select cast(c2 as int unsigned) from tb1; +sql_error select cast(c3 as binary(0)) from tb1; +sql_error select cast(c3 as binary(-1)) from tb1; +sql_error select cast(c3 as nchar(0)) from tb1; +sql_error select cast(c3 as nchar(-1)) from tb1; +sql_error select cast(c3 as tinyint) from tb1; +sql_error select cast(c3 as bool) from tb1; +sql_error select cast(c3 as smallint) from tb1; +sql_error select cast(c3 as int) from tb1; +sql_error select cast(c3 as float) from tb1; +sql_error select cast(c3 as double) from tb1; +sql_error select cast(c3 as tinyint unsigned) from tb1; +sql_error select cast(c3 as smallint unsigned) from tb1; +sql_error select cast(c3 as int unsigned) from tb1; +sql_error select cast(c4 as binary(0)) from tb1; +sql_error select cast(c4 as binary(-1)) from tb1; +sql_error select cast(c4 as nchar(0)) from tb1; +sql_error select cast(c4 as nchar(-1)) from tb1; +sql_error select cast(c4 as tinyint) from tb1; +sql_error select cast(c4 as bool) from tb1; +sql_error select cast(c4 as smallint) from tb1; +sql_error select cast(c4 as int) from tb1; +sql_error select cast(c4 as float) from tb1; +sql_error select cast(c4 as double) from tb1; +sql_error select cast(c4 as tinyint unsigned) from tb1; +sql_error select cast(c4 as smallint unsigned) from tb1; +sql_error select cast(c4 as int unsigned) from tb1; +sql_error select cast(c5 as binary(0)) from tb1; +sql_error select cast(c5 as binary(-1)) from tb1; +sql_error select cast(c5 as nchar(0)) from tb1; +sql_error select cast(c5 as nchar(-1)) from tb1; +sql_error select cast(c5 as tinyint) from tb1; +sql_error select cast(c5 as bool) from tb1; +sql_error select cast(c5 as smallint) from tb1; +sql_error select cast(c5 as int) from tb1; +sql_error select cast(c5 as float) from tb1; +sql_error select cast(c5 as double) from tb1; +sql_error select cast(c5 as tinyint unsigned) from tb1; +sql_error select cast(c5 as smallint unsigned) from tb1; +sql_error select cast(c5 as int unsigned) from tb1; +sql_error select cast(c6 as binary(0)) from tb1; +sql_error select cast(c6 as binary(-1)) from tb1; +sql_error select cast(c6 as nchar(0)) from tb1; +sql_error select cast(c6 as nchar(-1)) from tb1; +sql_error select cast(c6 as tinyint) from tb1; +sql_error select cast(c6 as bool) from tb1; +sql_error select cast(c6 as smallint) from tb1; +sql_error select cast(c6 as int) from tb1; +sql_error select cast(c6 as float) from tb1; +sql_error select cast(c6 as double) from tb1; +sql_error select cast(c6 as tinyint unsigned) from tb1; +sql_error select cast(c6 as smallint unsigned) from tb1; +sql_error select cast(c6 as int unsigned) from tb1; +sql_error select cast(c7 as binary(0)) from tb1; +sql_error select cast(c7 as binary(-1)) from tb1; +sql_error select cast(c7 as nchar(0)) from tb1; +sql_error select cast(c7 as nchar(-1)) from tb1; +sql_error select cast(c7 as tinyint) from tb1; +sql_error select cast(c7 as bool) from tb1; +sql_error select cast(c7 as smallint) from tb1; +sql_error select cast(c7 as int) from tb1; +sql_error select cast(c7 as float) from tb1; +sql_error select cast(c7 as double) from tb1; +sql_error select cast(c7 as tinyint unsigned) from tb1; +sql_error select cast(c7 as smallint unsigned) from tb1; +sql_error select cast(c7 as int unsigned) from tb1; +sql_error select cast(c8 as binary(0)) from tb1; +sql_error select cast(c8 as binary(-1)) from tb1; +sql_error select cast(c8 as nchar(0)) from tb1; +sql_error select cast(c8 as nchar(-1)) from tb1; +sql_error select cast(c8 as tinyint) from tb1; +sql_error select cast(c8 as bool) from tb1; +sql_error select cast(c8 as smallint) from tb1; +sql_error select cast(c8 as int) from tb1; +sql_error select cast(c8 as float) from tb1; +sql_error select cast(c8 as double) from tb1; +sql_error select cast(c8 as tinyint unsigned) from tb1; +sql_error select cast(c8 as smallint unsigned) from tb1; +sql_error select cast(c8 as int unsigned) from tb1; +sql_error select cast(c8 as timestamp) from tb1; +sql_error select cast(c9 as binary(0)) from tb1; +sql_error select cast(c9 as binary(-1)) from tb1; +sql_error select cast(c9 as nchar(0)) from tb1; +sql_error select cast(c9 as nchar(-1)) from tb1; +sql_error select cast(c9 as tinyint) from tb1; +sql_error select cast(c9 as bool) from tb1; +sql_error select cast(c9 as smallint) from tb1; +sql_error select cast(c9 as int) from tb1; +sql_error select cast(c9 as float) from tb1; +sql_error select cast(c9 as double) from tb1; +sql_error select cast(c9 as tinyint unsigned) from tb1; +sql_error select cast(c9 as smallint unsigned) from tb1; +sql_error select cast(c9 as int unsigned) from tb1; +sql_error select cast(c9 as timestamp) from tb1; +sql_error select cast(c9 as binary(5)) from tb1; +sql_error select cast(c10 as binary(0)) from tb1; +sql_error select cast(c10 as binary(-1)) from tb1; +sql_error select cast(c10 as nchar(0)) from tb1; +sql_error select cast(c10 as nchar(-1)) from tb1; +sql_error select cast(c10 as tinyint) from tb1; +sql_error select cast(c10 as bool) from tb1; +sql_error select cast(c10 as smallint) from tb1; +sql_error select cast(c10 as int) from tb1; +sql_error select cast(c10 as float) from tb1; +sql_error select cast(c10 as double) from tb1; +sql_error select cast(c10 as tinyint unsigned) from tb1; +sql_error select cast(c10 as smallint unsigned) from tb1; +sql_error select cast(c10 as int unsigned) from tb1; +sql_error select cast(c11 as binary(0)) from tb1; +sql_error select cast(c11 as binary(-1)) from tb1; +sql_error select cast(c11 as nchar(0)) from tb1; +sql_error select cast(c11 as nchar(-1)) from tb1; +sql_error select cast(c11 as tinyint) from tb1; +sql_error select cast(c11 as bool) from tb1; +sql_error select cast(c11 as smallint) from tb1; +sql_error select cast(c11 as int) from tb1; +sql_error select cast(c11 as float) from tb1; +sql_error select cast(c11 as double) from tb1; +sql_error select cast(c11 as tinyint unsigned) from tb1; +sql_error select cast(c11 as smallint unsigned) from tb1; +sql_error select cast(c11 as int unsigned) from tb1; +sql_error select cast(c12 as binary(0)) from tb1; +sql_error select cast(c12 as binary(-1)) from tb1; +sql_error select cast(c12 as nchar(0)) from tb1; +sql_error select cast(c12 as nchar(-1)) from tb1; +sql_error select cast(c12 as tinyint) from tb1; +sql_error select cast(c12 as bool) from tb1; +sql_error select cast(c12 as smallint) from tb1; +sql_error select cast(c12 as int) from tb1; +sql_error select cast(c12 as float) from tb1; +sql_error select cast(c12 as double) from tb1; +sql_error select cast(c12 as tinyint unsigned) from tb1; +sql_error select cast(c12 as smallint unsigned) from tb1; +sql_error select cast(c12 as int unsigned) from tb1; +sql_error select cast(c13 as binary(0)) from tb1; +sql_error select cast(c13 as binary(-1)) from tb1; +sql_error select cast(c13 as nchar(0)) from tb1; +sql_error select cast(c13 as nchar(-1)) from tb1; +sql_error select cast(c13 as tinyint) from tb1; +sql_error select cast(c13 as bool) from tb1; +sql_error select cast(c13 as smallint) from tb1; +sql_error select cast(c13 as int) from tb1; +sql_error select cast(c13 as float) from tb1; +sql_error select cast(c13 as double) from tb1; +sql_error select cast(c13 as tinyint unsigned) from tb1; +sql_error select cast(c13 as smallint unsigned) from tb1; +sql_error select cast(c13 as int unsigned) from tb1; +sql_error select cast(12345678900000000000000000 as binary(10)) from tb1; +sql_error select distinct cast("-abc" as bigint unsigned) from tb1; +sql_error select cast(c1) from tb1; +sql_error select cast(t1 as bigint) from stb1; +sql_error select cast(c2 as bigint)+avg(c2) from tb1; +sql_error select cast(c2 as bigint)+top(c2,1) from tb1; +sql_error select cast(c1 as bigint),avg(c3) from tb1; +sql_error select cast(c1 as bigint),top(c3,1) from tb1; +sql_error select cast(c2+c3 as binary(6)) from tb1 session(ts, 1s); +sql_error select cast(c2+c3 as binary(6)) from tb1 STATE_WINDOW(c1); +sql_error select cast(c2+c3 as binary(6)) from tb1 interval(1s) sliding(1s) fill(NULL); +sql_error select cast(c2+c3 as binary(6)) from stb1 group by t1; +sql_error select cast(c2+c3 as binary(6)) from stb1 group by ts; +sql_error select cast(c2+c3 as binary(6)) from stb1 group by c1; +sql_error select cast(c2+c3 as binary(6)) from stb1 group by tbname; +sql_error select cast(c2+c3 as binary(6)) from tb1 order by c2; +sql_error select cast(c8 as bigint),cast(c9 as bigint(12)) from tbn; +sql_error select cast(ts as binary(10)) from (select avg(c2) as a from stb1 interval(1s)); +sql_error select cast(a as timestamp) from (select cast(c2 as binary(2)) as a from tb1); + +print "test constant" + +sql select cast(13 as bigint) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 13 then + return -1 +endi +if $data10 != 13 then + return -1 +endi +sql select cast(13 as timestamp) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != @70-01-01 08:00:00.013@ then + return -1 +endi +if $data10 != @70-01-01 08:00:00.013@ then + return -1 +endi +sql select cast("abc" as bigint unsigned) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +if $data10 != 0 then + return -1 +endi +print "test bool column" + +sql select cast(c1 as bigint) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data20 != 1 then + return -1 +endi +if $data30 != 0 then + return -1 +endi +if $data40 != 1 then + return -1 +endi +if $data50 != 1 then + return -1 +endi +if $data60 != 1 then + return -1 +endi +sql select cast(c1 as binary(10)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != true then + return -1 +endi +if $data10 != true then + return -1 +endi +if $data20 != true then + return -1 +endi +if $data30 != false then + return -1 +endi +if $data40 != true then + return -1 +endi +if $data50 != true then + return -1 +endi +if $data60 != true then + return -1 +endi +sql select cast(c1 as binary(1)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != t then + return -1 +endi +if $data10 != t then + return -1 +endi +if $data20 != t then + return -1 +endi +if $data30 != f then + return -1 +endi +if $data40 != t then + return -1 +endi +if $data50 != t then + return -1 +endi +if $data60 != t then + return -1 +endi +sql select cast(c1 as timestamp) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != @70-01-01 08:00:00.001@ then + return -1 +endi +if $data10 != @70-01-01 08:00:00.001@ then + return -1 +endi +if $data20 != @70-01-01 08:00:00.001@ then + return -1 +endi +if $data30 != @70-01-01 08:00:00.000@ then + return -1 +endi +if $data40 != @70-01-01 08:00:00.001@ then + return -1 +endi +if $data50 != @70-01-01 08:00:00.001@ then + return -1 +endi +if $data60 != @70-01-01 08:00:00.001@ then + return -1 +endi +sql select cast(c1 as nchar(10)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != true then + return -1 +endi +if $data10 != true then + return -1 +endi +if $data20 != true then + return -1 +endi +if $data30 != false then + return -1 +endi +if $data40 != true then + return -1 +endi +if $data50 != true then + return -1 +endi +if $data60 != true then + return -1 +endi +sql select cast(c1 as nchar(1)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != t then + return -1 +endi +if $data10 != t then + return -1 +endi +if $data20 != t then + return -1 +endi +if $data30 != f then + return -1 +endi +if $data40 != t then + return -1 +endi +if $data50 != t then + return -1 +endi +if $data60 != t then + return -1 +endi +sql select cast(c1 as bigint unsigned) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data20 != 1 then + return -1 +endi +if $data30 != 0 then + return -1 +endi +if $data40 != 1 then + return -1 +endi +if $data50 != 1 then + return -1 +endi +if $data60 != 1 then + return -1 +endi + +print "test tinyint column" + +sql select cast(c2 as bigint) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 127 then + return -1 +endi +if $data60 != -127 then + return -1 +endi +sql select cast(c2 as binary(10)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 127 then + return -1 +endi +if $data60 != -127 then + return -1 +endi +sql select cast(c2 as binary(1)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 1 then + return -1 +endi +if $data60 != - then + return -1 +endi +sql select cast(c2 as timestamp) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != @70-01-01 08:00:00.001@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != @70-01-01 08:00:00.002@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @70-01-01 08:00:00.004@ then + return -1 +endi +if $data50 != @70-01-01 08:00:00.127@ then + return -1 +endi +if $data60 != @70-01-01 08:00:00.-127@ then + return -1 +endi +sql select cast(c2 as nchar(10)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 127 then + return -1 +endi +if $data60 != -127 then + return -1 +endi +sql select cast(c2 as nchar(1)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 1 then + return -1 +endi +if $data60 != - then + return -1 +endi +sql select cast(c2 as bigint unsigned) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 127 then + return -1 +endi +if $data60 != 18446744073709551489 then + return -1 +endi + +print "test smallint column" + +sql select cast(c3 as bigint) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 32767 then + return -1 +endi +if $data60 != -32767 then + return -1 +endi +sql select cast(c3 as binary(10)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 32767 then + return -1 +endi +if $data60 != -32767 then + return -1 +endi +sql select cast(c3 as binary(2)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 32 then + return -1 +endi +if $data60 != -3 then + return -1 +endi +sql select cast(c3 as timestamp) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != @70-01-01 08:00:00.001@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != @70-01-01 08:00:00.003@ then + return -1 +endi +if $data40 != @70-01-01 08:00:00.004@ then + return -1 +endi +if $data50 != @70-01-01 08:00:32.767@ then + return -1 +endi +if $data60 != @70-01-01 07:59:28.-767@ then + return -1 +endi +sql select cast(c3 as nchar(10)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 32767 then + return -1 +endi +if $data60 != -32767 then + return -1 +endi +sql select cast(c3 as nchar(3)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 327 then + return -1 +endi +if $data60 != -32 then + return -1 +endi +sql select cast(c3 as bigint unsigned) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 32767 then + return -1 +endi +if $data60 != 18446744073709518849 then + return -1 +endi + +print "test int column" + +sql select cast(c4 as bigint) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 2147483647 then + return -1 +endi +if $data60 != -2147483647 then + return -1 +endi +sql select cast(c4 as binary(10)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 2147483647 then + return -1 +endi +if $data60 != -214748364 then + return -1 +endi +sql select cast(c4 as binary(5)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 21474 then + return -1 +endi +if $data60 != -2147 then + return -1 +endi +sql select cast(c4 as timestamp) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != @70-01-01 08:00:00.001@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != @70-01-01 08:00:00.002@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @70-01-01 08:00:00.004@ then + return -1 +endi +if $data50 != @70-01-26 04:31:23.647@ then + return -1 +endi +if $data60 != @69-12-07 11:28:37.-647@ then + return -1 +endi +sql select cast(c4 as nchar(13)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 2147483647 then + return -1 +endi +if $data60 != -2147483647 then + return -1 +endi +sql select cast(c4 as nchar(3)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 214 then + return -1 +endi +if $data60 != -21 then + return -1 +endi +sql select cast(c4 as bigint unsigned) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 2147483647 then + return -1 +endi +if $data60 != 18446744071562067969 then + return -1 +endi + +print "test bigint column" + +sql select cast(c5 as bigint) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 9223372036854775807 then + return -1 +endi +if $data60 != -9223372036854775807 then + return -1 +endi +sql select cast(c5 as binary(20)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 9223372036854775807 then + return -1 +endi +if $data60 != -9223372036854775807 then + return -1 +endi +sql select cast(c5 as binary(5)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 92233 then + return -1 +endi +if $data60 != -9223 then + return -1 +endi +sql select cast(c5 as timestamp) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != @70-01-01 08:00:00.001@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != @70-01-01 08:00:00.003@ then + return -1 +endi +if $data40 != @70-01-01 08:00:00.004@ then + return -1 +endi +sql select cast(c5 as nchar(20)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 9223372036854775807 then + return -1 +endi +if $data60 != -9223372036854775807 then + return -1 +endi +sql select cast(c5 as nchar(6)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 922337 then + return -1 +endi +if $data60 != -92233 then + return -1 +endi +sql select cast(c5 as bigint unsigned) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 9223372036854775807 then + return -1 +endi +if $data60 != 9223372036854775809 then + return -1 +endi + +print "test float column" + +sql select cast(c6 as bigint) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != NULL then + return -1 +endi +if $data60 != NULL then + return -1 +endi +sql select cast(c6 as binary(60)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1.000000 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2.000000 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4.000000 then + return -1 +endi +if $data50 != 340282346638528859811704183484516925440.000000 then + return -1 +endi +if $data60 != -340282346638528859811704183484516925440.000000 then + return -1 +endi +sql select cast(c6 as binary(5)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1.000 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2.000 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4.000 then + return -1 +endi +if $data50 != 34028 then + return -1 +endi +if $data60 != -3402 then + return -1 +endi +sql select cast(c6 as timestamp) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != @70-01-01 08:00:00.001@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != @70-01-01 08:00:00.002@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @70-01-01 08:00:00.004@ then + return -1 +endi +if $data50 != NULL then + return -1 +endi +if $data60 != NULL then + return -1 +endi +sql select cast(c6 as nchar(50)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1.000000 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2.000000 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4.000000 then + return -1 +endi +if $data50 != 340282346638528859811704183484516925440.000000 then + return -1 +endi +if $data60 != -340282346638528859811704183484516925440.000000 then + return -1 +endi +sql select cast(c6 as nchar(6)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1.0000 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2.0000 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4.0000 then + return -1 +endi +if $data50 != 340282 then + return -1 +endi +if $data60 != -34028 then + return -1 +endi +sql select cast(c6 as bigint unsigned) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi + + +print "test double column" + +sql select cast(c7 as bigint) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != NULL then + return -1 +endi +if $data60 != NULL then + return -1 +endi +sql select cast(c7 as binary(400)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1.000000 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3.000000 then + return -1 +endi +if $data40 != 4.000000 then + return -1 +endi +if $data50 != 179769000000000006323030492138942643493033036433685336215410983289126434148906289940615299632196609445533816320312774433484859900046491141051651091672734470972759941382582304802812882753059262973637182942535982636884444611376868582636745405553206881859340916340092953230149901406738427651121855107737424232448.000000 then + return -1 +endi +if $data60 != -179769000000000006323030492138942643493033036433685336215410983289126434148906289940615299632196609445533816320312774433484859900046491141051651091672734470972759941382582304802812882753059262973637182942535982636884444611376868582636745405553206881859340916340092953230149901406738427651121855107737424232448.000000 then + return -1 +endi +sql select cast(c7 as binary(5)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1.000 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3.000 then + return -1 +endi +if $data40 != 4.000 then + return -1 +endi +if $data50 != 17976 then + return -1 +endi +if $data60 != -1797 then + return -1 +endi +sql select cast(c7 as timestamp) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != @70-01-01 08:00:00.001@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != @70-01-01 08:00:00.003@ then + return -1 +endi +if $data40 != @70-01-01 08:00:00.004@ then + return -1 +endi +if $data50 != NULL then + return -1 +endi +if $data60 != NULL then + return -1 +endi +sql select cast(c7 as nchar(500)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1.000000 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3.000000 then + return -1 +endi +if $data40 != 4.000000 then + return -1 +endi +if $data50 != 179769000000000006323030492138942643493033036433685336215410983289126434148906289940615299632196609445533816320312774433484859900046491141051651091672734470972759941382582304802812882753059262973637182942535982636884444611376868582636745405553206881859340916340092953230149901406738427651121855107737424232448.000000 then + return -1 +endi +if $data60 != -179769000000000006323030492138942643493033036433685336215410983289126434148906289940615299632196609445533816320312774433484859900046491141051651091672734470972759941382582304802812882753059262973637182942535982636884444611376868582636745405553206881859340916340092953230149901406738427651121855107737424232448.000000 then + return -1 +endi +sql select cast(c7 as nchar(6)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1.0000 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3.0000 then + return -1 +endi +if $data40 != 4.0000 then + return -1 +endi +if $data50 != 179769 then + return -1 +endi +if $data60 != -17976 then + return -1 +endi +sql select cast(c7 as bigint unsigned) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi + + +print "test binary column" + +sql select cast(c8 as bigint) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 123 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 234 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 456 then + return -1 +endi +if $data50 != 567 then + return -1 +endi +if $data60 != 678 then + return -1 +endi +sql select cast(c8 as binary(3)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 123 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 234 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 456 then + return -1 +endi +if $data50 != 567 then + return -1 +endi +if $data60 != 678 then + return -1 +endi +sql select cast(c8 as binary(2)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 12 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 23 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 45 then + return -1 +endi +if $data50 != 56 then + return -1 +endi +if $data60 != 67 then + return -1 +endi +sql select cast(c8 as nchar(4)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 123 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 234 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 456 then + return -1 +endi +if $data50 != 567 then + return -1 +endi +if $data60 != 678 then + return -1 +endi +sql select cast(c8 as nchar(1)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 5 then + return -1 +endi +if $data60 != 6 then + return -1 +endi +sql select cast(c8 as bigint unsigned) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 123 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 234 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 456 then + return -1 +endi +if $data50 != 567 then + return -1 +endi +if $data60 != 678 then + return -1 +endi + + +print "test nchar column" + +sql select cast(c9 as bigint) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1234 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3456 then + return -1 +endi +if $data40 != 4567 then + return -1 +endi +if $data50 != 5678 then + return -1 +endi +if $data60 != 6789 then + return -1 +endi +sql select cast(c9 as nchar(5)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1234 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3456 then + return -1 +endi +if $data40 != 4567 then + return -1 +endi +if $data50 != 5678 then + return -1 +endi +if $data60 != 6789 then + return -1 +endi +sql select cast(c9 as nchar(2)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 12 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 34 then + return -1 +endi +if $data40 != 45 then + return -1 +endi +if $data50 != 56 then + return -1 +endi +if $data60 != 67 then + return -1 +endi +sql select cast(c9 as bigint unsigned) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1234 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3456 then + return -1 +endi +if $data40 != 4567 then + return -1 +endi +if $data50 != 5678 then + return -1 +endi +if $data60 != 6789 then + return -1 +endi + + +print "test utinyint column" + +sql select cast(c10 as bigint) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 254 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c10 as binary(10)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 254 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c10 as binary(1)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 2 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c10 as timestamp) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != @70-01-01 08:00:00.001@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != @70-01-01 08:00:00.002@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @70-01-01 08:00:00.004@ then + return -1 +endi +if $data50 != @70-01-01 08:00:00.254@ then + return -1 +endi +if $data60 != @70-01-01 08:00:00.000@ then + return -1 +endi +sql select cast(c10 as nchar(10)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 254 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c10 as nchar(2)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 25 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c10 as bigint unsigned) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 254 then + return -1 +endi +if $data60 != 0 then + return -1 +endi + + +print "test usmallint column" + +sql select cast(c11 as bigint) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 65534 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c11 as binary(10)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 65534 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c11 as binary(1)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 6 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c11 as timestamp) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != @70-01-01 08:00:00.001@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != @70-01-01 08:00:00.003@ then + return -1 +endi +if $data40 != @70-01-01 08:00:00.004@ then + return -1 +endi +if $data50 != @70-01-01 08:01:05.534@ then + return -1 +endi +if $data60 != @70-01-01 08:00:00.000@ then + return -1 +endi +sql select cast(c11 as nchar(10)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 65534 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c11 as nchar(2)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 65 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c11 as bigint unsigned) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 65534 then + return -1 +endi +if $data60 != 0 then + return -1 +endi + + +print "test uint column" + +sql select cast(c12 as bigint) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 4294967294 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c12 as binary(10)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 4294967294 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c12 as binary(2)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 42 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c12 as timestamp) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != @70-01-01 08:00:00.001@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != @70-01-01 08:00:00.002@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != @70-01-01 08:00:00.004@ then + return -1 +endi +if $data50 != @70-02-20 01:02:47.294@ then + return -1 +endi +if $data60 != @70-01-01 08:00:00.000@ then + return -1 +endi +sql select cast(c12 as nchar(10)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 4294967294 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c12 as nchar(1)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 4 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c12 as bigint unsigned) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 4294967294 then + return -1 +endi +if $data60 != 0 then + return -1 +endi + + +print "test ubigint column" + +sql select cast(c13 as bigint) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 9223372036854775807 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c13 as binary(20)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 9223372036854775807 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c13 as binary(1)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 9 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c13 as timestamp) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != @70-01-01 08:00:00.001@ then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != @70-01-01 08:00:00.003@ then + return -1 +endi +if $data40 != @70-01-01 08:00:00.004@ then + return -1 +endi +if $data60 != @70-01-01 08:00:00.000@ then + return -1 +endi +sql select cast(c13 as nchar(20)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 9223372036854775807 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c13 as nchar(2)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 92 then + return -1 +endi +if $data60 != 0 then + return -1 +endi +sql select cast(c13 as bigint unsigned) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 9223372036854775807 then + return -1 +endi +if $data60 != 0 then + return -1 +endi diff --git a/tests/script/general/compute/cast_query2.sim b/tests/script/general/compute/cast_query2.sim new file mode 100644 index 0000000000000000000000000000000000000000..6cbb6a11ccfab156dea06d86e27a7e7810297f4a --- /dev/null +++ b/tests/script/general/compute/cast_query2.sim @@ -0,0 +1,1265 @@ +sleep 100 +sql connect + +sql use db; + + +print "test arithmetic" + +sql select cast(c2 + c3 as bigint) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 2 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 8 then + return -1 +endi +if $data50 != 32894 then + return -1 +endi +if $data60 != -32894 then + return -1 +endi +sql select cast((c2 + c3) as bigint) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 2 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 8 then + return -1 +endi +if $data50 != 32894 then + return -1 +endi +if $data60 != -32894 then + return -1 +endi +sql select cast((c2 * c3)+c4-6 as bigint) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != -4 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 14 then + return -1 +endi +if $data50 != 2151645050 then + return -1 +endi +if $data60 != -2143322244 then + return -1 +endi +sql select cast(11 as bigint)+c2 from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 12.000000000 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 13.000000000 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 15.000000000 then + return -1 +endi +if $data50 != 138.000000000 then + return -1 +endi +if $data60 != -116.000000000 then + return -1 +endi +sql select cast(c1 as bigint)+c2 from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 3.000000000 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 5.000000000 then + return -1 +endi +if $data50 != 128.000000000 then + return -1 +endi +if $data60 != -126.000000000 then + return -1 +endi +sql select cast(c2 as bigint)+11 from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 12.000000000 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 13.000000000 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 15.000000000 then + return -1 +endi +if $data50 != 138.000000000 then + return -1 +endi +if $data60 != -116.000000000 then + return -1 +endi +sql select cast(c2 as bigint)+11+floor(c2) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 13.000000000 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 15.000000000 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 19.000000000 then + return -1 +endi +if $data50 != 265.000000000 then + return -1 +endi +if $data60 != -243.000000000 then + return -1 +endi + +print "test function,column/tag/tbname/ts/_C0/_c0/scalar/agg/selectivity/self" + +sql select cast(c1 as bigint),c1,c2 from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data11 != 1 then + return -1 +endi +if $data12 != NULL then + return -1 +endi +if $data20 != 1 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data22 != 2 then + return -1 +endi +if $data30 != 0 then + return -1 +endi +if $data31 != 0 then + return -1 +endi +if $data32 != NULL then + return -1 +endi +if $data40 != 1 then + return -1 +endi +if $data41 != 1 then + return -1 +endi +if $data42 != 4 then + return -1 +endi +if $data50 != 1 then + return -1 +endi +if $data51 != 1 then + return -1 +endi +if $data52 != 127 then + return -1 +endi +if $data60 != 1 then + return -1 +endi +if $data61 != 1 then + return -1 +endi +if $data62 != -127 then + return -1 +endi +sql select cast(c1 as bigint),t1,ts,tbname,_C0,_c0 from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != @21-11-11 09:00:00.000@ then + return -1 +endi +if $data03 != tb1 then + return -1 +endi +if $data04 != @21-11-11 09:00:00.000@ then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data11 != 1 then + return -1 +endi +if $data12 != @21-11-11 09:00:01.000@ then + return -1 +endi +if $data13 != tb1 then + return -1 +endi +if $data14 != @21-11-11 09:00:01.000@ then + return -1 +endi +if $data20 != 1 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data22 != @21-11-11 09:00:02.000@ then + return -1 +endi +if $data23 != tb1 then + return -1 +endi +if $data24 != @21-11-11 09:00:02.000@ then + return -1 +endi +if $data30 != 0 then + return -1 +endi +if $data31 != 1 then + return -1 +endi +if $data32 != @21-11-11 09:00:03.000@ then + return -1 +endi +if $data33 != tb1 then + return -1 +endi +if $data34 != @21-11-11 09:00:03.000@ then + return -1 +endi +if $data40 != 1 then + return -1 +endi +if $data41 != 1 then + return -1 +endi +if $data42 != @21-11-11 09:00:04.000@ then + return -1 +endi +if $data43 != tb1 then + return -1 +endi +if $data44 != @21-11-11 09:00:04.000@ then + return -1 +endi +if $data50 != 1 then + return -1 +endi +if $data51 != 1 then + return -1 +endi +if $data52 != @21-11-11 09:00:05.000@ then + return -1 +endi +if $data53 != tb1 then + return -1 +endi +if $data54 != @21-11-11 09:00:05.000@ then + return -1 +endi +if $data60 != 1 then + return -1 +endi +if $data61 != 1 then + return -1 +endi +if $data62 != @21-11-11 09:00:06.000@ then + return -1 +endi +if $data63 != tb1 then + return -1 +endi +if $data64 != @21-11-11 09:00:06.000@ then + return -1 +endi +sql select cast(c1 as bigint),floor(c3) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data11 != NULL then + return -1 +endi +if $data20 != 1 then + return -1 +endi +if $data21 != NULL then + return -1 +endi +if $data30 != 0 then + return -1 +endi +if $data31 != 3 then + return -1 +endi +if $data40 != 1 then + return -1 +endi +if $data41 != 4 then + return -1 +endi +if $data50 != 1 then + return -1 +endi +if $data51 != 32767 then + return -1 +endi +if $data60 != 1 then + return -1 +endi +if $data61 != -32767 then + return -1 +endi +sql select cast(c1 as bigint),cast(c2+c3 as binary(6)) from tb1; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data01 != 2.0000 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data11 != NULL then + return -1 +endi +if $data20 != 1 then + return -1 +endi +if $data21 != NULL then + return -1 +endi +if $data30 != 0 then + return -1 +endi +if $data31 != NULL then + return -1 +endi +if $data40 != 1 then + return -1 +endi +if $data41 != 8.0000 then + return -1 +endi +if $data50 != 1 then + return -1 +endi +if $data51 != 32894. then + return -1 +endi +if $data60 != 1 then + return -1 +endi +if $data61 != -32894 then + return -1 +endi + +sql select cast(c2+c3 as binary(6)) from tb1 where c2 is not null and c3 is not null; +if $rows != 4 then + return -1 +endi +if $data00 != 2.0000 then + return -1 +endi +if $data10 != 8.0000 then + return -1 +endi +if $data20 != 32894. then + return -1 +endi +if $data30 != -32894 then + return -1 +endi +sql select cast(c2 as binary(6)) from tb1 order by ts desc; +if $rows != 7 then + return -1 +endi +if $data00 != -127 then + return -1 +endi +if $data10 != 127 then + return -1 +endi +if $data20 != 4 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 2 then + return -1 +endi +if $data50 != NULL then + return -1 +endi +if $data60 != 1 then + return -1 +endi + +sql select cast(c2+c3 as binary(6)) from tb1 order by ts desc; +if $rows != 7 then + return -1 +endi +if $data00 != -32894 then + return -1 +endi +if $data10 != 32894. then + return -1 +endi +if $data20 != 8.0000 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != NULL then + return -1 +endi +if $data50 != NULL then + return -1 +endi +if $data60 != 2.0000 then + return -1 +endi +sql select cast(c2+c3 as binary(6)) from tb1 order by ts desc limit 3 offset 2; +if $rows != 3 then + return -1 +endi +if $data00 != 8.0000 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi + +sql select cast(c2 as binary(2)) from stb1; +if $rows != 14 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 12 then + return -1 +endi +if $data60 != -1 then + return -1 +endi +if $data70 != 1 then + return -1 +endi +if $data80 != 2 then + return -1 +endi +if $data90 != 3 then + return -1 +endi +sql select cast(c2 as binary(2)) from stb1 order by ts desc; +if $rows != 14 then + return -1 +endi +if $data00 != -1 then +if $data00 != 7 then +return -1 +endi +endi +if $data10 != 7 then +if $data10 != -1 then + return -1 +endi +endi +if $data20 != 6 then +if $data20 != 12 then + return -1 +endi +endi +if $data30 != 12 then +if $data30 != 6 then + return -1 +endi +endi +if $data40 != 4 then +if $data40 != 5 then + return -1 +endi +endi +if $data50 != 5 then +if $data50 != 4 then + return -1 +endi +endi +if $data60 != 4 then +if $data60 != NULL then + return -1 +endi +endi +if $data70 != NULL then +if $data70 != 4 then + return -1 +endi +endi +if $data80 != 2 then +if $data80 != 3 then + return -1 +endi +endi +if $data90 != 3 then +if $data90 != 2 then + return -1 +endi +endi + +sql select cast(c4 as bigint),t1 from stb1 order by ts desc; +if $rows != 14 then + return -1 +endi +if $data00 != -2147483647 then +if $data00 != 7 then + return -1 +endi +endi +if $data01 != 1 then +if $data01 != 2 then + return -1 +endi +endi +if $data10 != 7 then +if $data10 != -2147483647 then + return -1 +endi +endi +if $data11 != 1 then +if $data11 != 2 then + return -1 +endi +endi +if $data20 != 6 then +if $data20 != 2147483647 then + return -1 +endi +endi +if $data21 != 2 then +if $data21 != 1 then + return -1 +endi +endi +if $data30 != 2147483647 then +if $data30 != 6 then + return -1 +endi +endi +if $data31 != 1 then +if $data31 != 2 then + return -1 +endi +endi +if $data40 != 4 then +if $data40 != 5 then + return -1 +endi +endi +if $data41 != 1 then +if $data41 != 2 then + return -1 +endi +endi +if $data50 != 5 then +if $data50 != 4 then + return -1 +endi +endi +if $data51 != 1 then +if $data51 != 2 then + return -1 +endi +endi +if $data60 != 4 then +if $data60 != NULL then + return -1 +endi +endi +if $data61 != 2 then +if $data61 != 1 then + return -1 +endi +endi +if $data70 != NULL then +if $data70 != 4 then + return -1 +endi +endi +if $data71 != 1 then +if $data71 != 2 then + return -1 +endi +endi +if $data80 != 2 then +if $data80 != 2 then + return -1 +endi +endi +if $data81 != 1 then +if $data81 != 2 then + return -1 +endi +endi +if $data90 != 2 then + return -1 +endi +if $data91 != 2 then +if $data91 != 1 then + return -1 +endi +endi + +sql select cast(c3 as bigint),tbname from stb1; +if $rows != 14 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data01 != tb1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data11 != tb1 then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data21 != tb1 then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data31 != tb1 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data41 != tb1 then + return -1 +endi +if $data50 != 32767 then + return -1 +endi +if $data51 != tb1 then + return -1 +endi +if $data60 != -32767 then + return -1 +endi +if $data61 != tb1 then + return -1 +endi +if $data70 != 1 then + return -1 +endi +if $data71 != tb2 then + return -1 +endi +if $data80 != 2 then + return -1 +endi +if $data81 != tb2 then + return -1 +endi +if $data90 != 3 then + return -1 +endi +if $data91 != tb2 then + return -1 +endi + +sql select cast(c3 as bigint),tbname from stb1 where t1 > 1; +if $rows != 7 then + return -1 +endi + +sql select cast(c8 as bigint),cast(c9 as bigint) from tbn; +if $rows != 7 then + return -1 +endi +if $data00 != 111 then + return -1 +endi +if $data01 != 1111 then + return -1 +endi +if $data10 != 222 then + return -1 +endi +if $data11 != 2222 then + return -1 +endi +if $data20 != 333 then + return -1 +endi +if $data21 != 3333 then + return -1 +endi +if $data30 != 444 then + return -1 +endi +if $data31 != 4444 then + return -1 +endi +if $data40 != 555 then + return -1 +endi +if $data41 != 5555 then + return -1 +endi +if $data50 != 666 then + return -1 +endi +if $data51 != 6666 then + return -1 +endi +if $data60 != 777 then + return -1 +endi +if $data61 != 7777 then + return -1 +endi + +sql select cast(c8 as bigint),cast(c9 as bigint) from tbn order by ts desc; +if $rows != 7 then + return -1 +endi +if $data00 != 777 then + return -1 +endi +if $data01 != 7777 then + return -1 +endi +if $data10 != 666 then + return -1 +endi +if $data11 != 6666 then + return -1 +endi +if $data20 != 555 then + return -1 +endi +if $data21 != 5555 then + return -1 +endi +if $data30 != 444 then + return -1 +endi +if $data31 != 4444 then + return -1 +endi +if $data40 != 333 then + return -1 +endi +if $data41 != 3333 then + return -1 +endi +if $data50 != 222 then + return -1 +endi +if $data51 != 2222 then + return -1 +endi +if $data60 != 111 then + return -1 +endi +if $data61 != 1111 then + return -1 +endi + +sql select cast(cast(c8 as binary(2)) as bigint) from tbn; +if $rows != 7 then + return -1 +endi +if $data00 != 11 then + return -1 +endi +if $data10 != 22 then + return -1 +endi +if $data20 != 33 then + return -1 +endi +if $data30 != 44 then + return -1 +endi +if $data40 != 55 then + return -1 +endi +if $data50 != 66 then + return -1 +endi +if $data60 != 77 then + return -1 +endi + +sql select cast(cast(cast(cast(ts as bigint) as binary(5)) as bigint)+cast(cast(cast(ts as bigint) as binary(2)) as bigint) as bigint) from tbn; +if $rows != 7 then + return -1 +endi +if $data00 != 16381 then + return -1 +endi +if $data10 != 16381 then + return -1 +endi +if $data20 != 16381 then + return -1 +endi +if $data30 != 16381 then + return -1 +endi +if $data40 != 16381 then + return -1 +endi +if $data50 != 16381 then + return -1 +endi +if $data60 != 16381 then + return -1 +endi + +sql select cast(cast(cast(cast(ts as bigint) as binary(5)) as bigint)+cast(cast(cast(ts as bigint) as binary(2)) as bigint) as bigint) from tb3; +if $rows != 0 then + return -1 +endi + +sql select cast(a as bigint) from (select avg(c2) as a from stb1 interval(1s)); +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 2 then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != 4 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 66 then + return -1 +endi +if $data60 != -60 then + return -1 +endi + +sql select cast(c2 as binary(10)) from (select * from stb1); +if $rows != 14 then + return -1 +endi + +sql select cast(a as binary(10)) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)); +if $rows != 10 then + return -1 +endi +if $data00 != 1.000000 then + return -1 +endi +if $data10 != 2.000000 then + return -1 +endi +if $data20 != 2.500000 then + return -1 +endi +if $data30 != 4.000000 then + return -1 +endi +if $data40 != 4.500000 then + return -1 +endi +if $data50 != 66.500000 then + return -1 +endi +if $data60 != -60.000000 then + return -1 +endi +if $data70 != NULL then + return -1 +endi +if $data80 != NULL then + return -1 +endi +if $data90 != NULL then + return -1 +endi + +sql select cast(a as bigint) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts; +if $rows != 10 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 2 then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != 4 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 66 then + return -1 +endi +if $data60 != -60 then + return -1 +endi +if $data70 != NULL then + return -1 +endi +if $data80 != NULL then + return -1 +endi +if $data90 != NULL then + return -1 +endi + +sql select cast(a as bigint) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc; +if $rows != 10 then + return -1 +endi +if $data00 != NULL then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != -60 then + return -1 +endi +if $data40 != 66 then + return -1 +endi +if $data50 != 4 then + return -1 +endi +if $data60 != 4 then + return -1 +endi +if $data70 != 2 then + return -1 +endi +if $data80 != 2 then + return -1 +endi +if $data90 != 1 then + return -1 +endi + +sql select cast(a as bigint) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc; +if $rows != 10 then + return -1 +endi +if $data00 != NULL then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 66 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 4 then + return -1 +endi +if $data60 != 2 then + return -1 +endi +if $data70 != 2 then + return -1 +endi +if $data80 != 1 then + return -1 +endi +if $data90 != -60 then + return -1 +endi + +sql select cast(a as bigint) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a; +if $rows != 10 then + return -1 +endi +if $data00 != -60 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != 2 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 4 then + return -1 +endi +if $data60 != 66 then + return -1 +endi +if $data70 != NULL then + return -1 +endi +if $data80 != NULL then + return -1 +endi +if $data90 != NULL then + return -1 +endi + +sql select cast(a as bigint) from (select cast(c2 as binary(2)) as a from tb1); +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 12 then + return -1 +endi +if $data60 != -1 then + return -1 +endi + +sql select cast(tb1.c3 as binary(10)),cast(tb2.c3 as binary(10)) from tb1,tb2 where tb1.ts=tb2.ts; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data21 != 3 then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data31 != 4 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data41 != 5 then + return -1 +endi +if $data50 != 32767 then + return -1 +endi +if $data51 != 6 then + return -1 +endi +if $data60 != -32767 then + return -1 +endi +if $data61 != 7 then + return -1 +endi + +sql select cast(c3 as binary(10)) from tb1 union all select cast(c3 as binary(10)) from tb2; +if $rows != 14 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != 3 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data50 != 32767 then + return -1 +endi +if $data60 != -32767 then + return -1 +endi +if $data70 != 1 then + return -1 +endi +if $data80 != 2 then + return -1 +endi +if $data90 != 3 then + return -1 +endi + + + \ No newline at end of file diff --git a/tests/script/general/compute/cast_query3.sim b/tests/script/general/compute/cast_query3.sim new file mode 100644 index 0000000000000000000000000000000000000000..3b5ecc41b32a6ed5646f08fa979e85b62ba32467 --- /dev/null +++ b/tests/script/general/compute/cast_query3.sim @@ -0,0 +1,63 @@ +sleep 100 +sql connect + +sql use db; + +sql select cast(stb1.c4 as binary(10)),cast(stba.c5 as binary(10)) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts; +if $rows != 7 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data11 != 2 then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data21 != 3 then + return -1 +endi +if $data30 != NULL then + return -1 +endi +if $data31 != 4 then + return -1 +endi +if $data40 != 4 then + return -1 +endi +if $data41 != 5 then + return -1 +endi +if $data50 != 2147483647 then + return -1 +endi +if $data51 != 6 then + return -1 +endi +if $data60 != -214748364 then + return -1 +endi +if $data61 != 7 then + return -1 +endi + +sql select cast(c4 as binary(10)) as a from stb1 union all select cast(c5 as binary(10)) as a from stba; +if $rows != 44 then + return -1 +endi + +sql select cast(c2 as bigint) from stba; +if $rows != 30 then + return -1 +endi + + \ No newline at end of file