未验证 提交 b0a25e92 编写于 作者: D dapan1121 提交者: GitHub

Merge pull request #7899 from taosdata/feature/TD-5925

td-5925
...@@ -76,7 +76,6 @@ static int32_t getDelimiterIndex(SStrToken* pTableName); ...@@ -76,7 +76,6 @@ static int32_t getDelimiterIndex(SStrToken* pTableName);
static bool validateTableColumnInfo(SArray* pFieldList, SSqlCmd* pCmd); static bool validateTableColumnInfo(SArray* pFieldList, SSqlCmd* pCmd);
static bool validateTagParams(SArray* pTagsList, SArray* pFieldList, SSqlCmd* pCmd); static bool validateTagParams(SArray* pTagsList, SArray* pFieldList, SSqlCmd* pCmd);
static int32_t setObjFullName(char* fullName, const char* account, SStrToken* pDB, SStrToken* tableName, int32_t* len);
static void getColumnName(tSqlExprItem* pItem, char* resultFieldName, char* rawName, int32_t nameLength); static void getColumnName(tSqlExprItem* pItem, char* resultFieldName, char* rawName, int32_t nameLength);
static int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t colIndex, tSqlExprItem* pItem, static int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t colIndex, tSqlExprItem* pItem,
...@@ -335,7 +334,7 @@ static int setColumnFilterInfoForTimestamp(SSqlCmd* pCmd, SQueryInfo* pQueryInfo ...@@ -335,7 +334,7 @@ static int setColumnFilterInfoForTimestamp(SSqlCmd* pCmd, SQueryInfo* pQueryInfo
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta); STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta);
if (convertTimestampStrToInt64(pVar, tinfo.precision) < -1) { if (convertTimestampStrToInt64(pVar, tinfo.precision) < 0) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg);
} }
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
...@@ -1698,57 +1697,6 @@ static int32_t getDelimiterIndex(SStrToken* pTableName) { ...@@ -1698,57 +1697,6 @@ static int32_t getDelimiterIndex(SStrToken* pTableName) {
return -1; return -1;
} }
int32_t setObjFullName(char* fullName, const char* account, SStrToken* pDB, SStrToken* tableName, int32_t* xlen) {
int32_t totalLen = 0;
if (account != NULL) {
int32_t len = (int32_t)strlen(account);
strcpy(fullName, account);
fullName[len] = TS_PATH_DELIMITER[0];
totalLen += (len + 1);
}
/* db name is not specified, the tableName dose not include db name */
if (pDB != NULL) {
if (pDB->n >= TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN || pDB->n == 0) {
return TSDB_CODE_TSC_INVALID_OPERATION;
}
memcpy(&fullName[totalLen], pDB->z, pDB->n);
totalLen += pDB->n;
}
if (tableName != NULL) {
if (pDB != NULL) {
fullName[totalLen] = TS_PATH_DELIMITER[0];
totalLen += 1;
/* here we only check the table name length limitation */
if (!tscValidateTableNameLength(tableName->n)) {
return TSDB_CODE_TSC_INVALID_OPERATION;
}
} else { // pDB == NULL, the db prefix name is specified in tableName
/* the length limitation includes tablename + dbname + sep */
if (tableName->n >= TSDB_TABLE_NAME_LEN + TSDB_DB_NAME_LEN) {
return TSDB_CODE_TSC_INVALID_OPERATION;
}
}
memcpy(&fullName[totalLen], tableName->z, tableName->n);
totalLen += tableName->n;
}
if (xlen != NULL) {
*xlen = totalLen;
}
if (totalLen < TSDB_TABLE_FNAME_LEN) {
fullName[totalLen] = 0;
}
return (totalLen < TSDB_TABLE_FNAME_LEN) ? TSDB_CODE_SUCCESS : TSDB_CODE_TSC_INVALID_OPERATION;
}
void tscInsertPrimaryTsSourceColumn(SQueryInfo* pQueryInfo, uint64_t tableUid) { void tscInsertPrimaryTsSourceColumn(SQueryInfo* pQueryInfo, uint64_t tableUid) {
SSchema s = {.type = TSDB_DATA_TYPE_TIMESTAMP, .bytes = TSDB_KEYSIZE, .colId = PRIMARYKEY_TIMESTAMP_COL_INDEX}; SSchema s = {.type = TSDB_DATA_TYPE_TIMESTAMP, .bytes = TSDB_KEYSIZE, .colId = PRIMARYKEY_TIMESTAMP_COL_INDEX};
tscColumnListInsert(pQueryInfo->colList, PRIMARYKEY_TIMESTAMP_COL_INDEX, tableUid, &s); tscColumnListInsert(pQueryInfo->colList, PRIMARYKEY_TIMESTAMP_COL_INDEX, tableUid, &s);
...@@ -3737,11 +3685,7 @@ static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, ...@@ -3737,11 +3685,7 @@ static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo,
} }
} }
if (pExpr->tokenId == TK_LE || pExpr->tokenId == TK_LT) { if (pExpr->tokenId == TK_IN) {
retVal = tVariantDump(&pRight->value, (char*)&pColumnFilter->upperBndd, colType, false);
// TK_GT,TK_GE,TK_EQ,TK_NE are based on the pColumn->lowerBndd
} else if (pExpr->tokenId == TK_IN) {
tVariant *pVal; tVariant *pVal;
if (pRight->tokenId != TK_SET || !serializeExprListToVariant(pRight->Expr.paramList, &pVal, colType, timePrecision)) { if (pRight->tokenId != TK_SET || !serializeExprListToVariant(pRight->Expr.paramList, &pVal, colType, timePrecision)) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg);
...@@ -3767,6 +3711,10 @@ static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, ...@@ -3767,6 +3711,10 @@ static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo,
size_t len = twcslen((wchar_t*)pColumnFilter->pz); size_t len = twcslen((wchar_t*)pColumnFilter->pz);
pColumnFilter->len = len * TSDB_NCHAR_SIZE; pColumnFilter->len = len * TSDB_NCHAR_SIZE;
} else if (pExpr->tokenId == TK_LE || pExpr->tokenId == TK_LT) {
retVal = tVariantDump(&pRight->value, (char*)&pColumnFilter->upperBndd, colType, false);
// TK_GT,TK_GE,TK_EQ,TK_NE are based on the pColumn->lowerBndd
} else { } else {
retVal = tVariantDump(&pRight->value, (char*)&pColumnFilter->lowerBndd, colType, false); retVal = tVariantDump(&pRight->value, (char*)&pColumnFilter->lowerBndd, colType, false);
} }
...@@ -3825,9 +3773,6 @@ typedef struct SCondExpr { ...@@ -3825,9 +3773,6 @@ typedef struct SCondExpr {
tSqlExpr* pColumnCond; tSqlExpr* pColumnCond;
tSqlExpr* pTableCond;
int16_t relType; // relation between table name in expression and other tag
// filter condition expression, TK_AND or TK_OR
int16_t tableCondIndex; int16_t tableCondIndex;
tSqlExpr* pJoinExpr; // join condition tSqlExpr* pJoinExpr; // join condition
...@@ -3836,51 +3781,6 @@ typedef struct SCondExpr { ...@@ -3836,51 +3781,6 @@ typedef struct SCondExpr {
static int32_t getTimeRange(STimeWindow* win, tSqlExpr* pRight, int32_t optr, int16_t timePrecision); static int32_t getTimeRange(STimeWindow* win, tSqlExpr* pRight, int32_t optr, int16_t timePrecision);
static int32_t tablenameListToString(tSqlExpr* pExpr, SStringBuilder* sb) {
SArray* pList = pExpr->Expr.paramList;
int32_t size = (int32_t) taosArrayGetSize(pList);
if (size <= 0) {
return TSDB_CODE_TSC_INVALID_OPERATION;
}
if (size > 0) {
taosStringBuilderAppendStringLen(sb, QUERY_COND_REL_PREFIX_IN, QUERY_COND_REL_PREFIX_IN_LEN);
}
for (int32_t i = 0; i < size; ++i) {
tSqlExprItem* pSub = taosArrayGet(pList, i);
tVariant* pVar = &pSub->pNode->value;
taosStringBuilderAppendStringLen(sb, pVar->pz, pVar->nLen);
if (i < size - 1) {
taosStringBuilderAppendString(sb, TBNAME_LIST_SEP);
}
if (pVar->nLen <= 0 || !tscValidateTableNameLength(pVar->nLen)) {
return TSDB_CODE_TSC_INVALID_OPERATION;
}
}
return TSDB_CODE_SUCCESS;
}
static int32_t tablenameCondToString(tSqlExpr* pExpr, uint32_t opToken, SStringBuilder* sb) {
assert(opToken == TK_LIKE || opToken == TK_MATCH || opToken == TK_NMATCH);
if (opToken == TK_LIKE) {
taosStringBuilderAppendStringLen(sb, QUERY_COND_REL_PREFIX_LIKE, QUERY_COND_REL_PREFIX_LIKE_LEN);
taosStringBuilderAppendString(sb, pExpr->value.pz);
} else if (opToken == TK_MATCH) {
taosStringBuilderAppendStringLen(sb, QUERY_COND_REL_PREFIX_MATCH, QUERY_COND_REL_PREFIX_MATCH_LEN);
taosStringBuilderAppendString(sb, pExpr->value.pz);
} else if (opToken == TK_NMATCH) {
taosStringBuilderAppendStringLen(sb, QUERY_COND_REL_PREFIX_NMATCH, QUERY_COND_REL_PREFIX_NMATCH_LEN);
taosStringBuilderAppendString(sb, pExpr->value.pz);
}
return TSDB_CODE_SUCCESS;
}
enum { enum {
TSQL_EXPR_TS = 1, TSQL_EXPR_TS = 1,
TSQL_EXPR_TAG = 2, TSQL_EXPR_TAG = 2,
...@@ -3898,7 +3798,6 @@ static int32_t checkColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCol ...@@ -3898,7 +3798,6 @@ static int32_t checkColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCol
SSchema* pSchema = tscGetTableColumnSchema(pTableMeta, pIndex->columnIndex); SSchema* pSchema = tscGetTableColumnSchema(pTableMeta, pIndex->columnIndex);
int32_t ret = 0; int32_t ret = 0;
const char* msg1 = "non binary column not support like/match operator"; const char* msg1 = "non binary column not support like/match operator";
const char* msg2 = "binary column not support this operator";
const char* msg3 = "bool column not support this operator"; const char* msg3 = "bool column not support this operator";
const char* msg4 = "primary key not support this operator"; const char* msg4 = "primary key not support this operator";
...@@ -3919,19 +3818,7 @@ static int32_t checkColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCol ...@@ -3919,19 +3818,7 @@ static int32_t checkColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCol
pColFilter->filterstr = pColFilter->filterstr =
((pSchema->type == TSDB_DATA_TYPE_BINARY || pSchema->type == TSDB_DATA_TYPE_NCHAR) ? 1 : 0); ((pSchema->type == TSDB_DATA_TYPE_BINARY || pSchema->type == TSDB_DATA_TYPE_NCHAR) ? 1 : 0);
if (pColFilter->filterstr) { if (!pColFilter->filterstr) {
if (pExpr->tokenId != TK_EQ
&& pExpr->tokenId != TK_NE
&& pExpr->tokenId != TK_ISNULL
&& pExpr->tokenId != TK_NOTNULL
&& pExpr->tokenId != TK_LIKE
&& pExpr->tokenId != TK_MATCH
&& pExpr->tokenId != TK_NMATCH
&& pExpr->tokenId != TK_IN) {
ret = invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2);
goto _err_ret;
}
} else {
if (pExpr->tokenId == TK_LIKE || pExpr->tokenId == TK_MATCH || pExpr->tokenId == TK_NMATCH) { if (pExpr->tokenId == TK_LIKE || pExpr->tokenId == TK_MATCH || pExpr->tokenId == TK_NMATCH) {
ret = invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); ret = invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1);
goto _err_ret; goto _err_ret;
...@@ -3961,40 +3848,6 @@ _err_ret: ...@@ -3961,40 +3848,6 @@ _err_ret:
return ret; return ret;
} }
static int32_t getTablenameCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr* pTableCond, SStringBuilder* sb) {
const char* msg0 = "invalid table name list";
const char* msg1 = "not string following like";
if (pTableCond == NULL) {
return TSDB_CODE_SUCCESS;
}
tSqlExpr* pLeft = pTableCond->pLeft;
tSqlExpr* pRight = pTableCond->pRight;
if (!isTablenameToken(&pLeft->columnName)) {
return TSDB_CODE_TSC_INVALID_OPERATION;
}
int32_t ret = TSDB_CODE_SUCCESS;
if (pTableCond->tokenId == TK_IN) {
ret = tablenameListToString(pRight, sb);
} else if (pTableCond->tokenId == TK_LIKE || pTableCond->tokenId == TK_MATCH || pTableCond->tokenId == TK_NMATCH) {
if (pRight->tokenId != TK_STRING) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1);
}
ret = tablenameCondToString(pRight, pTableCond->tokenId, sb);
}
if (ret != TSDB_CODE_SUCCESS) {
invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg0);
}
return ret;
}
static int32_t getColQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr** pExpr) { static int32_t getColQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr** pExpr) {
int32_t ret = TSDB_CODE_SUCCESS; int32_t ret = TSDB_CODE_SUCCESS;
...@@ -4117,8 +3970,9 @@ static int32_t checkAndSetJoinCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tS ...@@ -4117,8 +3970,9 @@ static int32_t checkAndSetJoinCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tS
index.columnIndex = index.columnIndex - tscGetNumOfColumns(pTableMetaInfo->pTableMeta); index.columnIndex = index.columnIndex - tscGetNumOfColumns(pTableMetaInfo->pTableMeta);
if (tscColumnExists(pTableMetaInfo->tagColList, pTagSchema1->colId, pTableMetaInfo->pTableMeta->id.uid) < 0) { if (tscColumnExists(pTableMetaInfo->tagColList, pTagSchema1->colId, pTableMetaInfo->pTableMeta->id.uid) < 0) {
tscColumnListInsert(pTableMetaInfo->tagColList, index.columnIndex, pTableMeta->id.uid, pTagSchema1); tscColumnListInsert(pTableMetaInfo->tagColList, index.columnIndex, pTableMeta->id.uid, pTagSchema1);
atomic_add_fetch_32(&pTableMetaInfo->joinTagNum, 1);
if (taosArrayGetSize(pTableMetaInfo->tagColList) > 1) { if (pTableMetaInfo->joinTagNum > 1) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2);
} }
} }
...@@ -4150,7 +4004,9 @@ static int32_t checkAndSetJoinCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tS ...@@ -4150,7 +4004,9 @@ static int32_t checkAndSetJoinCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tS
if (tscColumnExists(pTableMetaInfo->tagColList, pTagSchema2->colId, pTableMeta->id.uid) < 0) { if (tscColumnExists(pTableMetaInfo->tagColList, pTagSchema2->colId, pTableMeta->id.uid) < 0) {
tscColumnListInsert(pTableMetaInfo->tagColList, index.columnIndex, pTableMeta->id.uid, pTagSchema2); tscColumnListInsert(pTableMetaInfo->tagColList, index.columnIndex, pTableMeta->id.uid, pTagSchema2);
if (taosArrayGetSize(pTableMetaInfo->tagColList) > 1) { atomic_add_fetch_32(&pTableMetaInfo->joinTagNum, 1);
if (pTableMetaInfo->joinTagNum > 1) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2);
} }
} }
...@@ -4433,18 +4289,6 @@ static bool validateJoinExprNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr ...@@ -4433,18 +4289,6 @@ static bool validateJoinExprNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr
return true; return true;
} }
static bool validTableNameOptr(tSqlExpr* pExpr) {
const char nameFilterOptr[] = {TK_IN, TK_LIKE, TK_MATCH, TK_NMATCH};
for (int32_t i = 0; i < tListLen(nameFilterOptr); ++i) {
if (pExpr->tokenId == nameFilterOptr[i]) {
return true;
}
}
return false;
}
static int32_t setExprToCond(tSqlExpr** parent, tSqlExpr* pExpr, const char* msg, int32_t parentOptr, char* msgBuf) { static int32_t setExprToCond(tSqlExpr** parent, tSqlExpr* pExpr, const char* msg, int32_t parentOptr, char* msgBuf) {
if (*parent != NULL) { if (*parent != NULL) {
if (parentOptr == TK_OR && msg != NULL) { if (parentOptr == TK_OR && msg != NULL) {
...@@ -4588,8 +4432,6 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSql ...@@ -4588,8 +4432,6 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSql
const char* msg2 = "illegal column name"; const char* msg2 = "illegal column name";
const char* msg4 = "too many join tables"; const char* msg4 = "too many join tables";
const char* msg5 = "not support ordinary column join"; const char* msg5 = "not support ordinary column join";
const char* msg6 = "only one query condition on tbname allowed";
const char* msg7 = "only in/like allowed in filter table name";
tSqlExpr* pLeft = (*pExpr)->pLeft; tSqlExpr* pLeft = (*pExpr)->pLeft;
tSqlExpr* pRight = (*pExpr)->pRight; tSqlExpr* pRight = (*pExpr)->pRight;
...@@ -4706,54 +4548,30 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSql ...@@ -4706,54 +4548,30 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSql
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1);
} }
// in case of in operator, keep it in a seprate attribute if (pRight != NULL && pRight->tokenId == TK_ID) { // join on tag columns for stable query
if (index.columnIndex == TSDB_TBNAME_COLUMN_INDEX) { if (!validateJoinExprNode(pCmd, pQueryInfo, *pExpr, &index)) {
if (!validTableNameOptr(*pExpr)) { return TSDB_CODE_TSC_INVALID_OPERATION;
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg7);
}
if (!UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1);
} }
if (pCondExpr->pTableCond == NULL) { pQueryInfo->type |= TSDB_QUERY_TYPE_JOIN_QUERY;
pCondExpr->pTableCond = *pExpr; ret = setExprToCond(&pCondExpr->pJoinExpr, *pExpr, NULL, parentOptr, pCmd->payload);
pCondExpr->relType = parentOptr; *pExpr = NULL;
pCondExpr->tableCondIndex = index.tableIndex; if (type) {
} else { *type |= TSQL_EXPR_JOIN;
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg6); }
} else {
// do nothing
// ret = setExprToCond(pCmd, &pCondExpr->pTagCond,
// *pExpr, NULL, parentOptr);
tSqlExpr *rexpr = NULL;
if ((*pExpr)->tokenId == TK_NE && (pSchema->type != TSDB_DATA_TYPE_BINARY && pSchema->type != TSDB_DATA_TYPE_NCHAR && pSchema->type != TSDB_DATA_TYPE_BOOL)) {
handleNeOptr(&rexpr, *pExpr);
*pExpr = rexpr;
} }
if (type) { if (type) {
*type |= TSQL_EXPR_TAG; *type |= TSQL_EXPR_TAG;
} }
*pExpr = NULL;
} else {
if (pRight != NULL && pRight->tokenId == TK_ID) { // join on tag columns for stable query
if (!validateJoinExprNode(pCmd, pQueryInfo, *pExpr, &index)) {
return TSDB_CODE_TSC_INVALID_OPERATION;
}
pQueryInfo->type |= TSDB_QUERY_TYPE_JOIN_QUERY;
ret = setExprToCond(&pCondExpr->pJoinExpr, *pExpr, NULL, parentOptr, pCmd->payload);
*pExpr = NULL;
if (type) {
*type |= TSQL_EXPR_JOIN;
}
} else {
// do nothing
// ret = setExprToCond(pCmd, &pCondExpr->pTagCond,
// *pExpr, NULL, parentOptr);
tSqlExpr *rexpr = NULL;
if ((*pExpr)->tokenId == TK_NE && (pSchema->type != TSDB_DATA_TYPE_BINARY && pSchema->type != TSDB_DATA_TYPE_NCHAR && pSchema->type != TSDB_DATA_TYPE_BOOL)) {
handleNeOptr(&rexpr, *pExpr);
*pExpr = rexpr;
}
if (type) {
*type |= TSQL_EXPR_TAG;
}
}
} }
} else { // query on other columns } else { // query on other columns
if (type) { if (type) {
...@@ -4940,84 +4758,6 @@ int tableNameCompar(const void* lhs, const void* rhs) { ...@@ -4940,84 +4758,6 @@ int tableNameCompar(const void* lhs, const void* rhs) {
return ret > 0 ? 1 : -1; return ret > 0 ? 1 : -1;
} }
static int32_t setTableCondForSTableQuery(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, const char* account,
tSqlExpr* pExpr, int16_t tableCondIndex, SStringBuilder* sb) {
const char* msg = "table name too long";
if (pExpr == NULL) {
return TSDB_CODE_SUCCESS;
}
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, tableCondIndex);
STagCond* pTagCond = &pQueryInfo->tagCond;
pTagCond->tbnameCond.uid = pTableMetaInfo->pTableMeta->id.uid;
assert(pExpr->tokenId == TK_LIKE
|| pExpr->tokenId == TK_MATCH
|| pExpr->tokenId == TK_NMATCH
|| pExpr->tokenId == TK_IN);
if (pExpr->tokenId == TK_LIKE || pExpr->tokenId == TK_MATCH || pExpr->tokenId == TK_NMATCH) {
char* str = taosStringBuilderGetResult(sb, NULL);
pQueryInfo->tagCond.tbnameCond.cond = strdup(str);
pQueryInfo->tagCond.tbnameCond.len = (int32_t) strlen(str);
return TSDB_CODE_SUCCESS;
} else {
SStringBuilder sb1;
memset(&sb1, 0, sizeof(sb1));
taosStringBuilderAppendStringLen(&sb1, QUERY_COND_REL_PREFIX_IN, QUERY_COND_REL_PREFIX_IN_LEN);
// remove the duplicated input table names
int32_t num = 0;
char* tableNameString = taosStringBuilderGetResult(sb, NULL);
char** segments = strsplit(tableNameString + QUERY_COND_REL_PREFIX_IN_LEN, TBNAME_LIST_SEP, &num);
qsort(segments, num, POINTER_BYTES, tableNameCompar);
int32_t j = 1;
for (int32_t i = 1; i < num; ++i) {
if (strcmp(segments[i], segments[i - 1]) != 0) {
segments[j++] = segments[i];
}
}
num = j;
char name[TSDB_DB_NAME_LEN] = {0};
tNameGetDbName(&pTableMetaInfo->name, name);
SStrToken dbToken = {.type = TK_STRING, .z = name, .n = (uint32_t)strlen(name)};
for (int32_t i = 0; i < num; ++i) {
if (i >= 1) {
taosStringBuilderAppendStringLen(&sb1, TBNAME_LIST_SEP, 1);
}
char idBuf[TSDB_TABLE_FNAME_LEN] = {0};
int32_t xlen = (int32_t)strlen(segments[i]);
SStrToken t = {.z = segments[i], .n = xlen, .type = TK_STRING};
int32_t ret = setObjFullName(idBuf, account, &dbToken, &t, &xlen);
if (ret != TSDB_CODE_SUCCESS) {
taosStringBuilderDestroy(&sb1);
tfree(segments);
invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg);
return ret;
}
taosStringBuilderAppendString(&sb1, idBuf);
}
char* str = taosStringBuilderGetResult(&sb1, NULL);
pQueryInfo->tagCond.tbnameCond.cond = strdup(str);
pQueryInfo->tagCond.tbnameCond.len = (int32_t)strlen(str);
taosStringBuilderDestroy(&sb1);
tfree(segments);
return TSDB_CODE_SUCCESS;
}
}
int32_t mergeTimeRange(SSqlCmd* pCmd, STimeWindow* res, STimeWindow* win, int32_t optr) { int32_t mergeTimeRange(SSqlCmd* pCmd, STimeWindow* res, STimeWindow* win, int32_t optr) {
const char* msg0 = "only one time stamp window allowed"; const char* msg0 = "only one time stamp window allowed";
...@@ -5157,10 +4897,6 @@ static int32_t validateJoinExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondExpr ...@@ -5157,10 +4897,6 @@ static int32_t validateJoinExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondExpr
} }
static void cleanQueryExpr(SCondExpr* pCondExpr) { static void cleanQueryExpr(SCondExpr* pCondExpr) {
if (pCondExpr->pTableCond) {
tSqlExprDestroy(pCondExpr->pTableCond);
}
if (pCondExpr->pColumnCond) { if (pCondExpr->pColumnCond) {
tSqlExprDestroy(pCondExpr->pColumnCond); tSqlExprDestroy(pCondExpr->pColumnCond);
} }
...@@ -5456,7 +5192,7 @@ static int32_t getQueryTimeRange(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr ...@@ -5456,7 +5192,7 @@ static int32_t getQueryTimeRange(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr
//multiple tables's query time range mixed together //multiple tables's query time range mixed together
tExprNode* p = NULL; tExprNode* p = NULL;
SFilterInfo *filter = NULL; void *filter = NULL;
SArray* colList = taosArrayInit(10, sizeof(SColIndex)); SArray* colList = taosArrayInit(10, sizeof(SColIndex));
ret = exprTreeFromSqlExpr(pCmd, &p, *pExpr, pQueryInfo, colList, NULL); ret = exprTreeFromSqlExpr(pCmd, &p, *pExpr, pQueryInfo, colList, NULL);
...@@ -5498,7 +5234,6 @@ int32_t validateWhereNode(SQueryInfo* pQueryInfo, tSqlExpr** pExpr, SSqlObj* pSq ...@@ -5498,7 +5234,6 @@ int32_t validateWhereNode(SQueryInfo* pQueryInfo, tSqlExpr** pExpr, SSqlObj* pSq
int32_t ret = TSDB_CODE_SUCCESS; int32_t ret = TSDB_CODE_SUCCESS;
// tags query condition may be larger than 512bytes, therefore, we need to prepare enough large space // tags query condition may be larger than 512bytes, therefore, we need to prepare enough large space
SStringBuilder sb; memset(&sb, 0, sizeof(sb));
SCondExpr condExpr = {0}; SCondExpr condExpr = {0};
if ((*pExpr)->pLeft == NULL || (*pExpr)->pRight == NULL) { if ((*pExpr)->pLeft == NULL || (*pExpr)->pRight == NULL) {
...@@ -5531,12 +5266,12 @@ int32_t validateWhereNode(SQueryInfo* pQueryInfo, tSqlExpr** pExpr, SSqlObj* pSq ...@@ -5531,12 +5266,12 @@ int32_t validateWhereNode(SQueryInfo* pQueryInfo, tSqlExpr** pExpr, SSqlObj* pSq
condExpr.pTagCond = (*pExpr); condExpr.pTagCond = (*pExpr);
*pExpr = NULL; *pExpr = NULL;
// 1. check if it is a join query // check if it is a join query
if ((ret = validateJoinExpr(&pSql->cmd, pQueryInfo, &condExpr)) != TSDB_CODE_SUCCESS) { if ((ret = validateJoinExpr(&pSql->cmd, pQueryInfo, &condExpr)) != TSDB_CODE_SUCCESS) {
goto PARSE_WHERE_EXIT; goto PARSE_WHERE_EXIT;
} }
// 2. get the query time range // get the query time range
if ((ret = convertTimeRangeFromExpr(&pSql->cmd, pQueryInfo, condExpr.pTimewindow)) != TSDB_CODE_SUCCESS) { if ((ret = convertTimeRangeFromExpr(&pSql->cmd, pQueryInfo, condExpr.pTimewindow)) != TSDB_CODE_SUCCESS) {
goto PARSE_WHERE_EXIT; goto PARSE_WHERE_EXIT;
} }
...@@ -5544,19 +5279,13 @@ int32_t validateWhereNode(SQueryInfo* pQueryInfo, tSqlExpr** pExpr, SSqlObj* pSq ...@@ -5544,19 +5279,13 @@ int32_t validateWhereNode(SQueryInfo* pQueryInfo, tSqlExpr** pExpr, SSqlObj* pSq
if ((ret = getQueryTimeRange(&pSql->cmd, pQueryInfo, &condExpr.pTimewindow)) != TSDB_CODE_SUCCESS) { if ((ret = getQueryTimeRange(&pSql->cmd, pQueryInfo, &condExpr.pTimewindow)) != TSDB_CODE_SUCCESS) {
goto PARSE_WHERE_EXIT; goto PARSE_WHERE_EXIT;
} }
// 3. get the tag query condition // get the tag query condition
if ((ret = getTagQueryCondExpr(&pSql->cmd, pQueryInfo, &condExpr)) != TSDB_CODE_SUCCESS) { if ((ret = getTagQueryCondExpr(&pSql->cmd, pQueryInfo, &condExpr)) != TSDB_CODE_SUCCESS) {
goto PARSE_WHERE_EXIT; goto PARSE_WHERE_EXIT;
} }
// 4. get the table name query condition // other column query condition
if ((ret = getTablenameCond(&pSql->cmd, pQueryInfo, condExpr.pTableCond, &sb)) != TSDB_CODE_SUCCESS) {
goto PARSE_WHERE_EXIT;
}
// 5. other column query condition
if ((ret = checkColumnQueryCondInfo(&pSql->cmd, pQueryInfo, condExpr.pColumnCond, TK_AND)) != TSDB_CODE_SUCCESS) { if ((ret = checkColumnQueryCondInfo(&pSql->cmd, pQueryInfo, condExpr.pColumnCond, TK_AND)) != TSDB_CODE_SUCCESS) {
goto PARSE_WHERE_EXIT; goto PARSE_WHERE_EXIT;
} }
...@@ -5565,21 +5294,11 @@ int32_t validateWhereNode(SQueryInfo* pQueryInfo, tSqlExpr** pExpr, SSqlObj* pSq ...@@ -5565,21 +5294,11 @@ int32_t validateWhereNode(SQueryInfo* pQueryInfo, tSqlExpr** pExpr, SSqlObj* pSq
goto PARSE_WHERE_EXIT; goto PARSE_WHERE_EXIT;
} }
// join condition
// 6. join condition
if ((ret = getJoinCondInfo(&pSql->cmd, pQueryInfo, condExpr.pJoinExpr)) != TSDB_CODE_SUCCESS) { if ((ret = getJoinCondInfo(&pSql->cmd, pQueryInfo, condExpr.pJoinExpr)) != TSDB_CODE_SUCCESS) {
goto PARSE_WHERE_EXIT; goto PARSE_WHERE_EXIT;
} }
// 7. query condition for table name
pQueryInfo->tagCond.relType = (condExpr.relType == TK_AND) ? TSDB_RELATION_AND : TSDB_RELATION_OR;
ret = setTableCondForSTableQuery(&pSql->cmd, pQueryInfo, getAccountId(pSql), condExpr.pTableCond, condExpr.tableCondIndex, &sb);
taosStringBuilderDestroy(&sb);
if (ret) {
goto PARSE_WHERE_EXIT;
}
//if (!validateFilterExpr(pQueryInfo)) { //if (!validateFilterExpr(pQueryInfo)) {
// ret = invalidOperationMsg(tscGetErrorMsgPayload(&pSql->cmd), msg2); // ret = invalidOperationMsg(tscGetErrorMsgPayload(&pSql->cmd), msg2);
// goto PARSE_WHERE_EXIT; // goto PARSE_WHERE_EXIT;
...@@ -5650,6 +5369,10 @@ int32_t getTimeRange(STimeWindow* win, tSqlExpr* pRight, int32_t optr, int16_t t ...@@ -5650,6 +5369,10 @@ int32_t getTimeRange(STimeWindow* win, tSqlExpr* pRight, int32_t optr, int16_t t
pRight->flags &= ~(1 << EXPR_FLAG_NS_TIMESTAMP); pRight->flags &= ~(1 << EXPR_FLAG_NS_TIMESTAMP);
} }
if (pRight->value.nType == -1) {
return TSDB_CODE_TSC_INVALID_OPERATION;
}
tVariantDump(&pRight->value, (char*)&val, TSDB_DATA_TYPE_BIGINT, true); tVariantDump(&pRight->value, (char*)&val, TSDB_DATA_TYPE_BIGINT, true);
} }
...@@ -9230,13 +8953,17 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS ...@@ -9230,13 +8953,17 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS
(*pExpr)->pVal = calloc(1, sizeof(tVariant)); (*pExpr)->pVal = calloc(1, sizeof(tVariant));
tVariantAssign((*pExpr)->pVal, &pSqlExpr->value); tVariantAssign((*pExpr)->pVal, &pSqlExpr->value);
STableMeta* pTableMeta = tscGetMetaInfo(pQueryInfo, 0)->pTableMeta; STableMeta* pTableMeta = tscGetMetaInfo(pQueryInfo, pQueryInfo->curTableIdx)->pTableMeta;
if (pCols != NULL && taosArrayGetSize(pCols) > 0) { if (pCols != NULL) {
SColIndex* idx = taosArrayGet(pCols, 0); size_t colSize = taosArrayGetSize(pCols);
SSchema* pSchema = tscGetTableColumnSchema(pTableMeta, idx->colIndex);
// convert time by precision if (colSize > 0) {
if (pSchema != NULL && TSDB_DATA_TYPE_TIMESTAMP == pSchema->type && TSDB_DATA_TYPE_BINARY == (*pExpr)->pVal->nType) { SColIndex* idx = taosArrayGet(pCols, colSize - 1);
ret = setColumnFilterInfoForTimestamp(pCmd, pQueryInfo, (*pExpr)->pVal); SSchema* pSchema = tscGetTableColumnSchema(pTableMeta, idx->colIndex);
// convert time by precision
if (pSchema != NULL && TSDB_DATA_TYPE_TIMESTAMP == pSchema->type && TSDB_DATA_TYPE_BINARY == (*pExpr)->pVal->nType) {
ret = setColumnFilterInfoForTimestamp(pCmd, pQueryInfo, (*pExpr)->pVal);
}
} }
} }
return ret; return ret;
...@@ -9279,8 +9006,18 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS ...@@ -9279,8 +9006,18 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS
(*pExpr)->nodeType = TSQL_NODE_COL; (*pExpr)->nodeType = TSQL_NODE_COL;
(*pExpr)->pSchema = calloc(1, sizeof(SSchema)); (*pExpr)->pSchema = calloc(1, sizeof(SSchema));
SSchema* pSchema = tscGetTableColumnSchema(pTableMeta, index.columnIndex); SSchema* pSchema = NULL;
*(*pExpr)->pSchema = *pSchema;
if (index.columnIndex == TSDB_TBNAME_COLUMN_INDEX) {
pSchema = (*pExpr)->pSchema;
strcpy(pSchema->name, TSQL_TBNAME_L);
pSchema->type = TSDB_DATA_TYPE_BINARY;
pSchema->colId = TSDB_TBNAME_COLUMN_INDEX;
pSchema->bytes = -1;
} else {
pSchema = tscGetTableColumnSchema(pTableMeta, index.columnIndex);
*(*pExpr)->pSchema = *pSchema;
}
if (pCols != NULL) { // record the involved columns if (pCols != NULL) { // record the involved columns
SColIndex colIndex = {0}; SColIndex colIndex = {0};
...@@ -9301,9 +9038,13 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS ...@@ -9301,9 +9038,13 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS
if (colSize > 0) { if (colSize > 0) {
SColIndex* idx = taosArrayGet(pCols, colSize - 1); SColIndex* idx = taosArrayGet(pCols, colSize - 1);
SSchema* pSchema = tscGetTableColumnSchema(pTableMeta, idx->colIndex); if (idx->colIndex == TSDB_TBNAME_COLUMN_INDEX) {
if (pSchema != NULL) { colType = TSDB_DATA_TYPE_BINARY;
colType = pSchema->type; } else {
SSchema* pSchema = tscGetTableColumnSchema(pTableMeta, idx->colIndex);
if (pSchema != NULL) {
colType = pSchema->type;
}
} }
} }
} }
......
...@@ -703,11 +703,6 @@ static int32_t tscEstimateQueryMsgSize(SSqlObj *pSql) { ...@@ -703,11 +703,6 @@ static int32_t tscEstimateQueryMsgSize(SSqlObj *pSql) {
} }
} }
SCond* pCond = &pQueryInfo->tagCond.tbnameCond;
if (pCond->len > 0) {
srcColListSize += pCond->len;
}
return MIN_QUERY_MSG_PKT_SIZE + minMsgSize() + sizeof(SQueryTableMsg) + srcColListSize + srcColFilterSize + srcTagFilterSize + return MIN_QUERY_MSG_PKT_SIZE + minMsgSize() + sizeof(SQueryTableMsg) + srcColListSize + srcColFilterSize + srcTagFilterSize +
exprSize + tsBufSize + tableSerialize + sqlLen + 4096 + pQueryInfo->bufLen; exprSize + tsBufSize + tableSerialize + sqlLen + 4096 + pQueryInfo->bufLen;
} }
...@@ -956,8 +951,6 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { ...@@ -956,8 +951,6 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pQueryMsg->numOfOutput = htons((int16_t)query.numOfOutput); // this is the stage one output column number pQueryMsg->numOfOutput = htons((int16_t)query.numOfOutput); // this is the stage one output column number
pQueryMsg->numOfGroupCols = htons(pQueryInfo->groupbyExpr.numOfGroupCols); pQueryMsg->numOfGroupCols = htons(pQueryInfo->groupbyExpr.numOfGroupCols);
pQueryMsg->tagNameRelType = htons(pQueryInfo->tagCond.relType);
pQueryMsg->tbnameCondLen = htonl(pQueryInfo->tagCond.tbnameCond.len);
pQueryMsg->queryType = htonl(pQueryInfo->type); pQueryMsg->queryType = htonl(pQueryInfo->type);
pQueryMsg->prevResultLen = htonl(pQueryInfo->bufLen); pQueryMsg->prevResultLen = htonl(pQueryInfo->bufLen);
...@@ -1076,12 +1069,6 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { ...@@ -1076,12 +1069,6 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pMsg += pQueryInfo->bufLen; pMsg += pQueryInfo->bufLen;
} }
SCond* pCond = &pQueryInfo->tagCond.tbnameCond;
if (pCond->len > 0) {
strncpy(pMsg, pCond->cond, pCond->len);
pMsg += pCond->len;
}
// compressed ts block // compressed ts block
pQueryMsg->tsBuf.tsOffset = htonl((int32_t)(pMsg - pCmd->payload)); pQueryMsg->tsBuf.tsOffset = htonl((int32_t)(pMsg - pCmd->payload));
......
...@@ -1347,7 +1347,11 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow ...@@ -1347,7 +1347,11 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
pCmd->command = TSDB_SQL_SELECT; pCmd->command = TSDB_SQL_SELECT;
tscResetForNextRetrieve(&pSql->res); tscResetForNextRetrieve(&pSql->res);
assert(pSupporter->f == NULL); if (pSupporter->f != NULL) {
fclose(pSupporter->f);
pSupporter->f = NULL;
}
taosGetTmpfilePath("ts-join", pSupporter->path); taosGetTmpfilePath("ts-join", pSupporter->path);
// TODO check for failure // TODO check for failure
......
...@@ -814,7 +814,7 @@ typedef struct SDummyInputInfo { ...@@ -814,7 +814,7 @@ typedef struct SDummyInputInfo {
SSDataBlock *block; SSDataBlock *block;
STableQueryInfo *pTableQueryInfo; STableQueryInfo *pTableQueryInfo;
SSqlObj *pSql; // refactor: remove it SSqlObj *pSql; // refactor: remove it
SFilterInfo *pFilterInfo; void *pFilterInfo;
} SDummyInputInfo; } SDummyInputInfo;
typedef struct SJoinStatus { typedef struct SJoinStatus {
...@@ -830,7 +830,7 @@ typedef struct SJoinOperatorInfo { ...@@ -830,7 +830,7 @@ typedef struct SJoinOperatorInfo {
SRspResultInfo resultInfo; // todo refactor, add this info for each operator SRspResultInfo resultInfo; // todo refactor, add this info for each operator
} SJoinOperatorInfo; } SJoinOperatorInfo;
static void doSetupSDataBlock(SSqlRes* pRes, SSDataBlock* pBlock, SFilterInfo* pFilterInfo) { static void doSetupSDataBlock(SSqlRes* pRes, SSDataBlock* pBlock, void* pFilterInfo) {
int32_t offset = 0; int32_t offset = 0;
char* pData = pRes->data; char* pData = pRes->data;
...@@ -847,8 +847,9 @@ static void doSetupSDataBlock(SSqlRes* pRes, SSDataBlock* pBlock, SFilterInfo* p ...@@ -847,8 +847,9 @@ static void doSetupSDataBlock(SSqlRes* pRes, SSDataBlock* pBlock, SFilterInfo* p
// filter data if needed // filter data if needed
if (pFilterInfo) { if (pFilterInfo) {
//doSetFilterColumnInfo(pFilterInfo, numOfFilterCols, pBlock); SColumnDataParam param = {.numOfCols = pBlock->info.numOfCols, .pDataBlock = pBlock->pDataBlock};
filterSetColFieldData(pFilterInfo, pBlock->info.numOfCols, pBlock->pDataBlock); filterSetColFieldData(pFilterInfo, &param, getColumnDataFromId);
bool gotNchar = false; bool gotNchar = false;
filterConverNcharColumns(pFilterInfo, pBlock->info.rows, &gotNchar); filterConverNcharColumns(pFilterInfo, pBlock->info.rows, &gotNchar);
int8_t* p = NULL; int8_t* p = NULL;
...@@ -1111,7 +1112,7 @@ static void destroyDummyInputOperator(void* param, int32_t numOfOutput) { ...@@ -1111,7 +1112,7 @@ static void destroyDummyInputOperator(void* param, int32_t numOfOutput) {
} }
// todo this operator servers as the adapter for Operator tree and SqlRes result, remove it later // todo this operator servers as the adapter for Operator tree and SqlRes result, remove it later
SOperatorInfo* createDummyInputOperator(SSqlObj* pSql, SSchema* pSchema, int32_t numOfCols, SFilterInfo* pFilters) { SOperatorInfo* createDummyInputOperator(SSqlObj* pSql, SSchema* pSchema, int32_t numOfCols, void* pFilters) {
assert(numOfCols > 0); assert(numOfCols > 0);
STimeWindow win = {.skey = INT64_MIN, .ekey = INT64_MAX}; STimeWindow win = {.skey = INT64_MIN, .ekey = INT64_MAX};
...@@ -1253,7 +1254,7 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue ...@@ -1253,7 +1254,7 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue
// if it is a join query, create join operator here // if it is a join query, create join operator here
int32_t numOfCol1 = pTableMeta->tableInfo.numOfColumns; int32_t numOfCol1 = pTableMeta->tableInfo.numOfColumns;
SFilterInfo *pFilters = NULL; void *pFilters = NULL;
STblCond *pCond = NULL; STblCond *pCond = NULL;
if (px->colCond) { if (px->colCond) {
pCond = tsGetTableFilter(px->colCond, pTableMeta->id.uid, 0); pCond = tsGetTableFilter(px->colCond, pTableMeta->id.uid, 0);
...@@ -1280,7 +1281,7 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue ...@@ -1280,7 +1281,7 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue
for(int32_t i = 1; i < px->numOfTables; ++i) { for(int32_t i = 1; i < px->numOfTables; ++i) {
STableMeta* pTableMeta1 = tscGetMetaInfo(px, i)->pTableMeta; STableMeta* pTableMeta1 = tscGetMetaInfo(px, i)->pTableMeta;
numOfCol1 = pTableMeta1->tableInfo.numOfColumns; numOfCol1 = pTableMeta1->tableInfo.numOfColumns;
SFilterInfo *pFilters1 = NULL; void *pFilters1 = NULL;
SSchema* pSchema1 = tscGetTableSchema(pTableMeta1); SSchema* pSchema1 = tscGetTableSchema(pTableMeta1);
int32_t n = pTableMeta1->tableInfo.numOfColumns; int32_t n = pTableMeta1->tableInfo.numOfColumns;
...@@ -2906,16 +2907,6 @@ bool tscValidateColumnId(STableMetaInfo* pTableMetaInfo, int32_t colId, int32_t ...@@ -2906,16 +2907,6 @@ bool tscValidateColumnId(STableMetaInfo* pTableMetaInfo, int32_t colId, int32_t
int32_t tscTagCondCopy(STagCond* dest, const STagCond* src) { int32_t tscTagCondCopy(STagCond* dest, const STagCond* src) {
memset(dest, 0, sizeof(STagCond)); memset(dest, 0, sizeof(STagCond));
if (src->tbnameCond.cond != NULL) {
dest->tbnameCond.cond = strdup(src->tbnameCond.cond);
if (dest->tbnameCond.cond == NULL) {
return -1;
}
}
dest->tbnameCond.uid = src->tbnameCond.uid;
dest->tbnameCond.len = src->tbnameCond.len;
dest->joinInfo.hasJoin = src->joinInfo.hasJoin; dest->joinInfo.hasJoin = src->joinInfo.hasJoin;
for (int32_t i = 0; i < TSDB_MAX_JOIN_TABLE_NUM; ++i) { for (int32_t i = 0; i < TSDB_MAX_JOIN_TABLE_NUM; ++i) {
...@@ -2934,9 +2925,6 @@ int32_t tscTagCondCopy(STagCond* dest, const STagCond* src) { ...@@ -2934,9 +2925,6 @@ int32_t tscTagCondCopy(STagCond* dest, const STagCond* src) {
} }
} }
dest->relType = src->relType;
if (src->pCond == NULL) { if (src->pCond == NULL) {
return 0; return 0;
} }
...@@ -3026,8 +3014,6 @@ void tscColCondRelease(SArray** pCond) { ...@@ -3026,8 +3014,6 @@ void tscColCondRelease(SArray** pCond) {
void tscTagCondRelease(STagCond* pTagCond) { void tscTagCondRelease(STagCond* pTagCond) {
free(pTagCond->tbnameCond.cond);
if (pTagCond->pCond != NULL) { if (pTagCond->pCond != NULL) {
size_t s = taosArrayGetSize(pTagCond->pCond); size_t s = taosArrayGetSize(pTagCond->pCond);
for (int32_t i = 0; i < s; ++i) { for (int32_t i = 0; i < s; ++i) {
......
...@@ -88,7 +88,6 @@ void tExprTreeDestroy(tExprNode *pNode, void (*fp)(void *)); ...@@ -88,7 +88,6 @@ void tExprTreeDestroy(tExprNode *pNode, void (*fp)(void *));
void exprTreeToBinary(SBufferWriter* bw, tExprNode* pExprTree); void exprTreeToBinary(SBufferWriter* bw, tExprNode* pExprTree);
tExprNode* exprTreeFromBinary(const void* data, size_t size); tExprNode* exprTreeFromBinary(const void* data, size_t size);
tExprNode* exprTreeFromTableName(const char* tbnameCond);
tExprNode* exprdup(tExprNode* pTree); tExprNode* exprdup(tExprNode* pTree);
void exprTreeToBinary(SBufferWriter* bw, tExprNode* pExprTree); void exprTreeToBinary(SBufferWriter* bw, tExprNode* pExprTree);
......
...@@ -325,14 +325,6 @@ static void* exception_calloc(size_t nmemb, size_t size) { ...@@ -325,14 +325,6 @@ static void* exception_calloc(size_t nmemb, size_t size) {
return p; return p;
} }
static void* exception_malloc(size_t size) {
void* p = malloc(size);
if (p == NULL) {
THROW(TSDB_CODE_QRY_OUT_OF_MEMORY);
}
return p;
}
static UNUSED_FUNC char* exception_strdup(const char* str) { static UNUSED_FUNC char* exception_strdup(const char* str) {
char* p = strdup(str); char* p = strdup(str);
if (p == NULL) { if (p == NULL) {
...@@ -395,97 +387,6 @@ tExprNode* exprTreeFromBinary(const void* data, size_t size) { ...@@ -395,97 +387,6 @@ tExprNode* exprTreeFromBinary(const void* data, size_t size) {
return exprTreeFromBinaryImpl(&br); return exprTreeFromBinaryImpl(&br);
} }
tExprNode* exprTreeFromTableName(const char* tbnameCond) {
if (!tbnameCond) {
return NULL;
}
int32_t anchor = CLEANUP_GET_ANCHOR();
tExprNode* expr = exception_calloc(1, sizeof(tExprNode));
CLEANUP_PUSH_VOID_PTR_PTR(true, tExprTreeDestroy, expr, NULL);
expr->nodeType = TSQL_NODE_EXPR;
tExprNode* left = exception_calloc(1, sizeof(tExprNode));
expr->_node.pLeft = left;
left->nodeType = TSQL_NODE_COL;
SSchema* pSchema = exception_calloc(1, sizeof(SSchema));
left->pSchema = pSchema;
*pSchema = *tGetTbnameColumnSchema();
tExprNode* right = exception_calloc(1, sizeof(tExprNode));
expr->_node.pRight = right;
if (strncmp(tbnameCond, QUERY_COND_REL_PREFIX_LIKE, QUERY_COND_REL_PREFIX_LIKE_LEN) == 0) {
right->nodeType = TSQL_NODE_VALUE;
expr->_node.optr = TSDB_RELATION_LIKE;
tVariant* pVal = exception_calloc(1, sizeof(tVariant));
right->pVal = pVal;
size_t len = strlen(tbnameCond + QUERY_COND_REL_PREFIX_LIKE_LEN) + 1;
pVal->pz = exception_malloc(len);
memcpy(pVal->pz, tbnameCond + QUERY_COND_REL_PREFIX_LIKE_LEN, len);
pVal->nType = TSDB_DATA_TYPE_BINARY;
pVal->nLen = (int32_t)len;
} else if (strncmp(tbnameCond, QUERY_COND_REL_PREFIX_MATCH, QUERY_COND_REL_PREFIX_MATCH_LEN) == 0) {
right->nodeType = TSQL_NODE_VALUE;
expr->_node.optr = TSDB_RELATION_MATCH;
tVariant* pVal = exception_calloc(1, sizeof(tVariant));
right->pVal = pVal;
size_t len = strlen(tbnameCond + QUERY_COND_REL_PREFIX_MATCH_LEN) + 1;
pVal->pz = exception_malloc(len);
memcpy(pVal->pz, tbnameCond + QUERY_COND_REL_PREFIX_MATCH_LEN, len);
pVal->nType = TSDB_DATA_TYPE_BINARY;
pVal->nLen = (int32_t)len;
} else if (strncmp(tbnameCond, QUERY_COND_REL_PREFIX_NMATCH, QUERY_COND_REL_PREFIX_NMATCH_LEN) == 0) {
right->nodeType = TSQL_NODE_VALUE;
expr->_node.optr = TSDB_RELATION_NMATCH;
tVariant* pVal = exception_calloc(1, sizeof(tVariant));
right->pVal = pVal;
size_t len = strlen(tbnameCond + QUERY_COND_REL_PREFIX_NMATCH_LEN) + 1;
pVal->pz = exception_malloc(len);
memcpy(pVal->pz, tbnameCond + QUERY_COND_REL_PREFIX_NMATCH_LEN, len);
pVal->nType = TSDB_DATA_TYPE_BINARY;
pVal->nLen = (int32_t)len;
} else if (strncmp(tbnameCond, QUERY_COND_REL_PREFIX_IN, QUERY_COND_REL_PREFIX_IN_LEN) == 0) {
right->nodeType = TSQL_NODE_VALUE;
expr->_node.optr = TSDB_RELATION_IN;
tVariant* pVal = exception_calloc(1, sizeof(tVariant));
right->pVal = pVal;
pVal->nType = TSDB_DATA_TYPE_POINTER_ARRAY;
pVal->arr = taosArrayInit(2, POINTER_BYTES);
const char* cond = tbnameCond + QUERY_COND_REL_PREFIX_IN_LEN;
for (const char *e = cond; *e != 0; e++) {
if (*e == TS_PATH_DELIMITER[0]) {
cond = e + 1;
} else if (*e == ',') {
size_t len = e - cond;
char* p = exception_malloc(len + VARSTR_HEADER_SIZE);
STR_WITH_SIZE_TO_VARSTR(p, cond, (VarDataLenT)len);
cond += len;
taosArrayPush(pVal->arr, &p);
}
}
if (*cond != 0) {
size_t len = strlen(cond) + VARSTR_HEADER_SIZE;
char* p = exception_malloc(len);
STR_WITH_SIZE_TO_VARSTR(p, cond, (VarDataLenT)(len - VARSTR_HEADER_SIZE));
taosArrayPush(pVal->arr, &p);
}
taosArraySortString(pVal->arr, taosArrayCompareString);
}
CLEANUP_EXECUTE_TO(anchor, false);
return expr;
}
void buildFilterSetFromBinary(void **q, const char *buf, int32_t len) { void buildFilterSetFromBinary(void **q, const char *buf, int32_t len) {
SBufferReader br = tbufInitReader(buf, len, false); SBufferReader br = tbufInitReader(buf, len, false);
uint32_t type = tbufReadUint32(&br); uint32_t type = tbufReadUint32(&br);
......
...@@ -492,7 +492,6 @@ typedef struct { ...@@ -492,7 +492,6 @@ typedef struct {
SSessionWindow sw; // session window SSessionWindow sw; // session window
uint16_t tagCondLen; // tag length in current query uint16_t tagCondLen; // tag length in current query
uint16_t colCondLen; // column length in current query uint16_t colCondLen; // column length in current query
uint32_t tbnameCondLen; // table name filter condition string length
int16_t numOfGroupCols; // num of group by columns int16_t numOfGroupCols; // num of group by columns
int16_t orderByIdx; int16_t orderByIdx;
int16_t orderType; // used in group by xx order by xxx int16_t orderType; // used in group by xx order by xxx
...@@ -502,7 +501,6 @@ typedef struct { ...@@ -502,7 +501,6 @@ typedef struct {
int64_t offset; int64_t offset;
uint32_t queryType; // denote another query process uint32_t queryType; // denote another query process
int16_t numOfOutput; // final output columns numbers int16_t numOfOutput; // final output columns numbers
int16_t tagNameRelType; // relation of tag criteria and tbname criteria
int16_t fillType; // interpolate type int16_t fillType; // interpolate type
uint64_t fillVal; // default value array list uint64_t fillVal; // default value array list
int32_t secondStageOutput; int32_t secondStageOutput;
......
...@@ -352,8 +352,7 @@ SArray *tsdbRetrieveDataBlock(TsdbQueryHandleT *pQueryHandle, SArray *pColumnIdL ...@@ -352,8 +352,7 @@ SArray *tsdbRetrieveDataBlock(TsdbQueryHandleT *pQueryHandle, SArray *pColumnIdL
* @param pTagCond. tag query condition * @param pTagCond. tag query condition
*/ */
int32_t tsdbQuerySTableByTagCond(STsdbRepo *tsdb, uint64_t uid, TSKEY key, const char *pTagCond, size_t len, int32_t tsdbQuerySTableByTagCond(STsdbRepo *tsdb, uint64_t uid, TSKEY key, const char *pTagCond, size_t len,
int16_t tagNameRelType, const char *tbnameCond, STableGroupInfo *pGroupList, STableGroupInfo *pGroupList, SColIndex *pColIndex, int32_t numOfCols);
SColIndex *pColIndex, int32_t numOfCols);
/** /**
* destroy the created table group list, which is generated by tag query * destroy the created table group list, which is generated by tag query
......
...@@ -569,7 +569,7 @@ static void shellPrintNChar(const char *str, int length, int width) { ...@@ -569,7 +569,7 @@ static void shellPrintNChar(const char *str, int length, int width) {
while (pos < length) { while (pos < length) {
wchar_t wc; wchar_t wc;
int bytes = mbtowc(&wc, str + pos, MB_CUR_MAX); int bytes = mbtowc(&wc, str + pos, MB_CUR_MAX);
if (bytes == 0) { if (bytes <= 0) {
break; break;
} }
pos += bytes; pos += bytes;
......
...@@ -264,7 +264,7 @@ typedef struct SQueryAttr { ...@@ -264,7 +264,7 @@ typedef struct SQueryAttr {
SOrderedPrjQueryInfo prjInfo; // limit value for each vgroup, only available in global order projection query. SOrderedPrjQueryInfo prjInfo; // limit value for each vgroup, only available in global order projection query.
SSingleColumnFilterInfo* pFilterInfo; SSingleColumnFilterInfo* pFilterInfo;
SFilterInfo *pFilters; void *pFilters;
void* tsdb; void* tsdb;
SMemRef memRef; SMemRef memRef;
...@@ -399,7 +399,6 @@ typedef struct SQueryParam { ...@@ -399,7 +399,6 @@ typedef struct SQueryParam {
char *sql; char *sql;
char *tagCond; char *tagCond;
char *colCond; char *colCond;
char *tbnameCond;
char *prevResult; char *prevResult;
SArray *pTableIdList; SArray *pTableIdList;
SSqlExpr **pExpr; SSqlExpr **pExpr;
...@@ -407,7 +406,7 @@ typedef struct SQueryParam { ...@@ -407,7 +406,7 @@ typedef struct SQueryParam {
SExprInfo *pExprs; SExprInfo *pExprs;
SExprInfo *pSecExprs; SExprInfo *pSecExprs;
SFilterInfo *pFilters; void *pFilters;
SColIndex *pGroupColIndex; SColIndex *pGroupColIndex;
SColumnInfo *pTagColumnInfo; SColumnInfo *pTagColumnInfo;
...@@ -417,6 +416,11 @@ typedef struct SQueryParam { ...@@ -417,6 +416,11 @@ typedef struct SQueryParam {
SUdfInfo *pUdfInfo; SUdfInfo *pUdfInfo;
} SQueryParam; } SQueryParam;
typedef struct SColumnDataParam{
int32_t numOfCols;
SArray* pDataBlock;
} SColumnDataParam;
typedef struct STableScanInfo { typedef struct STableScanInfo {
void *pQueryHandle; void *pQueryHandle;
int32_t numOfBlocks; int32_t numOfBlocks;
...@@ -640,11 +644,11 @@ int32_t createQueryFunc(SQueriedTableInfo* pTableInfo, int32_t numOfOutput, SExp ...@@ -640,11 +644,11 @@ int32_t createQueryFunc(SQueriedTableInfo* pTableInfo, int32_t numOfOutput, SExp
int32_t createIndirectQueryFuncExprFromMsg(SQueryTableMsg *pQueryMsg, int32_t numOfOutput, SExprInfo **pExprInfo, int32_t createIndirectQueryFuncExprFromMsg(SQueryTableMsg *pQueryMsg, int32_t numOfOutput, SExprInfo **pExprInfo,
SSqlExpr **pExpr, SExprInfo *prevExpr, SUdfInfo *pUdfInfo); SSqlExpr **pExpr, SExprInfo *prevExpr, SUdfInfo *pUdfInfo);
int32_t createQueryFilter(char *data, uint16_t len, SFilterInfo** pFilters); int32_t createQueryFilter(char *data, uint16_t len, void** pFilters);
SGroupbyExpr *createGroupbyExprFromMsg(SQueryTableMsg *pQueryMsg, SColIndex *pColIndex, int32_t *code); SGroupbyExpr *createGroupbyExprFromMsg(SQueryTableMsg *pQueryMsg, SColIndex *pColIndex, int32_t *code);
SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SGroupbyExpr *pGroupbyExpr, SExprInfo *pExprs, SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SGroupbyExpr *pGroupbyExpr, SExprInfo *pExprs,
SExprInfo *pSecExprs, STableGroupInfo *pTableGroupInfo, SColumnInfo* pTagCols, SFilterInfo* pFilters, int32_t vgId, char* sql, uint64_t qId, SUdfInfo* pUdfInfo); SExprInfo *pSecExprs, STableGroupInfo *pTableGroupInfo, SColumnInfo* pTagCols, void* pFilters, int32_t vgId, char* sql, uint64_t qId, SUdfInfo* pUdfInfo);
int32_t initQInfo(STsBufInfo* pTsBufInfo, void* tsdb, void* sourceOptr, SQInfo* pQInfo, SQueryParam* param, char* start, int32_t initQInfo(STsBufInfo* pTsBufInfo, void* tsdb, void* sourceOptr, SQInfo* pQInfo, SQueryParam* param, char* start,
int32_t prevResultLen, void* merger); int32_t prevResultLen, void* merger);
...@@ -684,5 +688,6 @@ void freeQueryAttr(SQueryAttr *pQuery); ...@@ -684,5 +688,6 @@ void freeQueryAttr(SQueryAttr *pQuery);
int32_t getMaximumIdleDurationSec(); int32_t getMaximumIdleDurationSec();
void doInvokeUdf(SUdfInfo* pUdfInfo, SQLFunctionCtx *pCtx, int32_t idx, int32_t type); void doInvokeUdf(SUdfInfo* pUdfInfo, SQLFunctionCtx *pCtx, int32_t idx, int32_t type);
int32_t getColumnDataFromId(void *param, int32_t id, void **data);
#endif // TDENGINE_QEXECUTOR_H #endif // TDENGINE_QEXECUTOR_H
...@@ -83,6 +83,12 @@ enum { ...@@ -83,6 +83,12 @@ enum {
RANGE_TYPE_MR_CTX = 3, RANGE_TYPE_MR_CTX = 3,
}; };
enum {
FI_ACTION_NO_NEED = 1,
FI_ACTION_CONTINUE,
FI_ACTION_STOP,
};
typedef struct OptrStr { typedef struct OptrStr {
uint16_t optr; uint16_t optr;
char *str; char *str;
...@@ -106,6 +112,7 @@ typedef struct SFilterColRange { ...@@ -106,6 +112,7 @@ typedef struct SFilterColRange {
typedef bool (*rangeCompFunc) (const void *, const void *, const void *, const void *, __compar_fn_t); typedef bool (*rangeCompFunc) (const void *, const void *, const void *, const void *, __compar_fn_t);
typedef int32_t(*filter_desc_compare_func)(const void *, const void *); typedef int32_t(*filter_desc_compare_func)(const void *, const void *);
typedef bool(*filter_exec_func)(void *, int32_t, int8_t**, SDataStatis *, int16_t); typedef bool(*filter_exec_func)(void *, int32_t, int8_t**, SDataStatis *, int16_t);
typedef int32_t (*filer_get_col_from_id)(void *, int32_t, void **);
typedef struct SFilterRangeCompare { typedef struct SFilterRangeCompare {
int64_t s; int64_t s;
...@@ -323,14 +330,16 @@ typedef struct SFilterInfo { ...@@ -323,14 +330,16 @@ typedef struct SFilterInfo {
#define FILTER_EMPTY_RES(i) FILTER_GET_FLAG((i)->status, FI_STATUS_EMPTY) #define FILTER_EMPTY_RES(i) FILTER_GET_FLAG((i)->status, FI_STATUS_EMPTY)
extern int32_t filterInitFromTree(tExprNode* tree, SFilterInfo **pinfo, uint32_t options); extern int32_t filterInitFromTree(tExprNode* tree, void **pinfo, uint32_t options);
extern bool filterExecute(SFilterInfo *info, int32_t numOfRows, int8_t** p, SDataStatis *statis, int16_t numOfCols); extern bool filterExecute(SFilterInfo *info, int32_t numOfRows, int8_t** p, SDataStatis *statis, int16_t numOfCols);
extern int32_t filterSetColFieldData(SFilterInfo *info, int32_t numOfCols, SArray* pDataBlock); extern int32_t filterSetColFieldData(SFilterInfo *info, void *param, filer_get_col_from_id fp);
extern int32_t filterGetTimeRange(SFilterInfo *info, STimeWindow *win); extern int32_t filterGetTimeRange(SFilterInfo *info, STimeWindow *win);
extern int32_t filterConverNcharColumns(SFilterInfo* pFilterInfo, int32_t rows, bool *gotNchar); extern int32_t filterConverNcharColumns(SFilterInfo* pFilterInfo, int32_t rows, bool *gotNchar);
extern int32_t filterFreeNcharColumns(SFilterInfo* pFilterInfo); extern int32_t filterFreeNcharColumns(SFilterInfo* pFilterInfo);
extern void filterFreeInfo(SFilterInfo *info); extern void filterFreeInfo(SFilterInfo *info);
extern bool filterRangeExecute(SFilterInfo *info, SDataStatis *pDataStatis, int32_t numOfCols, int32_t numOfRows); extern bool filterRangeExecute(SFilterInfo *info, SDataStatis *pDataStatis, int32_t numOfCols, int32_t numOfRows);
extern int32_t filterIsIndexedColumnQuery(SFilterInfo* info, int32_t idxId, bool *res);
extern int32_t filterGetIndexedColumnInfo(SFilterInfo* info, char** val, int32_t *order, int32_t *flag);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -38,12 +38,6 @@ typedef struct SJoinInfo { ...@@ -38,12 +38,6 @@ typedef struct SJoinInfo {
} SJoinInfo; } SJoinInfo;
typedef struct STagCond { typedef struct STagCond {
// relation between tbname list and query condition, including : TK_AND or TK_OR
int16_t relType;
// tbname query condition, only support tbname query condition on one table
SCond tbnameCond;
// join condition, only support two tables join currently // join condition, only support two tables join currently
SJoinInfo joinInfo; SJoinInfo joinInfo;
...@@ -93,6 +87,7 @@ typedef struct STableMetaInfo { ...@@ -93,6 +87,7 @@ typedef struct STableMetaInfo {
SName name; SName name;
char aliasName[TSDB_TABLE_NAME_LEN]; // alias name of table specified in query sql char aliasName[TSDB_TABLE_NAME_LEN]; // alias name of table specified in query sql
SArray *tagColList; // SArray<SColumn*>, involved tag columns SArray *tagColList; // SArray<SColumn*>, involved tag columns
int32_t joinTagNum;
} STableMetaInfo; } STableMetaInfo;
struct SQInfo; // global merge operator struct SQInfo; // global merge operator
...@@ -100,7 +95,7 @@ struct SQueryAttr; // query object ...@@ -100,7 +95,7 @@ struct SQueryAttr; // query object
typedef struct STableFilter { typedef struct STableFilter {
uint64_t uid; uint64_t uid;
SFilterInfo info; void *info;
} STableFilter; } STableFilter;
typedef struct SQueryInfo { typedef struct SQueryInfo {
......
...@@ -2969,6 +2969,10 @@ void filterRowsInDataBlock(SQueryRuntimeEnv* pRuntimeEnv, SSingleColumnFilterInf ...@@ -2969,6 +2969,10 @@ void filterRowsInDataBlock(SQueryRuntimeEnv* pRuntimeEnv, SSingleColumnFilterInf
} }
if (!tsBufNextPos(pRuntimeEnv->pTsBuf)) { if (!tsBufNextPos(pRuntimeEnv->pTsBuf)) {
if (i < (numOfRows - 1)) {
all = false;
}
break; break;
} }
} }
...@@ -3010,11 +3014,15 @@ void filterColRowsInDataBlock(SQueryRuntimeEnv* pRuntimeEnv, SSDataBlock* pBlock ...@@ -3010,11 +3014,15 @@ void filterColRowsInDataBlock(SQueryRuntimeEnv* pRuntimeEnv, SSDataBlock* pBlock
p[offset] = true; p[offset] = true;
} }
if (!tsBufNextPos(pRuntimeEnv->pTsBuf)) { if (!tsBufNextPos(pRuntimeEnv->pTsBuf)) {
if (i < (numOfRows - 1)) {
all = false;
}
break; break;
} }
} }
// save the cursor status // save the cursor status
pRuntimeEnv->current->cur = tsBufGetCursor(pRuntimeEnv->pTsBuf); pRuntimeEnv->current->cur = tsBufGetCursor(pRuntimeEnv->pTsBuf);
} else { } else {
...@@ -3076,6 +3084,22 @@ void doSetFilterColumnInfo(SSingleColumnFilterInfo* pFilterInfo, int32_t numOfFi ...@@ -3076,6 +3084,22 @@ void doSetFilterColumnInfo(SSingleColumnFilterInfo* pFilterInfo, int32_t numOfFi
} }
} }
FORCE_INLINE int32_t getColumnDataFromId(void *param, int32_t id, void **data) {
int32_t numOfCols = ((SColumnDataParam *)param)->numOfCols;
SArray* pDataBlock = ((SColumnDataParam *)param)->pDataBlock;
for (int32_t j = 0; j < numOfCols; ++j) {
SColumnInfoData* pColInfo = taosArrayGet(pDataBlock, j);
if (id == pColInfo->info.colId) {
*data = pColInfo->pData;
break;
}
}
return TSDB_CODE_SUCCESS;
}
int32_t loadDataBlockOnDemand(SQueryRuntimeEnv* pRuntimeEnv, STableScanInfo* pTableScanInfo, SSDataBlock* pBlock, int32_t loadDataBlockOnDemand(SQueryRuntimeEnv* pRuntimeEnv, STableScanInfo* pTableScanInfo, SSDataBlock* pBlock,
uint32_t* status) { uint32_t* status) {
*status = BLK_DATA_NO_NEEDED; *status = BLK_DATA_NO_NEEDED;
...@@ -3230,7 +3254,8 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv* pRuntimeEnv, STableScanInfo* pTa ...@@ -3230,7 +3254,8 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv* pRuntimeEnv, STableScanInfo* pTa
} }
if (pQueryAttr->pFilters != NULL) { if (pQueryAttr->pFilters != NULL) {
filterSetColFieldData(pQueryAttr->pFilters, pBlock->info.numOfCols, pBlock->pDataBlock); SColumnDataParam param = {.numOfCols = pBlock->info.numOfCols, .pDataBlock = pBlock->pDataBlock};
filterSetColFieldData(pQueryAttr->pFilters, &param, getColumnDataFromId);
} }
if (pQueryAttr->pFilters != NULL || pRuntimeEnv->pTsBuf != NULL) { if (pQueryAttr->pFilters != NULL || pRuntimeEnv->pTsBuf != NULL) {
...@@ -7517,7 +7542,6 @@ int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SQueryParam* param) { ...@@ -7517,7 +7542,6 @@ int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SQueryParam* param) {
pQueryMsg->order = htons(pQueryMsg->order); pQueryMsg->order = htons(pQueryMsg->order);
pQueryMsg->orderColId = htons(pQueryMsg->orderColId); pQueryMsg->orderColId = htons(pQueryMsg->orderColId);
pQueryMsg->queryType = htonl(pQueryMsg->queryType); pQueryMsg->queryType = htonl(pQueryMsg->queryType);
pQueryMsg->tagNameRelType = htons(pQueryMsg->tagNameRelType);
pQueryMsg->numOfCols = htons(pQueryMsg->numOfCols); pQueryMsg->numOfCols = htons(pQueryMsg->numOfCols);
pQueryMsg->numOfOutput = htons(pQueryMsg->numOfOutput); pQueryMsg->numOfOutput = htons(pQueryMsg->numOfOutput);
...@@ -7532,7 +7556,6 @@ int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SQueryParam* param) { ...@@ -7532,7 +7556,6 @@ int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SQueryParam* param) {
pQueryMsg->tsBuf.tsOrder = htonl(pQueryMsg->tsBuf.tsOrder); pQueryMsg->tsBuf.tsOrder = htonl(pQueryMsg->tsBuf.tsOrder);
pQueryMsg->numOfTags = htonl(pQueryMsg->numOfTags); pQueryMsg->numOfTags = htonl(pQueryMsg->numOfTags);
pQueryMsg->tbnameCondLen = htonl(pQueryMsg->tbnameCondLen);
pQueryMsg->secondStageOutput = htonl(pQueryMsg->secondStageOutput); pQueryMsg->secondStageOutput = htonl(pQueryMsg->secondStageOutput);
pQueryMsg->sqlstrLen = htonl(pQueryMsg->sqlstrLen); pQueryMsg->sqlstrLen = htonl(pQueryMsg->sqlstrLen);
pQueryMsg->prevResultLen = htonl(pQueryMsg->prevResultLen); pQueryMsg->prevResultLen = htonl(pQueryMsg->prevResultLen);
...@@ -7776,17 +7799,6 @@ int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SQueryParam* param) { ...@@ -7776,17 +7799,6 @@ int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SQueryParam* param) {
pMsg += pQueryMsg->prevResultLen; pMsg += pQueryMsg->prevResultLen;
} }
if (pQueryMsg->tbnameCondLen > 0) {
param->tbnameCond = calloc(1, pQueryMsg->tbnameCondLen + 1);
if (param->tbnameCond == NULL) {
code = TSDB_CODE_QRY_OUT_OF_MEMORY;
goto _cleanup;
}
strncpy(param->tbnameCond, pMsg, pQueryMsg->tbnameCondLen);
pMsg += pQueryMsg->tbnameCondLen;
}
//skip ts buf //skip ts buf
if ((pQueryMsg->tsBuf.tsOffset + pQueryMsg->tsBuf.tsLen) > 0) { if ((pQueryMsg->tsBuf.tsOffset + pQueryMsg->tsBuf.tsLen) > 0) {
pMsg = (char *)pQueryMsg + pQueryMsg->tsBuf.tsOffset + pQueryMsg->tsBuf.tsLen; pMsg = (char *)pQueryMsg + pQueryMsg->tsBuf.tsOffset + pQueryMsg->tsBuf.tsLen;
...@@ -8167,7 +8179,7 @@ int32_t createQueryFunc(SQueriedTableInfo* pTableInfo, int32_t numOfOutput, SExp ...@@ -8167,7 +8179,7 @@ int32_t createQueryFunc(SQueriedTableInfo* pTableInfo, int32_t numOfOutput, SExp
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t createQueryFilter(char *data, uint16_t len, SFilterInfo** pFilters) { int32_t createQueryFilter(char *data, uint16_t len, void** pFilters) {
tExprNode* expr = NULL; tExprNode* expr = NULL;
TRY(TSDB_MAX_TAG_CONDITIONS) { TRY(TSDB_MAX_TAG_CONDITIONS) {
...@@ -8421,7 +8433,7 @@ FORCE_INLINE bool checkQIdEqual(void *qHandle, uint64_t qId) { ...@@ -8421,7 +8433,7 @@ FORCE_INLINE bool checkQIdEqual(void *qHandle, uint64_t qId) {
} }
SQInfo* createQInfoImpl(SQueryTableMsg* pQueryMsg, SGroupbyExpr* pGroupbyExpr, SExprInfo* pExprs, SQInfo* createQInfoImpl(SQueryTableMsg* pQueryMsg, SGroupbyExpr* pGroupbyExpr, SExprInfo* pExprs,
SExprInfo* pSecExprs, STableGroupInfo* pTableGroupInfo, SColumnInfo* pTagCols, SFilterInfo* pFilters, int32_t vgId, SExprInfo* pSecExprs, STableGroupInfo* pTableGroupInfo, SColumnInfo* pTagCols, void* pFilters, int32_t vgId,
char* sql, uint64_t qId, SUdfInfo* pUdfInfo) { char* sql, uint64_t qId, SUdfInfo* pUdfInfo) {
int16_t numOfCols = pQueryMsg->numOfCols; int16_t numOfCols = pQueryMsg->numOfCols;
int16_t numOfOutput = pQueryMsg->numOfOutput; int16_t numOfOutput = pQueryMsg->numOfOutput;
......
...@@ -28,14 +28,14 @@ OptrStr gOptrStr[] = { ...@@ -28,14 +28,14 @@ OptrStr gOptrStr[] = {
{TSDB_RELATION_GREATER_EQUAL, ">="}, {TSDB_RELATION_GREATER_EQUAL, ">="},
{TSDB_RELATION_NOT_EQUAL, "!="}, {TSDB_RELATION_NOT_EQUAL, "!="},
{TSDB_RELATION_LIKE, "like"}, {TSDB_RELATION_LIKE, "like"},
{TSDB_RELATION_MATCH, "match"},
{TSDB_RELATION_MATCH, "nmatch"},
{TSDB_RELATION_ISNULL, "is null"}, {TSDB_RELATION_ISNULL, "is null"},
{TSDB_RELATION_NOTNULL, "not null"}, {TSDB_RELATION_NOTNULL, "not null"},
{TSDB_RELATION_IN, "in"}, {TSDB_RELATION_IN, "in"},
{TSDB_RELATION_AND, "and"}, {TSDB_RELATION_AND, "and"},
{TSDB_RELATION_OR, "or"}, {TSDB_RELATION_OR, "or"},
{TSDB_RELATION_NOT, "not"} {TSDB_RELATION_NOT, "not"},
{TSDB_RELATION_MATCH, "match"},
{TSDB_RELATION_NMATCH, "nmatch"},
}; };
static FORCE_INLINE int32_t filterFieldColDescCompare(const void *desc1, const void *desc2) { static FORCE_INLINE int32_t filterFieldColDescCompare(const void *desc1, const void *desc2) {
...@@ -937,7 +937,7 @@ int32_t filterAddUnitToGroup(SFilterGroup *group, uint16_t unitIdx) { ...@@ -937,7 +937,7 @@ int32_t filterAddUnitToGroup(SFilterGroup *group, uint16_t unitIdx) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t filterConvertSetFromBinary(void **q, const char *buf, int32_t len, uint32_t tType) { int32_t filterConvertSetFromBinary(void **q, const char *buf, int32_t len, uint32_t tType, bool tolower) {
SBufferReader br = tbufInitReader(buf, len, false); SBufferReader br = tbufInitReader(buf, len, false);
uint32_t sType = tbufReadUint32(&br); uint32_t sType = tbufReadUint32(&br);
SHashObj *pObj = taosHashInit(256, taosGetDefaultHashFunction(tType), true, false); SHashObj *pObj = taosHashInit(256, taosGetDefaultHashFunction(tType), true, false);
...@@ -1113,6 +1113,10 @@ int32_t filterConvertSetFromBinary(void **q, const char *buf, int32_t len, uint3 ...@@ -1113,6 +1113,10 @@ int32_t filterConvertSetFromBinary(void **q, const char *buf, int32_t len, uint3
} }
t = varDataLen(tmp); t = varDataLen(tmp);
pvar = varDataVal(tmp); pvar = varDataVal(tmp);
if (tolower) {
strntolower_s(pvar, pvar, (int32_t)t);
}
break; break;
} }
case TSDB_DATA_TYPE_NCHAR: { case TSDB_DATA_TYPE_NCHAR: {
...@@ -1157,7 +1161,7 @@ int32_t filterAddGroupUnitFromNode(SFilterInfo *info, tExprNode* tree, SArray *g ...@@ -1157,7 +1161,7 @@ int32_t filterAddGroupUnitFromNode(SFilterInfo *info, tExprNode* tree, SArray *g
if (tree->_node.optr == TSDB_RELATION_IN && (!IS_VAR_DATA_TYPE(type))) { if (tree->_node.optr == TSDB_RELATION_IN && (!IS_VAR_DATA_TYPE(type))) {
void *data = NULL; void *data = NULL;
filterConvertSetFromBinary((void **)&data, var->pz, var->nLen, type); filterConvertSetFromBinary((void **)&data, var->pz, var->nLen, type, false);
CHK_LRET(data == NULL, TSDB_CODE_QRY_APP_ERROR, "failed to convert in param"); CHK_LRET(data == NULL, TSDB_CODE_QRY_APP_ERROR, "failed to convert in param");
if (taosHashGetSize((SHashObj *)data) <= 0) { if (taosHashGetSize((SHashObj *)data) <= 0) {
...@@ -1484,19 +1488,6 @@ _return: ...@@ -1484,19 +1488,6 @@ _return:
return code; return code;
} }
#if 0
int32_t filterInitUnitFunc(SFilterInfo *info) {
for (uint16_t i = 0; i < info->unitNum; ++i) {
SFilterUnit* unit = &info->units[i];
info->cunits[i].func = getComparFunc(FILTER_UNIT_DATA_TYPE(unit), unit->compare.optr);
}
return TSDB_CODE_SUCCESS;
}
#endif
void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options) { void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options) {
if (qDebugFlag & DEBUG_DEBUG) { if (qDebugFlag & DEBUG_DEBUG) {
CHK_LRETV(info == NULL, "%s - FilterInfo: EMPTY", msg); CHK_LRETV(info == NULL, "%s - FilterInfo: EMPTY", msg);
...@@ -1811,7 +1802,10 @@ int32_t filterInitValFieldData(SFilterInfo *info) { ...@@ -1811,7 +1802,10 @@ int32_t filterInitValFieldData(SFilterInfo *info) {
} }
if (unit->compare.optr == TSDB_RELATION_IN) { if (unit->compare.optr == TSDB_RELATION_IN) {
filterConvertSetFromBinary((void **)&fi->data, var->pz, var->nLen, type); SSchema *sch = FILTER_UNIT_COL_DESC(info, unit);
bool tolower = (sch->colId == -1) ? true : false;
filterConvertSetFromBinary((void **)&fi->data, var->pz, var->nLen, type, tolower);
CHK_LRET(fi->data == NULL, TSDB_CODE_QRY_APP_ERROR, "failed to convert in param"); CHK_LRET(fi->data == NULL, TSDB_CODE_QRY_APP_ERROR, "failed to convert in param");
FILTER_SET_FLAG(fi->flag, FLD_DATA_IS_HASH); FILTER_SET_FLAG(fi->flag, FLD_DATA_IS_HASH);
...@@ -2544,8 +2538,6 @@ int32_t filterPostProcessRange(SFilterInfo *info) { ...@@ -2544,8 +2538,6 @@ int32_t filterPostProcessRange(SFilterInfo *info) {
int32_t filterGenerateComInfo(SFilterInfo *info) { int32_t filterGenerateComInfo(SFilterInfo *info) {
uint16_t n = 0;
info->cunits = malloc(info->unitNum * sizeof(*info->cunits)); info->cunits = malloc(info->unitNum * sizeof(*info->cunits));
info->blkUnitRes = malloc(sizeof(*info->blkUnitRes) * info->unitNum); info->blkUnitRes = malloc(sizeof(*info->blkUnitRes) * info->unitNum);
info->blkUnits = malloc(sizeof(*info->blkUnits) * (info->unitNum + 1) * info->groupNum); info->blkUnits = malloc(sizeof(*info->blkUnits) * (info->unitNum + 1) * info->groupNum);
...@@ -2573,24 +2565,6 @@ int32_t filterGenerateComInfo(SFilterInfo *info) { ...@@ -2573,24 +2565,6 @@ int32_t filterGenerateComInfo(SFilterInfo *info) {
info->cunits[i].dataSize = FILTER_UNIT_COL_SIZE(info, unit); info->cunits[i].dataSize = FILTER_UNIT_COL_SIZE(info, unit);
info->cunits[i].dataType = FILTER_UNIT_DATA_TYPE(unit); info->cunits[i].dataType = FILTER_UNIT_DATA_TYPE(unit);
} }
uint16_t cgroupNum = info->groupNum + 1;
for (uint16_t i = 0; i < info->groupNum; ++i) {
cgroupNum += info->groups[i].unitNum;
}
info->cgroups = malloc(cgroupNum * sizeof(*info->cgroups));
for (uint16_t i = 0; i < info->groupNum; ++i) {
info->cgroups[n++] = info->groups[i].unitNum;
for (uint16_t m = 0; m < info->groups[i].unitNum; ++m) {
info->cgroups[n++] = info->groups[i].unitIdxs[m];
}
}
info->cgroups[n] = 0;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
...@@ -2664,10 +2638,12 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SDataStatis *pDataStatis, int32_t ...@@ -2664,10 +2638,12 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SDataStatis *pDataStatis, int32_t
SDataStatis* pDataBlockst = &pDataStatis[index]; SDataStatis* pDataBlockst = &pDataStatis[index];
void *minVal, *maxVal; void *minVal, *maxVal;
float minv = 0;
float maxv = 0;
if (cunit->dataType == TSDB_DATA_TYPE_FLOAT) { if (cunit->dataType == TSDB_DATA_TYPE_FLOAT) {
float minv = (float)(*(double *)(&pDataBlockst->min)); minv = (float)(*(double *)(&pDataBlockst->min));
float maxv = (float)(*(double *)(&pDataBlockst->max)); maxv = (float)(*(double *)(&pDataBlockst->max));
minVal = &minv; minVal = &minv;
maxVal = &maxv; maxVal = &maxv;
...@@ -2786,8 +2762,10 @@ bool filterExecuteBasedOnStatisImpl(void *pinfo, int32_t numOfRows, int8_t** p, ...@@ -2786,8 +2762,10 @@ bool filterExecuteBasedOnStatisImpl(void *pinfo, int32_t numOfRows, int8_t** p,
bool all = true; bool all = true;
uint16_t *unitIdx = NULL; uint16_t *unitIdx = NULL;
*p = calloc(numOfRows, sizeof(int8_t)); if (*p == NULL) {
*p = calloc(numOfRows, sizeof(int8_t));
}
for (int32_t i = 0; i < numOfRows; ++i) { for (int32_t i = 0; i < numOfRows; ++i) {
//FILTER_UNIT_CLR_F(info); //FILTER_UNIT_CLR_F(info);
...@@ -2889,12 +2867,14 @@ static FORCE_INLINE bool filterExecuteImplIsNull(void *pinfo, int32_t numOfRows, ...@@ -2889,12 +2867,14 @@ static FORCE_INLINE bool filterExecuteImplIsNull(void *pinfo, int32_t numOfRows,
return all; return all;
} }
*p = calloc(numOfRows, sizeof(int8_t)); if (*p == NULL) {
*p = calloc(numOfRows, sizeof(int8_t));
}
for (int32_t i = 0; i < numOfRows; ++i) { for (int32_t i = 0; i < numOfRows; ++i) {
uint16_t uidx = info->groups[0].unitIdxs[0]; uint16_t uidx = info->groups[0].unitIdxs[0];
void *colData = (char *)info->cunits[uidx].colData + info->cunits[uidx].dataSize * i; void *colData = (char *)info->cunits[uidx].colData + info->cunits[uidx].dataSize * i;
(*p)[i] = isNull(colData, info->cunits[uidx].dataType); (*p)[i] = ((colData == NULL) || isNull(colData, info->cunits[uidx].dataType));
if ((*p)[i] == 0) { if ((*p)[i] == 0) {
all = false; all = false;
} }
...@@ -2910,12 +2890,14 @@ static FORCE_INLINE bool filterExecuteImplNotNull(void *pinfo, int32_t numOfRows ...@@ -2910,12 +2890,14 @@ static FORCE_INLINE bool filterExecuteImplNotNull(void *pinfo, int32_t numOfRows
return all; return all;
} }
*p = calloc(numOfRows, sizeof(int8_t)); if (*p == NULL) {
*p = calloc(numOfRows, sizeof(int8_t));
}
for (int32_t i = 0; i < numOfRows; ++i) { for (int32_t i = 0; i < numOfRows; ++i) {
uint16_t uidx = info->groups[0].unitIdxs[0]; uint16_t uidx = info->groups[0].unitIdxs[0];
void *colData = (char *)info->cunits[uidx].colData + info->cunits[uidx].dataSize * i; void *colData = (char *)info->cunits[uidx].colData + info->cunits[uidx].dataSize * i;
(*p)[i] = !isNull(colData, info->cunits[uidx].dataType); (*p)[i] = ((colData != NULL) && !isNull(colData, info->cunits[uidx].dataType));
if ((*p)[i] == 0) { if ((*p)[i] == 0) {
all = false; all = false;
} }
...@@ -2938,10 +2920,12 @@ bool filterExecuteImplRange(void *pinfo, int32_t numOfRows, int8_t** p, SDataSta ...@@ -2938,10 +2920,12 @@ bool filterExecuteImplRange(void *pinfo, int32_t numOfRows, int8_t** p, SDataSta
return all; return all;
} }
*p = calloc(numOfRows, sizeof(int8_t)); if (*p == NULL) {
*p = calloc(numOfRows, sizeof(int8_t));
}
for (int32_t i = 0; i < numOfRows; ++i) { for (int32_t i = 0; i < numOfRows; ++i) {
if (isNull(colData, info->cunits[0].dataType)) { if (colData == NULL || isNull(colData, info->cunits[0].dataType)) {
all = false; all = false;
colData += dataSize; colData += dataSize;
continue; continue;
...@@ -2966,13 +2950,16 @@ bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, int8_t** p, SDataStat ...@@ -2966,13 +2950,16 @@ bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, int8_t** p, SDataStat
if (filterExecuteBasedOnStatis(info, numOfRows, p, statis, numOfCols, &all) == 0) { if (filterExecuteBasedOnStatis(info, numOfRows, p, statis, numOfCols, &all) == 0) {
return all; return all;
} }
*p = calloc(numOfRows, sizeof(int8_t)); if (*p == NULL) {
*p = calloc(numOfRows, sizeof(int8_t));
}
for (int32_t i = 0; i < numOfRows; ++i) { for (int32_t i = 0; i < numOfRows; ++i) {
uint16_t uidx = info->groups[0].unitIdxs[0]; uint16_t uidx = info->groups[0].unitIdxs[0];
void *colData = (char *)info->cunits[uidx].colData + info->cunits[uidx].dataSize * i; void *colData = (char *)info->cunits[uidx].colData + info->cunits[uidx].dataSize * i;
if (isNull(colData, info->cunits[uidx].dataType)) { if (colData == NULL || isNull(colData, info->cunits[uidx].dataType)) {
(*p)[i] = 0;
all = false; all = false;
continue; continue;
} }
...@@ -2996,8 +2983,10 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SDataStatis * ...@@ -2996,8 +2983,10 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SDataStatis *
return all; return all;
} }
*p = calloc(numOfRows, sizeof(int8_t)); if (*p == NULL) {
*p = calloc(numOfRows, sizeof(int8_t));
}
for (int32_t i = 0; i < numOfRows; ++i) { for (int32_t i = 0; i < numOfRows; ++i) {
//FILTER_UNIT_CLR_F(info); //FILTER_UNIT_CLR_F(info);
...@@ -3013,7 +3002,7 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SDataStatis * ...@@ -3013,7 +3002,7 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SDataStatis *
//} else { //} else {
uint8_t optr = cunit->optr; uint8_t optr = cunit->optr;
if (isNull(colData, cunit->dataType)) { if (colData == NULL || isNull(colData, cunit->dataType)) {
(*p)[i] = optr == TSDB_RELATION_ISNULL ? true : false; (*p)[i] = optr == TSDB_RELATION_ISNULL ? true : false;
} else { } else {
if (optr == TSDB_RELATION_NOTNULL) { if (optr == TSDB_RELATION_NOTNULL) {
...@@ -3132,7 +3121,7 @@ _return: ...@@ -3132,7 +3121,7 @@ _return:
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t filterSetColFieldData(SFilterInfo *info, int32_t numOfCols, SArray* pDataBlock) { int32_t filterSetColFieldData(SFilterInfo *info, void *param, filer_get_col_from_id fp) {
CHK_LRET(info == NULL, TSDB_CODE_QRY_APP_ERROR, "info NULL"); CHK_LRET(info == NULL, TSDB_CODE_QRY_APP_ERROR, "info NULL");
CHK_LRET(info->fields[FLD_TYPE_COLUMN].num <= 0, TSDB_CODE_QRY_APP_ERROR, "no column fileds"); CHK_LRET(info->fields[FLD_TYPE_COLUMN].num <= 0, TSDB_CODE_QRY_APP_ERROR, "no column fileds");
...@@ -3143,15 +3132,8 @@ int32_t filterSetColFieldData(SFilterInfo *info, int32_t numOfCols, SArray* pDat ...@@ -3143,15 +3132,8 @@ int32_t filterSetColFieldData(SFilterInfo *info, int32_t numOfCols, SArray* pDat
for (uint16_t i = 0; i < info->fields[FLD_TYPE_COLUMN].num; ++i) { for (uint16_t i = 0; i < info->fields[FLD_TYPE_COLUMN].num; ++i) {
SFilterField* fi = &info->fields[FLD_TYPE_COLUMN].fields[i]; SFilterField* fi = &info->fields[FLD_TYPE_COLUMN].fields[i];
SSchema* sch = fi->desc; SSchema* sch = fi->desc;
for (int32_t j = 0; j < numOfCols; ++j) { (*fp)(param, sch->colId, &fi->data);
SColumnInfoData* pColInfo = taosArrayGet(pDataBlock, j);
if (sch->colId == pColInfo->info.colId) {
fi->data = pColInfo->pData;
break;
}
}
} }
filterUpdateComUnits(info); filterUpdateComUnits(info);
...@@ -3160,7 +3142,7 @@ int32_t filterSetColFieldData(SFilterInfo *info, int32_t numOfCols, SArray* pDat ...@@ -3160,7 +3142,7 @@ int32_t filterSetColFieldData(SFilterInfo *info, int32_t numOfCols, SArray* pDat
} }
int32_t filterInitFromTree(tExprNode* tree, SFilterInfo **pinfo, uint32_t options) { int32_t filterInitFromTree(tExprNode* tree, void **pinfo, uint32_t options) {
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
SFilterInfo *info = NULL; SFilterInfo *info = NULL;
...@@ -3197,8 +3179,6 @@ int32_t filterInitFromTree(tExprNode* tree, SFilterInfo **pinfo, uint32_t option ...@@ -3197,8 +3179,6 @@ int32_t filterInitFromTree(tExprNode* tree, SFilterInfo **pinfo, uint32_t option
taosArrayDestroy(group); taosArrayDestroy(group);
return code; return code;
} }
//ERR_JRET(filterInitUnitFunc(info));
} }
info->unitRes = malloc(info->unitNum * sizeof(*info->unitRes)); info->unitRes = malloc(info->unitNum * sizeof(*info->unitRes));
...@@ -3257,30 +3237,35 @@ bool filterRangeExecute(SFilterInfo *info, SDataStatis *pDataStatis, int32_t num ...@@ -3257,30 +3237,35 @@ bool filterRangeExecute(SFilterInfo *info, SDataStatis *pDataStatis, int32_t num
break; break;
} }
if ((pDataStatis[index].numOfNull <= 0) && (ctx->isnull && !ctx->notnull && !ctx->isrange)) { if (pDataStatis[index].numOfNull <= 0) {
ret = false; if (ctx->isnull && !ctx->notnull && !ctx->isrange) {
break;
}
// all data in current column are NULL, no need to check its boundary value
if (pDataStatis[index].numOfNull == numOfRows) {
// if isNULL query exists, load the null data column
if ((ctx->notnull || ctx->isrange) && (!ctx->isnull)) {
ret = false; ret = false;
break; break;
} }
} else if (pDataStatis[index].numOfNull > 0) {
if (pDataStatis[index].numOfNull == numOfRows) {
if ((ctx->notnull || ctx->isrange) && (!ctx->isnull)) {
ret = false;
break;
}
continue; continue;
} else {
if (ctx->isnull) {
continue;
}
}
} }
SDataStatis* pDataBlockst = &pDataStatis[index]; SDataStatis* pDataBlockst = &pDataStatis[index];
SFilterRangeNode *r = ctx->rs; SFilterRangeNode *r = ctx->rs;
float minv = 0;
float maxv = 0;
if (ctx->type == TSDB_DATA_TYPE_FLOAT) { if (ctx->type == TSDB_DATA_TYPE_FLOAT) {
float minv = (float)(*(double *)(&pDataBlockst->min)); minv = (float)(*(double *)(&pDataBlockst->min));
float maxv = (float)(*(double *)(&pDataBlockst->max)); maxv = (float)(*(double *)(&pDataBlockst->max));
minVal = &minv; minVal = &minv;
maxVal = &maxv; maxVal = &maxv;
...@@ -3441,6 +3426,52 @@ int32_t filterFreeNcharColumns(SFilterInfo* info) { ...@@ -3441,6 +3426,52 @@ int32_t filterFreeNcharColumns(SFilterInfo* info) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t filterIsIndexedColumnQuery(SFilterInfo* info, int32_t idxId, bool *res) {
CHK_LRET(info == NULL, TSDB_CODE_QRY_APP_ERROR, "null parameter");
CHK_JMP(info->fields[FLD_TYPE_COLUMN].num > 1 || info->fields[FLD_TYPE_COLUMN].num <= 0);
CHK_JMP(info->unitNum > 1 || info->unitNum <= 0);
CHK_JMP(FILTER_GET_COL_FIELD_ID(FILTER_GET_COL_FIELD(info, 0)) != idxId);
int32_t optr = FILTER_UNIT_OPTR(info->units);
CHK_JMP(optr == TSDB_RELATION_LIKE || optr == TSDB_RELATION_IN || optr == TSDB_RELATION_MATCH
|| optr == TSDB_RELATION_ISNULL || optr == TSDB_RELATION_NOTNULL);
*res = true;
return TSDB_CODE_SUCCESS;
_return:
*res = false;
return TSDB_CODE_SUCCESS;
}
int32_t filterGetIndexedColumnInfo(SFilterInfo* info, char** val, int32_t *order, int32_t *flag) {
SFilterComUnit *cunit = info->cunits;
uint8_t optr = cunit->optr;
*val = cunit->valData;
*order = TSDB_ORDER_ASC;
if (optr == TSDB_RELATION_LESS || optr == TSDB_RELATION_LESS_EQUAL) {
*order = TSDB_ORDER_DESC;
}
if (optr == TSDB_RELATION_NOT_EQUAL) {
*order = TSDB_ORDER_ASC|TSDB_ORDER_DESC;
}
if (cunit->valData2 == cunit->valData && optr != TSDB_RELATION_EQUAL) {
FILTER_SET_FLAG(*flag, FI_ACTION_NO_NEED);
}
return TSDB_CODE_SUCCESS;
}
......
...@@ -53,7 +53,6 @@ static void freeqinfoFn(void *qhandle) { ...@@ -53,7 +53,6 @@ static void freeqinfoFn(void *qhandle) {
void freeParam(SQueryParam *param) { void freeParam(SQueryParam *param) {
tfree(param->sql); tfree(param->sql);
tfree(param->tagCond); tfree(param->tagCond);
tfree(param->tbnameCond);
tfree(param->pTableIdList); tfree(param->pTableIdList);
taosArrayDestroy(param->pOperator); taosArrayDestroy(param->pOperator);
tfree(param->pExprs); tfree(param->pExprs);
...@@ -140,7 +139,7 @@ int32_t qCreateQueryInfo(void* tsdb, int32_t vgId, SQueryTableMsg* pQueryMsg, qi ...@@ -140,7 +139,7 @@ int32_t qCreateQueryInfo(void* tsdb, int32_t vgId, SQueryTableMsg* pQueryMsg, qi
qDebug("qmsg:%p query stable, uid:%"PRIu64", tid:%d", pQueryMsg, id->uid, id->tid); qDebug("qmsg:%p query stable, uid:%"PRIu64", tid:%d", pQueryMsg, id->uid, id->tid);
code = tsdbQuerySTableByTagCond(tsdb, id->uid, pQueryMsg->window.skey, param.tagCond, pQueryMsg->tagCondLen, code = tsdbQuerySTableByTagCond(tsdb, id->uid, pQueryMsg->window.skey, param.tagCond, pQueryMsg->tagCondLen,
pQueryMsg->tagNameRelType, param.tbnameCond, &tableGroupInfo, param.pGroupColIndex, numOfGroupByCols); &tableGroupInfo, param.pGroupColIndex, numOfGroupByCols);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
qError("qmsg:%p failed to query stable, reason: %s", pQueryMsg, tstrerror(code)); qError("qmsg:%p failed to query stable, reason: %s", pQueryMsg, tstrerror(code));
......
...@@ -2,6 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8...3.20) ...@@ -2,6 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8...3.20)
PROJECT(TDengine) PROJECT(TDengine)
INCLUDE_DIRECTORIES(inc) INCLUDE_DIRECTORIES(inc)
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/query/inc)
AUX_SOURCE_DIRECTORY(src SRC) AUX_SOURCE_DIRECTORY(src SRC)
ADD_LIBRARY(tsdb ${SRC}) ADD_LIBRARY(tsdb ${SRC})
TARGET_LINK_LIBRARIES(tsdb tfs common tutil) TARGET_LINK_LIBRARIES(tsdb tfs common tutil)
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "tlosertree.h" #include "tlosertree.h"
#include "tsdbint.h" #include "tsdbint.h"
#include "texpr.h" #include "texpr.h"
#include "qFilter.h"
#define EXTRA_BYTES 2 #define EXTRA_BYTES 2
#define ASCENDING_TRAVERSE(o) (o == TSDB_ORDER_ASC) #define ASCENDING_TRAVERSE(o) (o == TSDB_ORDER_ASC)
...@@ -167,6 +168,7 @@ static int32_t doGetExternalRow(STsdbQueryHandle* pQueryHandle, int16_t type, SM ...@@ -167,6 +168,7 @@ static int32_t doGetExternalRow(STsdbQueryHandle* pQueryHandle, int16_t type, SM
static void* doFreeColumnInfoData(SArray* pColumnInfoData); static void* doFreeColumnInfoData(SArray* pColumnInfoData);
static void* destroyTableCheckInfo(SArray* pTableCheckInfo); static void* destroyTableCheckInfo(SArray* pTableCheckInfo);
static bool tsdbGetExternalRow(TsdbQueryHandleT pHandle); static bool tsdbGetExternalRow(TsdbQueryHandleT pHandle);
static int32_t tsdbQueryTableList(STable* pTable, SArray* pRes, void* filterInfo);
static void tsdbInitDataBlockLoadInfo(SDataBlockLoadInfo* pBlockLoadInfo) { static void tsdbInitDataBlockLoadInfo(SDataBlockLoadInfo* pBlockLoadInfo) {
pBlockLoadInfo->slot = -1; pBlockLoadInfo->slot = -1;
...@@ -2688,21 +2690,6 @@ static int32_t getAllTableList(STable* pSuperTable, SArray* list) { ...@@ -2688,21 +2690,6 @@ static int32_t getAllTableList(STable* pSuperTable, SArray* list) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
static void destroyHelper(void* param) {
if (param == NULL) {
return;
}
tQueryInfo* pInfo = (tQueryInfo*)param;
if (pInfo->optr != TSDB_RELATION_IN) {
tfree(pInfo->q);
} else {
taosHashCleanup((SHashObj *)(pInfo->q));
}
free(param);
}
static bool loadBlockOfActiveTable(STsdbQueryHandle* pQueryHandle) { static bool loadBlockOfActiveTable(STsdbQueryHandle* pQueryHandle) {
if (pQueryHandle->checkFiles) { if (pQueryHandle->checkFiles) {
// check if the query range overlaps with the file data block // check if the query range overlaps with the file data block
...@@ -3637,109 +3624,8 @@ SArray* createTableGroup(SArray* pTableList, STSchema* pTagSchema, SColIndex* pC ...@@ -3637,109 +3624,8 @@ SArray* createTableGroup(SArray* pTableList, STSchema* pTagSchema, SColIndex* pC
return pTableGroup; return pTableGroup;
} }
static bool tableFilterFp(const void* pNode, void* param) { int32_t tsdbQuerySTableByTagCond(STsdbRepo* tsdb, uint64_t uid, TSKEY skey, const char* pTagCond, size_t len,
tQueryInfo* pInfo = (tQueryInfo*) param; STableGroupInfo* pGroupInfo, SColIndex* pColIndex, int32_t numOfCols) {
STable* pTable = (STable*)(SL_GET_NODE_DATA((SSkipListNode*)pNode));
char* val = NULL;
if (pInfo->sch.colId == TSDB_TBNAME_COLUMN_INDEX) {
val = (char*) TABLE_NAME(pTable);
} else {
val = tdGetKVRowValOfCol(pTable->tagVal, pInfo->sch.colId);
}
if (pInfo->optr == TSDB_RELATION_ISNULL || pInfo->optr == TSDB_RELATION_NOTNULL) {
if (pInfo->optr == TSDB_RELATION_ISNULL) {
return (val == NULL) || isNull(val, pInfo->sch.type);
} else if (pInfo->optr == TSDB_RELATION_NOTNULL) {
return (val != NULL) && (!isNull(val, pInfo->sch.type));
}
} else if (pInfo->optr == TSDB_RELATION_IN) {
int type = pInfo->sch.type;
if (type == TSDB_DATA_TYPE_BOOL || IS_SIGNED_NUMERIC_TYPE(type) || type == TSDB_DATA_TYPE_TIMESTAMP) {
int64_t v;
GET_TYPED_DATA(v, int64_t, pInfo->sch.type, val);
return NULL != taosHashGet((SHashObj *)pInfo->q, (char *)&v, sizeof(v));
} else if (IS_UNSIGNED_NUMERIC_TYPE(type)) {
uint64_t v;
GET_TYPED_DATA(v, uint64_t, pInfo->sch.type, val);
return NULL != taosHashGet((SHashObj *)pInfo->q, (char *)&v, sizeof(v));
}
else if (type == TSDB_DATA_TYPE_DOUBLE || type == TSDB_DATA_TYPE_FLOAT) {
double v;
GET_TYPED_DATA(v, double, pInfo->sch.type, val);
return NULL != taosHashGet((SHashObj *)pInfo->q, (char *)&v, sizeof(v));
} else if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR){
return NULL != taosHashGet((SHashObj *)pInfo->q, varDataVal(val), varDataLen(val));
}
}
int32_t ret = 0;
if (val == NULL) { //the val is possible to be null, so check it out carefully
ret = -1; // val is missing in table tags value pairs
} else {
ret = pInfo->compare(val, pInfo->q);
}
switch (pInfo->optr) {
case TSDB_RELATION_EQUAL: {
return ret == 0;
}
case TSDB_RELATION_NOT_EQUAL: {
return ret != 0;
}
case TSDB_RELATION_GREATER_EQUAL: {
return ret >= 0;
}
case TSDB_RELATION_GREATER: {
return ret > 0;
}
case TSDB_RELATION_LESS_EQUAL: {
return ret <= 0;
}
case TSDB_RELATION_LESS: {
return ret < 0;
}
case TSDB_RELATION_LIKE: {
return ret == 0;
}
case TSDB_RELATION_MATCH: {
return ret == 0;
}
case TSDB_RELATION_NMATCH: {
return ret == 0;
}
case TSDB_RELATION_IN: {
return ret == 1;
}
default:
assert(false);
}
return true;
}
static void getTableListfromSkipList(tExprNode *pExpr, SSkipList *pSkipList, SArray *result, SExprTraverseSupp *param);
static int32_t doQueryTableList(STable* pSTable, SArray* pRes, tExprNode* pExpr) {
// query according to the expression tree
SExprTraverseSupp supp = {
.nodeFilterFn = (__result_filter_fn_t) tableFilterFp,
.setupInfoFn = filterPrepare,
.pExtInfo = pSTable->tagSchema,
};
getTableListfromSkipList(pExpr, pSTable->pIndex, pRes, &supp);
tExprTreeDestroy(pExpr, destroyHelper);
return TSDB_CODE_SUCCESS;
}
int32_t tsdbQuerySTableByTagCond(STsdbRepo* tsdb, uint64_t uid, TSKEY skey, const char* pTagCond, size_t len,
int16_t tagNameRelType, const char* tbnameCond, STableGroupInfo* pGroupInfo,
SColIndex* pColIndex, int32_t numOfCols) {
if (tsdbRLockRepoMeta(tsdb) < 0) goto _error; if (tsdbRLockRepoMeta(tsdb) < 0) goto _error;
STable* pTable = tsdbGetTableByUid(tsdbGetMeta(tsdb), uid); STable* pTable = tsdbGetTableByUid(tsdbGetMeta(tsdb), uid);
...@@ -3765,7 +3651,7 @@ int32_t tsdbQuerySTableByTagCond(STsdbRepo* tsdb, uint64_t uid, TSKEY skey, cons ...@@ -3765,7 +3651,7 @@ int32_t tsdbQuerySTableByTagCond(STsdbRepo* tsdb, uint64_t uid, TSKEY skey, cons
STSchema* pTagSchema = tsdbGetTableTagSchema(pTable); STSchema* pTagSchema = tsdbGetTableTagSchema(pTable);
// no tags and tbname condition, all child tables of this stable are involved // no tags and tbname condition, all child tables of this stable are involved
if (tbnameCond == NULL && (pTagCond == NULL || len == 0)) { if (pTagCond == NULL || len == 0) {
int32_t ret = getAllTableList(pTable, res); int32_t ret = getAllTableList(pTable, res);
if (ret != TSDB_CODE_SUCCESS) { if (ret != TSDB_CODE_SUCCESS) {
tsdbUnlockRepoMeta(tsdb); tsdbUnlockRepoMeta(tsdb);
...@@ -3787,25 +3673,7 @@ int32_t tsdbQuerySTableByTagCond(STsdbRepo* tsdb, uint64_t uid, TSKEY skey, cons ...@@ -3787,25 +3673,7 @@ int32_t tsdbQuerySTableByTagCond(STsdbRepo* tsdb, uint64_t uid, TSKEY skey, cons
tExprNode* expr = NULL; tExprNode* expr = NULL;
TRY(TSDB_MAX_TAG_CONDITIONS) { TRY(TSDB_MAX_TAG_CONDITIONS) {
expr = exprTreeFromTableName(tbnameCond); expr = exprTreeFromBinary(pTagCond, len);
if (expr == NULL) {
expr = exprTreeFromBinary(pTagCond, len);
} else {
CLEANUP_PUSH_VOID_PTR_PTR(true, tExprTreeDestroy, expr, NULL);
tExprNode* tagExpr = exprTreeFromBinary(pTagCond, len);
if (tagExpr != NULL) {
CLEANUP_PUSH_VOID_PTR_PTR(true, tExprTreeDestroy, tagExpr, NULL);
tExprNode* tbnameExpr = expr;
expr = calloc(1, sizeof(tExprNode));
if (expr == NULL) {
THROW( TSDB_CODE_TDB_OUT_OF_MEMORY );
}
expr->nodeType = TSQL_NODE_EXPR;
expr->_node.optr = (uint8_t)tagNameRelType;
expr->_node.pLeft = tagExpr;
expr->_node.pRight = tbnameExpr;
}
}
CLEANUP_EXECUTE(); CLEANUP_EXECUTE();
} CATCH( code ) { } CATCH( code ) {
...@@ -3817,7 +3685,20 @@ int32_t tsdbQuerySTableByTagCond(STsdbRepo* tsdb, uint64_t uid, TSKEY skey, cons ...@@ -3817,7 +3685,20 @@ int32_t tsdbQuerySTableByTagCond(STsdbRepo* tsdb, uint64_t uid, TSKEY skey, cons
// TODO: more error handling // TODO: more error handling
} END_TRY } END_TRY
doQueryTableList(pTable, res, expr); void *filterInfo = NULL;
ret = filterInitFromTree(expr, &filterInfo, 0);
if (ret != TSDB_CODE_SUCCESS) {
terrno = ret;
goto _error;
}
tsdbQueryTableList(pTable, res, filterInfo);
filterFreeInfo(filterInfo);
tExprTreeDestroy(expr, NULL);
pGroupInfo->numOfTables = (uint32_t)taosArrayGetSize(res); pGroupInfo->numOfTables = (uint32_t)taosArrayGetSize(res);
pGroupInfo->pGroupList = createTableGroup(res, pTagSchema, pColIndex, numOfCols, skey); pGroupInfo->pGroupList = createTableGroup(res, pTagSchema, pColIndex, numOfCols, skey);
...@@ -4001,259 +3882,115 @@ void tsdbDestroyTableGroup(STableGroupInfo *pGroupList) { ...@@ -4001,259 +3882,115 @@ void tsdbDestroyTableGroup(STableGroupInfo *pGroupList) {
pGroupList->numOfTables = 0; pGroupList->numOfTables = 0;
} }
static void applyFilterToSkipListNode(SSkipList *pSkipList, tExprNode *pExpr, SArray *pResult, SExprTraverseSupp *param) {
SSkipListIterator* iter = tSkipListCreateIter(pSkipList);
// Scan each node in the skiplist by using iterator
while (tSkipListIterNext(iter)) {
SSkipListNode *pNode = tSkipListIterGet(iter);
if (exprTreeApplyFilter(pExpr, pNode, param)) {
taosArrayPush(pResult, &(SL_GET_NODE_DATA(pNode)));
}
}
tSkipListDestroyIter(iter);
}
typedef struct { static FORCE_INLINE int32_t tsdbGetTagDataFromId(void *param, int32_t id, void **data) {
char* v; STable* pTable = (STable*)(SL_GET_NODE_DATA((SSkipListNode *)param));
int32_t optr;
} SEndPoint; if (id == TSDB_TBNAME_COLUMN_INDEX) {
*data = TABLE_NAME(pTable);
typedef struct { } else {
SEndPoint* start; *data = tdGetKVRowValOfCol(pTable->tagVal, id);
SEndPoint* end;
} SQueryCond;
// todo check for malloc failure
static int32_t setQueryCond(tQueryInfo *queryColInfo, SQueryCond* pCond) {
int32_t optr = queryColInfo->optr;
if (optr == TSDB_RELATION_GREATER || optr == TSDB_RELATION_GREATER_EQUAL ||
optr == TSDB_RELATION_EQUAL || optr == TSDB_RELATION_NOT_EQUAL) {
pCond->start = calloc(1, sizeof(SEndPoint));
pCond->start->optr = queryColInfo->optr;
pCond->start->v = queryColInfo->q;
} else if (optr == TSDB_RELATION_LESS || optr == TSDB_RELATION_LESS_EQUAL) {
pCond->end = calloc(1, sizeof(SEndPoint));
pCond->end->optr = queryColInfo->optr;
pCond->end->v = queryColInfo->q;
} else if (optr == TSDB_RELATION_IN) {
pCond->start = calloc(1, sizeof(SEndPoint));
pCond->start->optr = queryColInfo->optr;
pCond->start->v = queryColInfo->q;
} else if (optr == TSDB_RELATION_LIKE) {
assert(0);
} else if (optr == TSDB_RELATION_MATCH) {
assert(0);
} else if (optr == TSDB_RELATION_NMATCH) {
assert(0);
} }
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
static void queryIndexedColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, SArray* result) {
SSkipListIterator* iter = NULL;
SQueryCond cond = {0};
if (setQueryCond(pQueryInfo, &cond) != TSDB_CODE_SUCCESS) {
//todo handle error
}
if (cond.start != NULL) {
iter = tSkipListCreateIterFromVal(pSkipList, (char*) cond.start->v, pSkipList->type, TSDB_ORDER_ASC);
} else {
iter = tSkipListCreateIterFromVal(pSkipList, (char*)(cond.end ? cond.end->v: NULL), pSkipList->type, TSDB_ORDER_DESC);
}
if (cond.start != NULL) {
int32_t optr = cond.start->optr;
if (optr == TSDB_RELATION_EQUAL) { // equals
while(tSkipListIterNext(iter)) {
SSkipListNode* pNode = tSkipListIterGet(iter);
int32_t ret = pQueryInfo->compare(SL_GET_NODE_KEY(pSkipList, pNode), cond.start->v);
if (ret != 0) {
break;
}
STableKeyInfo info = {.pTable = (void*)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL};
taosArrayPush(result, &info);
}
} else if (optr == TSDB_RELATION_GREATER || optr == TSDB_RELATION_GREATER_EQUAL) { // greater equal
bool comp = true;
int32_t ret = 0;
while(tSkipListIterNext(iter)) {
SSkipListNode* pNode = tSkipListIterGet(iter);
if (comp) {
ret = pQueryInfo->compare(SL_GET_NODE_KEY(pSkipList, pNode), cond.start->v);
assert(ret >= 0);
}
if (ret == 0 && optr == TSDB_RELATION_GREATER) {
continue;
} else {
STableKeyInfo info = {.pTable = (void*)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL};
taosArrayPush(result, &info);
comp = false;
}
}
} else if (optr == TSDB_RELATION_NOT_EQUAL) { // not equal
bool comp = true;
while(tSkipListIterNext(iter)) {
SSkipListNode* pNode = tSkipListIterGet(iter);
comp = comp && (pQueryInfo->compare(SL_GET_NODE_KEY(pSkipList, pNode), cond.start->v) == 0);
if (comp) {
continue;
}
STableKeyInfo info = {.pTable = (void*)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL};
taosArrayPush(result, &info);
}
tSkipListDestroyIter(iter);
comp = true; static void queryIndexedColumn(SSkipList* pSkipList, void* filterInfo, SArray* res) {
iter = tSkipListCreateIterFromVal(pSkipList, (char*) cond.start->v, pSkipList->type, TSDB_ORDER_DESC); SSkipListIterator* iter = NULL;
while(tSkipListIterNext(iter)) { char *startVal = NULL;
SSkipListNode* pNode = tSkipListIterGet(iter); int32_t order = 0;
comp = comp && (pQueryInfo->compare(SL_GET_NODE_KEY(pSkipList, pNode), cond.start->v) == 0); int32_t inRange = 0;
if (comp) { int32_t flag = 0;
continue; bool all = false;
} int8_t *addToResult = NULL;
STableKeyInfo info = {.pTable = (void*)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL};
taosArrayPush(result, &info);
}
} else if (optr == TSDB_RELATION_IN) { filterGetIndexedColumnInfo(filterInfo, &startVal, &order, &flag);
while(tSkipListIterNext(iter)) {
SSkipListNode* pNode = tSkipListIterGet(iter);
int32_t ret = pQueryInfo->compare(SL_GET_NODE_KEY(pSkipList, pNode), cond.start->v); tsdbDebug("filter index column start, order:%d, flag:%d", order, flag);
if (ret != 0) {
break;
}
STableKeyInfo info = {.pTable = (void*)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL}; while (order) {
taosArrayPush(result, &info); if (FILTER_GET_FLAG(order, TSDB_ORDER_ASC)) {
} iter = tSkipListCreateIterFromVal(pSkipList, startVal, pSkipList->type, TSDB_ORDER_ASC);
FILTER_CLR_FLAG(order, TSDB_ORDER_ASC);
} else { } else {
assert(0); iter = tSkipListCreateIterFromVal(pSkipList, startVal, pSkipList->type, TSDB_ORDER_DESC);
FILTER_CLR_FLAG(order, TSDB_ORDER_DESC);
} }
} else {
int32_t optr = cond.end ? cond.end->optr : TSDB_RELATION_INVALID; while (tSkipListIterNext(iter)) {
if (optr == TSDB_RELATION_LESS || optr == TSDB_RELATION_LESS_EQUAL) { SSkipListNode *pNode = tSkipListIterGet(iter);
bool comp = true;
int32_t ret = 0;
while (tSkipListIterNext(iter)) {
SSkipListNode *pNode = tSkipListIterGet(iter);
if (comp) {
ret = pQueryInfo->compare(SL_GET_NODE_KEY(pSkipList, pNode), cond.end->v);
assert(ret <= 0);
}
if (ret == 0 && optr == TSDB_RELATION_LESS) { if (inRange == 0 || !FILTER_GET_FLAG(flag, FI_ACTION_NO_NEED)) {
continue; tsdbDebug("filter index column, filter it");
} else { filterSetColFieldData(filterInfo, pNode, tsdbGetTagDataFromId);
STableKeyInfo info = {.pTable = (void *)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL}; all = filterExecute(filterInfo, 1, &addToResult, NULL, 0);
taosArrayPush(result, &info);
comp = false; // no need to compare anymore
}
} }
} else {
assert(pQueryInfo->optr == TSDB_RELATION_ISNULL || pQueryInfo->optr == TSDB_RELATION_NOTNULL); char *pData = SL_GET_NODE_DATA(pNode);
while (tSkipListIterNext(iter)) { tsdbDebug("filter index column, table:%s, result:%d", ((STable *)pData)->name->data, all);
SSkipListNode *pNode = tSkipListIterGet(iter);
bool isnull = isNull(SL_GET_NODE_KEY(pSkipList, pNode), pQueryInfo->sch.type); if (all || (addToResult && *addToResult)) {
if ((pQueryInfo->optr == TSDB_RELATION_ISNULL && isnull) || STableKeyInfo info = {.pTable = (void*)pData, .lastKey = TSKEY_INITIAL_VAL};
(pQueryInfo->optr == TSDB_RELATION_NOTNULL && (!isnull))) { taosArrayPush(res, &info);
STableKeyInfo info = {.pTable = (void *)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL}; inRange = 1;
taosArrayPush(result, &info); } else if (inRange){
} break;
} }
} }
inRange = 0;
tfree(addToResult);
tSkipListDestroyIter(iter);
} }
free(cond.start); tsdbDebug("filter index column end");
free(cond.end);
tSkipListDestroyIter(iter);
} }
static void queryIndexlessColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, SArray* res, __result_filter_fn_t filterFp) { static void queryIndexlessColumn(SSkipList* pSkipList, void* filterInfo, SArray* res) {
SSkipListIterator* iter = tSkipListCreateIter(pSkipList); SSkipListIterator* iter = tSkipListCreateIter(pSkipList);
int8_t *addToResult = NULL;
while (tSkipListIterNext(iter)) { while (tSkipListIterNext(iter)) {
bool addToResult = false;
SSkipListNode *pNode = tSkipListIterGet(iter); SSkipListNode *pNode = tSkipListIterGet(iter);
filterSetColFieldData(filterInfo, pNode, tsdbGetTagDataFromId);
char *pData = SL_GET_NODE_DATA(pNode); char *pData = SL_GET_NODE_DATA(pNode);
tstr *name = (tstr*) tsdbGetTableName((void*) pData);
// todo speed up by using hash
if (pQueryInfo->sch.colId == TSDB_TBNAME_COLUMN_INDEX) {
if (pQueryInfo->optr == TSDB_RELATION_IN) {
addToResult = pQueryInfo->compare(name, pQueryInfo->q);
} else if (pQueryInfo->optr == TSDB_RELATION_LIKE ||
pQueryInfo->optr == TSDB_RELATION_MATCH ||
pQueryInfo->optr == TSDB_RELATION_NMATCH) {
addToResult = !pQueryInfo->compare(name, pQueryInfo->q);
}
} else {
addToResult = filterFp(pNode, pQueryInfo);
}
if (addToResult) { bool all = filterExecute(filterInfo, 1, &addToResult, NULL, 0);
if (all || (addToResult && *addToResult)) {
STableKeyInfo info = {.pTable = (void*)pData, .lastKey = TSKEY_INITIAL_VAL}; STableKeyInfo info = {.pTable = (void*)pData, .lastKey = TSKEY_INITIAL_VAL};
taosArrayPush(res, &info); taosArrayPush(res, &info);
} }
} }
tfree(addToResult);
tSkipListDestroyIter(iter); tSkipListDestroyIter(iter);
} }
// Apply the filter expression to each node in the skiplist to acquire the qualified nodes in skip list
void getTableListfromSkipList(tExprNode *pExpr, SSkipList *pSkipList, SArray *result, SExprTraverseSupp *param) {
if (pExpr == NULL) {
return;
}
tExprNode *pLeft = pExpr->_node.pLeft;
tExprNode *pRight = pExpr->_node.pRight;
// column project static int32_t tsdbQueryTableList(STable* pTable, SArray* pRes, void* filterInfo) {
if (pLeft->nodeType != TSQL_NODE_EXPR && pRight->nodeType != TSQL_NODE_EXPR) { STSchema* pTSSchema = pTable->tagSchema;
assert(pLeft->nodeType == TSQL_NODE_COL && (pRight->nodeType == TSQL_NODE_VALUE || pRight->nodeType == TSQL_NODE_DUMMY)); bool indexQuery = false;
SSkipList *pSkipList = pTable->pIndex;
param->setupInfoFn(pExpr, param->pExtInfo);
filterIsIndexedColumnQuery(filterInfo, pTSSchema->columns->colId, &indexQuery);
if (indexQuery) {
queryIndexedColumn(pSkipList, filterInfo, pRes);
} else {
queryIndexlessColumn(pSkipList, filterInfo, pRes);
}
tQueryInfo *pQueryInfo = pExpr->_node.info; return TSDB_CODE_SUCCESS;
if (pQueryInfo->indexed && (pQueryInfo->optr != TSDB_RELATION_LIKE }
&& pQueryInfo->optr != TSDB_RELATION_MATCH && pQueryInfo->optr != TSDB_RELATION_NMATCH
&& pQueryInfo->optr != TSDB_RELATION_IN)) {
queryIndexedColumn(pSkipList, pQueryInfo, result);
} else {
queryIndexlessColumn(pSkipList, pQueryInfo, result, param->nodeFilterFn);
}
return;
}
// The value of hasPK is always 0.
uint8_t weight = pLeft->_node.hasPK + pRight->_node.hasPK;
assert(weight == 0 && pSkipList != NULL && taosArrayGetSize(result) == 0);
//apply the hierarchical filter expression to every node in skiplist to find the qualified nodes
applyFilterToSkipListNode(pSkipList, pExpr, result, param);
}
...@@ -233,14 +233,20 @@ int patternMatch(const char *patterStr, const char *str, size_t size, const SPat ...@@ -233,14 +233,20 @@ int patternMatch(const char *patterStr, const char *str, size_t size, const SPat
int32_t i = 0; int32_t i = 0;
int32_t j = 0; int32_t j = 0;
int32_t o = 0;
int32_t m = 0;
while ((c = patterStr[i++]) != 0) { while ((c = patterStr[i++]) != 0) {
if (c == pInfo->matchAll) { /* Match "*" */ if (c == pInfo->matchAll) { /* Match "*" */
while ((c = patterStr[i++]) == pInfo->matchAll || c == pInfo->matchOne) { while ((c = patterStr[i++]) == pInfo->matchAll || c == pInfo->matchOne) {
if (c == pInfo->matchOne && (j > size || str[j++] == 0)) { if (c == pInfo->matchOne) {
// empty string, return not match if (j > size || str[j++] == 0) {
return TSDB_PATTERN_NOWILDCARDMATCH; // empty string, return not match
return TSDB_PATTERN_NOWILDCARDMATCH;
} else {
++o;
}
} }
} }
...@@ -249,9 +255,10 @@ int patternMatch(const char *patterStr, const char *str, size_t size, const SPat ...@@ -249,9 +255,10 @@ int patternMatch(const char *patterStr, const char *str, size_t size, const SPat
} }
char next[3] = {toupper(c), tolower(c), 0}; char next[3] = {toupper(c), tolower(c), 0};
m = o;
while (1) { while (1) {
size_t n = strcspn(str, next); size_t n = strcspn(str + m, next);
str += n; str += m + n;
if (str[0] == 0 || (n >= size)) { if (str[0] == 0 || (n >= size)) {
break; break;
...@@ -261,12 +268,14 @@ int patternMatch(const char *patterStr, const char *str, size_t size, const SPat ...@@ -261,12 +268,14 @@ int patternMatch(const char *patterStr, const char *str, size_t size, const SPat
if (ret != TSDB_PATTERN_NOMATCH) { if (ret != TSDB_PATTERN_NOMATCH) {
return ret; return ret;
} }
m = 0;
} }
return TSDB_PATTERN_NOWILDCARDMATCH; return TSDB_PATTERN_NOWILDCARDMATCH;
} }
c1 = str[j++]; c1 = str[j++];
++o;
if (j <= size) { if (j <= size) {
if (c == '\\' && patterStr[i] == '_' && c1 == '_') { i++; continue; } if (c == '\\' && patterStr[i] == '_' && c1 == '_') { i++; continue; }
if (c == c1 || tolower(c) == tolower(c1) || (c == pInfo->matchOne && c1 != 0)) { if (c == c1 || tolower(c) == tolower(c1) || (c == pInfo->matchOne && c1 != 0)) {
...@@ -292,7 +301,7 @@ int WCSPatternMatch(const wchar_t *patterStr, const wchar_t *str, size_t size, c ...@@ -292,7 +301,7 @@ int WCSPatternMatch(const wchar_t *patterStr, const wchar_t *str, size_t size, c
if (c == matchAll) { /* Match "%" */ if (c == matchAll) { /* Match "%" */
while ((c = patterStr[i++]) == matchAll || c == matchOne) { while ((c = patterStr[i++]) == matchAll || c == matchOne) {
if (c == matchOne && (j > size || str[j++] == 0)) { if (c == matchOne && (j >= size || str[j++] == 0)) {
return TSDB_PATTERN_NOWILDCARDMATCH; return TSDB_PATTERN_NOWILDCARDMATCH;
} }
} }
......
...@@ -769,7 +769,7 @@ class TDTestCase: ...@@ -769,7 +769,7 @@ class TDTestCase:
tdSql.query(f"select distinct c1,c2 from (select * from t1 where c1 < {tbnum}) ") tdSql.query(f"select distinct c1,c2 from (select * from t1 where c1 < {tbnum}) ")
tdSql.checkRows(3) tdSql.checkRows(3)
tdSql.query(f"select distinct c1,c2 from (select * from stb1 where t2 !=0 and t2 != 1) ") tdSql.query(f"select distinct c1,c2 from (select * from stb1 where t2 !=0 and t2 != 1) ")
tdSql.checkRows(4) tdSql.checkRows(0)
tdSql.error("select distinct c1, c2 from (select distinct c1, c2 from stb1 where t0 > 2 and t1 < 3) ") tdSql.error("select distinct c1, c2 from (select distinct c1, c2 from stb1 where t0 > 2 and t1 < 3) ")
tdSql.error("select c1, c2 from (select distinct c1, c2 from stb1 where t0 > 2 and t1 < 3) ") tdSql.error("select c1, c2 from (select distinct c1, c2 from stb1 where t0 > 2 and t1 < 3) ")
tdSql.query("select distinct c1, c2 from (select c2, c1 from stb1 where c1 > 2 ) where c1 < 4") tdSql.query("select distinct c1, c2 from (select c2, c1 from stb1 where c1 > 2 ) where c1 < 4")
......
...@@ -80,10 +80,12 @@ class TDTestCase: ...@@ -80,10 +80,12 @@ class TDTestCase:
tdSql.error("select * from st where tbcol1 like '____'") tdSql.error("select * from st where tbcol1 like '____'")
# > for nchar type on column # > for nchar type on column
tdSql.error("select * from st where tbcol2 > 'taosdata'") tdSql.query("select * from st where tbcol2 > 'taosdata'")
tdSql.checkRows(10)
# >= for nchar type on column # >= for nchar type on column
tdSql.error("select * from st where tbcol2 >= 'taosdata'") tdSql.query("select * from st where tbcol2 >= 'taosdata'")
tdSql.checkRows(10)
# = for nchar type on column # = for nchar type on column
tdSql.query("select * from st where tbcol2 = 'taosdata1'") tdSql.query("select * from st where tbcol2 = 'taosdata1'")
...@@ -98,10 +100,12 @@ class TDTestCase: ...@@ -98,10 +100,12 @@ class TDTestCase:
tdSql.checkRows(9) tdSql.checkRows(9)
# > for nchar type on column # > for nchar type on column
tdSql.error("select * from st where tbcol2 < 'taodata'") tdSql.query("select * from st where tbcol2 < 'taodata'")
tdSql.checkRows(0)
# >= for nchar type on column # >= for nchar type on column
tdSql.error("select * from st where tbcol2 <= 'taodata'") tdSql.query("select * from st where tbcol2 <= 'taodata'")
tdSql.checkRows(0)
# % for nchar type on column case 1 # % for nchar type on column case 1
tdSql.query("select * from st where tbcol2 like '%'") tdSql.query("select * from st where tbcol2 like '%'")
...@@ -140,10 +144,12 @@ class TDTestCase: ...@@ -140,10 +144,12 @@ class TDTestCase:
tdSql.checkRows(10) tdSql.checkRows(10)
# > for binary type on column # > for binary type on column
tdSql.error("select * from st where tbcol3 > '涛思数据'") tdSql.query("select * from st where tbcol3 > '涛思数据'")
tdSql.checkRows(10)
# >= for binary type on column # >= for binary type on column
tdSql.error("select * from st where tbcol3 >= '涛思数据'") tdSql.query("select * from st where tbcol3 >= '涛思数据'")
tdSql.checkRows(10)
# = for binary type on column # = for binary type on column
tdSql.query("select * from st where tbcol3 = '涛思数据1'") tdSql.query("select * from st where tbcol3 = '涛思数据1'")
...@@ -158,10 +164,12 @@ class TDTestCase: ...@@ -158,10 +164,12 @@ class TDTestCase:
tdSql.checkRows(9) tdSql.checkRows(9)
# > for binary type on column # > for binary type on column
tdSql.error("select * from st where tbcol3 < '涛思数据'") tdSql.query("select * from st where tbcol3 < '涛思数据'")
tdSql.checkRows(0)
# >= for binary type on column # >= for binary type on column
tdSql.error("select * from st where tbcol3 <= '涛思数据'") tdSql.query("select * from st where tbcol3 <= '涛思数据'")
tdSql.checkRows(0)
# % for binary type on column case 1 # % for binary type on column case 1
tdSql.query("select * from st where tbcol3 like '%'") tdSql.query("select * from st where tbcol3 like '%'")
......
...@@ -66,7 +66,7 @@ class TDTestCase: ...@@ -66,7 +66,7 @@ class TDTestCase:
tdSql.checkData(0, 0, 12) tdSql.checkData(0, 0, 12)
tdSql.query("select count(*) from st where t2 <> '' ") tdSql.query("select count(*) from st where t2 <> '' ")
tdSql.checkData(0, 0, 24) tdSql.checkData(0, 0, 12)
tdSql.query("select count(*) from st where t3 is null") tdSql.query("select count(*) from st where t3 is null")
tdSql.checkData(0, 0, 12) tdSql.checkData(0, 0, 12)
...@@ -81,7 +81,7 @@ class TDTestCase: ...@@ -81,7 +81,7 @@ class TDTestCase:
tdSql.checkData(0, 0, 12) tdSql.checkData(0, 0, 12)
tdSql.query("select count(*) from st where t3 <> '' ") tdSql.query("select count(*) from st where t3 <> '' ")
tdSql.checkData(0, 0, 24) tdSql.checkData(0, 0, 12)
tdSql.query("select count(*) from st where c1 is not null") tdSql.query("select count(*) from st where c1 is not null")
tdSql.checkData(0, 0, 30) tdSql.checkData(0, 0, 30)
......
...@@ -159,7 +159,7 @@ if $data11 != 3 then ...@@ -159,7 +159,7 @@ if $data11 != 3 then
endi endi
sql_error select * from st2 where f7 between 2.0 and 3.0; sql_error select * from st2 where f7 between 2.0 and 3.0;
sql_error select * from st2 where f8 between 2.0 and 3.0; sql select * from st2 where f8 between 2.0 and 3.0;
sql_error select * from st2 where f9 between 2.0 and 3.0; sql select * from st2 where f9 between 2.0 and 3.0;
system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s stop -x SIGINT
...@@ -2,7 +2,7 @@ system sh/stop_dnodes.sh ...@@ -2,7 +2,7 @@ system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1 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 walLevel -v 1
system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 4 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 cache -v 1
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
...@@ -135,11 +135,63 @@ while $i < $blockNum ...@@ -135,11 +135,63 @@ while $i < $blockNum
$ts0 = $ts0 + 259200000 $ts0 = $ts0 + 259200000
endw endw
sql create table stb5 (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 timestamp, t2 int, t3 float, t4 bigint, t5 smallint, t6 tinyint, t7 double, t8 bool, t9 binary(100), t10 nchar(10))
sql create table tb5_1 using stb5 tags('2021-05-05 18:19:01',1,1.0,1,1,1,1.0,true ,'111111111','1')
sql create table tb5_2 using stb5 tags('2021-05-05 18:19:02',2,2.0,2,2,2,2.0,true ,'222222222','2')
sql create table tb5_3 using stb5 tags('2021-05-05 18:19:03',3,3.0,3,3,3,3.0,false,'333333333','3')
sql create table tb5_4 using stb5 tags('2021-05-05 18:19:04',4,4.0,4,4,4,4.0,false,'444444444','4')
sql create table tb5_5 using stb5 tags('2021-05-05 18:19:05',5,5.0,5,5,5,5.0,true,'555555555','5')
sql create table tb5_6 using stb5 tags('2021-05-05 18:19:06',6,6.0,6,6,6,6.0,true,'666666666','6')
sql create table tb5_7 using stb5 tags(NULL,7,NULL,7,NULL,7,NULL,false,NULL,'7')
sql create table tb5_8 using stb5 tags('2021-05-05 18:19:08',NULL,8.0,NULL,8,NULL,8.0,NULL,'888888888',NULL)
sql insert into tb5_1 values ('2021-05-05 18:19:00',1,1.0,1,1,1,1.0,true ,'1','1')
sql insert into tb5_1 values ('2021-05-05 18:19:01',2,2.0,2,2,2,2.0,true ,'2','2')
sql insert into tb5_1 values ('2021-05-05 18:19:02',3,3.0,3,3,3,3.0,false,'3','3')
sql insert into tb5_1 values ('2021-05-05 18:19:03',4,4.0,4,4,4,4.0,false,'4','4')
sql insert into tb5_1 values ('2021-05-05 18:19:04',11,11.0,11,11,11,11.0,true ,'11','11')
sql insert into tb5_1 values ('2021-05-05 18:19:05',12,12.0,12,12,12,12.0,true ,'12','12')
sql insert into tb5_1 values ('2021-05-05 18:19:06',13,13.0,13,13,13,13.0,false,'13','13')
sql insert into tb5_1 values ('2021-05-05 18:19:07',14,14.0,14,14,14,14.0,false,'14','14')
sql insert into tb5_2 values ('2021-05-05 18:19:08',21,21.0,21,21,21,21.0,true ,'21','21')
sql insert into tb5_2 values ('2021-05-05 18:19:09',22,22.0,22,22,22,22.0,true ,'22','22')
sql insert into tb5_2 values ('2021-05-05 18:19:10',23,23.0,23,23,23,23.0,false,'23','23')
sql insert into tb5_2 values ('2021-05-05 18:19:11',24,24.0,24,24,24,24.0,false,'24','24')
sql insert into tb5_3 values ('2021-05-05 18:19:12',31,31.0,31,31,31,31.0,true ,'31','31')
sql insert into tb5_3 values ('2021-05-05 18:19:13',32,32.0,32,32,32,32.0,true ,'32','32')
sql insert into tb5_3 values ('2021-05-05 18:19:14',33,33.0,33,33,33,33.0,false,'33','33')
sql insert into tb5_3 values ('2021-05-05 18:19:15',34,34.0,34,34,34,34.0,false,'34','34')
sql insert into tb5_4 values ('2021-05-05 18:19:16',41,41.0,41,41,41,41.0,true ,'41','41')
sql insert into tb5_4 values ('2021-05-05 18:19:17',42,42.0,42,42,42,42.0,true ,'42','42')
sql insert into tb5_4 values ('2021-05-05 18:19:18',43,43.0,43,43,43,43.0,false,'43','43')
sql insert into tb5_4 values ('2021-05-05 18:19:19',44,44.0,44,44,44,44.0,false,'44','44')
sql insert into tb5_5 values ('2021-05-05 18:19:20',51,51.0,51,51,51,51.0,true ,'51','51')
sql insert into tb5_5 values ('2021-05-05 18:19:21',52,52.0,52,52,52,52.0,true ,'52','52')
sql insert into tb5_5 values ('2021-05-05 18:19:22',53,53.0,53,53,53,53.0,false,'53','53')
sql insert into tb5_5 values ('2021-05-05 18:19:23',54,54.0,54,54,54,54.0,false,'54','54')
sql insert into tb5_6 values ('2021-05-05 18:19:24',61,61.0,61,61,61,61.0,true ,'61','61')
sql insert into tb5_6 values ('2021-05-05 18:19:25',62,62.0,62,62,62,62.0,true ,'62','62')
sql insert into tb5_6 values ('2021-05-05 18:19:26',63,63.0,63,63,63,63.0,false,'63','63')
sql insert into tb5_6 values ('2021-05-05 18:19:27',64,64.0,64,64,64,64.0,false,'64','64')
sql insert into tb5_6 values ('2021-05-05 18:19:28',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL)
sql insert into tb5_7 values ('2021-05-05 18:19:29',71,71.0,71,71,71,71.0,true ,'71','71')
sql insert into tb5_7 values ('2021-05-05 18:19:30',72,72.0,72,72,72,72.0,true ,'72','72')
sql insert into tb5_7 values ('2021-05-05 18:19:31',73,73.0,73,73,73,73.0,false,'73','73')
sql insert into tb5_7 values ('2021-05-05 18:19:32',74,74.0,74,74,74,74.0,false,'74','74')
sql insert into tb5_7 values ('2021-05-05 18:19:33',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL)
sql insert into tb5_8 values ('2021-05-05 18:19:34',81,81.0,81,81,81,81.0,true ,'81','81')
sql insert into tb5_8 values ('2021-05-05 18:19:35',82,82.0,82,82,82,82.0,true ,'82','82')
sql insert into tb5_8 values ('2021-05-05 18:19:36',83,83.0,83,83,83,83.0,false,'83','83')
sql insert into tb5_8 values ('2021-05-05 18:19:37',84,84.0,84,84,84,84.0,false,'84','84')
sql insert into tb5_8 values ('2021-05-05 18:19:38',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL)
sleep 100 sleep 100
sql connect sql connect
run general/parser/condition_query.sim run general/parser/condition_query.sim
run general/parser/condition_query2.sim
print ================== restart server to commit data into disk print ================== restart server to commit data into disk
system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s stop -x SIGINT
...@@ -150,4 +202,90 @@ sql connect ...@@ -150,4 +202,90 @@ sql connect
sleep 100 sleep 100
run general/parser/condition_query.sim run general/parser/condition_query.sim
run general/parser/condition_query2.sim
sql drop database if exists cdb
system sh/exec.sh -n dnode1 -s stop -x SIGINT
sleep 100
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 1000
system sh/cfg.sh -n dnode1 -c minTablesPerVnode -v 1000
system sh/exec.sh -n dnode1 -s start
sql create database if not exists cdb
sql use cdb
sql create table stba (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int)
sql create table stbb (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 bool)
sql create table stbc (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 float)
sql create table stbd (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 binary(10))
sql create table stbe (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 nchar(10))
sql create table tba_0 using stba tags(0)
sql create table tba_1 using stba tags(1)
sql create table tba_2 using stba tags(2)
sql create table tba_3 using stba tags(3)
sql create table tba_4 using stba tags(4)
sql create table tba_5 using stba tags(5)
sql create table tba_6 using stba tags(6)
sql create table tba_7 using stba tags(7)
sql create table tba_8 using stba tags(8)
sql create table tba_9 using stba tags(9)
sql create table tbb_0 using stbb tags(true)
sql create table tbb_1 using stbb tags(false)
sql create table tbb_2 using stbb tags(true)
sql create table tbb_3 using stbb tags(false)
sql create table tbb_4 using stbb tags(true)
sql create table tbb_5 using stbb tags(false)
sql create table tbb_6 using stbb tags(true)
sql create table tbb_7 using stbb tags(false)
sql create table tbb_8 using stbb tags(true)
sql create table tbb_9 using stbb tags(false)
sql create table tbc_0 using stbc tags(0)
sql create table tbc_1 using stbc tags(1)
sql create table tbc_2 using stbc tags(2)
sql create table tbc_3 using stbc tags(3)
sql create table tbc_4 using stbc tags(4)
sql create table tbc_5 using stbc tags(5)
sql create table tbc_6 using stbc tags(6)
sql create table tbc_7 using stbc tags(7)
sql create table tbc_8 using stbc tags(8)
sql create table tbc_9 using stbc tags(9)
sql create table tbd_0 using stbd tags('0000')
sql create table tbd_1 using stbd tags('1111')
sql create table tbd_2 using stbd tags('2222')
sql create table tbd_3 using stbd tags('3333')
sql create table tbd_4 using stbd tags('4444')
sql create table tbd_5 using stbd tags('5555')
sql create table tbd_6 using stbd tags('6666')
sql create table tbd_7 using stbd tags('7777')
sql create table tbd_8 using stbd tags('8888')
sql create table tbd_9 using stbd tags('9999')
sql create table tbe_0 using stbe tags('0000')
sql create table tbe_1 using stbe tags('1111')
sql create table tbe_2 using stbe tags('2222')
sql create table tbe_3 using stbe tags('3333')
sql create table tbe_4 using stbe tags('4444')
sql create table tbe_5 using stbe tags('5555')
sql create table tbe_6 using stbe tags('6666')
sql create table tbe_7 using stbe tags('7777')
sql create table tbe_8 using stbe tags('8888')
sql create table tbe_9 using stbe tags('9999')
run general/parser/condition_query3.sim
system sh/exec.sh -n dnode1 -s stop -x SIGINT
sleep 100
system sh/exec.sh -n dnode1 -s start
run general/parser/condition_query3.sim
sql use cdb; sql use cdb;
print "column test" print "column test"
...@@ -11,7 +10,7 @@ if $rows != 28 then ...@@ -11,7 +10,7 @@ if $rows != 28 then
return -1 return -1
endi endi
sql_error select * from stb1 where c8 > 0
sql_error select * from stb1 where c7 in (0,2,3,1); sql_error select * from stb1 where c7 in (0,2,3,1);
sql_error select * from stb1 where c8 in (true); sql_error select * from stb1 where c8 in (true);
sql_error select * from stb1 where c8 in (1,2); sql_error select * from stb1 where c8 in (1,2);
...@@ -33,14 +32,119 @@ sql_error select * from stb1 where c4 != 'null'; ...@@ -33,14 +32,119 @@ sql_error select * from stb1 where c4 != 'null';
sql_error select * from stb1 where c5 >= 'null'; sql_error select * from stb1 where c5 >= 'null';
sql_error select * from stb1 where c6 <= 'null'; sql_error select * from stb1 where c6 <= 'null';
sql_error select * from stb1 where c7 < 'nuLl'; sql_error select * from stb1 where c7 < 'nuLl';
sql_error select * from stb1 where c8 < 'nuLl'; sql_error select * from stb1 where c1 match '.*';
sql_error select * from stb1 where c9 > 'nuLl'; sql_error select * from stb1 where c2 match '.*';
sql_error select * from stb1 where c3 match '.*';
sql_error select * from stb1 where c4 match '.*';
sql_error select * from stb1 where c5 match '.*';
sql_error select * from stb1 where c6 match '.*';
sql_error select * from stb1 where c7 match '.*';
sql_error select * from stb1 where c9 match '.*';
sql_error select * from stb1 where ts match '.*';
sql_error select * from stb1 where c1 nmatch '.*';
sql_error select * from stb1 where c2 nmatch '.*';
sql_error select * from stb1 where c3 nmatch '.*';
sql_error select * from stb1 where c4 nmatch '.*';
sql_error select * from stb1 where c5 nmatch '.*';
sql_error select * from stb1 where c6 nmatch '.*';
sql_error select * from stb1 where c7 nmatch '.*';
sql_error select * from stb1 where c9 nmatch '.*';
sql_error select * from stb1 where ts nmatch '.*';
sql_error select * from (select * from stb1 where c7=true) a, (select * from stb1 where c1 > 30) b; sql_error select * from (select * from stb1 where c7=true) a, (select * from stb1 where c1 > 30) b;
sql_error select a.ts,a.c1,a.c8 from (select * from stb1 where c7=true) a, (select * from stb1 where c1 > 30) b where a.ts=b.ts and a.c1 > 50 or b.c1 < 60; sql_error select a.ts,a.c1,a.c8 from (select * from stb1 where c7=true) a, (select * from stb1 where c1 > 30) b where a.ts=b.ts and a.c1 > 50 or b.c1 < 60;
sql_error select a.ts,a.c1,a.c8 from (select * from stb1 where c7=true) a, (select * from stb1 where c1 > 30) b where a.ts=b.ts and ((a.c1 > 50 and a.c1 < 60) or (b.c2 > 60)); sql_error select a.ts,a.c1,a.c8 from (select * from stb1 where c7=true) a, (select * from stb1 where c1 > 30) b where a.ts=b.ts and ((a.c1 > 50 and a.c1 < 60) or (b.c2 > 60));
sql_error select * from stb1 where 'c2' is null; sql_error select * from stb1 where 'c2' is null;
sql_error select * from stb1 where 'c2' is not null; sql_error select * from stb1 where 'c2' is not null;
sql select * from stb1 where c9 > 'nuLl';
if $rows != 0 then
return -1
endi
sql select * from stb1 where c8 = '22' or c8 >= '62';
if $rows != 4 then
return -1
endi
if $data00 != @21-05-05 18:19:09.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:25.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:26.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:27.000@ then
return -1
endi
sql select * from stb1 where c8 < '11';
if $rows != 4 then
return -1
endi
if $data00 != @21-05-05 18:19:00.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:01.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:02.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:03.000@ then
return -1
endi
sql select * from stb1 where c8 <> '11';
if $rows != 27 then
return -1
endi
sql select * from stb1 where c9 > 'nuLl';
if $rows != 0 then
return -1
endi
sql select * from stb1 where c9 > '11' and c9 <= '21';
if $rows != 4 then
return -1
endi
if $data00 != @21-05-05 18:19:05.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:06.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:07.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:08.000@ then
return -1
endi
sql select * from stb1 where c9 <= '11' and c9 > '2' and c9 <> 3;
if $rows != 2 then
return -1
endi
if $data00 != @21-05-05 18:19:03.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:04.000@ then
return -1
endi
sql select * from stb1 where c8 > 0
if $rows != 28 then
return -1
endi
sql select * from stb1 where c8 < 'nuLl';
if $rows != 28 then
return -1
endi
sql select * from stb1 where c2 > 3.0 or c2 < 60; sql select * from stb1 where c2 > 3.0 or c2 < 60;
if $rows != 28 then if $rows != 28 then
return -1 return -1
...@@ -2071,179 +2175,61 @@ if $data20 != @21-07-16 01:00:00.899@ then ...@@ -2071,179 +2175,61 @@ if $data20 != @21-07-16 01:00:00.899@ then
return -1 return -1
endi endi
sql select * from stb1 where c8 > 0;
print "ts test" if $rows != 28 then
sql_error select ts,c1,c7 from stb1 where ts != '2021-05-05 18:19:27'
sql_error select ts,c1,c7 from stb1 where ts > '2021-05-05 18:19:03.000' or ts < '2021-05-05 18:19:02.000';
sql_error select ts,c1,c7 from stb1 where ts > '2021-05-05 18:19:03.000' and ts > '2021-05-05 18:19:20.000' and ts != '2021-05-05 18:19:22.000';
sql_error select * from stb1 where ts2 like '2021-05-05%';
sql_error select ts,c1,c2 from stb1 where (ts > '2021-05-05 18:19:25.000' or ts < '2021-05-05 18:19:05.000') and ts > '2021-05-05 18:19:01.000' and ts < '2021-05-05 18:19:27.000';
sql_error select ts,c1,c2 from stb1 where (ts > '2021-05-05 18:19:20.000' or ts < '2021-05-05 18:19:05.000') and ts != '2021-05-05 18:19:25.000';
sql_error select ts,c1,c2 from stb1 where ((ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:10.000') or (ts >= '2021-05-05 18:19:15.000' and ts <= '2021-05-05 18:19:20.000') or (ts >= '2021-05-05 18:19:11.000' and ts <= '2021-05-05 18:19:14.000'));
sql_error select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' or ts < '2021-05-05 18:19:24.000';
sql select * from stb1 where ts is null;
if $rows != 0 then
return -1
endi
sql select * from stb1 where ts is not null and ts is null;
if $rows != 0 then
return -1
endi
sql select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' and ts < '2021-05-05 18:19:10.000';
if $rows != 0 then
return -1
endi
sql select * from stb1 where ts > '2021-05-05 18:19:03.000' and ts < '2021-05-05 18:19:02';
if $rows != 0 then
return -1 return -1
endi endi
sql select * from stb1 where ts is not null; sql select * from stb1 where c8 > 1 and c8 <= 21 and c8 < 11 and c8 >= 3;
if $rows != 29 then if $rows != 2 then
return -1 return -1
endi endi
if $data00 != @21-05-05 18:19:02.000@ then
sql select * from stb1 where ts is not null or ts is null;
if $rows != 29 then
return -1 return -1
endi endi
if $data10 != @21-05-05 18:19:03.000@ then
sql select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' or ts < '2021-05-05 18:19:25.000';
if $rows != 29 then
return -1 return -1
endi endi
sql select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' and ts < '2021-05-05 18:19:26.000'; sql select * from stb1 where c8 = 11 or c8 = 12 or c8 is null or c8 in ('13','23') or (c8 like '%4' and c8 like '3_');
if $rows != 1 then if $rows != 6 then
return -1
endi
if $data00 != @21-05-05 18:19:25.000@ then
return -1
endi
sql select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' or ts < '2021-05-05 18:19:28.000';
if $rows != 29 then
return -1
endi
sql select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' or ts > '2021-05-05 18:19:27.000';
if $rows != 4 then
return -1
endi
if $data00 != @21-05-05 18:19:25.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:26.000@ then
return -1 return -1
endi endi
if $data20 != @21-05-05 18:19:27.000@ then if $data00 != @21-05-05 18:19:04.000@ then
return -1 return -1
endi endi
if $data30 != @21-05-05 18:19:28.000@ then if $data10 != @21-05-05 18:19:05.000@ then
return -1 return -1
endi endi
if $data20 != @21-05-05 18:19:06.000@ then
sql select ts,c1,c2 from stb1 where ts > '2021-05-05 18:19:20.000' or ts < '2021-05-05 18:19:05.000' or ts != '2021-05-05 18:19:25.000';
if $rows != 29 then
return -1 return -1
endi endi
if $data30 != @21-05-05 18:19:10.000@ then
sql select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' or ts <> '2021-05-05 18:19:25.000';
if $rows != 29 then
return -1 return -1
endi endi
if $data40 != @21-05-05 18:19:15.000@ then
sql select ts,c1,c2 from stb1 where ((ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:10.999') or (ts >= '2021-05-05 18:19:15.000' and ts <= '2021-05-05 18:19:20.000') or (ts >= '2021-05-05 18:19:11.000' and ts <= '2021-05-05 18:19:14.999'));
if $rows != 16 then
return -1 return -1
endi endi
if $data00 != @21-05-05 18:19:05.000@ then if $data50 != @21-05-05 18:19:28.000@ then
return -1 return -1
endi endi
sql select ts,c1,c2 from stb1 where (ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:10.000') or (ts >= '2021-05-05 18:19:12.000' and ts <= '2021-05-05 18:19:14.000') or (ts >= '2021-05-05 18:19:08.000' and ts <= '2021-05-05 18:19:17.000'); sql select * from stb1 where c9 >= 3 and c9 <= 33;
if $rows != 13 then if $rows != 13 then
return -1 return -1
endi endi
if $data00 != @21-05-05 18:19:05.000@ then
return -1
endi
sql select ts,c1,c2 from stb1 where (ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:10.000') or (ts >= '2021-05-05 18:19:02.000' and ts <= '2021-05-05 18:19:03.000') or (ts >= '2021-05-05 18:19:01.000' and ts <= '2021-05-05 18:19:08.000');
if $rows != 10 then
return -1
endi
if $data00 != @21-05-05 18:19:01.000@ then
return -1
endi
sql select ts,c1,c2 from stb1 where ((ts >= '2021-05-05 18:19:08.000' and ts <= '2021-05-05 18:19:10.000') or (ts >= '2021-05-05 18:19:02.000' and ts <= '2021-05-05 18:19:03.000') or (ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:06.000') or (ts >= '2021-05-05 18:19:03.000' and ts <= '2021-05-05 18:19:12.000')) and (ts >= '2021-05-05 18:19:10.000');
if $rows != 3 then
return -1
endi
if $data00 != @21-05-05 18:19:10.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:11.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:12.000@ then
return -1
endi
sql select ts,c1,c7 from stb1 where ts > '2021-05-05 18:19:25.000' and ts != '2021-05-05 18:19:18'; sql select * from stb1 where c9 > 22 and c9 <= 38 and c8 < 30 and c8 >= 24;
if $rows != 3 then
return -1
endi
if $data00 != @21-05-05 18:19:26.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:27.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:28.000@ then
return -1
endi
sql select * from stb1 where ts > '2021-05-05 18:19:03.000' and ts > '2021-05-05 18:19:25';
if $rows != 3 then
return -1
endi
if $data00 != @21-05-05 18:19:26.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:27.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:28.000@ then
return -1
endi
sql select * from stb1 where ts < '2021-05-05 18:19:03.000' and ts < '2021-05-05 18:19:25';
if $rows != 3 then
return -1
endi
if $data00 != @21-05-05 18:19:00.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:01.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:02.000@ then
return -1
endi
sql select * from stb1 where ts > '2021-05-05 18:19:23.000' and ts < '2021-05-05 18:19:25';
if $rows != 1 then if $rows != 1 then
return -1 return -1
endi endi
if $data00 != @21-05-05 18:19:24.000@ then if $data00 != @21-05-05 18:19:11.000@ then
return -1 return -1
endi endi
sql select * from stb1 where ts > '2021-05-05 18:19:03.000' or ts > '2021-05-05 18:19:25';
if $rows != 25 then sql select * from stb1 where c9 = 11 or c9 = 12 or c9 is null or c9 in ('13','23') or ((c9 like '%4' or c9 like '3_') and c9 <> 34 and c9 != 44) and c9 < 45 and c9 like '1_';
if $rows != 6 then
return -1 return -1
endi endi
if $data00 != @21-05-05 18:19:04.000@ then if $data00 != @21-05-05 18:19:04.000@ then
...@@ -2255,485 +2241,104 @@ endi ...@@ -2255,485 +2241,104 @@ endi
if $data20 != @21-05-05 18:19:06.000@ then if $data20 != @21-05-05 18:19:06.000@ then
return -1 return -1
endi endi
if $data30 != @21-05-05 18:19:07.000@ then
sql select * from stb1 where ts < '2021-05-05 18:19:03.000' or ts < '2021-05-05 18:19:25';
if $rows != 25 then
return -1
endi
if $data00 != @21-05-05 18:19:00.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:01.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:02.000@ then
return -1
endi
sql select * from stb1 where ts > '2021-05-05 18:19:23.000' or ts < '2021-05-05 18:19:25';
if $rows != 29 then
return -1
endi
if $data00 != @21-05-05 18:19:00.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:01.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:02.000@ then
return -1
endi
sql select * from stb1 where (ts > '2021-05-05 18:19:23.000' or ts < '2021-05-05 18:19:25') and (ts > '2021-05-05 18:19:23.000' and ts < '2021-05-05 18:19:26');
if $rows != 2 then
return -1 return -1
endi endi
if $data00 != @21-05-05 18:19:24.000@ then if $data40 != @21-05-05 18:19:10.000@ then
return -1 return -1
endi endi
if $data10 != @21-05-05 18:19:25.000@ then if $data50 != @21-05-05 18:19:28.000@ then
return -1 return -1
endi endi
sql select * from stb1 where (ts > '2021-05-05 18:19:23.000' or ts < '2021-05-05 18:19:25') and (ts > '2021-05-05 18:19:23.000' or ts > '2021-05-05 18:19:26'); sql select * from stb1 where c8 match '^1.*';
if $rows != 5 then if $rows != 5 then
return -1 return -1
endi endi
if $data00 != @21-05-05 18:19:24.000@ then if $data00 != @21-05-05 18:19:00.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:25.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:26.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:27.000@ then
return -1
endi
if $data40 != @21-05-05 18:19:28.000@ then
return -1
endi
sql select * from stb2 where ts2 in ('2021-05-05 18:28:03','2021-05-05 18:28:05','2021-05-05 18:28:08');
if $rows != 3 then
return -1
endi
if $data00 != @21-05-05 18:19:02.000@ then
return -1 return -1
endi endi
if $data10 != @21-05-05 18:19:04.000@ then if $data10 != @21-05-05 18:19:04.000@ then
return -1 return -1
endi endi
if $data20 != @21-05-05 18:19:07.000@ then
return -1
endi
sql select * from stb2 where t3 in ('2021-05-05 18:38:38','2021-05-05 18:38:28','2021-05-05 18:38:08') and ts2 in ('2021-05-05 18:28:04','2021-05-05 18:28:04','2021-05-05 18:28:03');
if $rows != 2 then
return -1
endi
if $data00 != @21-05-05 18:19:02.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:03.000@ then
return -1
endi
sql select a.ts,b.ts,a.c1,b.u1,b.u2 from (select * from stb1) a, (select * from stb2) b where a.ts=b.ts and (a.ts < '2021-05-05 18:19:03.000' or a.ts >= '2021-05-05 18:19:13.000') and (b.ts >= '2021-05-05 18:19:01.000' and b.ts <= '2021-05-05 18:19:14.000');
if $rows != 4 then
return -1
endi
if $data00 != @21-05-05 18:19:01.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:02.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:13.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:14.000@ then
return -1
endi
sql select a.ts,c.ts,b.c1,c.u1,c.u2 from (select * from stb1) a, (select * from stb1) b, (select * from stb2) c where a.ts=b.ts and b.ts=c.ts and a.ts <= '2021-05-05 18:19:12.000' and b.ts >= '2021-05-05 18:19:06.000' and c.ts >= '2021-05-05 18:19:08.000' and c.ts <= '2021-05-05 18:19:11.000' and a.ts != '2021-05-05 18:19:10.000';
if $rows != 3 then
return -1
endi
if $data00 != @21-05-05 18:19:08.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:09.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:11.000@ then
return -1
endi
sql select ts,c1,c2,c8 from (select * from stb1) where (ts <= '2021-05-05 18:19:06.000' or ts >= '2021-05-05 18:19:13.000') and (ts >= '2021-05-05 18:19:02.000' and ts <= '2021-05-05 18:19:14.000') and ts != '2021-05-05 18:19:04.000';
if $rows != 6 then
return -1
endi
if $data00 != @21-05-05 18:19:02.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:03.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:05.000@ then if $data20 != @21-05-05 18:19:05.000@ then
return -1 return -1
endi endi
if $data30 != @21-05-05 18:19:06.000@ then if $data30 != @21-05-05 18:19:06.000@ then
return -1 return -1
endi endi
if $data40 != @21-05-05 18:19:13.000@ then if $data40 != @21-05-05 18:19:07.000@ then
return -1
endi
if $data50 != @21-05-05 18:19:14.000@ then
return -1 return -1
endi endi
sql select ts,c1,c2,c8 from (select * from stb1) where (ts <= '2021-05-05 18:19:03.000' or ts > '2021-05-05 18:19:26.000' or ts = '2021-05-05 18:19:26.000') and ts != '2021-05-05 18:19:03.000' and ts != '2021-05-05 18:19:26.000'; sql select * from stb1 where c8 match '1.*';
if $rows != 5 then if $rows != 10 then
return -1 return -1
endi endi
if $data00 != @21-05-05 18:19:00.000@ then if $data00 != @21-05-05 18:19:00.000@ then
return -1 return -1
endi endi
if $data10 != @21-05-05 18:19:01.000@ then if $data10 != @21-05-05 18:19:04.000@ then
return -1 return -1
endi endi
if $data20 != @21-05-05 18:19:02.000@ then if $data20 != @21-05-05 18:19:05.000@ then
return -1 return -1
endi endi
if $data30 != @21-05-05 18:19:27.000@ then if $data30 != @21-05-05 18:19:06.000@ then
return -1 return -1
endi endi
if $data40 != @21-05-05 18:19:28.000@ then if $data40 != @21-05-05 18:19:07.000@ then
return -1 return -1
endi endi
if $data50 != @21-05-05 18:19:08.000@ then
print "tbname test"
sql_error select * from stb1 where tbname like '%3' and tbname like '%4';
sql select * from stb1 where tbname like 'tb%';
if $rows != 29 then
return -1 return -1
endi endi
if $data60 != @21-05-05 18:19:12.000@ then
sql select * from stb1 where tbname like '%2';
if $rows != 4 then
return -1 return -1
endi endi
if $data00 != @21-05-05 18:19:08.000@ then if $data70 != @21-05-05 18:19:16.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:09.000@ then
return -1 return -1
endi endi
if $data20 != @21-05-05 18:19:10.000@ then if $data80 != @21-05-05 18:19:20.000@ then
return -1 return -1
endi endi
if $data30 != @21-05-05 18:19:11.000@ then if $data90 != @21-05-05 18:19:24.000@ then
return -1 return -1
endi endi
print "tag test" sql select * from stb1 where c8 match '1.+';
sql select * from stb1 where t1 in (1,2) and t1 in (2,3);
if $rows != 4 then if $rows != 4 then
return -1 return -1
endi endi
if $data00 != @21-05-05 18:19:08.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:09.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:10.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:11.000@ then
return -1
endi
sql select * from stb2 where t1 in (1,2) and t2 in (2) and t3 in ('2021-05-05 18:58:57.000');
if $rows != 0 then
return -1
endi
print "join test"
sql_error select * from tb1, tb2_1 where tb1.ts=tb2_1.ts or tb1.ts =tb2_1.ts;
sql select tb1.ts from tb1, tb2_1 where tb1.ts=tb2_1.ts and tb1.ts > '2021-05-05 18:19:03.000' and tb2_1.ts < '2021-05-05 18:19:06.000';
if $rows != 2 then
return -1
endi
if $data00 != @21-05-05 18:19:04.000@ then if $data00 != @21-05-05 18:19:04.000@ then
return -1 return -1
endi endi
if $data10 != @21-05-05 18:19:05.000@ then if $data10 != @21-05-05 18:19:05.000@ then
return -1 return -1
endi endi
sql select tb1.ts,tb1.*,tb2_1.* from tb1, tb2_1 where tb1.ts=tb2_1.ts and tb1.ts > '2021-05-05 18:19:03.000' and tb2_1.u1 < 5;
if $rows != 2 then
return -1
endi
if $data00 != @21-05-05 18:19:04.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:06.000@ then
return -1
endi
sql select tb1.ts,tb1.*,tb2_1.* from tb1, tb2_1 where tb1.ts=tb2_1.ts and tb1.ts >= '2021-05-05 18:19:03.000' and tb1.c7=false and tb2_1.u3>4;
if $rows != 2 then
return -1
endi
if $data00 != @21-05-05 18:19:03.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:07.000@ then
return -1
endi
sql select stb1.ts,stb1.c1,stb1.t1,stb2.ts,stb2.u1,stb2.t4 from stb1, stb2 where stb1.ts=stb2.ts and stb1.t1 = stb2.t4;
if $rows != 9 then
return -1
endi
if $data00 != @21-05-05 18:19:00.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:01.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:02.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:03.000@ then
return -1
endi
if $data40 != @21-05-05 18:19:04.000@ then
return -1
endi
if $data50 != @21-05-05 18:19:05.000@ then
return -1
endi
if $data60 != @21-05-05 18:19:06.000@ then
return -1
endi
if $data70 != @21-05-05 18:19:07.000@ then
return -1
endi
if $data80 != @21-05-05 18:19:11.000@ then
return -1
endi
sql select stb1.ts,stb1.c1,stb1.t1,stb2.ts,stb2.u1,stb2.t4 from stb1, stb2 where stb1.ts=stb2.ts and stb1.t1 = stb2.t4 and stb1.c1 > 2 and stb2.u1 <=4;
if $rows != 3 then
return -1
endi
if $data00 != @21-05-05 18:19:02.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:04.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:06.000@ then if $data20 != @21-05-05 18:19:06.000@ then
return -1 return -1
endi endi
if $data30 != @21-05-05 18:19:07.000@ then
print "column&ts test"
sql_error select count(*) from stb1 where ts > 0 or c1 > 0;
sql select * from stb1 where ts > '2021-05-05 18:19:03.000' and ts < '2021-05-05 18:19:20.000' and (c1 > 23 or c1 < 14) and c7 in (true) and c8 like '%2';
if $rows != 3 then
return -1
endi
if $data00 != @21-05-05 18:19:05.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:13.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:17.000@ then
return -1
endi
print "column&tbname test"
sql_error select count(*) from stb1 where tbname like 'tb%' or c1 > 0;
sql select * from stb1 where tbname like '%3' and c6 < 34 and c5 != 33 and c4 > 31;
if $rows != 1 then
return -1
endi
if $data00 != @21-05-05 18:19:13.000@ then
return -1 return -1
endi endi
print "column&tag test" sql select * from stb1 where c8 nmatch '^1.*';
sql_error select * from stb1 where t1 > 0 or c1 > 0 if $rows != 23 then
sql_error select * from stb1 where c1 > 0 or t1 > 0
sql_error select * from stb1 where t1 > 0 or c1 > 0 or t1 > 1
sql_error select * from stb1 where c1 > 0 or t1 > 0 or c1 > 1
sql_error select * from stb1 where t1 > 0 and c1 > 0 or t1 > 1
sql_error select * from stb1 where c1 > 0 or t1 > 0 and c1 > 1
sql_error select * from stb1 where c1 > 0 or t1 > 0 and c1 > 1
sql_error select * from stb1 where t1 > 0 or t1 > 0 and c1 > 1
sql_error select * from stb1 where (c1 > 0 and t1 > 0 ) or (t1 > 1 and c1 > 3)
sql_error select * from stb1 where (c1 > 0 and t1 > 0 ) or t1 > 1
sql_error select a.ts,b.ts,a.c1,b.u1,b.u2 from (select * from stb1) a, (select * from stb2) b where a.ts=b.ts and a.t1=b.t1;
sql select * from stb1 where c1 < 63 and t1 > 5
if $rows != 2 then
return -1
endi
if $data00 != @21-05-05 18:19:24.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:25.000@ then
return -1
endi
sql select * from stb1 where t1 > 3 and t1 < 5 and c1 != 42 and c1 != 44;
if $rows != 2 then
return -1
endi
if $data00 != @21-05-05 18:19:16.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:18.000@ then
return -1
endi
sql select * from stb1 where t1 > 1 and c1 > 21 and t1 < 3 and c1 < 24 and t1 != 3 and c1 != 23;
if $rows != 1 then
return -1
endi
if $data00 != @21-05-05 18:19:09.000@ then
return -1
endi
sql select * from stb1 where c1 > 1 and (t1 > 3 or t1 < 2) and (c2 > 2 and c2 < 62 and t1 != 4) and (t1 > 2 and t1 < 6) and c7 = true and c8 like '%2';
if $rows != 1 then
return -1
endi
if $data00 != @21-05-05 18:19:21.000@ then
return -1 return -1
endi endi
sql select * from stb1 where c1!=31 and c1 !=32 and c1 <> 63 and c1 <>1 and c1 <> 21 and c1 <> 2 and c7 <> true and c8 <> '3' and c9 <> '4' and c2<>13 and c3 <> 23 and c4 <> 33 and c5 <> 34 and c6 <> 43 and c2 <> 53 and t1 <> 5 and t2 <>4; sql select ts,c8 from stb1 where c8 nmatch '[2345]+';
if $rows != 3 then if $rows != 3 then
return -1 return -1
endi endi
if $data00 != @21-05-05 18:19:07.000@ then if $data00 != @21-05-05 18:19:00.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:11.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:27.000@ then
return -1
endi
print "column&join test"
sql_error select tb1.ts,tb1.c1,tb2_1.u1 from tb1, tb2_1 where tb1.ts=tb2_1.ts or tb1.c1 > 0;
print "ts&tbname test"
sql_error select count(*) from stb1 where ts > 0 or tbname like 'tb%';
print "ts&tag test"
sql_error select count(*) from stb1 where ts > 0 or t1 > 0;
sql select * from stb2 where t1!=1 and t2=2 and t3 in ('2021-05-05 18:58:58.000') and ts < '2021-05-05 18:19:13.000';
if $rows != 2 then
return -1
endi
if $data00 != @21-05-05 18:19:11.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:12.000@ then
return -1
endi
print "ts&join test"
sql_error select tb1.ts,tb1.c1,tb2_1.u1 from tb1, tb2_1 where tb1.ts=tb2_1.ts or tb1.ts > 0;
sql select tb1.ts,tb1.c1,tb2_1.u1 from tb1, tb2_1 where tb1.ts=tb2_1.ts and (tb1.ts > '2021-05-05 18:19:05.000' or tb1.ts < '2021-05-05 18:19:03.000' or tb1.ts > 0);
print "tbname&tag test"
sql select * from stb1 where tbname like 'tb%' and (t1=1 or t2=2 or t3=3) and t1 > 2;
if $rows != 4 then
return -1
endi
if $data00 != @21-05-05 18:19:12.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:13.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:14.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:15.000@ then
return -1
endi
print "tbname&join test"
print "tag&join test"
print "column&ts&tbname test"
sql_error select count(*) from stb1 where tbname like 'tb%' or c1 > 0 or ts > 0;
print "column&ts&tag test"
sql_error select count(*) from stb1 where t1 > 0 or c1 > 0 or ts > 0;
sql_error select count(*) from stb1 where c1 > 0 or t1 > 0 or ts > 0;
sql select * from stb1 where (t1 > 0 or t1 > 2 ) and ts > '2021-05-05 18:19:10.000' and (c1 > 1 or c1 > 3) and (c6 > 40 or c6 < 30) and (c8 like '%3' or c8 like '_4') and (c9 like '1%' or c9 like '6%' or (c9 like '%3' and c9 != '23')) and ts > '2021-05-05 18:19:22.000' and ts <= '2021-05-05 18:19:26.000';
if $rows != 1 then
return -1
endi
if $data00 != @21-05-05 18:19:26.000@ then
return -1 return -1
endi endi
sql select * from stb1 where ts > '2021-05-05 18:19:00.000' and c1 > 2 and t1 != 1 and c2 >= 23 and t2 >= 3 and c3 < 63 and c7 = false and t3 > 3 and t3 < 6 and c8 like '4%' and ts < '2021-05-05 18:19:19.000' and c2 > 40 and c3 != 42; if $data10 != @21-05-05 18:19:04.000@ then
if $rows != 1 then
return -1 return -1
endi endi
if $data00 != @21-05-05 18:19:18.000@ then if $data20 != @21-05-05 18:19:24.000@ then
return -1 return -1
endi endi
print "column&ts&join test"
print "column&tbname&tag test"
sql_error select count(*) from stb1 where c1 > 0 or tbname in ('tb1') or t1 > 0;
print "column&tbname&join test"
print "column&tag&join test"
print "ts&tbname&tag test"
sql_error select count(*) from stb1 where ts > 0 or tbname in ('tb1') or t1 > 0;
print "ts&tbname&join test"
print "ts&tag&join test"
print "tbname&tag&join test"
print "column&ts&tbname&tag test"
sql_error select * from stb1 where (tbname like 'tb%' or ts > '2021-05-05 18:19:01.000') and (t1 > 5 or t1 < 4) and c1 > 0;
sql_error select * from stb1 where (ts > '2021-05-05 18:19:01.000') and (ts > '2021-05-05 18:19:02.000' or t1 > 3) and (t1 > 5 or t1 < 4) and c1 > 0;
sql_error select ts,c1,c7 from stb1 where ts > '2021-05-05 18:19:03.000' or ts > '2021-05-05 18:19:20.000' and col > 0 and t1 > 0;
print "column&ts&tbname&join test"
print "column&ts&tag&join test"
print "column&tbname&tag&join test"
print "ts&tbname&tag&join test"
print "column&ts&tbname&tag&join test"
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
sql use cdb;
print "ts test"
sql_error select ts,c1,c7 from stb1 where ts != '2021-05-05 18:19:27'
sql_error select ts,c1,c7 from stb1 where ts > '2021-05-05 18:19:03.000' or ts < '2021-05-05 18:19:02.000';
sql_error select ts,c1,c7 from stb1 where ts > '2021-05-05 18:19:03.000' and ts > '2021-05-05 18:19:20.000' and ts != '2021-05-05 18:19:22.000';
sql_error select * from stb1 where ts2 like '2021-05-05%';
sql_error select ts,c1,c2 from stb1 where (ts > '2021-05-05 18:19:25.000' or ts < '2021-05-05 18:19:05.000') and ts > '2021-05-05 18:19:01.000' and ts < '2021-05-05 18:19:27.000';
sql_error select ts,c1,c2 from stb1 where (ts > '2021-05-05 18:19:20.000' or ts < '2021-05-05 18:19:05.000') and ts != '2021-05-05 18:19:25.000';
sql_error select ts,c1,c2 from stb1 where ((ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:10.000') or (ts >= '2021-05-05 18:19:15.000' and ts <= '2021-05-05 18:19:20.000') or (ts >= '2021-05-05 18:19:11.000' and ts <= '2021-05-05 18:19:14.000'));
sql_error select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' or ts < '2021-05-05 18:19:24.000';
sql_error select tbname,ts,t1,t2 from stb5 where t1 > '';
sql select * from stb1 where ts is null;
if $rows != 0 then
return -1
endi
sql select * from stb1 where ts is not null and ts is null;
if $rows != 0 then
return -1
endi
sql select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' and ts < '2021-05-05 18:19:10.000';
if $rows != 0 then
return -1
endi
sql select * from stb1 where ts > '2021-05-05 18:19:03.000' and ts < '2021-05-05 18:19:02';
if $rows != 0 then
return -1
endi
sql select * from stb1 where ts is not null;
if $rows != 29 then
return -1
endi
sql select * from stb1 where ts is not null or ts is null;
if $rows != 29 then
return -1
endi
sql select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' or ts < '2021-05-05 18:19:25.000';
if $rows != 29 then
return -1
endi
sql select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' and ts < '2021-05-05 18:19:26.000';
if $rows != 1 then
return -1
endi
if $data00 != @21-05-05 18:19:25.000@ then
return -1
endi
sql select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' or ts < '2021-05-05 18:19:28.000';
if $rows != 29 then
return -1
endi
sql select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' or ts > '2021-05-05 18:19:27.000';
if $rows != 4 then
return -1
endi
if $data00 != @21-05-05 18:19:25.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:26.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:27.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:28.000@ then
return -1
endi
sql select ts,c1,c2 from stb1 where ts > '2021-05-05 18:19:20.000' or ts < '2021-05-05 18:19:05.000' or ts != '2021-05-05 18:19:25.000';
if $rows != 29 then
return -1
endi
sql select ts,c1,c2 from stb1 where ts >= '2021-05-05 18:19:25.000' or ts <> '2021-05-05 18:19:25.000';
if $rows != 29 then
return -1
endi
sql select ts,c1,c2 from stb1 where ((ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:10.999') or (ts >= '2021-05-05 18:19:15.000' and ts <= '2021-05-05 18:19:20.000') or (ts >= '2021-05-05 18:19:11.000' and ts <= '2021-05-05 18:19:14.999'));
if $rows != 16 then
return -1
endi
if $data00 != @21-05-05 18:19:05.000@ then
return -1
endi
sql select ts,c1,c2 from stb1 where (ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:10.000') or (ts >= '2021-05-05 18:19:12.000' and ts <= '2021-05-05 18:19:14.000') or (ts >= '2021-05-05 18:19:08.000' and ts <= '2021-05-05 18:19:17.000');
if $rows != 13 then
return -1
endi
if $data00 != @21-05-05 18:19:05.000@ then
return -1
endi
sql select ts,c1,c2 from stb1 where (ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:10.000') or (ts >= '2021-05-05 18:19:02.000' and ts <= '2021-05-05 18:19:03.000') or (ts >= '2021-05-05 18:19:01.000' and ts <= '2021-05-05 18:19:08.000');
if $rows != 10 then
return -1
endi
if $data00 != @21-05-05 18:19:01.000@ then
return -1
endi
sql select ts,c1,c2 from stb1 where ((ts >= '2021-05-05 18:19:08.000' and ts <= '2021-05-05 18:19:10.000') or (ts >= '2021-05-05 18:19:02.000' and ts <= '2021-05-05 18:19:03.000') or (ts >= '2021-05-05 18:19:05.000' and ts <= '2021-05-05 18:19:06.000') or (ts >= '2021-05-05 18:19:03.000' and ts <= '2021-05-05 18:19:12.000')) and (ts >= '2021-05-05 18:19:10.000');
if $rows != 3 then
return -1
endi
if $data00 != @21-05-05 18:19:10.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:11.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:12.000@ then
return -1
endi
sql select ts,c1,c7 from stb1 where ts > '2021-05-05 18:19:25.000' and ts != '2021-05-05 18:19:18';
if $rows != 3 then
return -1
endi
if $data00 != @21-05-05 18:19:26.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:27.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:28.000@ then
return -1
endi
sql select * from stb1 where ts > '2021-05-05 18:19:03.000' and ts > '2021-05-05 18:19:25';
if $rows != 3 then
return -1
endi
if $data00 != @21-05-05 18:19:26.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:27.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:28.000@ then
return -1
endi
sql select * from stb1 where ts < '2021-05-05 18:19:03.000' and ts < '2021-05-05 18:19:25';
if $rows != 3 then
return -1
endi
if $data00 != @21-05-05 18:19:00.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:01.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:02.000@ then
return -1
endi
sql select * from stb1 where ts > '2021-05-05 18:19:23.000' and ts < '2021-05-05 18:19:25';
if $rows != 1 then
return -1
endi
if $data00 != @21-05-05 18:19:24.000@ then
return -1
endi
sql select * from stb1 where ts > '2021-05-05 18:19:03.000' or ts > '2021-05-05 18:19:25';
if $rows != 25 then
return -1
endi
if $data00 != @21-05-05 18:19:04.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:05.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:06.000@ then
return -1
endi
sql select * from stb1 where ts < '2021-05-05 18:19:03.000' or ts < '2021-05-05 18:19:25';
if $rows != 25 then
return -1
endi
if $data00 != @21-05-05 18:19:00.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:01.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:02.000@ then
return -1
endi
sql select * from stb1 where ts > '2021-05-05 18:19:23.000' or ts < '2021-05-05 18:19:25';
if $rows != 29 then
return -1
endi
if $data00 != @21-05-05 18:19:00.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:01.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:02.000@ then
return -1
endi
sql select * from stb1 where (ts > '2021-05-05 18:19:23.000' or ts < '2021-05-05 18:19:25') and (ts > '2021-05-05 18:19:23.000' and ts < '2021-05-05 18:19:26');
if $rows != 2 then
return -1
endi
if $data00 != @21-05-05 18:19:24.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:25.000@ then
return -1
endi
sql select * from stb1 where (ts > '2021-05-05 18:19:23.000' or ts < '2021-05-05 18:19:25') and (ts > '2021-05-05 18:19:23.000' or ts > '2021-05-05 18:19:26');
if $rows != 5 then
return -1
endi
if $data00 != @21-05-05 18:19:24.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:25.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:26.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:27.000@ then
return -1
endi
if $data40 != @21-05-05 18:19:28.000@ then
return -1
endi
sql select * from stb2 where ts2 in ('2021-05-05 18:28:03','2021-05-05 18:28:05','2021-05-05 18:28:08');
if $rows != 3 then
return -1
endi
if $data00 != @21-05-05 18:19:02.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:04.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:07.000@ then
return -1
endi
sql select * from stb2 where t3 in ('2021-05-05 18:38:38','2021-05-05 18:38:28','2021-05-05 18:38:08') and ts2 in ('2021-05-05 18:28:04','2021-05-05 18:28:04','2021-05-05 18:28:03');
if $rows != 2 then
return -1
endi
if $data00 != @21-05-05 18:19:02.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:03.000@ then
return -1
endi
sql select a.ts,b.ts,a.c1,b.u1,b.u2 from (select * from stb1) a, (select * from stb2) b where a.ts=b.ts and (a.ts < '2021-05-05 18:19:03.000' or a.ts >= '2021-05-05 18:19:13.000') and (b.ts >= '2021-05-05 18:19:01.000' and b.ts <= '2021-05-05 18:19:14.000');
if $rows != 4 then
return -1
endi
if $data00 != @21-05-05 18:19:01.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:02.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:13.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:14.000@ then
return -1
endi
sql select a.ts,c.ts,b.c1,c.u1,c.u2 from (select * from stb1) a, (select * from stb1) b, (select * from stb2) c where a.ts=b.ts and b.ts=c.ts and a.ts <= '2021-05-05 18:19:12.000' and b.ts >= '2021-05-05 18:19:06.000' and c.ts >= '2021-05-05 18:19:08.000' and c.ts <= '2021-05-05 18:19:11.000' and a.ts != '2021-05-05 18:19:10.000';
if $rows != 3 then
return -1
endi
if $data00 != @21-05-05 18:19:08.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:09.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:11.000@ then
return -1
endi
sql select ts,c1,c2,c8 from (select * from stb1) where (ts <= '2021-05-05 18:19:06.000' or ts >= '2021-05-05 18:19:13.000') and (ts >= '2021-05-05 18:19:02.000' and ts <= '2021-05-05 18:19:14.000') and ts != '2021-05-05 18:19:04.000';
if $rows != 6 then
return -1
endi
if $data00 != @21-05-05 18:19:02.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:03.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:05.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:06.000@ then
return -1
endi
if $data40 != @21-05-05 18:19:13.000@ then
return -1
endi
if $data50 != @21-05-05 18:19:14.000@ then
return -1
endi
sql select ts,c1,c2,c8 from (select * from stb1) where (ts <= '2021-05-05 18:19:03.000' or ts > '2021-05-05 18:19:26.000' or ts = '2021-05-05 18:19:26.000') and ts != '2021-05-05 18:19:03.000' and ts != '2021-05-05 18:19:26.000';
if $rows != 5 then
return -1
endi
if $data00 != @21-05-05 18:19:00.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:01.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:02.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:27.000@ then
return -1
endi
if $data40 != @21-05-05 18:19:28.000@ then
return -1
endi
print "tbname test"
sql select tbname from stb1;
if $rows != 6 then
return -1
endi
sql select * from stb1 where tbname like '%3' and tbname like '%4';
if $rows != 0 then
return -1
endi
sql select * from stb1 where tbname like 'tb%';
if $rows != 29 then
return -1
endi
sql select * from stb1 where tbname like '%2';
if $rows != 4 then
return -1
endi
if $data00 != @21-05-05 18:19:08.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:09.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:10.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:11.000@ then
return -1
endi
sql select tbname from stb1 where tbname = 'tb1';
if $rows != 1 then
return -1
endi
if $data00 != tb1 then
return -1
endi
sql select tbname from stb1 where tbname = 'tb1' or tbname = 'tb3';
if $rows != 2 then
return -1
endi
if $data00 != tb1 then
return -1
endi
if $data10 != tb3 then
return -1
endi
sql select tbname from stb1 where tbname <> 'tb1';
if $rows != 5 then
return -1
endi
if $data00 != tb2 then
return -1
endi
if $data10 != tb3 then
return -1
endi
if $data20 != tb4 then
return -1
endi
if $data30 != tb5 then
return -1
endi
if $data40 != tb6 then
return -1
endi
sql select tbname from stb1 where tbname <> 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
if $rows != 6 then
return -1
endi
if $data00 != tb1 then
return -1
endi
if $data10 != tb2 then
return -1
endi
if $data20 != tb3 then
return -1
endi
if $data30 != tb4 then
return -1
endi
if $data40 != tb5 then
return -1
endi
if $data50 != tb6 then
return -1
endi
sql select tbname from stb1 where tbname > 'tba';
if $rows != 0 then
return -1
endi
sql select tbname from stb1 where tbname > 'tb2' and tbname <= 'tb5';
if $rows != 3 then
return -1
endi
if $data00 != tb3 then
return -1
endi
if $data10 != tb4 then
return -1
endi
if $data20 != tb5 then
return -1
endi
sql select tbname from stb1 where tbname >= 'tb5' or tbname <= 'tb2';
if $rows != 4 then
return -1
endi
if $data00 != tb1 then
return -1
endi
if $data10 != tb2 then
return -1
endi
if $data20 != tb5 then
return -1
endi
if $data30 != tb6 then
return -1
endi
sql select tbname from stb1 where tbname is null;
if $rows != 0 then
return -1
endi
sql select tbname from stb1 where tbname is not null;
if $rows != 6 then
return -1
endi
if $data00 != tb1 then
return -1
endi
if $data10 != tb2 then
return -1
endi
if $data20 != tb3 then
return -1
endi
if $data30 != tb4 then
return -1
endi
if $data40 != tb5 then
return -1
endi
if $data50 != tb6 then
return -1
endi
sql select tbname from stb1 where tbname in ('tb2','tb6');
if $rows != 2 then
return -1
endi
if $data00 != tb2 then
return -1
endi
if $data10 != tb6 then
return -1
endi
sql select tbname from stb1 where tbname is not null and (tbname in ('tb2','tb6') or tbname like '%3');
if $rows != 3 then
return -1
endi
if $data00 != tb2 then
return -1
endi
if $data10 != tb3 then
return -1
endi
if $data20 != tb6 then
return -1
endi
sql select tbname from stb1 where (tbname like '%5' and tbname like 'tb%');
if $rows != 1 then
return -1
endi
if $data00 != tb5 then
return -1
endi
sql select * from stb1 where tbname = 'tb5' and tbname <> 'tb5';
if $rows != 0 then
return -1
endi
sql select * from stb1 where tbname = 'tb5' and tbname <> 'tb4';
if $rows != 4 then
return -1
endi
if $data00 != @21-05-05 18:19:20.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:21.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:22.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:23.000@ then
return -1
endi
sql select *,tbname from stb1 where tbname between 'tb2' and 'tb3';
if $rows != 8 then
return -1
endi
if $data00 != @21-05-05 18:19:08.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:09.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:10.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:11.000@ then
return -1
endi
if $data40 != @21-05-05 18:19:12.000@ then
return -1
endi
if $data50 != @21-05-05 18:19:13.000@ then
return -1
endi
if $data60 != @21-05-05 18:19:14.000@ then
return -1
endi
if $data70 != @21-05-05 18:19:15.000@ then
return -1
endi
sql select ts,c1,t9,t10,tbname from stb5 where tbname match '^3';
if $rows != 0 then
return -1
endi
sql select ts,c1,t9,t10,tbname from stb5 where tbname match 'tb.?_[34]';
if $rows != 8 then
return -1
endi
if $data00 != @21-05-05 18:19:12.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:13.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:14.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:15.000@ then
return -1
endi
if $data40 != @21-05-05 18:19:16.000@ then
return -1
endi
if $data50 != @21-05-05 18:19:17.000@ then
return -1
endi
if $data60 != @21-05-05 18:19:18.000@ then
return -1
endi
if $data70 != @21-05-05 18:19:19.000@ then
return -1
endi
sql select ts,c1,t9,t10,tbname from stb5 where tbname nmatch '[123467]+';
if $rows != 9 then
return -1
endi
if $data00 != @21-05-05 18:19:20.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:21.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:22.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:23.000@ then
return -1
endi
if $data40 != @21-05-05 18:19:34.000@ then
return -1
endi
if $data50 != @21-05-05 18:19:35.000@ then
return -1
endi
if $data60 != @21-05-05 18:19:36.000@ then
return -1
endi
if $data70 != @21-05-05 18:19:37.000@ then
return -1
endi
if $data80 != @21-05-05 18:19:38.000@ then
return -1
endi
sql select ts,c1,t9,t10,tbname from stb5 where tbname in ('tb5_1', 'TB5_2');
if $rows != 12 then
return -1
endi
sql select ts,c1,t9,t10,tbname from stb5 where tbname in ('tb5_1', 'TB5_2') or tbname in ('tb5_3');
if $rows != 16 then
return -1
endi
sql select ts,c1,t9,t10,tbname from stb5 where tbname in ('tb5_1', 'TB5_2') and tbname in ('tb5_2');
if $rows != 4 then
return -1
endi
if $data00 != @21-05-05 18:19:08.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:09.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:10.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:11.000@ then
return -1
endi
print "tag test"
sql_error select * from stb5 where t1 match '.*';
sql_error select * from stb5 where t2 match '.*';
sql_error select * from stb5 where t3 match '.*';
sql_error select * from stb5 where t4 match '.*';
sql_error select * from stb5 where t5 match '.*';
sql_error select * from stb5 where t6 match '.*';
sql_error select * from stb5 where t7 match '.*';
sql_error select * from stb5 where t8 match '.*';
sql_error select * from stb5 where t10 match '.*';
sql_error select * from tb1 where t1 in (1,2) and t1 in (2,3);
sql select * from stb1 where t1 in (1,2) and t1 in (2,3);
if $rows != 4 then
return -1
endi
if $data00 != @21-05-05 18:19:08.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:09.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:10.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:11.000@ then
return -1
endi
sql select * from stb1 where t1 in (1,2) or t1 in (2,3);
if $rows != 16 then
return -1
endi
sql select * from stb2 where t1 in (1,2) and t2 in (2) and t3 in ('2021-05-05 18:58:57.000');
if $rows != 0 then
return -1
endi
sql select *,t1 from stb5 where t1 > 0;
if $rows != 34 then
return -1
endi
sql select ts,c1,t1 from stb5 where ((t1 > 0 and t1 <= '2021-05-05 18:19:02.000') or (t1 >'2021-05-05 18:19:03.000' and t1 < '2021-05-05 18:19:06.000')) and t1 != '2021-05-05 18:19:04.000' and t1 is not null;
if $rows != 16 then
return -1
endi
sql select ts,c1,t1 from stb5 where ((t1 > 0 and t1 <= '2021-05-05 18:19:02.000') or (t1 >'2021-05-05 18:19:03.000' and t1 < '2021-05-05 18:19:06.000')) and t1 != '2021-05-05 18:19:04.000' and t1 is null;
if $rows != 0 then
return -1
endi
sql select ts,c1,t1 from stb5 where (((t1 > 0 and t1 <= '2021-05-05 18:19:02.000') or (t1 >'2021-05-05 18:19:03.000' and t1 < '2021-05-05 18:19:06.000')) and t1 != '2021-05-05 18:19:04.000') or t1 is null;
if $rows != 21 then
return -1
endi
sql select ts,c1,t2 from stb5 where t2 > 0 or t2 is null;
if $rows != 39 then
return -1
endi
sql select ts,c1,t2 from stb5 where (((t2 > 5 or t2 is null or t2 < 3) and t2 != 6) or t2 in (4, 3)) and t2 <= 3 and t2 >= 2;
if $rows != 8 then
return -1
endi
if $data00 != @21-05-05 18:19:08.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:09.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:10.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:11.000@ then
return -1
endi
if $data40 != @21-05-05 18:19:12.000@ then
return -1
endi
if $data50 != @21-05-05 18:19:13.000@ then
return -1
endi
if $data60 != @21-05-05 18:19:14.000@ then
return -1
endi
if $data70 != @21-05-05 18:19:15.000@ then
return -1
endi
sql select ts,c1,t2 from stb5 where t2 > 5.5;
if $rows != 10 then
return -1
endi
if $data00 != @21-05-05 18:19:24.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:25.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:26.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:27.000@ then
return -1
endi
if $data40 != @21-05-05 18:19:28.000@ then
return -1
endi
if $data50 != @21-05-05 18:19:29.000@ then
return -1
endi
if $data60 != @21-05-05 18:19:30.000@ then
return -1
endi
if $data70 != @21-05-05 18:19:31.000@ then
return -1
endi
if $data80 != @21-05-05 18:19:32.000@ then
return -1
endi
if $data90 != @21-05-05 18:19:33.000@ then
return -1
endi
sql select ts,c1,t2 from stb5 where t2 >= 5.5;
if $rows != 14 then
return -1
endi
sql select ts,c1,t3,t4,t5,t6,t7 from stb5 where t3 is null or t4 is null;
if $rows != 10 then
return -1
endi
if $data00 != @21-05-05 18:19:29.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:30.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:31.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:32.000@ then
return -1
endi
if $data40 != @21-05-05 18:19:33.000@ then
return -1
endi
if $data50 != @21-05-05 18:19:34.000@ then
return -1
endi
if $data60 != @21-05-05 18:19:35.000@ then
return -1
endi
if $data70 != @21-05-05 18:19:36.000@ then
return -1
endi
if $data80 != @21-05-05 18:19:37.000@ then
return -1
endi
if $data90 != @21-05-05 18:19:38.000@ then
return -1
endi
sql select ts,c1,t3,t4,t5,t6,t7 from stb5 where t3 is null or t4 is null or t5 <= 1 or t6 in (2,3) or t7 < 5;
if $rows != 30 then
return -1
endi
sql select ts,c1,t8,t9 from stb5 where t8 = true;
if $rows != 21 then
return -1
endi
sql select ts,c1,t8,t9 from stb5 where t8 <> true;
if $rows != 13 then
return -1
endi
sql select ts,c1,t8,t9 from stb5 where t8 = false;
if $rows != 13 then
return -1
endi
sql select ts,c1,t8,t9 from stb5 where t8 in (true, false);
if $rows != 34 then
return -1
endi
sql select ts,c1,t8,t9 from stb5 where t8 in (true, false) or t8 is null;
if $rows != 39 then
return -1
endi
sql select ts,c1,t8,t9 from stb5 where t8 in (true) and t8 is not null;
if $rows != 21 then
return -1
endi
sql select ts,c1,t9,t10 from stb5 where t9 > '12';
if $rows != 34 then
return -1
endi
sql select ts,c1,t9,t10 from stb5 where t9 = '11';
if $rows != 0 then
return -1
endi
sql select ts,c1,t9,t10 from stb5 where t9 <> '111111111';
if $rows != 26 then
return -1
endi
sql select ts,c1,t9,t10 from stb5 where t9 = '111111111';
if $rows != 8 then
return -1
endi
if $data00 != @21-05-05 18:19:00.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:01.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:02.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:03.000@ then
return -1
endi
if $data40 != @21-05-05 18:19:04.000@ then
return -1
endi
if $data50 != @21-05-05 18:19:05.000@ then
return -1
endi
if $data60 != @21-05-05 18:19:06.000@ then
return -1
endi
if $data70 != @21-05-05 18:19:07.000@ then
return -1
endi
sql select ts,c1,t9,t10 from stb5 where t9 >= '888888888';
if $rows != 5 then
return -1
endi
if $data00 != @21-05-05 18:19:34.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:35.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:36.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:37.000@ then
return -1
endi
if $data40 != @21-05-05 18:19:38.000@ then
return -1
endi
sql select ts,c1,t9,t10 from stb5 where t9 > '222222222' and t9 < '444444444';
if $rows != 4 then
return -1
endi
if $data00 != @21-05-05 18:19:12.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:13.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:14.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:15.000@ then
return -1
endi
sql select ts,c1,t9,t10 from stb5 where t9 > '0000000000' and t9 < '999999999';
if $rows != 0 then
return -1
endi
sql select ts,c1,t9,t10 from stb5 where t9 like '_1';
if $rows != 0 then
return -1
endi
sql select ts,c1,t9,t10 from stb5 where t9 like '%1';
if $rows != 8 then
return -1
endi
if $data00 != @21-05-05 18:19:00.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:01.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:02.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:03.000@ then
return -1
endi
if $data40 != @21-05-05 18:19:04.000@ then
return -1
endi
if $data50 != @21-05-05 18:19:05.000@ then
return -1
endi
if $data60 != @21-05-05 18:19:06.000@ then
return -1
endi
if $data70 != @21-05-05 18:19:07.000@ then
return -1
endi
sql select ts,c1,t9,t10 from stb5 where (t9 like '%1' or t9 in ('222222222','444444444')) and t9 is null;
if $rows != 0 then
return -1
endi
sql select ts,c1,t9,t10 from stb5 where t9 is null;
if $rows != 5 then
return -1
endi
if $data00 != @21-05-05 18:19:29.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:30.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:31.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:32.000@ then
return -1
endi
if $data40 != @21-05-05 18:19:33.000@ then
return -1
endi
sql select ts,c1,t9,t10 from stb5 where t9 is not null;
if $rows != 34 then
return -1
endi
sql select ts,c1,t9,t10 from stb5 where t9 is not null and t9 is null;
if $rows != 0 then
return -1
endi
sql select ts,c1,t9,t10 from stb5 where t9 like '_%' and t10 between 5 and 6;
if $rows != 9 then
return -1
endi
if $data00 != @21-05-05 18:19:20.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:21.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:22.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:23.000@ then
return -1
endi
if $data40 != @21-05-05 18:19:24.000@ then
return -1
endi
if $data50 != @21-05-05 18:19:25.000@ then
return -1
endi
if $data60 != @21-05-05 18:19:26.000@ then
return -1
endi
if $data70 != @21-05-05 18:19:27.000@ then
return -1
endi
if $data80 != @21-05-05 18:19:28.000@ then
return -1
endi
sql select ts,c1,t9,t10 from stb5 where t10 is not null;
if $rows != 34 then
return -1
endi
sql select ts,c1,t9,t10 from stb5 where t10 is null;
if $rows != 5 then
return -1
endi
if $data00 != @21-05-05 18:19:34.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:35.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:36.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:37.000@ then
return -1
endi
if $data40 != @21-05-05 18:19:38.000@ then
return -1
endi
sql select ts,c1,t9,t10 from stb5 where t10 is not null and t10 like '%__';
if $rows != 0 then
return -1
endi
sql select ts,c1,t9,t10 from stb5 where t10 is not null and t10 like '%_%';
if $rows != 34 then
return -1
endi
sql select ts,c1,t9,t10 from stb5 where t10 is not null and t10 like '%%_%%';
if $rows != 34 then
return -1
endi
sql select ts,c1,t9,t10 from stb5 where t10 is not null and t10 like '%_%%%_';
if $rows != 0 then
return -1
endi
sql select ts,c1,t9,t10 from stb5 where t10 like '_' and t10 between 2 and 3;
if $rows != 8 then
return -1
endi
if $data00 != @21-05-05 18:19:08.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:09.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:10.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:11.000@ then
return -1
endi
if $data40 != @21-05-05 18:19:12.000@ then
return -1
endi
if $data50 != @21-05-05 18:19:13.000@ then
return -1
endi
if $data60 != @21-05-05 18:19:14.000@ then
return -1
endi
if $data70 != @21-05-05 18:19:15.000@ then
return -1
endi
sql select ts,c1,t9,t10 from stb5 where t10 in ('a','3','bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb') or t10 in ('');
if $rows != 4 then
return -1
endi
if $data00 != @21-05-05 18:19:12.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:13.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:14.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:15.000@ then
return -1
endi
sql select ts,c1,t9,t10 from stb5 where t10 is null or (t10 > 1 and t10 < 7 and t10 in ('3','4','5') and t10 != 4 and t10 like '3');
if $rows != 9 then
return -1
endi
if $data00 != @21-05-05 18:19:12.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:13.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:14.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:15.000@ then
return -1
endi
if $data40 != @21-05-05 18:19:34.000@ then
return -1
endi
if $data50 != @21-05-05 18:19:35.000@ then
return -1
endi
if $data60 != @21-05-05 18:19:36.000@ then
return -1
endi
if $data70 != @21-05-05 18:19:37.000@ then
return -1
endi
if $data80 != @21-05-05 18:19:38.000@ then
return -1
endi
sql select ts,c1,t8,t9,t10 from stb5 where (t10 is null or t9 is null) and t8 is null;
if $rows != 5 then
return -1
endi
if $data00 != @21-05-05 18:19:34.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:35.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:36.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:37.000@ then
return -1
endi
if $data40 != @21-05-05 18:19:38.000@ then
return -1
endi
sql select ts,c1,t8,t9,t10 from stb5 where t10 between 3 and 7 and t9 between '' and '00000000000' and t9 like '_________' and (t10 like '3%'or t10 like '%4');
if $rows != 8 then
return -1
endi
if $data00 != @21-05-05 18:19:12.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:13.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:14.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:15.000@ then
return -1
endi
if $data40 != @21-05-05 18:19:16.000@ then
return -1
endi
if $data50 != @21-05-05 18:19:17.000@ then
return -1
endi
if $data60 != @21-05-05 18:19:18.000@ then
return -1
endi
if $data70 != @21-05-05 18:19:19.000@ then
return -1
endi
sql select ts,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10 from stb5 where t1 is not null and t2 between 2 and 7 and t3 in (2, 4,6) and t8 != false and t9 > '111111111' and t10 <= 5;
if $rows != 4 then
return -1
endi
if $data00 != @21-05-05 18:19:08.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:09.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:10.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:11.000@ then
return -1
endi
sql select * from stb5 where t1 <> 1;
if $rows != 34 then
return -1
endi
sql select t1,ts,c1 from stb5 where t1 <> '2021-05-05 18:19:01.000'
if $rows != 26 then
return -1
endi
sql select t1,ts,c1 from stb5 where t1 <> '2021-05-05 18:19:01.000' and t1 <> '2021-05-05 18:19:08.000';
if $rows != 21 then
return -1
endi
sql select t1,ts,c1 from stb5 where t1 > '2021-05-05 18:19:02.000';
if $rows != 22 then
return -1
endi
sql select ts,c1,t9,t10 from stb5 where t9 match '1.+';
if $rows != 8 then
return -1
endi
if $data00 != @21-05-05 18:19:00.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:01.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:02.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:03.000@ then
return -1
endi
if $data40 != @21-05-05 18:19:04.000@ then
return -1
endi
if $data50 != @21-05-05 18:19:05.000@ then
return -1
endi
if $data60 != @21-05-05 18:19:06.000@ then
return -1
endi
if $data70 != @21-05-05 18:19:07.000@ then
return -1
endi
sql select ts,c1,t9,t10 from stb5 where t9 match '[3-9]';
if $rows != 22 then
return -1
endi
sql select ts,c1,t9,t10 from stb5 where t9 match '8.*';
if $rows != 5 then
return -1
endi
if $data00 != @21-05-05 18:19:34.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:35.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:36.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:37.000@ then
return -1
endi
if $data40 != @21-05-05 18:19:38.000@ then
return -1
endi
sql select ts,c1,t9,t10 from stb5 where t9 nmatch '^[12345]*\$';
if $rows != 10 then
return -1
endi
if $data00 != @21-05-05 18:19:24.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:25.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:26.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:27.000@ then
return -1
endi
if $data40 != @21-05-05 18:19:28.000@ then
return -1
endi
if $data50 != @21-05-05 18:19:34.000@ then
return -1
endi
if $data60 != @21-05-05 18:19:35.000@ then
return -1
endi
if $data70 != @21-05-05 18:19:36.000@ then
return -1
endi
if $data80 != @21-05-05 18:19:37.000@ then
return -1
endi
if $data90 != @21-05-05 18:19:38.000@ then
return -1
endi
print "join test"
sql_error select * from tb1, tb2_1 where tb1.ts=tb2_1.ts or tb1.ts =tb2_1.ts;
sql select tb1.ts from tb1, tb2_1 where tb1.ts=tb2_1.ts and tb1.ts > '2021-05-05 18:19:03.000' and tb2_1.ts < '2021-05-05 18:19:06.000';
if $rows != 2 then
return -1
endi
if $data00 != @21-05-05 18:19:04.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:05.000@ then
return -1
endi
sql select tb1.ts,tb1.*,tb2_1.* from tb1, tb2_1 where tb1.ts=tb2_1.ts and tb1.ts > '2021-05-05 18:19:03.000' and tb2_1.u1 < 5;
if $rows != 2 then
return -1
endi
if $data00 != @21-05-05 18:19:04.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:06.000@ then
return -1
endi
sql select tb1.ts,tb1.*,tb2_1.* from tb1, tb2_1 where tb1.ts=tb2_1.ts and tb1.ts >= '2021-05-05 18:19:03.000' and tb1.c7=false and tb2_1.u3>4;
if $rows != 2 then
return -1
endi
if $data00 != @21-05-05 18:19:03.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:07.000@ then
return -1
endi
sql select stb1.ts,stb1.c1,stb1.t1,stb2.ts,stb2.u1,stb2.t4 from stb1, stb2 where stb1.ts=stb2.ts and stb1.t1 = stb2.t4;
if $rows != 9 then
return -1
endi
if $data00 != @21-05-05 18:19:00.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:01.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:02.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:03.000@ then
return -1
endi
if $data40 != @21-05-05 18:19:04.000@ then
return -1
endi
if $data50 != @21-05-05 18:19:05.000@ then
return -1
endi
if $data60 != @21-05-05 18:19:06.000@ then
return -1
endi
if $data70 != @21-05-05 18:19:07.000@ then
return -1
endi
if $data80 != @21-05-05 18:19:11.000@ then
return -1
endi
sql select stb1.ts,stb1.c1,stb1.t1,stb2.ts,stb2.u1,stb2.t4 from stb1, stb2 where stb1.ts=stb2.ts and stb1.t1 = stb2.t4 and stb1.c1 > 2 and stb2.u1 <=4;
if $rows != 3 then
return -1
endi
if $data00 != @21-05-05 18:19:02.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:04.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:06.000@ then
return -1
endi
sql select stb1.ts,stb1.t1,stb1.c1,stb5.c2 from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts and (stb1.c1 between 20 and 50 and (stb5.c2 > 22 and stb5.c2 < 33));
if $rows != 4 then
return -1
endi
if $data00 != @21-05-05 18:19:10.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:11.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:12.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:13.000@ then
return -1
endi
sql select stb1.ts,stb1.t1,stb1.c1,stb5.c2 from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts;
if $rows != 29 then
return -1
endi
sql select stb1.c1,stb5.c1 from stb1, stb5 where stb1.t1=stb5.t2 and (stb1.c1 > 10 and stb5.c1 < 20) and stb1.ts=stb5.ts ;
if $rows != 4 then
return -1
endi
if $data00 != 11 then
return -1
endi
if $data10 != 12 then
return -1
endi
if $data20 != 13 then
return -1
endi
if $data30 != 14 then
return -1
endi
print "column&ts test"
sql_error select count(*) from stb1 where ts > 0 or c1 > 0;
sql select * from stb1 where ts > '2021-05-05 18:19:03.000' and ts < '2021-05-05 18:19:20.000' and (c1 > 23 or c1 < 14) and c7 in (true) and c8 like '%2';
if $rows != 3 then
return -1
endi
if $data00 != @21-05-05 18:19:05.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:13.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:17.000@ then
return -1
endi
print "column&tbname test"
sql_error select count(*) from stb1 where tbname like 'tb%' or c1 > 0;
sql select * from stb1 where tbname like '%3' and c6 < 34 and c5 != 33 and c4 > 31;
if $rows != 1 then
return -1
endi
if $data00 != @21-05-05 18:19:13.000@ then
return -1
endi
sql select ts,c1,tbname from stb5 where c1 > 30 and tbname > 'tb5_3' and tbname < 'tb5_8' and c1 < 72 and c1 between 44 and 54;
if $rows != 5 then
return -1
endi
if $data00 != @21-05-05 18:19:19.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:20.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:21.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:22.000@ then
return -1
endi
if $data40 != @21-05-05 18:19:23.000@ then
return -1
endi
sql select ts,c8,tbname from stb5 where (tbname like '%3' or tbname like '%4' or tbname = 'tb5_6') and tbname between 'tb5_2' and 'tb5_7' and (c8 like '3_' or c8 like '_4');
if $rows != 6 then
return -1
endi
if $data00 != @21-05-05 18:19:12.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:13.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:14.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:15.000@ then
return -1
endi
if $data40 != @21-05-05 18:19:19.000@ then
return -1
endi
if $data50 != @21-05-05 18:19:27.000@ then
return -1
endi
print "column&tag test"
sql_error select * from stb1 where t1 > 0 or c1 > 0
sql_error select * from stb1 where c1 > 0 or t1 > 0
sql_error select * from stb1 where t1 > 0 or c1 > 0 or t1 > 1
sql_error select * from stb1 where c1 > 0 or t1 > 0 or c1 > 1
sql_error select * from stb1 where t1 > 0 and c1 > 0 or t1 > 1
sql_error select * from stb1 where c1 > 0 or t1 > 0 and c1 > 1
sql_error select * from stb1 where c1 > 0 or t1 > 0 and c1 > 1
sql_error select * from stb1 where t1 > 0 or t1 > 0 and c1 > 1
sql_error select * from stb1 where (c1 > 0 and t1 > 0 ) or (t1 > 1 and c1 > 3)
sql_error select * from stb1 where (c1 > 0 and t1 > 0 ) or t1 > 1
sql_error select a.ts,b.ts,a.c1,b.u1,b.u2 from (select * from stb1) a, (select * from stb2) b where a.ts=b.ts and a.t1=b.t1;
sql select * from stb1 where c1 < 63 and t1 > 5
if $rows != 2 then
return -1
endi
if $data00 != @21-05-05 18:19:24.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:25.000@ then
return -1
endi
sql select * from stb1 where t1 > 3 and t1 < 5 and c1 != 42 and c1 != 44;
if $rows != 2 then
return -1
endi
if $data00 != @21-05-05 18:19:16.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:18.000@ then
return -1
endi
sql select * from stb1 where t1 > 1 and c1 > 21 and t1 < 3 and c1 < 24 and t1 != 3 and c1 != 23;
if $rows != 1 then
return -1
endi
if $data00 != @21-05-05 18:19:09.000@ then
return -1
endi
sql select * from stb1 where c1 > 1 and (t1 > 3 or t1 < 2) and (c2 > 2 and c2 < 62 and t1 != 4) and (t1 > 2 and t1 < 6) and c7 = true and c8 like '%2';
if $rows != 1 then
return -1
endi
if $data00 != @21-05-05 18:19:21.000@ then
return -1
endi
sql select * from stb1 where c1!=31 and c1 !=32 and c1 <> 63 and c1 <>1 and c1 <> 21 and c1 <> 2 and c7 <> true and c8 <> '3' and c9 <> '4' and c2<>13 and c3 <> 23 and c4 <> 33 and c5 <> 34 and c6 <> 43 and c2 <> 53 and t1 <> 5 and t2 <>4;
if $rows != 3 then
return -1
endi
if $data00 != @21-05-05 18:19:07.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:11.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:27.000@ then
return -1
endi
sql select ts,t1,c1,t2 from stb5 where t1 in ('2021-05-05 18:19:02.000','2021-05-05 18:19:04.000','2021-05-05 18:19:06.000','2021-05-05 18:19:08.000') and c1 is null and t2 is null;
if $rows != 1 then
return -1
endi
if $data00 != @21-05-05 18:19:38.000@ then
return -1
endi
sql select ts,t1,c1,t2 from stb5 where t1 in ('2021-05-05 18:19:02.000','2021-05-05 18:19:04.000','2021-05-05 18:19:06.000','2021-05-05 18:19:08.000') and t2 is not null and ts between '2021-05-05 18:19:10.000' and '2021-05-05 18:19:20.000' and t2 < 3;
if $rows != 2 then
return -1
endi
if $data00 != @21-05-05 18:19:10.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:11.000@ then
return -1
endi
sql select ts,t1,c1,t2,tbname,t8,t9 from stb5 where (((t8 != false or t8 is null) and (t9 like '%8' or t9 like '%6') and t2 is not null) or (t8 in (false) and t1 is null)) and (c1 is null or (c1 > 62 and c1 <= 72));
if $rows != 6 then
return -1
endi
if $data00 != @21-05-05 18:19:26.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:27.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:28.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:29.000@ then
return -1
endi
if $data40 != @21-05-05 18:19:30.000@ then
return -1
endi
if $data50 != @21-05-05 18:19:33.000@ then
return -1
endi
print "column&join test"
sql_error select tb1.ts,tb1.c1,tb2_1.u1 from tb1, tb2_1 where tb1.ts=tb2_1.ts or tb1.c1 > 0;
sql select stb5.ts,stb5.c1,stb5.t1,stb5.t8,stb5.t9,stb5.t10 from stb1,stb5 where stb1.ts=stb5.ts and stb1.t3=stb5.t7 and (stb5.c1 > 60 or stb5.c1 <= 11 or stb5.c1 is null);
if $rows != 10 then
return -1
endi
if $data00 != @21-05-05 18:19:00.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:01.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:02.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:03.000@ then
return -1
endi
if $data40 != @21-05-05 18:19:04.000@ then
return -1
endi
if $data50 != @21-05-05 18:19:24.000@ then
return -1
endi
if $data60 != @21-05-05 18:19:25.000@ then
return -1
endi
if $data70 != @21-05-05 18:19:26.000@ then
return -1
endi
if $data80 != @21-05-05 18:19:27.000@ then
return -1
endi
if $data90 != @21-05-05 18:19:28.000@ then
return -1
endi
sql select stb5.ts,stb5.c1,stb5.t1,stb5.t8,stb5.t9,stb5.t10 from stb1,stb5 where stb1.ts=stb5.ts and stb1.t3=stb5.t7 and (stb5.c1 > 60 or stb5.c1 <= 11 or stb5.c1 is null or stb5.c2 between 30 and 40) and (stb1.c9 like '%3' or stb1.c8 like '%4') and stb5.c9 like '%3%';
if $rows != 4 then
return -1
endi
if $data00 != @21-05-05 18:19:02.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:14.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:15.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:26.000@ then
return -1
endi
print "ts&tbname test"
sql_error select count(*) from stb1 where ts > 0 or tbname like 'tb%';
sql_error select tbname,ts,c1,tbname from stb5 where tbname like '%' and tbname between '' and 'tb5_3' and ts between '2021-05-05 18:19:05.000' and '2021-05-05 18:19:10.000' and ts <> '2021-05-05 18:19:07.000';
sql select tbname,ts,c1,tbname from stb5 where (tbname like '%5' or tbname like '%8') and ts between '2021-05-05 18:19:21.000' and '2021-05-05 18:19:35.000';
if $rows != 5 then
return -1
endi
if $data01 != @21-05-05 18:19:21.000@ then
return -1
endi
if $data11 != @21-05-05 18:19:22.000@ then
return -1
endi
if $data21 != @21-05-05 18:19:23.000@ then
return -1
endi
if $data31 != @21-05-05 18:19:34.000@ then
return -1
endi
if $data41 != @21-05-05 18:19:35.000@ then
return -1
endi
sql select tbname,ts,c1,tbname from stb5 where tbname like '%' and tbname between '' and 'tb5_3' and ts between '2021-05-05 18:19:10.000' and '2021-05-05 18:19:05.000';
if $rows != 0 then
return -1
endi
sql select tbname,ts,c1,tbname from stb5 where tbname like '%' and tbname between '' and 'tb5_3' and ts between '2021-05-05 18:19:05.000' and '2021-05-05 18:19:10.000' and ts <> '2021-05-05 18:19:05.000' and ts != '2021-05-05 18:19:10.000' order by ts desc;
if $rows != 4 then
return -1
endi
if $data01 != @21-05-05 18:19:09.000@ then
return -1
endi
if $data11 != @21-05-05 18:19:08.000@ then
return -1
endi
if $data21 != @21-05-05 18:19:07.000@ then
return -1
endi
if $data31 != @21-05-05 18:19:06.000@ then
return -1
endi
print "ts&tag test"
sql_error select count(*) from stb1 where ts > 0 or t1 > 0;
sql select * from stb2 where t1!=1 and t2=2 and t3 in ('2021-05-05 18:58:58.000') and ts < '2021-05-05 18:19:13.000';
if $rows != 2 then
return -1
endi
if $data00 != @21-05-05 18:19:11.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:12.000@ then
return -1
endi
sql select t1,ts,c1,t1,t2 from stb5 where (t1 > 1 or t1 is null or t2 is null) and (t1 in ('2021-05-05 18:19:02.000','2021-05-05 18:19:04.000') or t1 is null) and t2 >= 4 order by ts;
if $rows != 9 then
return -1
endi
if $data01 != @21-05-05 18:19:16.000@ then
return -1
endi
if $data11 != @21-05-05 18:19:17.000@ then
return -1
endi
if $data21 != @21-05-05 18:19:18.000@ then
return -1
endi
if $data31 != @21-05-05 18:19:19.000@ then
return -1
endi
if $data41 != @21-05-05 18:19:29.000@ then
return -1
endi
if $data51 != @21-05-05 18:19:30.000@ then
return -1
endi
if $data61 != @21-05-05 18:19:31.000@ then
return -1
endi
if $data71 != @21-05-05 18:19:32.000@ then
return -1
endi
if $data81 != @21-05-05 18:19:33.000@ then
return -1
endi
print "ts&join test"
sql_error select tb1.ts,tb1.c1,tb2_1.u1 from tb1, tb2_1 where tb1.ts=tb2_1.ts or tb1.ts > 0;
sql_error select stb1.tbname,stb5.tbname,stb1.ts,stb1.c1,stb1.t1 from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts and (stb1.ts = '2021-05-05 18:19:10.000' or stb1.ts = '2021-05-05 18:19:11.000');
sql select tb1.ts,tb1.c1,tb2_1.u1 from tb1, tb2_1 where tb1.ts=tb2_1.ts and (tb1.ts > '2021-05-05 18:19:05.000' or tb1.ts < '2021-05-05 18:19:03.000' or tb1.ts > 0) and tb1.ts between '0' and '2021-05-05 18:19:04.000' and tb2_1.ts < '2021-05-05 18:19:03.000';
if $rows != 3 then
return -1
endi
if $data00 != @21-05-05 18:19:00.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:01.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:02.000@ then
return -1
endi
sql select stb1.tbname,stb5.tbname,stb1.ts,stb1.c1,stb1.t1 from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts and (stb1.ts = '2021-05-05 18:19:10.000' or stb1.ts <= '2021-05-05 18:19:11.000') and stb5.ts > '2021-05-05 18:19:05.000' and stb5.ts != '2021-05-05 18:19:11.000';
if $rows != 5 then
return -1
endi
if $data02 != @21-05-05 18:19:06.000@ then
return -1
endi
if $data12 != @21-05-05 18:19:07.000@ then
return -1
endi
if $data22 != @21-05-05 18:19:08.000@ then
return -1
endi
if $data32 != @21-05-05 18:19:09.000@ then
return -1
endi
if $data42 != @21-05-05 18:19:10.000@ then
return -1
endi
print "tbname&tag test"
sql select * from stb1 where tbname like 'tb%' and (t1=1 or t2=2 or t3=3) and t1 > 2;
if $rows != 4 then
return -1
endi
if $data00 != @21-05-05 18:19:12.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:13.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:14.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:15.000@ then
return -1
endi
sql select ts,t1,c1,t2,tbname,t8,t9 from stb5 where tbname = 'tb5_1' or t1 = '2021-05-05 18:19:02.000';
if $rows != 12 then
return -1
endi
sql select ts,t1,c1,t2,tbname,t8,t9 from stb5 where t1 = '2021-05-05 18:19:02.000' or tbname = 'tb5_1';
if $rows != 12 then
return -1
endi
sql select t2,t1,t2,t3,t4,t8 from stb5 where t2 > 1 and t2 < 3 or t3 >= 1 and t3 <=1 or t8 in (false);
if $rows != 5 then
return -1
endi
sql select tbname,ts,c1,t1,t2,t3,t8 from stb5 where (t2 > 1 and t2 < 3 or t3 >= 1 and t3 <=1 or t8 in (false) or tbname like 'tb5_8' or tbname in ('tb5_5')) and tbname < 'tb5_3' and t3 > 1.0 and ts < '2021-05-05 18:19:10.000';
if $rows != 2 then
return -1
endi
print "tbname&join test"
sql select stb1.tbname,stb5.tbname,stb1.ts,stb1.c1,stb1.t1 from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts and stb1.tbname < 'tb4' and (stb5.tbname like 'tb5_3' or stb5.tbname = 'tb5_1') and stb5.tbname like '%____%_%';
if $rows != 12 then
return -1
endi
sql select stb1.tbname,stb5.tbname,stb1.ts,stb1.c1,stb1.t1 from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts and stb1.tbname < 'tb4' and (stb5.tbname like 'tb5_3' or stb5.tbname = 'tb5_1') and stb5.tbname like '%____%_%_';
if $rows != 0 then
return -1
endi
print "tag&join test"
sql select stb1.ts,stb1.c1,stb1.t1 from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts and stb1.t1 >= -1 and stb1.t1 < 100 and stb1.t1 in (1,2,3,5,6) and stb1.t1 <> 3 and stb1.t1 <= 5 and stb1.t1 >=2;
if $rows != 8 then
return -1
endi
if $data00 != @21-05-05 18:19:08.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:09.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:10.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:11.000@ then
return -1
endi
if $data40 != @21-05-05 18:19:20.000@ then
return -1
endi
if $data50 != @21-05-05 18:19:21.000@ then
return -1
endi
if $data60 != @21-05-05 18:19:22.000@ then
return -1
endi
if $data70 != @21-05-05 18:19:23.000@ then
return -1
endi
sql select stb1.ts,stb1.c1,stb5.t1,stb5.t6,stb5.t7,stb5.t8 from stb1,stb5 where stb1.ts=stb5.ts and stb1.t3=stb5.t7 and stb5.t1 >'2021-05-05 18:19:01.000';
if $rows != 21 then
return -1
endi
sql select stb1.ts,stb1.c1,stb1.t1,stb5.t3,stb5.t6,stb5.t7,stb5.t8,stb5.t9 from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts and stb5.t9 like '_%_______5555%55_';
if $rows != 0 then
return -1
endi
sql select stb1.ts,stb1.c1,stb1.t1,stb5.t3,stb5.t6,stb5.t7,stb5.t8,stb5.t9 from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts and stb5.t9 like '%_%__55%%%%55%55';
if $rows != 4 then
return -1
endi
if $data00 != @21-05-05 18:19:20.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:21.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:22.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:23.000@ then
return -1
endi
print "column&ts&tbname test"
sql_error select count(*) from stb1 where tbname like 'tb%' or c1 > 0 or ts > 0;
sql select * from stb5 where tbname > '' and (tbname like '%8') and tbname is null;
if $rows != 0 then
return -1
endi
sql select ts,c1,ts,c1,ts,c1,c8 from stb5 where tbname > '' and (tbname like '%8' or tbname like '%3') and tbname is not null and tbname in ('tb5_2','tb5_8') and tbname < 'aaaaaaaaaaa' and ts <= 1620209977000 and (c9 like '_3' or c9 <> '82');
if $rows != 3 then
return -1
endi
if $data00 != @21-05-05 18:19:34.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:36.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:37.000@ then
return -1
endi
print "column&ts&tag test"
sql_error select count(*) from stb1 where t1 > 0 or c1 > 0 or ts > 0;
sql_error select count(*) from stb1 where c1 > 0 or t1 > 0 or ts > 0;
sql select * from stb1 where (t1 > 0 or t1 > 2 ) and ts > '2021-05-05 18:19:10.000' and (c1 > 1 or c1 > 3) and (c6 > 40 or c6 < 30) and (c8 like '%3' or c8 like '_4') and (c9 like '1%' or c9 like '6%' or (c9 like '%3' and c9 != '23')) and ts > '2021-05-05 18:19:22.000' and ts <= '2021-05-05 18:19:26.000';
if $rows != 1 then
return -1
endi
if $data00 != @21-05-05 18:19:26.000@ then
return -1
endi
sql select * from stb1 where ts > '2021-05-05 18:19:00.000' and c1 > 2 and t1 != 1 and c2 >= 23 and t2 >= 3 and c3 < 63 and c7 = false and t3 > 3 and t3 < 6 and c8 like '4%' and ts < '2021-05-05 18:19:19.000' and c2 > 40 and c3 != 42;
if $rows != 1 then
return -1
endi
if $data00 != @21-05-05 18:19:18.000@ then
return -1
endi
print "column&ts&join test"
sql select stb1.ts,stb1.c1,stb1.t1 from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts and stb1.ts > '2021-05-05 18:19:09.000' and stb5.ts < '2021-05-05 18:19:25.000' and stb1.c9 like '%4';
if $rows != 4 then
return -1
endi
if $data00 != @21-05-05 18:19:11.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:15.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:19.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:23.000@ then
return -1
endi
print "column&tbname&tag test"
sql_error select count(*) from stb1 where c1 > 0 or tbname in ('tb1') or t1 > 0;
sql select * from stb5 where c1 > 10 and tbname in ('tb5_2','tb5_3','tb5_4') and t9 like '%4';
if $rows != 4 then
return -1
endi
if $data00 != @21-05-05 18:19:16.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:17.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:18.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:19.000@ then
return -1
endi
print "column&tbname&join test"
sql select stb1.ts,stb1.c1,stb5.c1,stb1.t1 from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts and (stb5.c1 > 10 or stb5.c1 is null) and stb5.tbname in ('tb5_2','tb5_3','tb5_6') and (stb5.c1 < 24 or stb5.c1 is null);
if $rows != 4 then
return -1
endi
if $data00 != @21-05-05 18:19:08.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:09.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:10.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:28.000@ then
return -1
endi
sql select stb1.ts,stb1.c1,stb5.c1,stb1.t1 from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts and (stb5.c1 > 10 or stb5.c1 is null) and stb5.tbname in ('tb5_2', 'tb5_3','tb5_6') and (stb5.c1 < 24 or stb5.c1 is null) and stb5.c1 is not null;
if $rows != 3 then
return -1
endi
if $data00 != @21-05-05 18:19:08.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:09.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:10.000@ then
return -1
endi
print "column&tag&join test"
sql select stb1.ts,stb1.c1,stb1.t1 from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts and stb1.t1 >= -1 and stb1.t1 < 100 and stb1.t1 in (1,2,3,5,6) and stb1.t1 <> 3 and stb1.t1 <= 5 and stb1.t1 >=2 and stb1.c1 >= 22 and stb1.c1 <= 53 and stb1.c1 in (23,24,50,54,21);
if $rows != 2 then
return -1
endi
if $data00 != @21-05-05 18:19:10.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:11.000@ then
return -1
endi
sql select stb1.ts,stb1.t3,stb1.tbname,stb1.c1,stb5.tbname from stb1,stb5 where stb1.ts=stb5.ts and stb1.t3=stb5.t7 and stb1.t2 > 1;
if $rows != 21 then
return -1
endi
sql select stb1.ts,stb1.t3,stb1.tbname,stb1.c1,stb5.t9,stb1.t2 from stb1,stb5 where stb1.ts=stb5.ts and stb1.t3=stb5.t7 and stb1.t2 between 2 and 5 and (stb5.t9 like '%2' or stb5.t9 like '%3') and stb1.ts < '2021-05-05 18:19:14.000' and stb5.ts > '2021-05-05 18:19:09.000';
if $rows != 4 then
return -1
endi
if $data00 != @21-05-05 18:19:10.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:11.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:12.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:13.000@ then
return -1
endi
print "ts&tbname&tag test"
sql_error select count(*) from stb1 where ts > 0 or tbname in ('tb1') or t1 > 0;
sql select tbname,ts,t1,t2 from stb5 where ts > 0 and ts between '2021-05-05 18:19:06.001' and '2021-05-05 18:19:30.000' and (tbname='tb5_6' or tbname in ('tb5_1')) and t1 > '2021-05-05 18:19:01.000';
if $rows != 5 then
return -1
endi
if $data01 != @21-05-05 18:19:24.000@ then
return -1
endi
if $data11 != @21-05-05 18:19:25.000@ then
return -1
endi
if $data21 != @21-05-05 18:19:26.000@ then
return -1
endi
if $data31 != @21-05-05 18:19:27.000@ then
return -1
endi
if $data41 != @21-05-05 18:19:28.000@ then
return -1
endi
print "ts&tbname&join test"
sql_error select stb1.ts,stb1.c1,stb5.c1,stb1.t1 from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts and stb5.tbname in ('tb5_2', 'tb5_3','tb5_6') and stb5.ts < 1111111111111111111111;
sql select stb1.ts,stb1.c1,stb5.c1,stb1.t1,stb1.tbname from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts and stb5.tbname in ('tb5_2', 'tb5_3','tb5_6') and stb5.ts < 11111111111111111 and (stb1.tbname like '%6' or stb1.tbname in ('tb2')) and stb1.ts between '2021-05-05 18:19:10.000' and '2021-05-05 18:19:26.000';
if $rows != 5 then
return -1
endi
if $data00 != @21-05-05 18:19:10.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:11.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:24.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:25.000@ then
return -1
endi
if $data40 != @21-05-05 18:19:26.000@ then
return -1
endi
print "ts&tag&join test"
sql select stb1.ts,stb1.c1,stb5.t1,stb5.t3,stb5.t6,stb5.t7,stb5.t8,stb5.t9 from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts and stb5.t1 > '2021-05-05 18:19:02.000' and stb5.t1 between '2021-05-05 18:19:05.000' and '2021-05-05 18:19:06.000' and stb5.ts between '2021-05-05 18:19:23.000' and '2021-05-05 18:19:25.000';
if $rows != 3 then
return -1
endi
if $data00 != @21-05-05 18:19:23.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:24.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:25.000@ then
return -1
endi
print "tbname&tag&join test"
sql select stb1.ts,stb1.c1,stb5.t1,stb5.t3,stb5.t6,stb5.t7,stb5.t8,stb5.t9 from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts and stb5.t1 > '2021-05-05 18:19:01.000' and stb5.t1 between '2021-05-05 18:19:00.000' and '2021-05-05 18:19:06.000' and (stb5.tbname like '%3' or stb5.tbname like '%2');
if $rows != 8 then
return -1
endi
if $data00 != @21-05-05 18:19:08.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:09.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:10.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:11.000@ then
return -1
endi
if $data40 != @21-05-05 18:19:12.000@ then
return -1
endi
if $data50 != @21-05-05 18:19:13.000@ then
return -1
endi
if $data60 != @21-05-05 18:19:14.000@ then
return -1
endi
if $data70 != @21-05-05 18:19:15.000@ then
return -1
endi
print "column&ts&tbname&tag test"
sql_error select * from stb1 where (tbname like 'tb%' or ts > '2021-05-05 18:19:01.000') and (t1 > 5 or t1 < 4) and c1 > 0;
sql_error select * from stb1 where (ts > '2021-05-05 18:19:01.000') and (ts > '2021-05-05 18:19:02.000' or t1 > 3) and (t1 > 5 or t1 < 4) and c1 > 0;
sql_error select ts,c1,c7 from stb1 where ts > '2021-05-05 18:19:03.000' or ts > '2021-05-05 18:19:20.000' and col > 0 and t1 > 0;
sql select t4,tbname,ts,c1 from stb5 where ((tbname like '%4') or t4 >= 6) and ts between '2021-05-05 18:19:20.000' and '2021-05-05 18:19:30.000' and (c1 is null or c1 >= 62 and c1 <= 71);
if $rows != 5 then
return -1
endi
if $data02 != @21-05-05 18:19:25.000@ then
return -1
endi
if $data12 != @21-05-05 18:19:26.000@ then
return -1
endi
if $data22 != @21-05-05 18:19:27.000@ then
return -1
endi
if $data32 != @21-05-05 18:19:28.000@ then
return -1
endi
if $data42 != @21-05-05 18:19:29.000@ then
return -1
endi
print "column&ts&tbname&join test"
sql select stb1.ts,stb1.c1,stb5.t1,stb5.t3,stb5.t6,stb5.t7,stb5.t8,stb5.t9 from stb1, stb5 where stb1.t1=stb5.t2 and stb1.ts=stb5.ts and stb5.t1 > '2021-05-05 18:19:01.000' and stb5.t1 between '2021-05-05 18:19:00.000' and '2021-05-05 18:19:06.000' and (stb5.tbname like '%3' or stb5.tbname like '%2') and stb1.ts between '2021-05-05 18:19:09.000' and '2021-05-05 18:19:14.000' and stb1.c1 > 23;
if $rows != 4 then
return -1
endi
if $data00 != @21-05-05 18:19:11.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:12.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:13.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:14.000@ then
return -1
endi
print "column&ts&tag&join test"
sql select stb1.ts,stb1.c1,stb5.t1,stb5.t6,stb5.t7,stb5.t8 from stb1,stb5 where stb1.ts=stb5.ts and stb1.t3=stb5.t7 and stb5.t8 = true and stb5.t7< 3.0000 and stb5.ts > '2021-05-05 18:19:02.000' and stb5.c1 between 10 and 22 and stb5.t1 >'2021-05-05 18:19:01.000';
if $rows != 2 then
return -1
endi
if $data00 != @21-05-05 18:19:08.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:09.000@ then
return -1
endi
print "column&tbname&tag&join test"
sql select stb1.ts,stb1.c1,stb5.t1,stb5.t6,stb5.t7,stb5.t8 from stb1,stb5 where stb1.ts=stb5.ts and stb1.t3=stb5.t7 and stb1.c1 > 11 and (stb5.tbname like '%3' or stb5.tbname like '%6' or stb5.tbname = 'tb5_4') and stb5.t7 > 4 and stb5.t8 <> 'false';
if $rows != 4 then
return -1
endi
if $data00 != @21-05-05 18:19:24.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:25.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:26.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:27.000@ then
return -1
endi
print "ts&tbname&tag&join test"
sql select stb1.ts,stb1.c1,stb5.t1,stb5.t6,stb5.t7,stb5.t8 from stb1,stb5 where stb1.ts=stb5.ts and stb1.t3=stb5.t7 and stb1.ts between '2021-05-05 18:19:15.000' and '2099-05-05 18:19:15.000' and stb5.tbname in ('tb5_3','tb5_5','tb5_6') and stb5.t1 >= '2021-05-05 18:19:03.000' and stb5.t1 <= '2021-05-05 18:19:08.000' and stb5.ts <='2021-05-05 18:19:25.000';
if $rows != 7 then
return -1
endi
if $data00 != @21-05-05 18:19:15.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:20.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:21.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:22.000@ then
return -1
endi
if $data40 != @21-05-05 18:19:23.000@ then
return -1
endi
if $data50 != @21-05-05 18:19:24.000@ then
return -1
endi
if $data60 != @21-05-05 18:19:25.000@ then
return -1
endi
print "column&ts&tbname&tag&join test"
sql select stb1.ts,stb1.c1,stb5.t1,stb5.t6,stb5.t7,stb5.t8 from stb1,stb5 where stb1.ts=stb5.ts and stb1.t3=stb5.t7 and stb1.ts between '2021-05-05 18:19:15.000' and '2099-05-05 18:19:15.000' and stb5.tbname in ('tb5_3','tb5_5','tb5_6') and stb5.t1 >= '2021-05-05 18:19:03.000' and stb5.t1 <= '2021-05-05 18:19:08.000' and stb5.ts <='2021-05-05 18:19:25.000' and stb1.c1 between 34 and 60;
if $rows != 5 then
return -1
endi
if $data00 != @21-05-05 18:19:15.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:20.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:21.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:22.000@ then
return -1
endi
if $data40 != @21-05-05 18:19:23.000@ then
return -1
endi
sql select stb1.ts,stb1.c1,stb5.t1,stb5.t6,stb5.t7,stb5.t8 from stb1,stb5 where stb1.ts=stb5.ts and stb1.t3=stb5.t7 and stb5.tbname<>'tb5_1' and stb5.t1 <> '2021-05-05 18:19:02.000' and stb1.ts > '2021-05-05 18:19:12.000' and stb5.c1 != 32 and stb5.t6 > 3 and stb5.t7 < 6 and stb5.t8 <> false;
if $rows != 4 then
return -1
endi
if $data00 != @21-05-05 18:19:20.000@ then
return -1
endi
if $data10 != @21-05-05 18:19:21.000@ then
return -1
endi
if $data20 != @21-05-05 18:19:22.000@ then
return -1
endi
if $data30 != @21-05-05 18:19:23.000@ then
return -1
endi
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
sql use cdb;
print "index tag test"
sql select tbname,t1 from stba;
if $rows != 10 then
return -1
endi
sql select tbname,t1 from stba where t1 > 2;
if $rows != 7 then
return -1
endi
sql select tbname,t1 from stba where t1 >= 4;
if $rows != 6 then
return -1
endi
sql select tbname,t1 from stba where t1 >= 3 and t1 <= 6;
if $rows != 4 then
return -1
endi
sql select tbname,t1 from stba where t1 = 3;
if $rows != 1 then
return -1
endi
sql select tbname,t1 from stba where t1 <> 6;
if $rows != 9 then
return -1
endi
sql select tbname,t1 from stba where t1 < 6;
if $rows != 6 then
return -1
endi
sql select tbname,t1 from stba where t1 < 6 and t1 >= 2;
if $rows != 4 then
return -1
endi
sql select tbname,t1 from stba where t1 is null;
if $rows != 0 then
return -1
endi
sql select tbname,t1 from stba where t1 is not null;
if $rows != 10 then
return -1
endi
sql_error select tbname,t1 from stbb where t1 > true;
sql select tbname,t1 from stbb where t1 = true;
if $rows != 5 then
return -1
endi
sql select tbname,t1 from stbb where t1 <> true;
if $rows != 5 then
return -1
endi
sql select tbname,t1 from stbb where t1 is null;
if $rows != 0 then
return -1
endi
sql select tbname,t1 from stbb where t1 is not null;
if $rows != 10 then
return -1
endi
sql select tbname,t1 from stbc;
if $rows != 10 then
return -1
endi
sql select tbname,t1 from stbc where t1 > 2;
if $rows != 7 then
return -1
endi
sql select tbname,t1 from stbc where t1 >= 4;
if $rows != 6 then
return -1
endi
sql select tbname,t1 from stbc where t1 >= 3 and t1 <= 6;
if $rows != 4 then
return -1
endi
sql select tbname,t1 from stbc where t1 = 3;
if $rows != 1 then
return -1
endi
sql select tbname,t1 from stbc where t1 <> 6;
if $rows != 9 then
return -1
endi
sql select tbname,t1 from stbc where t1 < 6;
if $rows != 6 then
return -1
endi
sql select tbname,t1 from stbc where t1 < 6 and t1 >= 2;
if $rows != 4 then
return -1
endi
sql select tbname,t1 from stbc where t1 is null;
if $rows != 0 then
return -1
endi
sql select tbname,t1 from stbc where t1 is not null;
if $rows != 10 then
return -1
endi
sql select tbname,t1 from stbd where t1 > '2222';
if $rows != 7 then
return -1
endi
sql select tbname,t1 from stbd where t1 >= '4444';
if $rows != 6 then
return -1
endi
sql select tbname,t1 from stbd where t1 >= '3333' and t1 <= '6666';
if $rows != 4 then
return -1
endi
sql select tbname,t1 from stbd where t1 = '3333';
if $rows != 1 then
return -1
endi
sql select tbname,t1 from stbd where t1 <> '6666';
if $rows != 9 then
return -1
endi
sql select tbname,t1 from stbd where t1 < '6666';
if $rows != 6 then
return -1
endi
sql select tbname,t1 from stbd where t1 < '6666' and t1 >= '2222';
if $rows != 4 then
return -1
endi
sql select tbname,t1 from stbd where t1 is null;
if $rows != 0 then
return -1
endi
sql select tbname,t1 from stbd where t1 is not null;
if $rows != 10 then
return -1
endi
sql select tbname,t1 from stbe where t1 > '2222';
if $rows != 7 then
return -1
endi
sql select tbname,t1 from stbe where t1 >= '4444';
if $rows != 6 then
return -1
endi
sql select tbname,t1 from stbe where t1 >= '3333' and t1 <= '6666';
if $rows != 4 then
return -1
endi
sql select tbname,t1 from stbe where t1 = '3333';
if $rows != 1 then
return -1
endi
sql select tbname,t1 from stbe where t1 <> '6666';
if $rows != 9 then
return -1
endi
sql select tbname,t1 from stbe where t1 < '6666';
if $rows != 6 then
return -1
endi
sql select tbname,t1 from stbe where t1 < '6666' and t1 >= '2222';
if $rows != 4 then
return -1
endi
sql select tbname,t1 from stbe where t1 is null;
if $rows != 0 then
return -1
endi
sql select tbname,t1 from stbe where t1 is not null;
if $rows != 10 then
return -1
endi
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
...@@ -125,11 +125,10 @@ if $data21 != 2 then ...@@ -125,11 +125,10 @@ if $data21 != 2 then
return -1 return -1
endi endi
# multiple tbname in is not allowed NOW sql select count(*) from $stb where tbname in ('ti_tb1', 'ti_tb300') and tbname in ('ti_tb5', 'ti_tb1000') group by t1 order by t1 asc
sql_error select count(*) from $stb where tbname in ('ti_tb1', 'ti_tb300') and tbname in ('ti_tb5', 'ti_tb1000') group by t1 order by t1 asc if $rows != 0 then
#if $rows != 4 then return -1
# return -1 endi
#endi
#if $data00 != $rowNum then #if $data00 != $rowNum then
# return -1 # return -1
#endi #endi
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册