commit
c4f96ffc98
|
@ -118,7 +118,7 @@ static bool hasNormalColumnFilter(SQueryInfo* pQueryInfo);
|
|||
|
||||
static int32_t validateLimitNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSqlNode, SSqlObj* pSql);
|
||||
static int32_t parseCreateDBOptions(SSqlCmd* pCmd, SCreateDbInfo* pCreateDbSql);
|
||||
static int32_t getColumnIndexByName(SSqlCmd* pCmd, const SStrToken* pToken, SQueryInfo* pQueryInfo, SColumnIndex* pIndex);
|
||||
static int32_t getColumnIndexByName(const SStrToken* pToken, SQueryInfo* pQueryInfo, SColumnIndex* pIndex, char* msg);
|
||||
static int32_t getTableIndexByName(SStrToken* pToken, SQueryInfo* pQueryInfo, SColumnIndex* pIndex);
|
||||
|
||||
static int32_t getTableIndexImpl(SStrToken* pTableToken, SQueryInfo* pQueryInfo, SColumnIndex* pIndex);
|
||||
|
@ -989,7 +989,7 @@ static int32_t validateStateWindowNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SS
|
|||
}
|
||||
|
||||
SColumnIndex index = COLUMN_INDEX_INITIALIZER;
|
||||
if (getColumnIndexByName(pCmd, col, pQueryInfo, &index) != TSDB_CODE_SUCCESS) {
|
||||
if (getColumnIndexByName(col, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
||||
}
|
||||
|
||||
|
@ -1055,7 +1055,7 @@ int32_t validateSessionNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode * pS
|
|||
}
|
||||
|
||||
SColumnIndex index = COLUMN_INDEX_INITIALIZER;
|
||||
if (getColumnIndexByName(pCmd, col, pQueryInfo, &index) != TSDB_CODE_SUCCESS) {
|
||||
if (getColumnIndexByName(col, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3);
|
||||
}
|
||||
if (index.columnIndex != PRIMARYKEY_TIMESTAMP_COL_INDEX) {
|
||||
|
@ -1197,16 +1197,17 @@ int32_t tscSetTableFullName(SName* pName, SStrToken* pTableName, SSqlObj* pSql)
|
|||
} else { // get current DB name first, and then set it into path
|
||||
char* t = cloneCurrentDBName(pSql);
|
||||
if (strlen(t) == 0) {
|
||||
tfree(t);
|
||||
return TSDB_CODE_TSC_DB_NOT_SELECTED;
|
||||
}
|
||||
|
||||
code = tNameFromString(pName, t, T_NAME_ACCT | T_NAME_DB);
|
||||
if (code != 0) {
|
||||
free(t);
|
||||
tfree(t);
|
||||
return TSDB_CODE_TSC_DB_NOT_SELECTED;
|
||||
}
|
||||
|
||||
free(t);
|
||||
tfree(t);
|
||||
|
||||
if (pTableName->n >= TSDB_TABLE_NAME_LEN) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
||||
|
@ -2024,7 +2025,7 @@ int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t
|
|||
} else if (optr == TK_ID) {
|
||||
SColumnIndex index = COLUMN_INDEX_INITIALIZER;
|
||||
|
||||
if (getColumnIndexByName(pCmd, &pItem->pNode->colInfo, pQueryInfo, &index) != TSDB_CODE_SUCCESS) {
|
||||
if (getColumnIndexByName(&pItem->pNode->colInfo, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg0);
|
||||
}
|
||||
|
||||
|
@ -2209,7 +2210,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
|
|||
pExpr = tscExprAppend(pQueryInfo, functionId, &index, TSDB_DATA_TYPE_BIGINT, size, getNewResColId(pCmd), size, false);
|
||||
} else {
|
||||
// count the number of table created according to the super table
|
||||
if (getColumnIndexByName(pCmd, pToken, pQueryInfo, &index) != TSDB_CODE_SUCCESS) {
|
||||
if (getColumnIndexByName(pToken, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3);
|
||||
}
|
||||
|
||||
|
@ -2282,7 +2283,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
|
|||
}
|
||||
|
||||
SColumnIndex index = COLUMN_INDEX_INITIALIZER;
|
||||
if ((getColumnIndexByName(pCmd, &pParamElem->pNode->colInfo, pQueryInfo, &index) != TSDB_CODE_SUCCESS)) {
|
||||
if ((getColumnIndexByName(&pParamElem->pNode->colInfo, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS)) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3);
|
||||
}
|
||||
|
||||
|
@ -2447,7 +2448,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
|
|||
}
|
||||
|
||||
} else {
|
||||
if (getColumnIndexByName(pCmd, &pParamElem->pNode->colInfo, pQueryInfo, &index) != TSDB_CODE_SUCCESS) {
|
||||
if (getColumnIndexByName(&pParamElem->pNode->colInfo, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3);
|
||||
}
|
||||
|
||||
|
@ -2519,7 +2520,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
|
|||
}
|
||||
|
||||
SColumnIndex index = COLUMN_INDEX_INITIALIZER;
|
||||
if (getColumnIndexByName(pCmd, &pParamElem->pNode->colInfo, pQueryInfo, &index) != TSDB_CODE_SUCCESS) {
|
||||
if (getColumnIndexByName(&pParamElem->pNode->colInfo, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3);
|
||||
}
|
||||
|
||||
|
@ -2631,7 +2632,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
|
|||
tSqlExpr* pParam = pParamItem->pNode;
|
||||
|
||||
SColumnIndex index = COLUMN_INDEX_INITIALIZER;
|
||||
if (getColumnIndexByName(pCmd, &pParam->colInfo, pQueryInfo, &index) != TSDB_CODE_SUCCESS) {
|
||||
if (getColumnIndexByName(&pParam->colInfo, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3);
|
||||
}
|
||||
|
||||
|
@ -2781,7 +2782,7 @@ static int16_t doGetColumnIndex(SQueryInfo* pQueryInfo, int32_t index, SStrToken
|
|||
return columnIndex;
|
||||
}
|
||||
|
||||
int32_t doGetColumnIndexByName(SSqlCmd* pCmd, SStrToken* pToken, SQueryInfo* pQueryInfo, SColumnIndex* pIndex) {
|
||||
int32_t doGetColumnIndexByName(SStrToken* pToken, SQueryInfo* pQueryInfo, SColumnIndex* pIndex, char* msg) {
|
||||
const char* msg0 = "ambiguous column name";
|
||||
const char* msg1 = "invalid column name";
|
||||
|
||||
|
@ -2797,7 +2798,7 @@ int32_t doGetColumnIndexByName(SSqlCmd* pCmd, SStrToken* pToken, SQueryInfo* pQu
|
|||
|
||||
if (colIndex != COLUMN_INDEX_INITIAL_VAL) {
|
||||
if (pIndex->columnIndex != COLUMN_INDEX_INITIAL_VAL) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg0);
|
||||
return invalidOperationMsg(msg, msg0);
|
||||
} else {
|
||||
pIndex->tableIndex = i;
|
||||
pIndex->columnIndex = colIndex;
|
||||
|
@ -2812,7 +2813,7 @@ int32_t doGetColumnIndexByName(SSqlCmd* pCmd, SStrToken* pToken, SQueryInfo* pQu
|
|||
}
|
||||
|
||||
if (pIndex->columnIndex == COLUMN_INDEX_INITIAL_VAL) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
||||
return invalidOperationMsg(msg, msg1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2862,7 +2863,7 @@ int32_t getTableIndexByName(SStrToken* pToken, SQueryInfo* pQueryInfo, SColumnIn
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t getColumnIndexByName(SSqlCmd* pCmd, const SStrToken* pToken, SQueryInfo* pQueryInfo, SColumnIndex* pIndex) {
|
||||
int32_t getColumnIndexByName(const SStrToken* pToken, SQueryInfo* pQueryInfo, SColumnIndex* pIndex, char* msg) {
|
||||
if (pQueryInfo->pTableMetaInfo == NULL || pQueryInfo->numOfTables == 0) {
|
||||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||
}
|
||||
|
@ -2873,7 +2874,7 @@ int32_t getColumnIndexByName(SSqlCmd* pCmd, const SStrToken* pToken, SQueryInfo*
|
|||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||
}
|
||||
|
||||
return doGetColumnIndexByName(pCmd, &tmpToken, pQueryInfo, pIndex);
|
||||
return doGetColumnIndexByName(&tmpToken, pQueryInfo, pIndex, msg);
|
||||
}
|
||||
|
||||
int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||
|
@ -3233,7 +3234,7 @@ int32_t validateGroupbyNode(SQueryInfo* pQueryInfo, SArray* pList, SSqlCmd* pCmd
|
|||
SStrToken token = {pVar->nLen, pVar->nType, pVar->pz};
|
||||
|
||||
SColumnIndex index = COLUMN_INDEX_INITIALIZER;
|
||||
if (getColumnIndexByName(pCmd, &token, pQueryInfo, &index) != TSDB_CODE_SUCCESS) {
|
||||
if (getColumnIndexByName(&token, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
||||
}
|
||||
|
||||
|
@ -3614,7 +3615,7 @@ static int32_t getColumnQueryCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSq
|
|||
return getColumnQueryCondInfo(pCmd, pQueryInfo, pExpr->pRight, pExpr->tokenId);
|
||||
} else { // handle leaf node
|
||||
SColumnIndex index = COLUMN_INDEX_INITIALIZER;
|
||||
if (getColumnIndexByName(pCmd, &pExpr->pLeft->colInfo, pQueryInfo, &index) != TSDB_CODE_SUCCESS) {
|
||||
if (getColumnIndexByName(&pExpr->pLeft->colInfo, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) {
|
||||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||
}
|
||||
|
||||
|
@ -3643,7 +3644,7 @@ static int32_t checkAndSetJoinCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tS
|
|||
}
|
||||
|
||||
SColumnIndex index = COLUMN_INDEX_INITIALIZER;
|
||||
if (getColumnIndexByName(pCmd, &pExpr->pLeft->colInfo, pQueryInfo, &index) != TSDB_CODE_SUCCESS) {
|
||||
if (getColumnIndexByName(&pExpr->pLeft->colInfo, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4);
|
||||
}
|
||||
|
||||
|
@ -3676,7 +3677,7 @@ static int32_t checkAndSetJoinCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tS
|
|||
int16_t leftIdx = index.tableIndex;
|
||||
|
||||
index = (SColumnIndex)COLUMN_INDEX_INITIALIZER;
|
||||
if (getColumnIndexByName(pCmd, &pExpr->pRight->colInfo, pQueryInfo, &index) != TSDB_CODE_SUCCESS) {
|
||||
if (getColumnIndexByName(&pExpr->pRight->colInfo, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4);
|
||||
}
|
||||
|
||||
|
@ -3746,7 +3747,7 @@ static int32_t validateSQLExpr(SSqlCmd* pCmd, tSqlExpr* pExpr, SQueryInfo* pQuer
|
|||
}
|
||||
|
||||
SColumnIndex index = COLUMN_INDEX_INITIALIZER;
|
||||
if (getColumnIndexByName(pCmd, &pExpr->colInfo, pQueryInfo, &index) != TSDB_CODE_SUCCESS) {
|
||||
if (getColumnIndexByName(&pExpr->colInfo, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) {
|
||||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||
}
|
||||
|
||||
|
@ -3795,6 +3796,7 @@ static int32_t validateSQLExpr(SSqlCmd* pCmd, tSqlExpr* pExpr, SQueryInfo* pQuer
|
|||
uint64_t id = -1;
|
||||
for(int32_t i = 0; i < inc; ++i) {
|
||||
SExprInfo* p1 = tscExprGet(pQueryInfo, i + outputIndex);
|
||||
|
||||
int16_t t = p1->base.resType;
|
||||
if (t == TSDB_DATA_TYPE_BINARY || t == TSDB_DATA_TYPE_NCHAR || t == TSDB_DATA_TYPE_BOOL || t == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||
|
@ -3802,7 +3804,10 @@ static int32_t validateSQLExpr(SSqlCmd* pCmd, tSqlExpr* pExpr, SQueryInfo* pQuer
|
|||
|
||||
if (i == 0) {
|
||||
id = p1->base.uid;
|
||||
} else if (id != p1->base.uid) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (id != p1->base.uid) {
|
||||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||
}
|
||||
}
|
||||
|
@ -3938,7 +3943,7 @@ static bool validateJoinExprNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr
|
|||
|
||||
SColumnIndex rightIndex = COLUMN_INDEX_INITIALIZER;
|
||||
|
||||
if (getColumnIndexByName(pCmd, &pRight->colInfo, pQueryInfo, &rightIndex) != TSDB_CODE_SUCCESS) {
|
||||
if (getColumnIndexByName(&pRight->colInfo, pQueryInfo, &rightIndex, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) {
|
||||
invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
||||
return false;
|
||||
}
|
||||
|
@ -4048,7 +4053,7 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSql
|
|||
int32_t ret = TSDB_CODE_SUCCESS;
|
||||
|
||||
SColumnIndex index = COLUMN_INDEX_INITIALIZER;
|
||||
if (getColumnIndexByName(pCmd, &pLeft->colInfo, pQueryInfo, &index) != TSDB_CODE_SUCCESS) {
|
||||
if (getColumnIndexByName(&pLeft->colInfo, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
||||
}
|
||||
|
||||
|
@ -4091,7 +4096,7 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSql
|
|||
|
||||
int16_t leftIdx = index.tableIndex;
|
||||
|
||||
if (getColumnIndexByName(pCmd, &pRight->colInfo, pQueryInfo, &index) != TSDB_CODE_SUCCESS) {
|
||||
if (getColumnIndexByName(&pRight->colInfo, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
||||
}
|
||||
|
||||
|
@ -4254,7 +4259,7 @@ static void doExtractExprForSTable(SSqlCmd* pCmd, tSqlExpr** pExpr, SQueryInfo*
|
|||
tSqlExpr* pLeft = (*pExpr)->pLeft;
|
||||
|
||||
SColumnIndex index = COLUMN_INDEX_INITIALIZER;
|
||||
if (getColumnIndexByName(pCmd, &pLeft->colInfo, pQueryInfo, &index) != TSDB_CODE_SUCCESS) {
|
||||
if (getColumnIndexByName(&pLeft->colInfo, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4421,7 +4426,7 @@ static int32_t getTimeRangeFromExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlE
|
|||
return getTimeRangeFromExpr(pCmd, pQueryInfo, pExpr->pRight);
|
||||
} else {
|
||||
SColumnIndex index = COLUMN_INDEX_INITIALIZER;
|
||||
if (getColumnIndexByName(pCmd, &pExpr->pLeft->colInfo, pQueryInfo, &index) != TSDB_CODE_SUCCESS) {
|
||||
if (getColumnIndexByName(&pExpr->pLeft->colInfo, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) {
|
||||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||
}
|
||||
|
||||
|
@ -5153,7 +5158,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
|
|||
SColumnIndex index = COLUMN_INDEX_INITIALIZER;
|
||||
|
||||
if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { // super table query
|
||||
if (getColumnIndexByName(pCmd, &columnName, pQueryInfo, &index) != TSDB_CODE_SUCCESS) {
|
||||
if (getColumnIndexByName(&columnName, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
||||
}
|
||||
|
||||
|
@ -5248,7 +5253,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
|
|||
pItem = taosArrayGet(pSqlNode->pSortOrder, 1);
|
||||
tVariant* pVar2 = &pItem->pVar;
|
||||
SStrToken cname = {pVar2->nLen, pVar2->nType, pVar2->pz};
|
||||
if (getColumnIndexByName(pCmd, &cname, pQueryInfo, &index) != TSDB_CODE_SUCCESS) {
|
||||
if (getColumnIndexByName(&cname, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
||||
}
|
||||
|
||||
|
@ -5262,7 +5267,7 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
|
|||
}
|
||||
|
||||
} else { // meter query
|
||||
if (getColumnIndexByName(pCmd, &columnName, pQueryInfo, &index) != TSDB_CODE_SUCCESS) {
|
||||
if (getColumnIndexByName(&columnName, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
||||
}
|
||||
if (index.columnIndex != PRIMARYKEY_TIMESTAMP_COL_INDEX && !isTopBottomQuery(pQueryInfo)) {
|
||||
|
@ -5357,28 +5362,29 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
|||
return code;
|
||||
}
|
||||
|
||||
char* pMsg = tscGetErrorMsgPayload(pCmd);
|
||||
STableMeta* pTableMeta = pTableMetaInfo->pTableMeta;
|
||||
|
||||
if (pAlterSQL->tableType == TSDB_SUPER_TABLE && !(UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo))) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg20);
|
||||
return invalidOperationMsg(pMsg, msg20);
|
||||
}
|
||||
|
||||
if (pAlterSQL->type == TSDB_ALTER_TABLE_ADD_TAG_COLUMN || pAlterSQL->type == TSDB_ALTER_TABLE_DROP_TAG_COLUMN ||
|
||||
pAlterSQL->type == TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN || pAlterSQL->type == TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN) {
|
||||
if (!UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3);
|
||||
return invalidOperationMsg(pMsg, msg3);
|
||||
}
|
||||
} else if ((pAlterSQL->type == TSDB_ALTER_TABLE_UPDATE_TAG_VAL) && (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo))) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4);
|
||||
return invalidOperationMsg(pMsg, msg4);
|
||||
} else if ((pAlterSQL->type == TSDB_ALTER_TABLE_ADD_COLUMN || pAlterSQL->type == TSDB_ALTER_TABLE_DROP_COLUMN || pAlterSQL->type == TSDB_ALTER_TABLE_CHANGE_COLUMN) &&
|
||||
UTIL_TABLE_IS_CHILD_TABLE(pTableMetaInfo)) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg6);
|
||||
return invalidOperationMsg(pMsg, msg6);
|
||||
}
|
||||
|
||||
if (pAlterSQL->type == TSDB_ALTER_TABLE_ADD_TAG_COLUMN) {
|
||||
SArray* pFieldList = pAlterSQL->pAddColumns;
|
||||
if (taosArrayGetSize(pFieldList) > 1) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg5);
|
||||
return invalidOperationMsg(pMsg, msg5);
|
||||
}
|
||||
|
||||
TAOS_FIELD* p = taosArrayGet(pFieldList, 0);
|
||||
|
@ -5389,31 +5395,31 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
|||
tscFieldInfoAppend(&pQueryInfo->fieldsInfo, p);
|
||||
} else if (pAlterSQL->type == TSDB_ALTER_TABLE_DROP_TAG_COLUMN) {
|
||||
if (tscGetNumOfTags(pTableMeta) == 1) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg7);
|
||||
return invalidOperationMsg(pMsg, msg7);
|
||||
}
|
||||
|
||||
// numOfTags == 1
|
||||
if (taosArrayGetSize(pAlterSQL->varList) > 1) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg8);
|
||||
return invalidOperationMsg(pMsg, msg8);
|
||||
}
|
||||
|
||||
tVariantListItem* pItem = taosArrayGet(pAlterSQL->varList, 0);
|
||||
if (pItem->pVar.nLen >= TSDB_COL_NAME_LEN) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg9);
|
||||
return invalidOperationMsg(pMsg, msg9);
|
||||
}
|
||||
|
||||
SColumnIndex index = COLUMN_INDEX_INITIALIZER;
|
||||
SStrToken name = {.z = pItem->pVar.pz, .n = pItem->pVar.nLen, .type = TK_STRING};
|
||||
|
||||
if (getColumnIndexByName(pCmd, &name, pQueryInfo, &index) != TSDB_CODE_SUCCESS) {
|
||||
if (getColumnIndexByName(&name, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) {
|
||||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||
}
|
||||
|
||||
int32_t numOfCols = tscGetNumOfColumns(pTableMeta);
|
||||
if (index.columnIndex < numOfCols) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg10);
|
||||
return invalidOperationMsg(pMsg, msg10);
|
||||
} else if (index.columnIndex == numOfCols) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg11);
|
||||
return invalidOperationMsg(pMsg, msg11);
|
||||
}
|
||||
|
||||
char name1[128] = {0};
|
||||
|
@ -5431,24 +5437,24 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
|||
tVariantListItem* pDstItem = taosArrayGet(pAlterSQL->varList, 1);
|
||||
|
||||
if (pSrcItem->pVar.nLen >= TSDB_COL_NAME_LEN || pDstItem->pVar.nLen >= TSDB_COL_NAME_LEN) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg9);
|
||||
return invalidOperationMsg(pMsg, msg9);
|
||||
}
|
||||
|
||||
if (pSrcItem->pVar.nType != TSDB_DATA_TYPE_BINARY || pDstItem->pVar.nType != TSDB_DATA_TYPE_BINARY) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg10);
|
||||
return invalidOperationMsg(pMsg, msg10);
|
||||
}
|
||||
|
||||
SColumnIndex srcIndex = COLUMN_INDEX_INITIALIZER;
|
||||
SColumnIndex destIndex = COLUMN_INDEX_INITIALIZER;
|
||||
|
||||
SStrToken srcToken = {.z = pSrcItem->pVar.pz, .n = pSrcItem->pVar.nLen, .type = TK_STRING};
|
||||
if (getColumnIndexByName(pCmd, &srcToken, pQueryInfo, &srcIndex) != TSDB_CODE_SUCCESS) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg17);
|
||||
if (getColumnIndexByName(&srcToken, pQueryInfo, &srcIndex, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) {
|
||||
return invalidOperationMsg(pMsg, msg17);
|
||||
}
|
||||
|
||||
SStrToken destToken = {.z = pDstItem->pVar.pz, .n = pDstItem->pVar.nLen, .type = TK_STRING};
|
||||
if (getColumnIndexByName(pCmd, &destToken, pQueryInfo, &destIndex) == TSDB_CODE_SUCCESS) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg19);
|
||||
if (getColumnIndexByName(&destToken, pQueryInfo, &destIndex, tscGetErrorMsgPayload(pCmd)) == TSDB_CODE_SUCCESS) {
|
||||
return invalidOperationMsg(pMsg, msg19);
|
||||
}
|
||||
|
||||
tVariantListItem* pItem = taosArrayGet(pVarList, 0);
|
||||
|
@ -5475,12 +5481,12 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
|||
|
||||
SColumnIndex columnIndex = COLUMN_INDEX_INITIALIZER;
|
||||
SStrToken name = {.type = TK_STRING, .z = item->pVar.pz, .n = item->pVar.nLen};
|
||||
if (getColumnIndexByName(pCmd, &name, pQueryInfo, &columnIndex) != TSDB_CODE_SUCCESS) {
|
||||
if (getColumnIndexByName(&name, pQueryInfo, &columnIndex, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) {
|
||||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||
}
|
||||
|
||||
if (columnIndex.columnIndex < tscGetNumOfColumns(pTableMeta)) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg12);
|
||||
return invalidOperationMsg(pMsg, msg12);
|
||||
}
|
||||
|
||||
tVariantListItem* pItem = taosArrayGet(pVarList, 1);
|
||||
|
@ -5488,7 +5494,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
|||
pAlterSQL->tagData.data = calloc(1, pTagsSchema->bytes * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE);
|
||||
|
||||
if (tVariantDump(&pItem->pVar, pAlterSQL->tagData.data, pTagsSchema->type, true) != TSDB_CODE_SUCCESS) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg13);
|
||||
return invalidOperationMsg(pMsg, msg13);
|
||||
}
|
||||
|
||||
pAlterSQL->tagData.dataLen = pTagsSchema->bytes;
|
||||
|
@ -5496,14 +5502,14 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
|||
// validate the length of binary
|
||||
if ((pTagsSchema->type == TSDB_DATA_TYPE_BINARY || pTagsSchema->type == TSDB_DATA_TYPE_NCHAR) &&
|
||||
varDataTLen(pAlterSQL->tagData.data) > pTagsSchema->bytes) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg14);
|
||||
return invalidOperationMsg(pMsg, msg14);
|
||||
}
|
||||
|
||||
int32_t schemaLen = sizeof(STColumn) * numOfTags;
|
||||
int32_t size = sizeof(SUpdateTableTagValMsg) + pTagsSchema->bytes + schemaLen + TSDB_EXTRA_PAYLOAD_SIZE;
|
||||
|
||||
if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, size)) {
|
||||
tscError("0x%"PRIx64" failed to malloc for alter table msg", pSql->self);
|
||||
tscError("0x%"PRIx64" failed to malloc for alter table pMsg", pSql->self);
|
||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
@ -5518,7 +5524,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
|||
pUpdateMsg->numOfTags = htons(numOfTags);
|
||||
pUpdateMsg->schemaLen = htonl(schemaLen);
|
||||
|
||||
// the schema is located after the msg body, then followed by true tag value
|
||||
// the schema is located after the pMsg body, then followed by true tag value
|
||||
char* d = pUpdateMsg->data;
|
||||
SSchema* pTagCols = tscGetTableTagSchema(pTableMeta);
|
||||
for (int i = 0; i < numOfTags; ++i) {
|
||||
|
@ -5531,7 +5537,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
|||
d += sizeof(STColumn);
|
||||
}
|
||||
|
||||
// copy the tag value to msg body
|
||||
// copy the tag value to pMsg body
|
||||
pItem = taosArrayGet(pVarList, 1);
|
||||
tVariantDump(&pItem->pVar, pUpdateMsg->data + schemaLen, pTagsSchema->type, true);
|
||||
|
||||
|
@ -5550,8 +5556,8 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
|||
} else if (pAlterSQL->type == TSDB_ALTER_TABLE_ADD_COLUMN) {
|
||||
SArray* pFieldList = pAlterSQL->pAddColumns;
|
||||
if (taosArrayGetSize(pFieldList) > 1) {
|
||||
const char* msg = "only support add one column";
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg);
|
||||
const char* msgx = "only support add one column";
|
||||
return invalidOperationMsg(pMsg, msgx);
|
||||
}
|
||||
|
||||
TAOS_FIELD* p = taosArrayGet(pFieldList, 0);
|
||||
|
@ -5562,24 +5568,24 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
|||
tscFieldInfoAppend(&pQueryInfo->fieldsInfo, p);
|
||||
} else if (pAlterSQL->type == TSDB_ALTER_TABLE_DROP_COLUMN) {
|
||||
if (tscGetNumOfColumns(pTableMeta) == TSDB_MIN_COLUMNS) { //
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg15);
|
||||
return invalidOperationMsg(pMsg, msg15);
|
||||
}
|
||||
|
||||
size_t size = taosArrayGetSize(pAlterSQL->varList);
|
||||
if (size > 1) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg16);
|
||||
return invalidOperationMsg(pMsg, msg16);
|
||||
}
|
||||
|
||||
tVariantListItem* pItem = taosArrayGet(pAlterSQL->varList, 0);
|
||||
|
||||
SColumnIndex columnIndex = COLUMN_INDEX_INITIALIZER;
|
||||
SStrToken name = {.type = TK_STRING, .z = pItem->pVar.pz, .n = pItem->pVar.nLen};
|
||||
if (getColumnIndexByName(pCmd, &name, pQueryInfo, &columnIndex) != TSDB_CODE_SUCCESS) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg17);
|
||||
if (getColumnIndexByName(&name, pQueryInfo, &columnIndex, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) {
|
||||
return invalidOperationMsg(pMsg, msg17);
|
||||
}
|
||||
|
||||
if (columnIndex.columnIndex == PRIMARYKEY_TIMESTAMP_COL_INDEX) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg18);
|
||||
return invalidOperationMsg(pMsg, msg18);
|
||||
}
|
||||
|
||||
char name1[TSDB_COL_NAME_LEN] = {0};
|
||||
|
@ -5588,79 +5594,79 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
|||
tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
|
||||
} else if (pAlterSQL->type == TSDB_ALTER_TABLE_CHANGE_COLUMN) {
|
||||
if (taosArrayGetSize(pAlterSQL->pAddColumns) >= 2) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg16);
|
||||
return invalidOperationMsg(pMsg, msg16);
|
||||
}
|
||||
|
||||
|
||||
TAOS_FIELD* pItem = taosArrayGet(pAlterSQL->pAddColumns, 0);
|
||||
if (pItem->type != TSDB_DATA_TYPE_BINARY && pItem->type != TSDB_DATA_TYPE_NCHAR) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg21);
|
||||
return invalidOperationMsg(pMsg, msg21);
|
||||
}
|
||||
|
||||
SColumnIndex columnIndex = COLUMN_INDEX_INITIALIZER;
|
||||
SStrToken name = {.type = TK_STRING, .z = pItem->name, .n = (uint32_t)strlen(pItem->name)};
|
||||
if (getColumnIndexByName(pCmd, &name, pQueryInfo, &columnIndex) != TSDB_CODE_SUCCESS) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg17);
|
||||
if (getColumnIndexByName(&name, pQueryInfo, &columnIndex, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) {
|
||||
return invalidOperationMsg(pMsg, msg17);
|
||||
}
|
||||
|
||||
SSchema* pColSchema = tscGetTableColumnSchema(pTableMetaInfo->pTableMeta, columnIndex.columnIndex);
|
||||
|
||||
if (pColSchema->type != TSDB_DATA_TYPE_BINARY && pColSchema->type != TSDB_DATA_TYPE_NCHAR) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg21);
|
||||
return invalidOperationMsg(pMsg, msg21);
|
||||
}
|
||||
|
||||
if (pItem->type != pColSchema->type) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg23);
|
||||
return invalidOperationMsg(pMsg, msg23);
|
||||
}
|
||||
|
||||
if ((pItem->type == TSDB_DATA_TYPE_BINARY && (pItem->bytes <= 0 || pItem->bytes > TSDB_MAX_BINARY_LEN)) ||
|
||||
(pItem->type == TSDB_DATA_TYPE_NCHAR && (pItem->bytes <= 0 || pItem->bytes > TSDB_MAX_NCHAR_LEN))) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg24);
|
||||
return invalidOperationMsg(pMsg, msg24);
|
||||
}
|
||||
|
||||
if (pItem->bytes <= pColSchema->bytes) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg22);
|
||||
return invalidOperationMsg(pMsg, msg22);
|
||||
}
|
||||
|
||||
TAOS_FIELD f = tscCreateField(pColSchema->type, name.z, pItem->bytes);
|
||||
tscFieldInfoAppend(&pQueryInfo->fieldsInfo, &f);
|
||||
}else if (pAlterSQL->type == TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN) {
|
||||
if (taosArrayGetSize(pAlterSQL->pAddColumns) >= 2) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg16);
|
||||
return invalidOperationMsg(pMsg, msg16);
|
||||
}
|
||||
|
||||
TAOS_FIELD* pItem = taosArrayGet(pAlterSQL->pAddColumns, 0);
|
||||
if (pItem->type != TSDB_DATA_TYPE_BINARY && pItem->type != TSDB_DATA_TYPE_NCHAR) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg21);
|
||||
return invalidOperationMsg(pMsg, msg21);
|
||||
}
|
||||
|
||||
SColumnIndex columnIndex = COLUMN_INDEX_INITIALIZER;
|
||||
SStrToken name = {.type = TK_STRING, .z = pItem->name, .n = (uint32_t)strlen(pItem->name)};
|
||||
if (getColumnIndexByName(pCmd, &name, pQueryInfo, &columnIndex) != TSDB_CODE_SUCCESS) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg17);
|
||||
if (getColumnIndexByName(&name, pQueryInfo, &columnIndex, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS) {
|
||||
return invalidOperationMsg(pMsg, msg17);
|
||||
}
|
||||
|
||||
SSchema* pColSchema = tscGetTableColumnSchema(pTableMetaInfo->pTableMeta, columnIndex.columnIndex);
|
||||
|
||||
if (columnIndex.columnIndex < tscGetNumOfColumns(pTableMetaInfo->pTableMeta)) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg10);
|
||||
return invalidOperationMsg(pMsg, msg10);
|
||||
}
|
||||
|
||||
if (pColSchema->type != TSDB_DATA_TYPE_BINARY && pColSchema->type != TSDB_DATA_TYPE_NCHAR) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg21);
|
||||
return invalidOperationMsg(pMsg, msg21);
|
||||
}
|
||||
|
||||
if (pItem->type != pColSchema->type) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg23);
|
||||
return invalidOperationMsg(pMsg, msg23);
|
||||
}
|
||||
|
||||
if ((pItem->type == TSDB_DATA_TYPE_BINARY && (pItem->bytes <= 0 || pItem->bytes > TSDB_MAX_BINARY_LEN)) ||
|
||||
(pItem->type == TSDB_DATA_TYPE_NCHAR && (pItem->bytes <= 0 || pItem->bytes > TSDB_MAX_NCHAR_LEN))) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg24);
|
||||
return invalidOperationMsg(pMsg, msg24);
|
||||
}
|
||||
|
||||
if (pItem->bytes <= pColSchema->bytes) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg22);
|
||||
return invalidOperationMsg(pMsg, msg22);
|
||||
}
|
||||
|
||||
TAOS_FIELD f = tscCreateField(pColSchema->type, name.z, pItem->bytes);
|
||||
|
@ -6938,7 +6944,7 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
|
|||
if (strncmp(sToken->z, pTagSchema[t].name, sToken->n) == 0 && strlen(pTagSchema[t].name) == sToken->n) {
|
||||
SSchema* pSchema = &pTagSchema[t];
|
||||
|
||||
char tagVal[TSDB_MAX_TAGS_LEN];
|
||||
char tagVal[TSDB_MAX_TAGS_LEN] = {0};
|
||||
if (pSchema->type == TSDB_DATA_TYPE_BINARY || pSchema->type == TSDB_DATA_TYPE_NCHAR) {
|
||||
if (pItem->pVar.nLen > pSchema->bytes) {
|
||||
tdDestroyKVRowBuilder(&kvRowBuilder);
|
||||
|
@ -7241,7 +7247,7 @@ int32_t tscGetExprFilters(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SArray* pSelect
|
|||
} else {
|
||||
tSqlExprItem* pParamElem = taosArrayGet(pSqlExpr->pParam, 0);
|
||||
SStrToken* pToken = &pParamElem->pNode->colInfo;
|
||||
getColumnIndexByName(pCmd, pToken, pQueryInfo, &index);
|
||||
getColumnIndexByName(pToken, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd));
|
||||
}
|
||||
|
||||
size_t numOfNodeInSel = tscNumOfExprs(pQueryInfo);
|
||||
|
@ -7429,7 +7435,7 @@ int32_t getHavingExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SArray* pSelectNode
|
|||
|
||||
if (pExpr1->tokenId == TK_ID) {
|
||||
SColumnIndex index = COLUMN_INDEX_INITIALIZER;
|
||||
if ((getColumnIndexByName(pCmd, &pExpr1->colInfo, pQueryInfo, &index) != TSDB_CODE_SUCCESS)) {
|
||||
if ((getColumnIndexByName(&pExpr1->colInfo, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd)) != TSDB_CODE_SUCCESS)) {
|
||||
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
||||
}
|
||||
|
||||
|
@ -7855,6 +7861,12 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf
|
|||
|
||||
int32_t timeWindowQuery =
|
||||
(TPARSER_HAS_TOKEN(pSqlNode->interval.interval) || TPARSER_HAS_TOKEN(pSqlNode->sessionVal.gap));
|
||||
TSDB_QUERY_SET_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_TABLE_QUERY);
|
||||
|
||||
// parse the group by clause in the first place
|
||||
if (validateGroupbyNode(pQueryInfo, pSqlNode->pGroupby, pCmd) != TSDB_CODE_SUCCESS) {
|
||||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||
}
|
||||
|
||||
if (validateSelectNodeList(pCmd, pQueryInfo, pSqlNode->pSelNodeList, false, false, timeWindowQuery) !=
|
||||
TSDB_CODE_SUCCESS) {
|
||||
|
@ -8184,7 +8196,7 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS
|
|||
}
|
||||
} else if (pSqlExpr->type == SQL_NODE_TABLE_COLUMN) { // column name, normal column arithmetic expression
|
||||
SColumnIndex index = COLUMN_INDEX_INITIALIZER;
|
||||
int32_t ret = getColumnIndexByName(pCmd, &pSqlExpr->colInfo, pQueryInfo, &index);
|
||||
int32_t ret = getColumnIndexByName(&pSqlExpr->colInfo, pQueryInfo, &index, tscGetErrorMsgPayload(pCmd));
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -2398,11 +2398,12 @@ int tscProcessRetrieveRspFromNode(SSqlObj *pSql) {
|
|||
}
|
||||
|
||||
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||
if (pCmd->command == TSDB_SQL_RETRIEVE) {
|
||||
tscSetResRawPtr(pRes, pQueryInfo);
|
||||
} else if ((UTIL_TABLE_IS_CHILD_TABLE(pTableMetaInfo) || UTIL_TABLE_IS_NORMAL_TABLE(pTableMetaInfo)) && !TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_SUBQUERY)) {
|
||||
tscSetResRawPtr(pRes, pQueryInfo);
|
||||
} else if (tscNonOrderedProjectionQueryOnSTable(pQueryInfo, 0) && !TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_JOIN_QUERY) && !TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_JOIN_SEC_STAGE)) {
|
||||
if ((pCmd->command == TSDB_SQL_RETRIEVE) ||
|
||||
((UTIL_TABLE_IS_CHILD_TABLE(pTableMetaInfo) || UTIL_TABLE_IS_NORMAL_TABLE(pTableMetaInfo)) &&
|
||||
!TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_SUBQUERY)) ||
|
||||
(tscNonOrderedProjectionQueryOnSTable(pQueryInfo, 0) &&
|
||||
!TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_JOIN_QUERY) &&
|
||||
!TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_JOIN_SEC_STAGE))) {
|
||||
tscSetResRawPtr(pRes, pQueryInfo);
|
||||
}
|
||||
|
||||
|
|
|
@ -2450,6 +2450,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
|
|||
if (ret != 0) {
|
||||
pRes->code = ret;
|
||||
tscAsyncResultOnError(pSql);
|
||||
tfree(pDesc);
|
||||
tfree(pMemoryBuf);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -578,84 +578,7 @@ int32_t tscCreateResPointerInfo(SSqlRes* pRes, SQueryInfo* pQueryInfo) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
void tscSetResRawPtr(SSqlRes* pRes, SQueryInfo* pQueryInfo) {
|
||||
assert(pRes->numOfCols > 0);
|
||||
|
||||
int32_t offset = 0;
|
||||
|
||||
for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) {
|
||||
SInternalField* pInfo = (SInternalField*)TARRAY_GET_ELEM(pQueryInfo->fieldsInfo.internalField, i);
|
||||
|
||||
pRes->urow[i] = pRes->data + offset * pRes->numOfRows;
|
||||
pRes->length[i] = pInfo->field.bytes;
|
||||
|
||||
offset += pInfo->field.bytes;
|
||||
|
||||
// generated the user-defined column result
|
||||
if (pInfo->pExpr->pExpr == NULL && TSDB_COL_IS_UD_COL(pInfo->pExpr->base.colInfo.flag)) {
|
||||
if (pInfo->pExpr->base.param[1].nType == TSDB_DATA_TYPE_NULL) {
|
||||
setNullN(pRes->urow[i], pInfo->field.type, pInfo->field.bytes, (int32_t) pRes->numOfRows);
|
||||
} else {
|
||||
if (pInfo->field.type == TSDB_DATA_TYPE_NCHAR || pInfo->field.type == TSDB_DATA_TYPE_BINARY) {
|
||||
assert(pInfo->pExpr->base.param[1].nLen <= pInfo->field.bytes);
|
||||
|
||||
for (int32_t k = 0; k < pRes->numOfRows; ++k) {
|
||||
char* p = ((char**)pRes->urow)[i] + k * pInfo->field.bytes;
|
||||
|
||||
memcpy(varDataVal(p), pInfo->pExpr->base.param[1].pz, pInfo->pExpr->base.param[1].nLen);
|
||||
varDataSetLen(p, pInfo->pExpr->base.param[1].nLen);
|
||||
}
|
||||
} else {
|
||||
for (int32_t k = 0; k < pRes->numOfRows; ++k) {
|
||||
char* p = ((char**)pRes->urow)[i] + k * pInfo->field.bytes;
|
||||
memcpy(p, &pInfo->pExpr->base.param[1].i64, pInfo->field.bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (pInfo->field.type == TSDB_DATA_TYPE_NCHAR) {
|
||||
// convert unicode to native code in a temporary buffer extra one byte for terminated symbol
|
||||
pRes->buffer[i] = realloc(pRes->buffer[i], pInfo->field.bytes * pRes->numOfRows);
|
||||
|
||||
// string terminated char for binary data
|
||||
memset(pRes->buffer[i], 0, pInfo->field.bytes * pRes->numOfRows);
|
||||
|
||||
char* p = pRes->urow[i];
|
||||
for (int32_t k = 0; k < pRes->numOfRows; ++k) {
|
||||
char* dst = pRes->buffer[i] + k * pInfo->field.bytes;
|
||||
|
||||
if (isNull(p, TSDB_DATA_TYPE_NCHAR)) {
|
||||
memcpy(dst, p, varDataTLen(p));
|
||||
} else if (varDataLen(p) > 0) {
|
||||
int32_t length = taosUcs4ToMbs(varDataVal(p), varDataLen(p), varDataVal(dst));
|
||||
varDataSetLen(dst, length);
|
||||
|
||||
if (length == 0) {
|
||||
tscError("charset:%s to %s. val:%s convert failed.", DEFAULT_UNICODE_ENCODEC, tsCharset, (char*)p);
|
||||
}
|
||||
} else {
|
||||
varDataSetLen(dst, 0);
|
||||
}
|
||||
|
||||
p += pInfo->field.bytes;
|
||||
}
|
||||
|
||||
memcpy(pRes->urow[i], pRes->buffer[i], pInfo->field.bytes * pRes->numOfRows);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void tscSetResRawPtrRv(SSqlRes* pRes, SQueryInfo* pQueryInfo, SSDataBlock* pBlock, bool convertNchar) {
|
||||
assert(pRes->numOfCols > 0);
|
||||
|
||||
for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) {
|
||||
SInternalField* pInfo = (SInternalField*)TARRAY_GET_ELEM(pQueryInfo->fieldsInfo.internalField, i);
|
||||
|
||||
SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, i);
|
||||
|
||||
pRes->urow[i] = pColData->pData;
|
||||
pRes->length[i] = pInfo->field.bytes;
|
||||
|
||||
static void setResRawPtrImpl(SSqlRes* pRes, SInternalField* pInfo, int32_t i, bool convertNchar) {
|
||||
// generated the user-defined column result
|
||||
if (pInfo->pExpr->pExpr == NULL && TSDB_COL_IS_UD_COL(pInfo->pExpr->base.colInfo.flag)) {
|
||||
if (pInfo->pExpr->base.param[1].nType == TSDB_DATA_TYPE_NULL) {
|
||||
|
@ -708,6 +631,87 @@ void tscSetResRawPtrRv(SSqlRes* pRes, SQueryInfo* pQueryInfo, SSDataBlock* pBloc
|
|||
memcpy(pRes->urow[i], pRes->buffer[i], pInfo->field.bytes * pRes->numOfRows);
|
||||
}
|
||||
}
|
||||
|
||||
void tscSetResRawPtr(SSqlRes* pRes, SQueryInfo* pQueryInfo) {
|
||||
assert(pRes->numOfCols > 0);
|
||||
|
||||
int32_t offset = 0;
|
||||
for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) {
|
||||
SInternalField* pInfo = (SInternalField*)TARRAY_GET_ELEM(pQueryInfo->fieldsInfo.internalField, i);
|
||||
|
||||
pRes->urow[i] = pRes->data + offset * pRes->numOfRows;
|
||||
pRes->length[i] = pInfo->field.bytes;
|
||||
|
||||
offset += pInfo->field.bytes;
|
||||
setResRawPtrImpl(pRes, pInfo, i, true);
|
||||
}
|
||||
}
|
||||
|
||||
void tscSetResRawPtrRv(SSqlRes* pRes, SQueryInfo* pQueryInfo, SSDataBlock* pBlock, bool convertNchar) {
|
||||
assert(pRes->numOfCols > 0);
|
||||
|
||||
for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) {
|
||||
SInternalField* pInfo = (SInternalField*)TARRAY_GET_ELEM(pQueryInfo->fieldsInfo.internalField, i);
|
||||
|
||||
SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, i);
|
||||
|
||||
pRes->urow[i] = pColData->pData;
|
||||
pRes->length[i] = pInfo->field.bytes;
|
||||
|
||||
setResRawPtrImpl(pRes, pInfo, i, convertNchar);
|
||||
/*
|
||||
// generated the user-defined column result
|
||||
if (pInfo->pExpr->pExpr == NULL && TSDB_COL_IS_UD_COL(pInfo->pExpr->base.colInfo.flag)) {
|
||||
if (pInfo->pExpr->base.param[1].nType == TSDB_DATA_TYPE_NULL) {
|
||||
setNullN(pRes->urow[i], pInfo->field.type, pInfo->field.bytes, (int32_t) pRes->numOfRows);
|
||||
} else {
|
||||
if (pInfo->field.type == TSDB_DATA_TYPE_NCHAR || pInfo->field.type == TSDB_DATA_TYPE_BINARY) {
|
||||
assert(pInfo->pExpr->base.param[1].nLen <= pInfo->field.bytes);
|
||||
|
||||
for (int32_t k = 0; k < pRes->numOfRows; ++k) {
|
||||
char* p = ((char**)pRes->urow)[i] + k * pInfo->field.bytes;
|
||||
|
||||
memcpy(varDataVal(p), pInfo->pExpr->base.param[1].pz, pInfo->pExpr->base.param[1].nLen);
|
||||
varDataSetLen(p, pInfo->pExpr->base.param[1].nLen);
|
||||
}
|
||||
} else {
|
||||
for (int32_t k = 0; k < pRes->numOfRows; ++k) {
|
||||
char* p = ((char**)pRes->urow)[i] + k * pInfo->field.bytes;
|
||||
memcpy(p, &pInfo->pExpr->base.param[1].i64, pInfo->field.bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (convertNchar && pInfo->field.type == TSDB_DATA_TYPE_NCHAR) {
|
||||
// convert unicode to native code in a temporary buffer extra one byte for terminated symbol
|
||||
pRes->buffer[i] = realloc(pRes->buffer[i], pInfo->field.bytes * pRes->numOfRows);
|
||||
|
||||
// string terminated char for binary data
|
||||
memset(pRes->buffer[i], 0, pInfo->field.bytes * pRes->numOfRows);
|
||||
|
||||
char* p = pRes->urow[i];
|
||||
for (int32_t k = 0; k < pRes->numOfRows; ++k) {
|
||||
char* dst = pRes->buffer[i] + k * pInfo->field.bytes;
|
||||
|
||||
if (isNull(p, TSDB_DATA_TYPE_NCHAR)) {
|
||||
memcpy(dst, p, varDataTLen(p));
|
||||
} else if (varDataLen(p) > 0) {
|
||||
int32_t length = taosUcs4ToMbs(varDataVal(p), varDataLen(p), varDataVal(dst));
|
||||
varDataSetLen(dst, length);
|
||||
|
||||
if (length == 0) {
|
||||
tscError("charset:%s to %s. val:%s convert failed.", DEFAULT_UNICODE_ENCODEC, tsCharset, (char*)p);
|
||||
}
|
||||
} else {
|
||||
varDataSetLen(dst, 0);
|
||||
}
|
||||
|
||||
p += pInfo->field.bytes;
|
||||
}
|
||||
|
||||
memcpy(pRes->urow[i], pRes->buffer[i], pInfo->field.bytes * pRes->numOfRows);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
static SColumnInfo* extractColumnInfoFromResult(SArray* pTableCols) {
|
||||
|
@ -989,6 +993,8 @@ static void destroyDummyInputOperator(void* param, int32_t numOfOutput) {
|
|||
pInfo->block = destroyOutputBuf(pInfo->block);
|
||||
pInfo->pSql = NULL;
|
||||
|
||||
doDestroyFilterInfo(pInfo->pFilterInfo, pInfo->numOfFilterCols);
|
||||
|
||||
cleanupResultRowInfo(&pInfo->pTableQueryInfo->resInfo);
|
||||
tfree(pInfo->pTableQueryInfo);
|
||||
}
|
||||
|
|
|
@ -256,7 +256,7 @@ int32_t tNameExtractFullName(const SName* name, char* dst) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
int32_t len = snprintf(dst, TSDB_ACCT_ID_LEN + 1 + TSDB_DB_NAME_LEN, "%s.%s", name->acctId, name->dbname);
|
||||
int32_t len = snprintf(dst, TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN, "%s.%s", name->acctId, name->dbname);
|
||||
|
||||
size_t tnameLen = strlen(name->tname);
|
||||
if (tnameLen > 0) {
|
||||
|
|
|
@ -407,6 +407,7 @@ static int32_t toNchar(tVariant *pVariant, char **pDest, int32_t *pDestSize) {
|
|||
wchar_t *pWStr = calloc(1, (nLen + 1) * TSDB_NCHAR_SIZE);
|
||||
bool ret = taosMbsToUcs4(pDst, nLen, (char *)pWStr, (nLen + 1) * TSDB_NCHAR_SIZE, NULL);
|
||||
if (!ret) {
|
||||
tfree(pWStr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -606,7 +607,7 @@ int32_t tVariantDump(tVariant *pVariant, char *payload, int16_t type, bool inclu
|
|||
}
|
||||
|
||||
errno = 0; // reset global error code
|
||||
int64_t result;
|
||||
int64_t result = 0;
|
||||
|
||||
switch (type) {
|
||||
case TSDB_DATA_TYPE_BOOL: {
|
||||
|
@ -874,7 +875,8 @@ int32_t tVariantTypeSetType(tVariant *pVariant, char type) {
|
|||
free(pVariant->pz);
|
||||
pVariant->dKey = v;
|
||||
} else if (pVariant->nType >= TSDB_DATA_TYPE_BOOL && pVariant->nType <= TSDB_DATA_TYPE_BIGINT) {
|
||||
pVariant->dKey = (double)(pVariant->i64);
|
||||
double tmp = (double) pVariant->i64;
|
||||
pVariant->dKey = tmp;
|
||||
}
|
||||
|
||||
pVariant->nType = TSDB_DATA_TYPE_DOUBLE;
|
||||
|
|
|
@ -1068,8 +1068,10 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) {
|
|||
pStable->info.tableId = strdup(pCreate->tableName);
|
||||
pStable->info.type = TSDB_SUPER_TABLE;
|
||||
pStable->createdTime = taosGetTimestampMs();
|
||||
uint64_t x = (us&0x000000FFFFFFFFFF);
|
||||
|
||||
uint64_t x = (us & ((((uint64_t)1)<<40) - 1)); // todo refactor
|
||||
x = x << 24;
|
||||
|
||||
pStable->uid = x + ((sdbGetVersion() & ((1ul << 16) - 1ul)) << 8) + (taosRand() & ((1ul << 8) - 1ul));
|
||||
pStable->sversion = 0;
|
||||
pStable->tversion = 0;
|
||||
|
@ -1079,7 +1081,8 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) {
|
|||
int32_t schemaSize = numOfCols * sizeof(SSchema);
|
||||
pStable->schema = (SSchema *)calloc(1, schemaSize);
|
||||
if (pStable->schema == NULL) {
|
||||
free(pStable);
|
||||
tfree(pStable->info.tableId);
|
||||
tfree(pStable);
|
||||
mError("msg:%p, app:%p table:%s, failed to create, no schema input", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableName);
|
||||
return TSDB_CODE_MND_INVALID_TABLE_NAME;
|
||||
}
|
||||
|
@ -1096,6 +1099,9 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) {
|
|||
|
||||
if (!tIsValidSchema(pStable->schema, pStable->numOfColumns, pStable->numOfTags)) {
|
||||
mError("msg:%p, app:%p table:%s, failed to create table, invalid schema", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableName);
|
||||
tfree(pStable->info.tableId);
|
||||
tfree(pStable->schema);
|
||||
tfree(pStable);
|
||||
return TSDB_CODE_MND_INVALID_CREATE_TABLE_MSG;
|
||||
}
|
||||
|
||||
|
@ -2074,9 +2080,11 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) {
|
|||
pTable->superTable = pMsg->pSTable;
|
||||
} else {
|
||||
if (pTable->info.type == TSDB_SUPER_TABLE) {
|
||||
int64_t us = taosGetTimestampUs();
|
||||
uint64_t x = (us&0x000000FFFFFFFFFF);
|
||||
uint64_t us = (uint64_t) taosGetTimestampUs();
|
||||
|
||||
uint64_t x = (us & ((((uint64_t)1)<<40) - 1));
|
||||
x = x << 24;
|
||||
|
||||
pTable->uid = x + ((sdbGetVersion() & ((1ul << 16) - 1ul)) << 8) + (taosRand() & ((1ul << 8) - 1ul));
|
||||
} else {
|
||||
pTable->uid = (((uint64_t)pTable->vgId) << 48) + ((((uint64_t)pTable->tid) & ((1ul << 24) - 1ul)) << 24) +
|
||||
|
|
|
@ -571,6 +571,7 @@ void doCompactSDataBlock(SSDataBlock* pBlock, int32_t numOfRows, int8_t* p);
|
|||
|
||||
SSDataBlock* createOutputBuf(SExprInfo* pExpr, int32_t numOfOutput, int32_t numOfRows);
|
||||
void* destroyOutputBuf(SSDataBlock* pBlock);
|
||||
void* doDestroyFilterInfo(SSingleColumnFilterInfo* pFilterInfo, int32_t numOfFilterCols);
|
||||
|
||||
void setInputDataBlock(SOperatorInfo* pOperator, SQLFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order);
|
||||
int32_t getNumOfResult(SQueryRuntimeEnv *pRuntimeEnv, SQLFunctionCtx* pCtx, int32_t numOfOutput);
|
||||
|
|
|
@ -179,7 +179,6 @@ static STsdbQueryCond createTsdbQueryCond(SQueryAttr* pQueryAttr, STimeWindow* w
|
|||
static STableIdInfo createTableIdInfo(STableQueryInfo* pTableQueryInfo);
|
||||
|
||||
static void setTableScanFilterOperatorInfo(STableScanInfo* pTableScanInfo, SOperatorInfo* pDownstream);
|
||||
static void* doDestroyFilterInfo(SSingleColumnFilterInfo* pFilterInfo, int32_t numOfFilterCols);
|
||||
|
||||
static int32_t getNumOfScanTimes(SQueryAttr* pQueryAttr);
|
||||
|
||||
|
@ -237,37 +236,41 @@ static int compareRowData(const void *a, const void *b, const void *userData) {
|
|||
|
||||
static void sortGroupResByOrderList(SGroupResInfo *pGroupResInfo, SQueryRuntimeEnv *pRuntimeEnv, SSDataBlock* pDataBlock) {
|
||||
SArray *columnOrderList = getOrderCheckColumns(pRuntimeEnv->pQueryAttr);
|
||||
if (taosArrayGetSize(columnOrderList) <= 0) {
|
||||
size_t size = taosArrayGetSize(columnOrderList);
|
||||
taosArrayDestroy(columnOrderList);
|
||||
|
||||
if (size <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t orderId = pRuntimeEnv->pQueryAttr->order.orderColId;
|
||||
if (orderId <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool found = false;
|
||||
int16_t dataOffset = 0;
|
||||
|
||||
//SColIndex *index = taosArrayGet(columnOrderList, 0);
|
||||
for (int32_t j = 0; j < pDataBlock->info.numOfCols; ++j) {
|
||||
SColumnInfoData* pColInfoData = (SColumnInfoData *)taosArrayGet(pDataBlock->pDataBlock, j);
|
||||
if (orderId == j) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
||||
dataOffset += pColInfoData->info.bytes;
|
||||
}
|
||||
|
||||
if (found == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
int16_t type = pRuntimeEnv->pQueryAttr->pExpr1[orderId].base.resType;
|
||||
|
||||
SRowCompSupporter support = {.pRuntimeEnv = pRuntimeEnv, .dataOffset = dataOffset, .comFunc = getComparFunc(type, 0)};
|
||||
|
||||
taosArraySortPWithExt(pGroupResInfo->pRows, compareRowData, &support);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
//setup the output buffer for each operator
|
||||
SSDataBlock* createOutputBuf(SExprInfo* pExpr, int32_t numOfOutput, int32_t numOfRows) {
|
||||
const static int32_t minSize = 8;
|
||||
|
@ -1798,8 +1801,10 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int32_t numOf
|
|||
pRuntimeEnv->prevRow[i] = pRuntimeEnv->prevRow[i - 1] + pQueryAttr->tableCols[i-1].bytes;
|
||||
}
|
||||
|
||||
if (pQueryAttr->tableCols[0].type == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||
*(int64_t*) pRuntimeEnv->prevRow[0] = INT64_MIN;
|
||||
}
|
||||
}
|
||||
|
||||
qDebug("QInfo:0x%"PRIx64" init runtime environment completed", GET_QID(pRuntimeEnv));
|
||||
|
||||
|
@ -1832,7 +1837,11 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int32_t numOf
|
|||
case OP_Groupby: {
|
||||
pRuntimeEnv->proot =
|
||||
createGroupbyOperatorInfo(pRuntimeEnv, pRuntimeEnv->proot, pQueryAttr->pExpr1, pQueryAttr->numOfOutput);
|
||||
|
||||
int32_t opType = pRuntimeEnv->proot->upstream[0]->operatorType;
|
||||
if (opType != OP_DummyInput) {
|
||||
setTableScanFilterOperatorInfo(pRuntimeEnv->proot->upstream[0]->info, pRuntimeEnv->proot);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case OP_SessionWindow: {
|
||||
|
@ -2683,10 +2692,6 @@ static uint32_t doFilterByBlockTimeWindow(STableScanInfo* pTableScanInfo, SSData
|
|||
}
|
||||
|
||||
void doSetFilterColumnInfo(SSingleColumnFilterInfo* pFilterInfo, int32_t numOfFilterCols, SSDataBlock* pBlock) {
|
||||
if (numOfFilterCols > 0 && pFilterInfo[0].pData != NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
// set the initial static data value filter expression
|
||||
for (int32_t i = 0; i < numOfFilterCols; ++i) {
|
||||
for (int32_t j = 0; j < pBlock->info.numOfCols; ++j) {
|
||||
|
|
|
@ -364,7 +364,7 @@ static int64_t getEarliestValidTimestamp(STsdbRepo* pTsdb) {
|
|||
STsdbCfg* pCfg = &pTsdb->config;
|
||||
|
||||
int64_t now = taosGetTimestamp(pCfg->precision);
|
||||
return now - (tsTickPerDay[pCfg->precision] * pCfg->keep);
|
||||
return now - (tsTickPerDay[pCfg->precision] * pCfg->keep) + 1; // needs to add one tick
|
||||
}
|
||||
|
||||
static void setQueryTimewindow(STsdbQueryHandle* pQueryHandle, STsdbQueryCond* pCond) {
|
||||
|
@ -488,6 +488,7 @@ TsdbQueryHandleT* tsdbQueryTables(STsdbRepo* tsdb, STsdbQueryCond* pCond, STable
|
|||
pQueryHandle->pTableCheckInfo = createCheckInfoFromTableGroup(pQueryHandle, groupList, pMeta, &psTable);
|
||||
if (pQueryHandle->pTableCheckInfo == NULL) {
|
||||
tsdbCleanupQueryHandle(pQueryHandle);
|
||||
taosArrayDestroy(psTable);
|
||||
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -575,8 +576,6 @@ void tsdbResetQueryHandleForNewTable(TsdbQueryHandleT queryHandle, STsdbQueryCon
|
|||
pQueryHandle->next = doFreeColumnInfoData(pQueryHandle->next);
|
||||
}
|
||||
|
||||
|
||||
|
||||
TsdbQueryHandleT tsdbQueryLastRow(STsdbRepo *tsdb, STsdbQueryCond *pCond, STableGroupInfo *groupList, uint64_t qId, SMemRef* pMemRef) {
|
||||
pCond->twindow = updateLastrowForEachGroup(groupList);
|
||||
|
||||
|
@ -2874,6 +2873,7 @@ static int32_t doGetExternalRow(STsdbQueryHandle* pQueryHandle, int16_t type, SM
|
|||
SArray* psTable = NULL;
|
||||
pSecQueryHandle->pTableCheckInfo = createCheckInfoFromCheckInfo(pCurrent, pSecQueryHandle->window.skey, &psTable);
|
||||
if (pSecQueryHandle->pTableCheckInfo == NULL) {
|
||||
taosArrayDestroy(psTable);
|
||||
terrno = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
goto out_of_memory;
|
||||
}
|
||||
|
|
|
@ -426,4 +426,28 @@ endi
|
|||
|
||||
sql_error select last_row(*) from (select * from nest_tb0) having c1 > 0
|
||||
|
||||
print ===========>td-4805
|
||||
sql_error select tbname, i from (select * from nest_tb0) group by i;
|
||||
|
||||
sql select count(*),c1 from (select * from nest_tb0) where c1 < 2 group by c1;
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data00 != 100 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data01 != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data10 != 100 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data11 != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
Loading…
Reference in New Issue