未验证 提交 4607bd5c 编写于 作者: S shenglian-zhou 提交者: GitHub

Merge branch 'develop' into szhou/hotfix/td-12164

...@@ -191,7 +191,7 @@ bool serializeExprListToVariant(SArray* pList, tVariant **dst, int16_t colType, ...@@ -191,7 +191,7 @@ bool serializeExprListToVariant(SArray* pList, tVariant **dst, int16_t colType,
} }
if (colType == TSDB_DATA_TYPE_BOOL && (var->i64 > 1 ||var->i64 < 0)) { if (colType == TSDB_DATA_TYPE_BOOL && (var->i64 > 1 ||var->i64 < 0)) {
break; break;
} }
tbufWriteInt64(&bw, var->i64); tbufWriteInt64(&bw, var->i64);
} else if (IS_UNSIGNED_NUMERIC_TYPE(colType)) { } else if (IS_UNSIGNED_NUMERIC_TYPE(colType)) {
if (IS_SIGNED_NUMERIC_TYPE(var->nType) || IS_UNSIGNED_NUMERIC_TYPE(var->nType)) { if (IS_SIGNED_NUMERIC_TYPE(var->nType) || IS_UNSIGNED_NUMERIC_TYPE(var->nType)) {
...@@ -603,11 +603,11 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { ...@@ -603,11 +603,11 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
char buf[TSDB_TABLE_FNAME_LEN]; char buf[TSDB_TABLE_FNAME_LEN];
SStrToken sTblToken; SStrToken sTblToken;
sTblToken.z = buf; sTblToken.z = buf;
if (pInfo->type != TSDB_SQL_DROP_DNODE) { if (pInfo->type != TSDB_SQL_DROP_DNODE) {
if ((escapeEnabled && (validateTableName(pzName->z, pzName->n, &sTblToken, &dbIncluded) != TSDB_CODE_SUCCESS)) || if ((escapeEnabled && (validateTableName(pzName->z, pzName->n, &sTblToken, &dbIncluded) != TSDB_CODE_SUCCESS)) ||
((!escapeEnabled) && (tscValidateName(pzName, escapeEnabled, &dbIncluded) != TSDB_CODE_SUCCESS))){ ((!escapeEnabled) && (tscValidateName(pzName, escapeEnabled, &dbIncluded) != TSDB_CODE_SUCCESS))){
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2);
} }
} }
...@@ -623,7 +623,7 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { ...@@ -623,7 +623,7 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
code = tscSetTableFullName(&pTableMetaInfo->name, &sTblToken, pSql, dbIncluded); code = tscSetTableFullName(&pTableMetaInfo->name, &sTblToken, pSql, dbIncluded);
if(code != TSDB_CODE_SUCCESS) { if(code != TSDB_CODE_SUCCESS) {
return code; return code;
} }
} else if (pInfo->type == TSDB_SQL_DROP_DNODE) { } else if (pInfo->type == TSDB_SQL_DROP_DNODE) {
if (pzName->type == TK_STRING) { if (pzName->type == TK_STRING) {
...@@ -765,7 +765,7 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { ...@@ -765,7 +765,7 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
char buf[TSDB_TABLE_FNAME_LEN]; char buf[TSDB_TABLE_FNAME_LEN];
SStrToken sTblToken; SStrToken sTblToken;
sTblToken.z = buf; sTblToken.z = buf;
if (validateTableName(pToken->z, pToken->n, &sTblToken, &dbIncluded) != TSDB_CODE_SUCCESS) { if (validateTableName(pToken->z, pToken->n, &sTblToken, &dbIncluded) != TSDB_CODE_SUCCESS) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1);
} }
...@@ -788,7 +788,7 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { ...@@ -788,7 +788,7 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
char buf[TSDB_TABLE_FNAME_LEN]; char buf[TSDB_TABLE_FNAME_LEN];
SStrToken sTblToken; SStrToken sTblToken;
sTblToken.z = buf; sTblToken.z = buf;
if (validateTableName(pToken->z, pToken->n, &sTblToken, &dbIncluded) != TSDB_CODE_SUCCESS) { if (validateTableName(pToken->z, pToken->n, &sTblToken, &dbIncluded) != TSDB_CODE_SUCCESS) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1);
} }
...@@ -804,7 +804,7 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { ...@@ -804,7 +804,7 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
const char* msg1 = "invalid database name"; const char* msg1 = "invalid database name";
SStrToken* pToken = taosArrayGet(pInfo->pMiscInfo->a, 0); SStrToken* pToken = taosArrayGet(pInfo->pMiscInfo->a, 0);
if (tscValidateName(pToken, false, NULL) != TSDB_CODE_SUCCESS) { if (tscValidateName(pToken, false, NULL) != TSDB_CODE_SUCCESS) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1);
} }
...@@ -2175,16 +2175,16 @@ int32_t validateSelectNodeList(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SArray* pS ...@@ -2175,16 +2175,16 @@ int32_t validateSelectNodeList(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SArray* pS
pQueryInfo->colList = taosArrayInit(4, POINTER_BYTES); pQueryInfo->colList = taosArrayInit(4, POINTER_BYTES);
} }
bool hasDistinct = false; bool hasDistinct = false;
bool hasAgg = false; bool hasAgg = false;
size_t numOfExpr = taosArrayGetSize(pSelNodeList); size_t numOfExpr = taosArrayGetSize(pSelNodeList);
int32_t distIdx = -1; int32_t distIdx = -1;
for (int32_t i = 0; i < numOfExpr; ++i) { for (int32_t i = 0; i < numOfExpr; ++i) {
int32_t outputIndex = (int32_t)tscNumOfExprs(pQueryInfo); int32_t outputIndex = (int32_t)tscNumOfExprs(pQueryInfo);
tSqlExprItem* pItem = taosArrayGet(pSelNodeList, i); tSqlExprItem* pItem = taosArrayGet(pSelNodeList, i);
if (hasDistinct == false) { if (hasDistinct == false) {
hasDistinct = (pItem->distinct == true); hasDistinct = (pItem->distinct == true);
distIdx = hasDistinct ? i : -1; distIdx = hasDistinct ? i : -1;
} }
if(pItem->aliasName != NULL && validateColumnName(pItem->aliasName) != TSDB_CODE_SUCCESS){ if(pItem->aliasName != NULL && validateColumnName(pItem->aliasName) != TSDB_CODE_SUCCESS){
...@@ -2202,7 +2202,7 @@ int32_t validateSelectNodeList(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SArray* pS ...@@ -2202,7 +2202,7 @@ int32_t validateSelectNodeList(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SArray* pS
return code; return code;
} }
} else if (type == SQL_NODE_SQLFUNCTION) { } else if (type == SQL_NODE_SQLFUNCTION) {
hasAgg = true; hasAgg = true;
if (hasDistinct) break; if (hasDistinct) break;
pItem->pNode->functionId = isValidFunction(pItem->pNode->Expr.operand.z, pItem->pNode->Expr.operand.n); pItem->pNode->functionId = isValidFunction(pItem->pNode->Expr.operand.z, pItem->pNode->Expr.operand.n);
...@@ -2252,12 +2252,12 @@ int32_t validateSelectNodeList(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SArray* pS ...@@ -2252,12 +2252,12 @@ int32_t validateSelectNodeList(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SArray* pS
} }
} }
//TODO(dengyihao), refactor as function //TODO(dengyihao), refactor as function
//handle distinct func mixed with other func //handle distinct func mixed with other func
if (hasDistinct == true) { if (hasDistinct == true) {
if (distIdx != 0 || hasAgg) { if (distIdx != 0 || hasAgg) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4);
} }
if (joinQuery) { if (joinQuery) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg6); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg6);
} }
...@@ -2267,11 +2267,11 @@ int32_t validateSelectNodeList(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SArray* pS ...@@ -2267,11 +2267,11 @@ int32_t validateSelectNodeList(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SArray* pS
if (pQueryInfo->pDownstream != NULL) { if (pQueryInfo->pDownstream != NULL) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg8); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg8);
} }
pQueryInfo->distinct = true; pQueryInfo->distinct = true;
} }
// there is only one user-defined column in the final result field, add the timestamp column. // there is only one user-defined column in the final result field, add the timestamp column.
size_t numOfSrcCols = taosArrayGetSize(pQueryInfo->colList); size_t numOfSrcCols = taosArrayGetSize(pQueryInfo->colList);
if ((numOfSrcCols <= 0 || !hasNoneUserDefineExpr(pQueryInfo)) && !tscQueryTags(pQueryInfo) && !tscQueryBlockInfo(pQueryInfo)) { if ((numOfSrcCols <= 0 || !hasNoneUserDefineExpr(pQueryInfo)) && !tscQueryTags(pQueryInfo) && !tscQueryBlockInfo(pQueryInfo)) {
...@@ -2759,7 +2759,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col ...@@ -2759,7 +2759,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
if (pItem->pNode->Expr.paramList == NULL || if (pItem->pNode->Expr.paramList == NULL ||
(functionId != TSDB_FUNC_LEASTSQR && functionId != TSDB_FUNC_DERIVATIVE && functionId != TSDB_FUNC_ELAPSED && numOfParams != 1) || (functionId != TSDB_FUNC_LEASTSQR && functionId != TSDB_FUNC_DERIVATIVE && functionId != TSDB_FUNC_ELAPSED && numOfParams != 1) ||
((functionId == TSDB_FUNC_LEASTSQR || functionId == TSDB_FUNC_DERIVATIVE) && numOfParams != 3) || ((functionId == TSDB_FUNC_LEASTSQR || functionId == TSDB_FUNC_DERIVATIVE) && numOfParams != 3) ||
(functionId == TSDB_FUNC_ELAPSED && numOfParams > 2)) { (functionId == TSDB_FUNC_ELAPSED && numOfParams != 1 && numOfParams != 2)) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2);
} }
...@@ -4698,7 +4698,12 @@ static int32_t validateSQLExprItem(SSqlCmd* pCmd, tSqlExpr* pExpr, ...@@ -4698,7 +4698,12 @@ static int32_t validateSQLExprItem(SSqlCmd* pCmd, tSqlExpr* pExpr,
if (pExpr->value.nType == (uint32_t)-1) { if (pExpr->value.nType == (uint32_t)-1) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3);
} }
//now allowing now +/- value in select expr
if (pExpr->tokenId == TK_TIMESTAMP) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3);
}
if (pExpr->type == SQL_NODE_VALUE) { if (pExpr->type == SQL_NODE_VALUE) {
*type = SQLEXPR_TYPE_VALUE; *type = SQLEXPR_TYPE_VALUE;
} }
......
...@@ -3783,7 +3783,7 @@ void tscSetQuerySort(SQueryInfo* pQueryInfo, SQueryAttr* pQueryAttr) { ...@@ -3783,7 +3783,7 @@ void tscSetQuerySort(SQueryInfo* pQueryInfo, SQueryAttr* pQueryAttr) {
size_t size = taosArrayGetSize(pQueryInfo->pUpstream); size_t size = taosArrayGetSize(pQueryInfo->pUpstream);
for(int32_t i = 0; i < size; ++i) { for(int32_t i = 0; i < size; ++i) {
SQueryInfo* pq = taosArrayGetP(pQueryInfo->pUpstream, i); SQueryInfo* pq = taosArrayGetP(pQueryInfo->pUpstream, i);
if (pq->groupbyTag && pq->interval.interval > 0) { if (pq->groupbyTag) {
pQueryAttr->needSort = true; pQueryAttr->needSort = true;
return; return;
} }
......
...@@ -113,7 +113,7 @@ int32_t tscAcquireRpc(const char *key, const char *user, const char *secretEncry ...@@ -113,7 +113,7 @@ int32_t tscAcquireRpc(const char *key, const char *user, const char *secretEncry
SRpcObj rpcObj; SRpcObj rpcObj;
memset(&rpcObj, 0, sizeof(rpcObj)); memset(&rpcObj, 0, sizeof(rpcObj));
strncpy(rpcObj.key, key, strlen(key)); tstrncpy(rpcObj.key, key, sizeof(rpcObj.key));
rpcObj.pDnodeConn = rpcOpen(&rpcInit); rpcObj.pDnodeConn = rpcOpen(&rpcInit);
if (rpcObj.pDnodeConn == NULL) { if (rpcObj.pDnodeConn == NULL) {
pthread_mutex_unlock(&rpcObjMutex); pthread_mutex_unlock(&rpcObjMutex);
......
...@@ -4928,7 +4928,11 @@ int32_t createProjectionExpr(SQueryInfo* pQueryInfo, STableMetaInfo* pTableMetaI ...@@ -4928,7 +4928,11 @@ int32_t createProjectionExpr(SQueryInfo* pQueryInfo, STableMetaInfo* pTableMetaI
} }
} }
pse->colInfo.flag = pSource->base.colInfo.flag; //TSDB_COL_NORMAL; if (!pQueryInfo->stableQuery && TSDB_COL_IS_TAG(pSource->base.colInfo.flag)) {
pse->colInfo.flag = (pSource->base.colInfo.flag) & (~TSDB_COL_TAG);
} else {
pse->colInfo.flag = pSource->base.colInfo.flag;
}
pse->resType = pSource->base.resType; pse->resType = pSource->base.resType;
pse->resBytes = pSource->base.resBytes; pse->resBytes = pSource->base.resBytes;
strncpy(pse->colInfo.name, pSource->base.aliasName, tListLen(pse->colInfo.name)); strncpy(pse->colInfo.name, pSource->base.aliasName, tListLen(pse->colInfo.name));
......
Subproject commit 0b4a16e96b5cc9cb6e4f8cacf6a1f3028c91adb0 Subproject commit 7eae58a0fbf7c7321dd1bdc96e375d4c832cf373
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#define DOUBLE_MAX 1.79e+308 #define DOUBLE_MAX 1.79e+308
#define ADDITION_CENTROID_NUM 2 #define ADDITION_CENTROID_NUM 2
#define COMPRESSION 400 #define COMPRESSION 300
#define GET_CENTROID(compression) (ceil(compression * M_PI / 2) + 1 + ADDITION_CENTROID_NUM) #define GET_CENTROID(compression) (ceil(compression * M_PI / 2) + 1 + ADDITION_CENTROID_NUM)
#define GET_THRESHOLD(compression) (7.5 + 0.37 * compression - 2e-4 * pow(compression, 2)) #define GET_THRESHOLD(compression) (7.5 + 0.37 * compression - 2e-4 * pow(compression, 2))
#define TDIGEST_SIZE(compression) (sizeof(TDigest) + sizeof(SCentroid)*GET_CENTROID(compression) + sizeof(SPt)*GET_THRESHOLD(compression)) #define TDIGEST_SIZE(compression) (sizeof(TDigest) + sizeof(SCentroid)*GET_CENTROID(compression) + sizeof(SPt)*GET_THRESHOLD(compression))
......
...@@ -590,6 +590,7 @@ SArray* createExecOperatorPlan(SQueryAttr* pQueryAttr) { ...@@ -590,6 +590,7 @@ SArray* createExecOperatorPlan(SQueryAttr* pQueryAttr) {
} }
// outer query order by support // outer query order by support
int32_t orderColId = pQueryAttr->order.orderColId; int32_t orderColId = pQueryAttr->order.orderColId;
if (pQueryAttr->vgId == 0 && orderColId != INT32_MIN) { if (pQueryAttr->vgId == 0 && orderColId != INT32_MIN) {
op = OP_Order; op = OP_Order;
taosArrayPush(plan, &op); taosArrayPush(plan, &op);
......
...@@ -279,6 +279,7 @@ bool qTableQuery(qinfo_t qinfo, uint64_t *qId) { ...@@ -279,6 +279,7 @@ bool qTableQuery(qinfo_t qinfo, uint64_t *qId) {
if (isQueryKilled(pQInfo)) { if (isQueryKilled(pQInfo)) {
qDebug("QInfo:0x%"PRIx64" it is already killed, abort", pQInfo->qId); qDebug("QInfo:0x%"PRIx64" it is already killed, abort", pQInfo->qId);
setQueryKilled(pQInfo);
pQInfo->runtimeEnv.outputBuf = NULL; pQInfo->runtimeEnv.outputBuf = NULL;
return doBuildResCheck(pQInfo); return doBuildResCheck(pQInfo);
} }
......
...@@ -131,7 +131,7 @@ void taosCloseLog() { ...@@ -131,7 +131,7 @@ void taosCloseLog() {
taosStopLog(); taosStopLog();
//tsem_post(&(tsLogObj.logHandle->buffNotEmpty)); //tsem_post(&(tsLogObj.logHandle->buffNotEmpty));
taosMsleep(MAX_LOG_INTERVAL/1000); taosMsleep(MAX_LOG_INTERVAL/1000);
if (taosCheckPthreadValid(tsLogObj.logHandle->asyncThread)) { if (tsLogObj.logHandle && taosCheckPthreadValid(tsLogObj.logHandle->asyncThread)) {
pthread_join(tsLogObj.logHandle->asyncThread, NULL); pthread_join(tsLogObj.logHandle->asyncThread, NULL);
} }
// In case that other threads still use log resources causing invalid write in valgrind // In case that other threads still use log resources causing invalid write in valgrind
......
...@@ -361,7 +361,10 @@ namespace TDengineDriver ...@@ -361,7 +361,10 @@ namespace TDengineDriver
threadArr[i] = new Thread(createTableThread.ThreadMain); threadArr[i] = new Thread(createTableThread.ThreadMain);
threadArr[i].Start(); threadArr[i].Start();
threadArr[i].Join(); }
for (int j = 0; j < numOfThreads; j++)
{
threadArr[j].Join();
} }
} }
...@@ -482,7 +485,10 @@ namespace TDengineDriver ...@@ -482,7 +485,10 @@ namespace TDengineDriver
threadArr[i] = new Thread(insertThread.ThreadMain); threadArr[i] = new Thread(insertThread.ThreadMain);
threadArr[i].Start(); threadArr[i].Start();
threadArr[i].Join(); }
for (int j = 0; j < numOfThreads; j++)
{
threadArr[j].Join();
} }
} }
......
...@@ -88,7 +88,7 @@ ...@@ -88,7 +88,7 @@
<dependency> <dependency>
<groupId>org.apache.logging.log4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId> <artifactId>log4j-core</artifactId>
<version>2.15.0</version> <version>2.16.0</version>
</dependency> </dependency>
<!-- junit --> <!-- junit -->
<dependency> <dependency>
......
...@@ -320,6 +320,8 @@ class ElapsedCase: ...@@ -320,6 +320,8 @@ class ElapsedCase:
def selectIllegalTest(self): def selectIllegalTest(self):
tdSql.execute("use wxy_db") tdSql.execute("use wxy_db")
tdSql.error("select elapsed() from t1")
tdSql.error("select elapsed(,) from t1")
tdSql.error("select elapsed(1) from t1 where ts > '2021-11-22 00:00:00' and ts < '2021-11-23 00:00:00'") tdSql.error("select elapsed(1) from t1 where ts > '2021-11-22 00:00:00' and ts < '2021-11-23 00:00:00'")
tdSql.error("select elapsed('2021-11-18 00:00:10') from t1 where ts > '2021-11-22 00:00:00' and ts < '2021-11-23 00:00:00'") tdSql.error("select elapsed('2021-11-18 00:00:10') from t1 where ts > '2021-11-22 00:00:00' and ts < '2021-11-23 00:00:00'")
tdSql.error("select elapsed(now) from t1 where ts > '2021-11-22 00:00:00' and ts < '2021-11-23 00:00:00'") tdSql.error("select elapsed(now) from t1 where ts > '2021-11-22 00:00:00' and ts < '2021-11-23 00:00:00'")
......
...@@ -69,7 +69,7 @@ class TDTestCase: ...@@ -69,7 +69,7 @@ class TDTestCase:
os.system("rm /tmp/*.sql") os.system("rm /tmp/*.sql")
os.system( os.system(
"%staosdump --databases db -o /tmp -B 32766 -L 1048576" % "%staosdump --databases db -o /tmp -B 16384 -L 1048576" %
binPath) binPath)
tdSql.execute("drop database db") tdSql.execute("drop database db")
......
...@@ -137,7 +137,6 @@ class TDTestCase: ...@@ -137,7 +137,6 @@ class TDTestCase:
# verify ns # verify ns
os.system("%staosdump -o ./taosdumptest/tmp6 dp3 st0_0" % binPath) os.system("%staosdump -o ./taosdumptest/tmp6 dp3 st0_0" % binPath)
assert os.system("%staosdump -o ./taosdumptest/tmp6 dp3 st0_0 -C ns " % binPath) != 0
# verify -D:--database # verify -D:--database
os.system("%staosdump -o ./taosdumptest/tmp5 --databases dp1,dp2 " % binPath) os.system("%staosdump -o ./taosdumptest/tmp5 --databases dp1,dp2 " % binPath)
......
...@@ -660,6 +660,19 @@ sql select c2-c2 from $tb ...@@ -660,6 +660,19 @@ sql select c2-c2 from $tb
sql select first(c1)-last(c1), spread(c2), max(c3) - min(c3), avg(c4)*count(c4) from $tb sql select first(c1)-last(c1), spread(c2), max(c3) - min(c3), avg(c4)*count(c4) from $tb
# arithmetic operation with now [d.21]===============================================================
sql_error select now from $tb
sql_error select now + 123 from $tb
sql_error select 123 + now from $tb
sql_error select now - 123 from $tb
sql_error select 123 - now from $tb
sql_error select now * 123 from $tb
sql_error select 123 * now from $tb
sql_error select now / 123 from $tb
sql_error select 123 / now from $tb
sql_error select now % 123 from $tb
sql_error select 123 % now from $tb
sql_error select 12 * now / 12 + 12 - 12 * 12 from $tb
#====================================================super table query================================================== #====================================================super table query==================================================
...@@ -941,4 +941,207 @@ if $data02 != 0 then ...@@ -941,4 +941,207 @@ if $data02 != 0 then
return -1 return -1
endi endi
print ==========================================> TD-11097
sql create database td11097
sql use td11097
sql create table meters2 (ts timestamp, voltage bigint,num int) tags (location binary(30), groupid int);
sql create table D001 using meters2 tags ("Beijing.Chaoyang", 1);
sql create table D002 using meters2 tags ("Beijing.haidian", 2);
sql create table D003 using meters2 tags ('"Beijing.Tongzhou"', 3);
$ts = 1639556426000
sql insert into d001 values ( $ts ,1,2);
sql insert into d001 values ( $ts +1m,2,3);
sql insert into d001 values ( $ts +2m,4,3);
sql insert into d001 values ( $ts +4m,8,3);
sql insert into d002 values ( $ts ,4,3);
sql insert into d002 values ( $ts +3m,40,3);
sql insert into d002 values ( $ts +1m,46,3);
sql insert into d001 values ( $ts +20m,1,2);
sql insert into d002 values ( $ts +21m,4,3);
sql select diff(voltage) value from meters2 group by tbname;
sql select sum(value) from (select diff(voltage) value from meters2 group by tbname) interval(1m) ;
sql select sum(value) from (select diff(voltage) value from meters2 group by tbname) interval(1m) order by ts;
sql select sum(value) from (select diff(voltage) value from meters2 group by tbname) interval(1m) order by ts desc;
$emptyString = @@
print execute sql select diff(voltage) value from meters2 group by tbname;
sql select diff(voltage) value from meters2 group by tbname;
if $data00 != @21-12-15 16:21:26.000@ then
return -1
endi
if $data01 != @1@ then
return -1
endi
if $data02 != @d001@ then
return -1
endi
if $data10 != @21-12-15 16:22:26.000@ then
return -1
endi
if $data11 != @2@ then
return -1
endi
if $data12 != @d001@ then
return -1
endi
if $data20 != @21-12-15 16:24:26.000@ then
return -1
endi
if $data21 != @4@ then
return -1
endi
if $data22 != @d001@ then
return -1
endi
if $data30 != @21-12-15 16:40:26.000@ then
return -1
endi
if $data31 != @-7@ then
return -1
endi
if $data32 != @d001@ then
return -1
endi
if $data40 != @21-12-15 16:21:26.000@ then
return -1
endi
if $data41 != @42@ then
return -1
endi
if $data42 != @d002@ then
return -1
endi
if $data50 != @21-12-15 16:23:26.000@ then
return -1
endi
if $data51 != @-6@ then
return -1
endi
if $data52 != @d002@ then
return -1
endi
if $data60 != @21-12-15 16:41:26.000@ then
return -1
endi
if $data61 != @-36@ then
return -1
endi
if $data62 != @d002@ then
return -1
endi
print execute sql select sum(value) from (select diff(voltage) value from meters2 group by tbname) interval(1m) ;
sql select sum(value) from (select diff(voltage) value from meters2 group by tbname) interval(1m) ;
if $data00 != @21-12-15 16:21:00.000@ then
return -1
endi
if $data01 != @43@ then
return -1
endi
if $data10 != @21-12-15 16:22:00.000@ then
return -1
endi
if $data11 != @2@ then
return -1
endi
if $data20 != @21-12-15 16:23:00.000@ then
return -1
endi
if $data21 != @-6@ then
return -1
endi
if $data30 != @21-12-15 16:24:00.000@ then
return -1
endi
if $data31 != @4@ then
return -1
endi
if $data40 != @21-12-15 16:40:00.000@ then
return -1
endi
if $data41 != @-7@ then
return -1
endi
if $data50 != @21-12-15 16:41:00.000@ then
return -1
endi
if $data51 != @-36@ then
return -1
endi
print execute sql select sum(value) from (select diff(voltage) value from meters2 group by tbname) interval(1m) order by ts;
sql select sum(value) from (select diff(voltage) value from meters2 group by tbname) interval(1m) order by ts;
if $data00 != @21-12-15 16:21:00.000@ then
return -1
endi
if $data01 != @43@ then
return -1
endi
if $data10 != @21-12-15 16:22:00.000@ then
return -1
endi
if $data11 != @2@ then
return -1
endi
if $data20 != @21-12-15 16:23:00.000@ then
return -1
endi
if $data21 != @-6@ then
return -1
endi
if $data30 != @21-12-15 16:24:00.000@ then
return -1
endi
if $data31 != @4@ then
return -1
endi
if $data40 != @21-12-15 16:40:00.000@ then
return -1
endi
if $data41 != @-7@ then
return -1
endi
if $data50 != @21-12-15 16:41:00.000@ then
return -1
endi
if $data51 != @-36@ then
return -1
endi
print execute sql select sum(value) from (select diff(voltage) value from meters2 group by tbname) interval(1m) order by ts desc;
sql select sum(value) from (select diff(voltage) value from meters2 group by tbname) interval(1m) order by ts desc;
if $data00 != @21-12-15 16:41:00.000@ then
return -1
endi
if $data01 != @-36@ then
return -1
endi
if $data10 != @21-12-15 16:40:00.000@ then
return -1
endi
if $data11 != @-7@ then
return -1
endi
if $data20 != @21-12-15 16:24:00.000@ then
return -1
endi
if $data21 != @4@ then
return -1
endi
if $data30 != @21-12-15 16:23:00.000@ then
return -1
endi
if $data31 != @-6@ then
return -1
endi
if $data40 != @21-12-15 16:22:00.000@ then
return -1
endi
if $data41 != @2@ then
return -1
endi
if $data50 != @21-12-15 16:21:00.000@ then
return -1
endi
if $data51 != @43@ then
return -1
endi
sql drop database td11097
system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s stop -x SIGINT
...@@ -956,4 +956,39 @@ sql_error select first(c1), count(*), t2, t1, tbname from select_tags_mt0 group ...@@ -956,4 +956,39 @@ sql_error select first(c1), count(*), t2, t1, tbname from select_tags_mt0 group
#sql select count(c1) from select_tags_mt0 where c1=99 group by tbname; #sql select count(c1) from select_tags_mt0 where c1=99 group by tbname;
#sql select count(*),tbname from select_tags_mt0 group by tbname #sql select count(*),tbname from select_tags_mt0 group by tbname
print ==================================> TD-11943
sql create database test11943;
sql use test11943;
sql create stable st (ts timestamp , id int ) tags (ind int );
sql insert into sub1 using st tags(1) values(now ,1);
sql insert into sub1 using st tags(1) values(now ,2);
sql insert into sub2 using st tags(2) values(now ,3);
sql insert into sub2 using st tags(2) values(now ,4);
sql select tbname ,max(id)+5 from sub1;
if $data00 != @sub1@ then
return -1
endi
if $data01 != @7.000000000@ then
return -1
endi
sql select ind, max(id)+5 from st group by tbname
if $data00 != @1@ then
return -1
endi
if $data01 != @7.000000000@ then
return -1
endi
if $data02 != @sub1@ then
return -1
endi
if $data10 != @2@ then
return -1
endi
if $data11 != @9.000000000@ then
return -1
endi
if $data12 != @sub2@ then
return -1
endi
sql drop database test11943
system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s stop -x SIGINT
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册