“dbdb93383c8e79f8ab3a1d7111fb5decf3dd06bd”上不存在“source/dnode/vnode/tsdb/src/tsdbIdx.c”
提交 6be57f76 编写于 作者: P plum-lihui

Merge branch '3.0' into test3.0/lihui

......@@ -21,6 +21,7 @@ extern "C" {
#endif
#include "os.h"
#include "taoserror.h"
typedef enum {
TSDB_GRANT_ALL,
......
......@@ -26,7 +26,7 @@ extern "C" {
extern bool gRaftDetailLog;
#define SYNC_RESP_TTL_MS 10000
#define SYNC_RESP_TTL_MS 10000000
#define SYNC_MAX_BATCH_SIZE 500
#define SYNC_INDEX_BEGIN 0
......
......@@ -135,6 +135,7 @@ typedef struct {
int64_t curVersion;
int64_t capacity;
int8_t curInvalid;
int8_t curStopped;
TdThreadMutex mutex;
SWalFilterCond cond;
SWalCkHead *pHead;
......
此差异已折叠。
......@@ -1750,7 +1750,10 @@ int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32
char* pStart = p;
for (int32_t i = 0; i < numOfCols; ++i) {
colLength[i] = htonl(colLength[i]);
ASSERT(colLength[i] < dataLen);
if (colLength[i] >= dataLen) {
tscError("invalid colLength %d, dataLen %d", colLength[i], dataLen);
ASSERT(0);
}
if (IS_VAR_DATA_TYPE(pResultInfo->fields[i].type)) {
pResultInfo->pCol[i].offset = (int32_t*)pStart;
......
......@@ -499,7 +499,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
code = catalogGetSTableMeta(info->pCatalog, &conn, &pName, &pTableMeta);
if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST || code == TSDB_CODE_MND_INVALID_STB) {
if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST || code == TSDB_CODE_MND_STB_NOT_EXIST) {
SSchemaAction schemaAction;
schemaAction.action = SCHEMA_ACTION_CREATE_STABLE;
memset(&schemaAction.createSTable, 0, sizeof(SCreateSTableActionInfo));
......
......@@ -158,7 +158,7 @@ static const SSysDbTableSchema userTagsSchema[] = {
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
{.name = "stable_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR},
{.name = "tag_name", .bytes = TSDB_COL_NAME_LEN - 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
{.name = "tag_type", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT},
{.name = "tag_type", .bytes = 32 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
{.name = "tag_value", .bytes = TSDB_MAX_TAGS_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR},
};
......
......@@ -213,10 +213,6 @@ static int32_t taosSetTfsCfg(SConfig *pCfg) {
memcpy(&tsDiskCfg[index], pCfg, sizeof(SDiskCfg));
if (pCfg->level == 0 && pCfg->primary == 1) {
tstrncpy(tsDataDir, pCfg->dir, PATH_MAX);
if (taosMulMkDir(tsDataDir) != 0) {
uError("failed to create dataDir:%s since %s", tsDataDir, terrstr());
return -1;
}
}
if (taosMulMkDir(pCfg->dir) != 0) {
uError("failed to create tfsDir:%s since %s", tsDataDir, terrstr());
......@@ -227,12 +223,13 @@ static int32_t taosSetTfsCfg(SConfig *pCfg) {
if (tsDataDir[0] == 0) {
if (pItem->str != NULL) {
taosAddDataDir(0, pItem->str, 0, 1);
taosAddDataDir(tsDiskCfgNum, pItem->str, 0, 1);
tstrncpy(tsDataDir, pItem->str, PATH_MAX);
if (taosMulMkDir(tsDataDir) != 0) {
uError("failed to create dataDir:%s since %s", tsDataDir, terrstr());
uError("failed to create tfsDir:%s since %s", tsDataDir, terrstr());
return -1;
}
tsDiskCfgNum++;
} else {
uError("datadir not set");
return -1;
......
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "tgrant.h"
#ifndef _GRANT
int32_t grantCheck(EGrantType grant) { return TSDB_CODE_SUCCESS; }
#endif
\ No newline at end of file
......@@ -190,6 +190,10 @@ static int32_t mndCreateFunc(SMnode *pMnode, SRpcMsg *pReq, SCreateFuncReq *pCre
int32_t code = -1;
STrans *pTrans = NULL;
if ((terrno = grantCheck(TSDB_GRANT_USER)) < 0) {
return code;
}
SFuncObj func = {0};
memcpy(func.name, pCreate->name, TSDB_FUNC_NAME_LEN);
func.createdTime = taosGetTimestampMs();
......
......@@ -128,7 +128,6 @@ int32_t mndInitGrant(SMnode *pMnode) {
void mndCleanupGrant() {}
void grantParseParameter() { mError("can't parsed parameter k"); }
int32_t grantCheck(EGrantType grant) { return TSDB_CODE_SUCCESS; }
void grantReset(SMnode *pMnode, EGrantType grant, uint64_t value) {}
void grantAdd(EGrantType grant, uint64_t value) {}
void grantRestore(EGrantType grant, uint64_t value) {}
......
......@@ -66,7 +66,7 @@ static int32_t mndInsInitMeta(SHashObj *hash) {
int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char *tbName, STableMetaRsp *pRsp) {
if (NULL == pMnode->infosMeta) {
terrno = TSDB_CODE_MND_NOT_READY;
terrno = TSDB_CODE_APP_NOT_READY;
return -1;
}
......@@ -92,7 +92,7 @@ int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char *
int32_t mndBuildInsTableCfg(SMnode *pMnode, const char *dbFName, const char *tbName, STableCfgRsp *pRsp) {
if (NULL == pMnode->infosMeta) {
terrno = TSDB_CODE_MND_NOT_READY;
terrno = TSDB_CODE_APP_NOT_READY;
return -1;
}
......
......@@ -68,7 +68,7 @@ int32_t mndPerfsInitMeta(SHashObj *hash) {
int32_t mndBuildPerfsTableSchema(SMnode *pMnode, const char *dbFName, const char *tbName, STableMetaRsp *pRsp) {
if (NULL == pMnode->perfsMeta) {
terrno = TSDB_CODE_MND_NOT_READY;
terrno = TSDB_CODE_APP_NOT_READY;
return -1;
}
......@@ -94,7 +94,7 @@ int32_t mndBuildPerfsTableSchema(SMnode *pMnode, const char *dbFName, const char
int32_t mndBuildPerfsTableCfg(SMnode *pMnode, const char *dbFName, const char *tbName, STableCfgRsp *pRsp) {
if (NULL == pMnode->perfsMeta) {
terrno = TSDB_CODE_MND_NOT_READY;
terrno = TSDB_CODE_APP_NOT_READY;
return -1;
}
......
......@@ -138,6 +138,14 @@ int32_t tqSendDataRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, con
ASSERT(taosArrayGetSize(pRsp->blockSchema) == 0);
}
if (pRsp->reqOffset.type == TMQ_OFFSET__LOG) {
if (pRsp->blockNum > 0) {
ASSERT(pRsp->rspOffset.version > pRsp->reqOffset.version);
} else {
ASSERT(pRsp->rspOffset.version >= pRsp->reqOffset.version);
}
}
int32_t len;
int32_t code;
tEncodeSize(tEncodeSMqDataRsp, pRsp, len, code);
......
......@@ -65,12 +65,14 @@ int64_t tqScan(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVa
qTaskInfo_t task = pExec->execCol.task;
if (qStreamPrepareScan(task, pOffset) < 0) {
tqDebug("prepare scan failed, return");
if (pOffset->type == TMQ_OFFSET__LOG) {
pRsp->rspOffset = *pOffset;
return 0;
} else {
tqOffsetResetToLog(pOffset, pHandle->snapshotVer);
if (qStreamPrepareScan(task, pOffset) < 0) {
tqDebug("prepare scan failed, return");
pRsp->rspOffset = *pOffset;
return 0;
}
......@@ -126,9 +128,16 @@ int64_t tqScan(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVa
ASSERT(pRsp->rspOffset.type != 0);
#if 0
if (pRsp->reqOffset.type == TMQ_OFFSET__LOG) {
ASSERT(pRsp->rspOffset.version + 1 >= pRsp->reqOffset.version);
if (pRsp->blockNum > 0) {
ASSERT(pRsp->rspOffset.version > pRsp->reqOffset.version);
} else {
ASSERT(pRsp->rspOffset.version >= pRsp->reqOffset.version);
}
}
#endif
tqDebug("task exec exited");
break;
}
......
......@@ -43,16 +43,12 @@ static int32_t tDecodeSTqHandle(SDecoder* pDecoder, STqHandle* pHandle) {
return 0;
}
int tqExecKeyCompare(const void* pKey1, int32_t kLen1, const void* pKey2, int32_t kLen2) {
return strcmp(pKey1, pKey2);
}
int32_t tqMetaOpen(STQ* pTq) {
if (tdbOpen(pTq->path, 16 * 1024, 1, &pTq->pMetaStore) < 0) {
ASSERT(0);
}
if (tdbTbOpen("handles", -1, -1, tqExecKeyCompare, pTq->pMetaStore, &pTq->pExecStore) < 0) {
if (tdbTbOpen("handles", -1, -1, 0, pTq->pMetaStore, &pTq->pExecStore) < 0) {
ASSERT(0);
}
......@@ -101,7 +97,7 @@ int32_t tqMetaOpen(STQ* pTq) {
handle.execHandle.execDb.pFilterOutTbUid =
taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
}
tqDebug("tq restore %s consumer %ld", handle.subKey, handle.consumerId);
tqDebug("tq restore %s consumer %ld vgId:%d", handle.subKey, handle.consumerId, TD_VID(pTq->pVnode));
taosHashPut(pTq->handles, pKey, kLen, &handle, sizeof(STqHandle));
}
......@@ -126,6 +122,9 @@ int32_t tqMetaSaveHandle(STQ* pTq, const char* key, const STqHandle* pHandle) {
tEncodeSize(tEncodeSTqHandle, pHandle, vlen, code);
ASSERT(code == 0);
tqDebug("tq save %s(%d) consumer %ld vgId:%d", pHandle->subKey, strlen(pHandle->subKey), pHandle->consumerId,
TD_VID(pTq->pVnode));
void* buf = taosMemoryCalloc(1, vlen);
if (buf == NULL) {
ASSERT(0);
......
......@@ -132,10 +132,12 @@ int32_t tqNextBlock(STqReader* pReader, SFetchRet* ret) {
while (1) {
if (!fromProcessedMsg) {
if (walNextValidMsg(pReader->pWalReader) < 0) {
pReader->ver = pReader->pWalReader->curVersion - pReader->pWalReader->curInvalid;
pReader->ver =
pReader->pWalReader->curVersion - (pReader->pWalReader->curInvalid | pReader->pWalReader->curStopped);
ret->offset.type = TMQ_OFFSET__LOG;
ret->offset.version = pReader->ver;
ret->fetchType = FETCH_TYPE__NONE;
tqDebug("return offset %ld, no more valid", ret->offset.version);
ASSERT(ret->offset.version >= 0);
return -1;
}
......@@ -167,6 +169,7 @@ int32_t tqNextBlock(STqReader* pReader, SFetchRet* ret) {
ret->offset.version = pReader->ver;
ASSERT(pReader->ver >= 0);
ret->fetchType = FETCH_TYPE__NONE;
tqDebug("return offset %ld, processed finish", ret->offset.version);
return 0;
}
}
......
......@@ -477,6 +477,11 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pR
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
pCreateReq = req.pReqs + iReq;
if ((terrno = grantCheck(TSDB_GRANT_TIMESERIES)) < 0) {
rcode = -1;
goto _exit;
}
// validate hash
sprintf(tbName, "%s.%s", pVnode->config.dbname, pCreateReq->name);
if (vnodeValidateTableHash(pVnode, tbName) < 0) {
......@@ -821,6 +826,13 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq
goto _exit;
}
if ((terrno = grantCheck(TSDB_GRANT_TIMESERIES)) < 0) {
pRsp->code = terrno;
tDecoderClear(&decoder);
taosArrayDestroy(createTbReq.ctb.tagName);
goto _exit;
}
if (metaCreateTable(pVnode->pMeta, version, &createTbReq) < 0) {
if (terrno != TSDB_CODE_TDB_TABLE_ALREADY_EXIST) {
submitBlkRsp.code = terrno;
......
......@@ -1005,7 +1005,7 @@ static int32_t generateIntervalScanRange(SStreamScanInfo* pInfo, SSDataBlock* pS
SColumnInfoData* pCalStartTsCol = taosArrayGet(pDestBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX);
SColumnInfoData* pCalEndTsCol = taosArrayGet(pDestBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX);
uint64_t groupId = getGroupId(pInfo->pTableScanOp, uidCol[0]);
for (int32_t i = 0; i < rows; ) {
for (int32_t i = 0; i < rows;) {
colDataAppend(pCalStartTsCol, pDestBlock->info.rows, (const char*)(tsCol + i), false);
STimeWindow win = getSlidingWindow(tsCol, &pInfo->interval, &pSrcBlock->info, &i);
colDataAppend(pCalEndTsCol, pDestBlock->info.rows, (const char*)(tsCol + i - 1), false);
......@@ -1169,8 +1169,11 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
return NULL;
} else if (ret.fetchType == FETCH_TYPE__NONE) {
pTaskInfo->streamInfo.lastStatus = ret.offset;
ASSERT(pTaskInfo->streamInfo.lastStatus.version + 1 >= pTaskInfo->streamInfo.prepareStatus.version);
qDebug("stream scan log return null");
ASSERT(pTaskInfo->streamInfo.lastStatus.version >= pTaskInfo->streamInfo.prepareStatus.version);
ASSERT(pTaskInfo->streamInfo.lastStatus.version + 1 == pInfo->tqReader->pWalReader->curVersion);
char formatBuf[80];
tFormatOffset(formatBuf, 80, &ret.offset);
qDebug("stream scan log return null, offset %s", formatBuf);
return NULL;
} else {
ASSERT(0);
......@@ -1674,6 +1677,87 @@ static SSDataBlock* buildInfoSchemaTableMetaBlock(char* tableName) {
return pBlock;
}
int32_t convertTagDataToStr(char* str, int type, void* buf, int32_t bufSize, int32_t* len) {
int32_t n = 0;
switch (type) {
case TSDB_DATA_TYPE_NULL:
n = sprintf(str, "null");
break;
case TSDB_DATA_TYPE_BOOL:
n = sprintf(str, (*(int8_t*)buf) ? "true" : "false");
break;
case TSDB_DATA_TYPE_TINYINT:
n = sprintf(str, "%d", *(int8_t*)buf);
break;
case TSDB_DATA_TYPE_SMALLINT:
n = sprintf(str, "%d", *(int16_t*)buf);
break;
case TSDB_DATA_TYPE_INT:
n = sprintf(str, "%d", *(int32_t*)buf);
break;
case TSDB_DATA_TYPE_BIGINT:
case TSDB_DATA_TYPE_TIMESTAMP:
n = sprintf(str, "%" PRId64, *(int64_t*)buf);
break;
case TSDB_DATA_TYPE_FLOAT:
n = sprintf(str, "%.5f", GET_FLOAT_VAL(buf));
break;
case TSDB_DATA_TYPE_DOUBLE:
n = sprintf(str, "%.9f", GET_DOUBLE_VAL(buf));
break;
case TSDB_DATA_TYPE_BINARY:
if (bufSize < 0) {
return TSDB_CODE_TSC_INVALID_VALUE;
}
memcpy(str, buf, bufSize);
n = bufSize;
break;
case TSDB_DATA_TYPE_NCHAR:
if (bufSize < 0) {
return TSDB_CODE_TSC_INVALID_VALUE;
}
int32_t length = taosUcs4ToMbs((TdUcs4*)buf, bufSize, str);
if (length <= 0) {
return TSDB_CODE_TSC_INVALID_VALUE;
}
n = length;
break;
case TSDB_DATA_TYPE_UTINYINT:
n = sprintf(str, "%u", *(uint8_t*)buf);
break;
case TSDB_DATA_TYPE_USMALLINT:
n = sprintf(str, "%u", *(uint16_t*)buf);
break;
case TSDB_DATA_TYPE_UINT:
n = sprintf(str, "%u", *(uint32_t*)buf);
break;
case TSDB_DATA_TYPE_UBIGINT:
n = sprintf(str, "%" PRIu64, *(uint64_t*)buf);
break;
default:
return TSDB_CODE_TSC_INVALID_VALUE;
}
if (len) *len = n;
return TSDB_CODE_SUCCESS;
}
static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) {
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
SSysTableScanInfo* pInfo = pOperator->info;
......@@ -1744,14 +1828,24 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) {
pColInfoData = taosArrayGet(p->pDataBlock, 2);
colDataAppend(pColInfoData, numOfRows, stableName, false);
// tag name
char tagName[TSDB_COL_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
STR_TO_VARSTR(tagName, smr.me.stbEntry.schemaTag.pSchema[i].name);
pColInfoData = taosArrayGet(p->pDataBlock, 3);
colDataAppend(pColInfoData, numOfRows, tagName, false);
// tag type
int8_t tagType = smr.me.stbEntry.schemaTag.pSchema[i].type;
pColInfoData = taosArrayGet(p->pDataBlock, 4);
colDataAppend(pColInfoData, numOfRows, (char*)&tagType, false);
char tagTypeStr[VARSTR_HEADER_SIZE + 32];
int tagTypeLen = sprintf(varDataVal(tagTypeStr), "%s", tDataTypes[tagType].name);
if (tagType == TSDB_DATA_TYPE_VARCHAR) {
tagTypeLen += sprintf(varDataVal(tagTypeStr) + tagTypeLen, "(%d)", (int32_t)(smr.me.stbEntry.schemaTag.pSchema[i].bytes - VARSTR_HEADER_SIZE));
} else if (tagType == TSDB_DATA_TYPE_NCHAR) {
tagTypeLen += sprintf(varDataVal(tagTypeStr) + tagTypeLen, "(%d)", (int32_t)((smr.me.stbEntry.schemaTag.pSchema[i].bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE));
}
varDataSetLen(tagTypeStr, tagTypeLen);
colDataAppend(pColInfoData, numOfRows, (char*)tagTypeStr, false);
STagVal tagVal = {0};
tagVal.cid = smr.me.stbEntry.schemaTag.pSchema[i].colId;
......@@ -1786,7 +1880,7 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) {
: (3 + DBL_MANT_DIG - DBL_MIN_EXP + VARSTR_HEADER_SIZE);
tagVarChar = taosMemoryMalloc(bufSize);
int32_t len = -1;
dataConverToStr(varDataVal(tagVarChar), tagType, tagData, tagLen, &len);
convertTagDataToStr(varDataVal(tagVarChar), tagType, tagData, tagLen, &len);
varDataSetLen(tagVarChar, len);
}
}
......
......@@ -1607,6 +1607,28 @@ static bool eliminateProjOptCanUseNewChildTargets(SLogicNode* pChild, SNodeList*
return cxt.canUse;
}
static void alignProjectionWithTarget(SLogicNode* pNode) {
if (QUERY_NODE_LOGIC_PLAN_PROJECT != pNode->type) {
return;
}
SProjectLogicNode* pProjectNode = (SProjectLogicNode*)pNode;
SNode* pProjection = NULL;
FOREACH(pProjection, pProjectNode->pProjections) {
SNode* pTarget = NULL;
bool keep = false;
FOREACH(pTarget, pNode->pTargets) {
if (0 == strcmp(((SColumnNode*)pProjection)->node.aliasName, ((SColumnNode*)pTarget)->colName)) {
keep = true;
break;
}
}
if (!keep) {
nodesListErase(pProjectNode->pProjections, cell);
}
}
}
static int32_t eliminateProjOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan,
SProjectLogicNode* pProjectNode) {
SLogicNode* pChild = (SLogicNode*)nodesListGetNode(pProjectNode->node.pChildren, 0);
......@@ -1634,6 +1656,7 @@ static int32_t eliminateProjOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan*
if (TSDB_CODE_SUCCESS == code) {
NODES_CLEAR_LIST(pProjectNode->node.pChildren);
nodesDestroyNode((SNode*)pProjectNode);
alignProjectionWithTarget(pChild);
}
pCxt->optimized = true;
return code;
......
......@@ -231,7 +231,6 @@ int32_t qwBuildAndSendCQueryMsg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn) {
int32_t code = tmsgPutToQueue(&mgmt->msgCb, QUERY_QUEUE, &pNewMsg);
if (TSDB_CODE_SUCCESS != code) {
QW_SCH_TASK_ELOG("put query continue msg to queue failed, vgId:%d, code:%s", mgmt->nodeId, tstrerror(code));
rpcFreeCont(req);
QW_ERR_RET(code);
}
......
......@@ -735,15 +735,13 @@ EDealRes sclRewriteFunction(SNode** pNode, SScalarCtx *ctx) {
res->translate = true;
if (colDataIsNull_s(output.columnData, 0)) {
res->isNull = true;
//res->node.resType.type = TSDB_DATA_TYPE_NULL;
//res->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_NULL].bytes;
} else {
res->node.resType.type = output.columnData->info.type;
res->node.resType.bytes = output.columnData->info.bytes;
res->node.resType.scale = output.columnData->info.scale;
res->node.resType.precision = output.columnData->info.precision;
if (colDataIsNull_s(output.columnData, 0)) {
res->isNull = true;
} else {
int32_t type = output.columnData->info.type;
if (type == TSDB_DATA_TYPE_JSON){
int32_t len = getJsonValueLen(output.columnData->pData);
......@@ -826,16 +824,11 @@ EDealRes sclRewriteOperator(SNode** pNode, SScalarCtx *ctx) {
res->translate = true;
if (colDataIsNull_s(output.columnData, 0)) {
if(node->node.resType.type != TSDB_DATA_TYPE_JSON){
res->node.resType.type = TSDB_DATA_TYPE_NULL;
res->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_NULL].bytes;
}else{
res->node.resType = node->node.resType;
if (colDataIsNull_s(output.columnData, 0)) {
res->isNull = true;
}
} else {
res->node.resType = node->node.resType;
} else {
int32_t type = output.columnData->info.type;
if (IS_VAR_DATA_TYPE(type)) { // todo refactor
res->datum.p = output.columnData->pData;
......
......@@ -36,6 +36,7 @@ typedef struct SSyncRaftEntry {
bool isWeak;
SyncTerm term;
SyncIndex index;
int64_t rid;
uint32_t dataLen; // origin RpcMsg.contLen
char data[]; // origin RpcMsg.pCont
} SSyncRaftEntry;
......
......@@ -137,6 +137,8 @@ cJSON* syncEntry2Json(const SSyncRaftEntry* pEntry) {
cJSON_AddStringToObject(pRoot, "term", u64buf);
snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pEntry->index);
cJSON_AddStringToObject(pRoot, "index", u64buf);
snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pEntry->rid);
cJSON_AddStringToObject(pRoot, "rid", u64buf);
cJSON_AddNumberToObject(pRoot, "dataLen", pEntry->dataLen);
char* s;
......
......@@ -19,11 +19,14 @@
#include "syncRespMgr.h"
int32_t syncNodeTimerRoutine(SSyncNode* ths) {
syncNodeEventLog(ths, "timer routines ... ");
syncNodeEventLog(ths, "timer routines");
#if 0
if (ths->vgId != 1) {
syncRespClean(ths->pSyncRespMgr);
}
#endif
return 0;
}
......
......@@ -300,6 +300,8 @@ int transSendResponse(const STransMsg* msg);
int transRegisterMsg(const STransMsg* msg);
int transSetDefaultAddr(void* shandle, const char* ip, const char* fqdn);
int transGetSockDebugInfo(struct sockaddr* sockname, char* dst);
int64_t transAllocHandle();
void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads, void* fp, void* shandle);
......
......@@ -37,9 +37,11 @@ typedef struct SCliConn {
uint32_t port;
SDelayTask* task;
// debug and log info
struct sockaddr_in addr;
struct sockaddr_in localAddr;
char src[32];
char dst[32];
} SCliConn;
typedef struct SCliMsg {
......@@ -95,6 +97,14 @@ static SCliConn* getConnFromPool(void* pool, char* ip, uint32_t port);
static void addConnToPool(void* pool, SCliConn* conn);
static void doCloseIdleConn(void* param);
static int sockDebugInfo(struct sockaddr* sockname, char* dst) {
struct sockaddr_in addr = *(struct sockaddr_in*)sockname;
char buf[20] = {0};
int r = uv_ip4_name(&addr, (char*)buf, sizeof(buf));
sprintf(dst, "%s:%d", buf, ntohs(addr.sin_port));
return r;
}
// register timer in each thread to clear expire conn
// static void cliTimeoutCb(uv_timer_t* handle);
// alloc buf for recv
......@@ -363,9 +373,9 @@ void cliHandleResp(SCliConn* conn) {
}
STraceId* trace = &transMsg.info.traceId;
tGTrace("%s conn %p %s received from %s:%d, local info:%s:%d, msg size:%d, code:0x%x", CONN_GET_INST_LABEL(conn),
conn, TMSG_INFO(pHead->msgType), taosInetNtoa(conn->addr.sin_addr), ntohs(conn->addr.sin_port),
taosInetNtoa(conn->localAddr.sin_addr), ntohs(conn->localAddr.sin_port), transMsg.contLen, transMsg.code);
tGTrace("%s conn %p %s received from %s, local info:%s, msg size:%d, code:0x%x", CONN_GET_INST_LABEL(conn), conn,
TMSG_INFO(pHead->msgType), conn->dst, conn->src, transMsg.contLen, transMsg.code);
if (pCtx == NULL && CONN_NO_PERSIST_BY_APP(conn)) {
tDebug("%s except, conn %p read while cli ignore it", CONN_GET_INST_LABEL(conn), conn);
......@@ -741,9 +751,8 @@ void cliSend(SCliConn* pConn) {
uv_buf_t wb = uv_buf_init((char*)pHead, msgLen);
STraceId* trace = &pMsg->info.traceId;
tGTrace("%s conn %p %s is sent to %s:%d, local info %s:%d", CONN_GET_INST_LABEL(pConn), pConn,
TMSG_INFO(pHead->msgType), taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port),
taosInetNtoa(pConn->localAddr.sin_addr), ntohs(pConn->localAddr.sin_port));
tGTrace("%s conn %p %s is sent to %s, local info %s", CONN_GET_INST_LABEL(pConn), pConn, TMSG_INFO(pHead->msgType),
pConn->dst, pConn->src);
if (pHead->persist == 1) {
CONN_SET_PERSIST_BY_APP(pConn);
......@@ -764,11 +773,16 @@ void cliConnCb(uv_connect_t* req, int status) {
cliHandleExcept(pConn);
return;
}
int addrlen = sizeof(pConn->addr);
uv_tcp_getpeername((uv_tcp_t*)pConn->stream, (struct sockaddr*)&pConn->addr, &addrlen);
// int addrlen = sizeof(pConn->addr);
struct sockaddr peername, sockname;
int addrlen = sizeof(peername);
uv_tcp_getpeername((uv_tcp_t*)pConn->stream, &peername, &addrlen);
transGetSockDebugInfo(&peername, pConn->dst);
addrlen = sizeof(pConn->localAddr);
uv_tcp_getsockname((uv_tcp_t*)pConn->stream, (struct sockaddr*)&pConn->localAddr, &addrlen);
addrlen = sizeof(sockname);
uv_tcp_getsockname((uv_tcp_t*)pConn->stream, &sockname, &addrlen);
transGetSockDebugInfo(&sockname, pConn->src);
tTrace("%s conn %p connect to server successfully", CONN_GET_INST_LABEL(pConn), pConn);
assert(pConn->stream == req->handle);
......
......@@ -102,7 +102,14 @@ void transFreeMsg(void* msg) {
}
taosMemoryFree((char*)msg - sizeof(STransMsgHead));
}
int transGetSockDebugInfo(struct sockaddr* sockname, char* dst) {
struct sockaddr_in addr = *(struct sockaddr_in*)sockname;
char buf[20] = {0};
int r = uv_ip4_name(&addr, (char*)buf, sizeof(buf));
sprintf(dst, "%s:%d", buf, ntohs(addr.sin_port));
return r;
}
int transInitBuffer(SConnBuffer* buf) {
transClearBuffer(buf);
return 0;
......
......@@ -44,8 +44,12 @@ typedef struct SSvrConn {
bool broken; // conn broken;
ConnStatus status;
struct sockaddr_in addr;
struct sockaddr_in localAddr;
uint32_t clientIp;
uint16_t port;
char src[32];
char dst[32];
int64_t refId;
int spi;
......@@ -248,15 +252,11 @@ static void uvHandleReq(SSvrConn* pConn) {
if (pConn->status == ConnNormal && pHead->noResp == 0) {
transRefSrvHandle(pConn);
tGTrace("%s conn %p %s received from %s:%d, local info:%s:%d, msg size:%d", transLabel(pTransInst), pConn,
TMSG_INFO(transMsg.msgType), taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port),
taosInetNtoa(pConn->localAddr.sin_addr), ntohs(pConn->localAddr.sin_port), transMsg.contLen);
tGTrace("%s conn %p %s received from %s, local info:%s, msg size:%d", transLabel(pTransInst), pConn,
TMSG_INFO(transMsg.msgType), pConn->dst, pConn->src, transMsg.contLen);
} else {
tGTrace("%s conn %p %s received from %s:%d, local info:%s:%d, msg size:%d, resp:%d, code:%d",
transLabel(pTransInst), pConn, TMSG_INFO(transMsg.msgType), taosInetNtoa(pConn->addr.sin_addr),
ntohs(pConn->addr.sin_port), taosInetNtoa(pConn->localAddr.sin_addr), ntohs(pConn->localAddr.sin_port),
transMsg.contLen, pHead->noResp, transMsg.code);
// no ref here
tGTrace("%s conn %p %s received from %s, local info:%s, msg size:%d, resp:%d, code:%d", transLabel(pTransInst),
pConn, TMSG_INFO(transMsg.msgType), pConn->dst, pConn->src, transMsg.contLen, pHead->noResp, transMsg.code);
}
// pHead->noResp = 1,
......@@ -278,14 +278,13 @@ static void uvHandleReq(SSvrConn* pConn) {
// set up conn info
SRpcConnInfo* pConnInfo = &(transMsg.info.conn);
pConnInfo->clientIp = (uint32_t)(pConn->addr.sin_addr.s_addr);
pConnInfo->clientPort = ntohs(pConn->addr.sin_port);
pConnInfo->clientIp = pConn->clientIp;
pConnInfo->clientPort = pConn->port;
tstrncpy(pConnInfo->user, pConn->user, sizeof(pConnInfo->user));
transReleaseExHandle(transGetRefMgt(), pConn->refId);
(*pTransInst->cfp)(pTransInst->parent, &transMsg, NULL);
// uv_timer_start(&pConn->pTimer, uvHandleActivityTimeout, pRpc->idleTime * 10000, 0);
}
void uvOnRecvCb(uv_stream_t* cli, ssize_t nread, const uv_buf_t* buf) {
......@@ -418,9 +417,8 @@ static void uvPrepareSendData(SSvrMsg* smsg, uv_buf_t* wb) {
STrans* pTransInst = pConn->pTransInst;
STraceId* trace = &pMsg->info.traceId;
tGTrace("%s conn %p %s is sent to %s:%d, local info:%s:%d, msglen:%d", transLabel(pTransInst), pConn,
TMSG_INFO(pHead->msgType), taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port),
taosInetNtoa(pConn->localAddr.sin_addr), ntohs(pConn->localAddr.sin_port), len);
tGTrace("%s conn %p %s is sent to %s, local info:%s, msglen:%d", transLabel(pTransInst), pConn,
TMSG_INFO(pHead->msgType), pConn->dst, pConn->src, len);
pHead->msgLen = htonl(len);
wb->base = msg;
......@@ -646,20 +644,26 @@ void uvOnConnectionCb(uv_stream_t* q, ssize_t nread, const uv_buf_t* buf) {
uv_fileno((const uv_handle_t*)pConn->pTcp, &fd);
tTrace("conn %p created, fd:%d", pConn, fd);
int addrlen = sizeof(pConn->addr);
if (0 != uv_tcp_getpeername(pConn->pTcp, (struct sockaddr*)&pConn->addr, &addrlen)) {
struct sockaddr peername, sockname;
int addrlen = sizeof(peername);
if (0 != uv_tcp_getpeername(pConn->pTcp, (struct sockaddr*)&peername, &addrlen)) {
tError("conn %p failed to get peer info", pConn);
transUnrefSrvHandle(pConn);
return;
}
transGetSockDebugInfo(&peername, pConn->dst);
addrlen = sizeof(pConn->localAddr);
if (0 != uv_tcp_getsockname(pConn->pTcp, (struct sockaddr*)&pConn->localAddr, &addrlen)) {
addrlen = sizeof(sockname);
if (0 != uv_tcp_getsockname(pConn->pTcp, (struct sockaddr*)&sockname, &addrlen)) {
tError("conn %p failed to get local info", pConn);
transUnrefSrvHandle(pConn);
return;
}
transGetSockDebugInfo(&sockname, pConn->src);
struct sockaddr_in addr = *(struct sockaddr_in*)&sockname;
pConn->clientIp = addr.sin_addr.s_addr;
pConn->port = ntohs(addr.sin_port);
uv_read_start((uv_stream_t*)(pConn->pTcp), uvAllocRecvBufferCb, uvOnRecvCb);
} else {
......
......@@ -21,7 +21,7 @@ static int32_t walFetchBodyNew(SWalReader *pRead);
static int32_t walSkipFetchBodyNew(SWalReader *pRead);
SWalReader *walOpenReader(SWal *pWal, SWalFilterCond *cond) {
SWalReader *pRead = taosMemoryMalloc(sizeof(SWalReader));
SWalReader *pRead = taosMemoryCalloc(1, sizeof(SWalReader));
if (pRead == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL;
......@@ -75,6 +75,7 @@ int32_t walNextValidMsg(SWalReader *pRead) {
wDebug("vgId:%d wal start to fetch, ver %ld, last ver %ld commit ver %ld, applied ver %ld, end ver %ld",
pRead->pWal->cfg.vgId, fetchVer, lastVer, committedVer, appliedVer, endVer);
pRead->curStopped = 0;
while (fetchVer <= endVer) {
if (walFetchHeadNew(pRead, fetchVer) < 0) {
return -1;
......@@ -93,6 +94,7 @@ int32_t walNextValidMsg(SWalReader *pRead) {
ASSERT(fetchVer == pRead->curVersion);
}
}
pRead->curStopped = 1;
return -1;
}
......@@ -221,6 +223,8 @@ static int32_t walFetchHeadNew(SWalReader *pRead, int64_t fetchVer) {
int64_t contLen;
bool seeked = false;
wDebug("vgId:%d, wal starts to fetch head %d", pRead->pWal->cfg.vgId, fetchVer);
if (pRead->curInvalid || pRead->curVersion != fetchVer) {
if (walReadSeekVer(pRead, fetchVer) < 0) {
ASSERT(0);
......@@ -257,6 +261,8 @@ static int32_t walFetchBodyNew(SWalReader *pRead) {
SWalCont *pReadHead = &pRead->pHead->head;
int64_t ver = pReadHead->version;
wDebug("vgId:%d, wal starts to fetch body %ld", pRead->pWal->cfg.vgId, ver);
if (pRead->capacity < pReadHead->bodyLen) {
void *ptr = taosMemoryRealloc(pRead->pHead, sizeof(SWalCkHead) + pReadHead->bodyLen);
if (ptr == NULL) {
......@@ -300,8 +306,8 @@ static int32_t walFetchBodyNew(SWalReader *pRead) {
return -1;
}
wDebug("version %ld is fetched, cursor advance", ver);
pRead->curVersion = ver + 1;
wDebug("version advance to %ld, fetch body", pRead->curVersion);
return 0;
}
......
此差异已折叠。
......@@ -101,7 +101,7 @@
./test.sh -f tsim/parser/constCol.sim
#./test.sh -f tsim/parser/create_db.sim
./test.sh -f tsim/parser/create_mt.sim
# TD-17653 ./test.sh -f tsim/parser/create_tb_with_tag_name.sim
./test.sh -f tsim/parser/create_tb_with_tag_name.sim
./test.sh -f tsim/parser/create_tb.sim
./test.sh -f tsim/parser/dbtbnameValidate.sim
./test.sh -f tsim/parser/distinct.sim
......@@ -113,8 +113,8 @@
# TD-17659 ./test.sh -f tsim/parser/function.sim
./test.sh -f tsim/parser/groupby-basic.sim
./test.sh -f tsim/parser/groupby.sim
# TD-17622 ./test.sh -f tsim/parser/having_child.sim
# TD-17622 ./test.sh -f tsim/parser/having.sim
./test.sh -f tsim/parser/having_child.sim
./test.sh -f tsim/parser/having.sim
./test.sh -f tsim/parser/import_commit1.sim
./test.sh -f tsim/parser/import_commit2.sim
./test.sh -f tsim/parser/import_commit3.sim
......@@ -129,7 +129,8 @@
# TD-17707 ./test.sh -f tsim/parser/join.sim
./test.sh -f tsim/parser/last_cache.sim
./test.sh -f tsim/parser/last_groupby.sim
# TD-17722 ./test.sh -f tsim/parser/lastrow.sim
./test.sh -f tsim/parser/lastrow.sim
./test.sh -f tsim/parser/lastrow2.sim
./test.sh -f tsim/parser/like.sim
# TD-17464 ./test.sh -f tsim/parser/limit.sim
# TD-17464 ./test.sh -f tsim/parser/limit1.sim
......@@ -137,7 +138,7 @@
./test.sh -f tsim/parser/mixed_blocks.sim
./test.sh -f tsim/parser/nchar.sim
# TD-17703 ./test.sh -f tsim/parser/nestquery.sim
# TD-17685 ./test.sh -f tsim/parser/null_char.sim
./test.sh -f tsim/parser/null_char.sim
./test.sh -f tsim/parser/precision_ns.sim
./test.sh -f tsim/parser/projection_limit_offset.sim
./test.sh -f tsim/parser/regex.sim
......@@ -146,12 +147,12 @@
./test.sh -f tsim/parser/select_from_cache_disk.sim
# TD-17659 ./test.sh -f tsim/parser/select_with_tags.sim
./test.sh -f tsim/parser/selectResNum.sim
# TD-17685 ./test.sh -f tsim/parser/set_tag_vals.sim
./test.sh -f tsim/parser/set_tag_vals.sim
./test.sh -f tsim/parser/single_row_in_tb.sim
# TD-17684 ./test.sh -f tsim/parser/sliding.sim
# TD-17722 ./test.sh -f tsim/parser/slimit_alter_tags.sim
# TD-17722 ./test.sh -f tsim/parser/slimit.sim
# TD-17722 ./test.sh -f tsim/parser/slimit1.sim
./test.sh -f tsim/parser/sliding.sim
./test.sh -f tsim/parser/slimit_alter_tags.sim
./test.sh -f tsim/parser/slimit.sim
./test.sh -f tsim/parser/slimit1.sim
./test.sh -f tsim/parser/stableOp.sim
# TD-17661 ./test.sh -f tsim/parser/tags_dynamically_specifiy.sim
# TD-17661 ./test.sh -f tsim/parser/tags_filter.sim
......
......@@ -63,10 +63,14 @@ print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4]
print $data[1][0] $data[1][1] $data[1][2] $data[1][3] $data[1][4]
print $data[2][0] $data[2][1] $data[2][2] $data[2][3] $data[2][4]
if $data(1)[2] != leader then
goto step3
$leaderNum = 0
if $data(1)[2] == leader then
$leaderNum = 1
endi
if $data(2)[2] == leader then
$leaderNum = 1
endi
if $data(2)[2] != follower then
if $leaderNum == 0 then
goto step3
endi
if $data(3)[2] != offline then
......@@ -97,10 +101,14 @@ print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4]
print $data[1][0] $data[1][1] $data[1][2] $data[1][3] $data[1][4]
print $data[2][0] $data[2][1] $data[2][2] $data[2][3] $data[2][4]
if $data(1)[2] != leader then
goto step4
$leaderNum = 0
if $data(1)[2] == leader then
$leaderNum = 1
endi
if $data(2)[2] == leader then
$leaderNum = 1
endi
if $data(2)[2] != follower then
if $leaderNum == 0 then
goto step4
endi
if $data(3)[2] != follower then
......@@ -132,10 +140,14 @@ print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4]
print $data[1][0] $data[1][1] $data[1][2] $data[1][3] $data[1][4]
print $data[2][0] $data[2][1] $data[2][2] $data[2][3] $data[2][4]
if $data(1)[2] != leader then
goto step5
$leaderNum = 0
if $data(1)[2] == leader then
$leaderNum = 1
endi
if $data(2)[2] == leader then
$leaderNum = 1
endi
if $data(2)[2] != follower then
if $leaderNum == 0 then
goto step5
endi
if $data(3)[2] != offline then
......@@ -169,10 +181,14 @@ print $data[2][0] $data[2][1] $data[2][2] $data[2][3] $data[2][4]
if $rows != 2 then
goto step6
endi
if $data(1)[2] != leader then
goto step6
$leaderNum = 0
if $data(1)[2] == leader then
$leaderNum = 1
endi
if $data(2)[2] == leader then
$leaderNum = 1
endi
if $data(2)[2] != follower then
if $leaderNum == 0 then
goto step6
endi
if $data(3)[2] != null then
......
......@@ -68,13 +68,17 @@ step31:
return -1
endi
sql show mnodes
if $data(1)[2] != leader then
goto step31
$leaderNum = 0
if $data(1)[2] == leader then
$leaderNum = 1
endi
if $data(2)[2] != follower then
goto step31
if $data(2)[2] == leader then
$leaderNum = 1
endi
if $data(3)[2] != follower then
if $data(3)[2] == leader then
$leaderNum = 1
endi
if $leaderNum == 0 then
goto step31
endi
......@@ -302,10 +306,10 @@ print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15
print ===> $data20 $data21 $data22 $data23 $data24 $data25
$leaderNum = 0
if $data(2)[2] == leader then
if $data(1)[2] == leader then
$leaderNum = 1
endi
if $data(3)[2] == leader then
if $data(2)[2] == leader then
$leaderNum = 1
endi
if $data(3)[2] == leader then
......
......@@ -93,7 +93,7 @@ sql_error create table tb11 using st2 (id,t1,) tags (1,1,1);
sql create table tb12 using st2 (t1,id) tags (2,1);
sql show tags from tb12;
if $rows != 5 then
if $rows != 4 then
return -1
endi
if $data05 != 1 then
......@@ -109,9 +109,9 @@ if $data35 != NULL then
return -1
endi
sql create table tb13 using st2 ("t1",'id') tags (2,1);
sql create table tb13 using st2 (t1,id) tags (2,1);
sql show tags from tb13;
if $rows != 2 then
if $rows != 4 then
return -1
endi
if $data05 != 1 then
......
echo '2020-1-1 1:1:1','abc','device',123,'9876', 'abc', 'net', 'mno', 'province', 'city', 'al' > C:\\Windows\\Temp\\data.sql
echo '2020-1-2 1:1:1','abc','device',123,'9876', 'abc', 'net', 'mno', 'province', 'city', 'al' >> C:\\Windows\\Temp\\data.sql
echo '2020-1-3 1:1:1','abc','device',123,'9876', 'abc', 'net', 'mno', 'province', 'city', 'al' >> C:\\Windows\\Temp\\data.sql
此差异已折叠。
......@@ -26,7 +26,6 @@ sql insert into tb1 values (now+50s ,3,3.0,3.0,3,3,3,false,"3","3")
sql insert into tb1 values (now+100s,4,4.0,4.0,4,4,4,true ,"4","4")
sql insert into tb1 values (now+150s,4,4.0,4.0,4,4,4,false,"4","4")
sql select count(*),f1 from tb1 group by f1 having count(f1) > 0 order by f1;
if $rows != 4 then
return -1
......@@ -56,7 +55,6 @@ if $data31 != 4 then
return -1
endi
sql select count(*),f1 from tb1 group by f1 having count(*) > 0 order by f1;
if $rows != 4 then
return -1
......@@ -299,13 +297,13 @@ if $data12 != 4 then
return -1
endi
sql_error select avg(f1),count(f1),sum(f1),twa(f1) from tb1 group by tbname having twa(f1) > 0;
sql select avg(f1),count(f1),sum(f1),twa(f1) from tb1 group by tbname having twa(f1) > 0;
sql_error select avg(f1),count(f1),sum(f1),twa(f1) from tb1 group by f1 having twa(f1) > 3;
sql select avg(f1),count(f1),sum(f1),twa(f1) from tb1 group by f1 having twa(f1) > 3;
sql_error select avg(f1),count(f1),sum(f1),twa(f1) from tb1 group by tbname having sum(f1) > 0;
sql select avg(f1),count(f1),sum(f1),twa(f1) from tb1 group by tbname having sum(f1) > 0;
sql_error select avg(f1),count(f1),sum(f1),twa(f1) from tb1 group by f1 having sum(f1) = 4;
sql select avg(f1),count(f1),sum(f1),twa(f1) from tb1 group by f1 having sum(f1) = 4;
sql select avg(f1),count(f1),sum(f1) from tb1 group by f1 having sum(f1) > 0 order by f1;
if $rows != 4 then
......@@ -381,7 +379,7 @@ if $data22 != 8 then
endi
###########and issue
sql select avg(f1),count(f1),sum(f1) from tb1 group by f1 having sum(f1) > 3 and sum(f1) > 1 order by f1;
sql select avg(f1),count(f1),sum(f1) from tb1 group by f1 having sum(f1) > 1 order by f1;
if $rows != 4 then
return -1
endi
......@@ -422,7 +420,6 @@ if $data32 != 8 then
return -1
endi
sql select avg(f1),count(f1),sum(f1) from tb1 group by f1 having sum(f1) > 3 or sum(f1) > 1 order by f1;
if $rows != 4 then
return -1
......@@ -497,7 +494,7 @@ if $data22 != 8 then
endi
############or issue
sql select avg(f1),count(f1),sum(f1) from tb1 group by f1 having sum(f1) > 3 or avg(f1) > 4 order by f1;
sql select avg(f1),count(f1),sum(f1) from tb1 group by f1 having sum(f1) > 3 and avg(f1) > 4 order by f1;
if $rows != 0 then
return -1
endi
......@@ -728,11 +725,11 @@ sql_error select avg(f1),count(tb1.*),sum(f1),stddev(f1) from tb1 group by f1 ha
sql_error select avg(f1),count(tb1.*),sum(f1),stddev(f1) from tb1 group by f1 having LEASTSQUARES(f1) < 1;
sql_error select avg(f1),count(tb1.*),sum(f1),stddev(f1) from tb1 group by f1 having LEASTSQUARES(f1,1,1) < 1;
sql select avg(f1),count(tb1.*),sum(f1),stddev(f1) from tb1 group by f1 having LEASTSQUARES(f1,1,1) < 1;
sql_error select avg(f1),count(tb1.*),sum(f1),stddev(f1) from tb1 group by f1 having LEASTSQUARES(f1,1,1) > 2;
sql select avg(f1),count(tb1.*),sum(f1),stddev(f1) from tb1 group by f1 having LEASTSQUARES(f1,1,1) > 2;
sql_error select avg(f1),count(tb1.*),sum(f1),stddev(f1),LEASTSQUARES(f1,1,1) from tb1 group by f1 having LEASTSQUARES(f1,1,1) > 2;
sql select avg(f1),count(tb1.*),sum(f1),stddev(f1),LEASTSQUARES(f1,1,1) from tb1 group by f1 having LEASTSQUARES(f1,1,1) > 2;
sql select avg(f1),count(tb1.*),sum(f1),stddev(f1),LEASTSQUARES(f1,1,1) from tb1 group by f1 having sum(f1) > 2 order by f1;
if $rows != 3 then
......@@ -1149,9 +1146,9 @@ sql_error select aPERCENTILE(f1,20) from tb1 group by f1 having apercentile(1) >
sql_error select aPERCENTILE(f1,20),LAST_ROW(f1) from tb1 group by f1 having apercentile(1) > 1;
sql_error select aPERCENTILE(f1,20),LAST_ROW(f1) from tb1 group by f1 having apercentile(f1,1) > 1;
sql select aPERCENTILE(f1,20),LAST_ROW(f1) from tb1 group by f1 having apercentile(f1,1) > 1;
sql_error select sum(f1) from tb1 group by f1 having last_row(f1) > 1;
sql select sum(f1) from tb1 group by f1 having last_row(f1) > 1;
sql_error select avg(f1) from tb1 group by f1 having diff(f1) > 0;
......@@ -1210,7 +1207,7 @@ if $data31 != 0.000000000 then
return -1
endi
sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) = 0 order by f1;
sql select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 group by f1 having spread(f1) = 0 order by f1;
if $rows != 4 then
return -1
endi
......@@ -1263,48 +1260,47 @@ if $data33 != 0.000000000 then
return -1
endi
sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) != 0 order by f1;
sql select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 group by f1 having spread(f1) != 0 order by f1;
if $rows != 0 then
return -1
endi
sql select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 group by f1 having spread(f1) + 1 > 0;
sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) + 1 > 0;
sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) + 1;
sql select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 group by f1 having spread(f1) + 1;
sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) + sum(f1);
sql select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 group by f1 having spread(f1) + sum(f1);
sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) + sum(f1) > 0;
sql select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 group by f1 having spread(f1) + sum(f1) > 0;
sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) - sum(f1) > 0;
sql select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 group by f1 having spread(f1) - sum(f1) > 0;
sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) * sum(f1) > 0;
sql select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 group by f1 having spread(f1) * sum(f1) > 0;
sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) / sum(f1) > 0;
sql select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 group by f1 having spread(f1) / sum(f1) > 0;
sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) > sum(f1);
sql select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 group by f1 having spread(f1) > sum(f1);
sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) and sum(f1);
sql_error select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 group by f1 having spread(f1) and sum(f1);
sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) 0 and sum(f1);
sql_error select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 group by f1 having spread(f1) 0 and sum(f1);
sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) + 0 and sum(f1);
sql_error select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 group by f1 having spread(f1) + 0 and sum(f1);
sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) - f1 and sum(f1);
sql_error select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 group by f1 having spread(f1) - f1 and sum(f1);
sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) - id1 and sum(f1);
sql_error select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 group by f1 having spread(f1) - id1 and sum(f1);
sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) > id1 and sum(f1);
sql_error select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 group by f1 having spread(f1) > id1 and sum(f1);
sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) > id1 and sum(f1) > 1;
sql_error select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 group by f1 having spread(f1) > id1 and sum(f1) > 1;
sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) > 2 and sum(f1) > 1 order by f1;
sql select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 group by f1 having spread(f1) > 2 and sum(f1) > 1 order by f1;
if $rows != 0 then
return -1
endi
sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) = 0 and sum(f1) > 1 order by f1;
sql select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 group by f1 having spread(f1) = 0 and sum(f1) > 1 order by f1;
if $rows != 4 then
return -1
endi
......@@ -1357,7 +1353,7 @@ if $data33 != 0.000000000 then
return -1
endi
sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having spread(f1) = 0 and avg(f1) > 1 order by f1;
sql select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 group by f1 having spread(f1) = 0 and avg(f1) > 1 order by f1;
if $rows != 3 then
return -1
endi
......@@ -1398,17 +1394,17 @@ if $data23 != 0.000000000 then
return -1
endi
sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by c1 having spread(f1) = 0 and avg(f1) > 1;
sql_error select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 group by c1 having spread(f1) = 0 and avg(f1) > 1;
sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by id1 having avg(id1) > 0;
sql select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 group by id1 having avg(id1) > 0;
sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by id1 having avg(f1) > id1;
sql select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 group by id1 having avg(f1) > id1;
sql_error select avg(f1),spread(f1,f2,tb1.f1),avg(id1) from tb1 group by id1 having avg(f1) > id1;
sql select avg(f1),spread(f1),spread(f2),spread(tb1.f1),avg(id1) from tb1 group by id1 having avg(f1) > id1;
sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by id1 having avg(f1) > 0;
sql select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 group by id1 having avg(f1) > 0;
sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having avg(f1) > 0 and avg(f1) = 3 order by f1;
sql select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 group by f1 having avg(f1) > 0 and avg(f1) = 3 order by f1;
if $rows != 1 then
return -1
endi
......@@ -1425,10 +1421,10 @@ if $data03 != 0.000000000 then
return -1
endi
#sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by f1 having avg(f1) < 0 and avg(f1) = 3;
sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 group by id1 having avg(f1) < 2;
#sql_error select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 group by f1 having avg(f1) < 0 and avg(f1) = 3;
sql select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 group by id1 having avg(f1) < 2;
sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f1 > 0 group by f1 having avg(f1) > 0 order by f1;
sql select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 where f1 > 0 group by f1 having avg(f1) > 0 order by f1;
if $rows != 4 then
return -1
endi
......@@ -1481,7 +1477,7 @@ if $data33 != 0.000000000 then
return -1
endi
sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f1 > 2 group by f1 having avg(f1) > 0 order by f1;
sql select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 where f1 > 2 group by f1 having avg(f1) > 0 order by f1;
if $rows != 2 then
return -1
endi
......@@ -1510,7 +1506,7 @@ if $data13 != 0.000000000 then
return -1
endi
sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f2 > 2 group by f1 having avg(f1) > 0 order by f1;
sql select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 where f2 > 2 group by f1 having avg(f1) > 0 order by f1;
if $rows != 2 then
return -1
endi
......@@ -1539,7 +1535,7 @@ if $data13 != 0.000000000 then
return -1
endi
sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f3 > 2 group by f1 having avg(f1) > 0 order by f1;
sql select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 where f3 > 2 group by f1 having avg(f1) > 0 order by f1;
if $rows != 2 then
return -1
endi
......@@ -1568,7 +1564,7 @@ if $data13 != 0.000000000 then
return -1
endi
sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f2 > 3 group by f1 having avg(f1) > 0 order by f1;
sql select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 where f2 > 3 group by f1 having avg(f1) > 0 order by f1;
if $rows != 1 then
return -1
endi
......@@ -1585,15 +1581,15 @@ if $data03 != 0.000000000 then
return -1
endi
sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f2 > 3 group by f1 having avg(ts) > 0;
sql_error select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 where f2 > 3 group by f1 having avg(ts) > 0;
sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f2 > 3 group by f1 having avg(f7) > 0;
sql_error select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 where f2 > 3 group by f1 having avg(f7) > 0;
sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f2 > 3 group by f1 having avg(f8) > 0;
sql_error select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 where f2 > 3 group by f1 having avg(f8) > 0;
sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f2 > 3 group by f1 having avg(f9) > 0;
sql_error select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 where f2 > 3 group by f1 having avg(f9) > 0;
sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f2 > 3 group by f1 having count(f9) > 0 order by f1;
sql select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 where f2 > 3 group by f1 having count(f9) > 0 order by f1;
if $rows != 1 then
return -1
endi
......@@ -1610,9 +1606,9 @@ if $data03 != 0.000000000 then
return -1
endi
sql_error select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f2 > 3 group by f1 having last(f9) > 0;
sql select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 where f2 > 3 group by f1 having last(f9) > 0;
sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f2 > 3 group by f1 having last(f2) > 0 order by f1;
sql select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 where f2 > 3 group by f1 having last(f2) > 0 order by f1;
if $rows != 1 then
return -1
endi
......@@ -1629,7 +1625,7 @@ if $data03 != 0.000000000 then
return -1
endi
sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f2 > 3 group by f1 having last(f3) > 0 order by f1;
sql select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 where f2 > 3 group by f1 having last(f3) > 0 order by f1;
if $rows != 1 then
return -1
endi
......@@ -1646,7 +1642,7 @@ if $data03 != 0.000000000 then
return -1
endi
sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f2 > 1 group by f1 having last(f3) > 0 order by f1;
sql select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 where f2 > 1 group by f1 having last(f3) > 0 order by f1;
if $rows != 3 then
return -1
endi
......@@ -1687,7 +1683,7 @@ if $data23 != 0.000000000 then
return -1
endi
sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f2 > 1 group by f1 having last(f4) > 0 order by f1;
sql select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 where f2 > 1 group by f1 having last(f4) > 0 order by f1;
if $rows != 3 then
return -1
endi
......@@ -1728,7 +1724,7 @@ if $data23 != 0.000000000 then
return -1
endi
sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f2 > 1 group by f1 having last(f5) > 0 order by f1;
sql select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 where f2 > 1 group by f1 having last(f5) > 0 order by f1;
if $rows != 3 then
return -1
endi
......@@ -1769,7 +1765,7 @@ if $data23 != 0.000000000 then
return -1
endi
sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f2 > 1 group by f1 having last(f6) > 0 order by f1;
sql select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 where f2 > 1 group by f1 having last(f6) > 0 order by f1;
if $rows != 3 then
return -1
endi
......@@ -1811,17 +1807,17 @@ if $data23 != 0.000000000 then
endi
sql_error select avg(f1),spread(f1,f2,tb1.f1),f1,f2 from tb1 where f2 > 1 group by f1 having last(f6) > 0;
sql_error select avg(f1),spread(f1),spread(f2),spread(tb1.f1),f1,f2 from tb1 where f2 > 1 group by f1 having last(f6) > 0;
sql_error select avg(f1),spread(f1,f2,tb1.f1),f1,f6 from tb1 where f2 > 1 group by f1 having last(f6) > 0;
sql_error select avg(f1),spread(f1),spread(f2),spread(tb1.f1),f1,f6 from tb1 where f2 > 1 group by f1 having last(f6) > 0;
sql_error select avg(f1),spread(f1,f2,tb1.f1),f1,f6 from tb1 where f2 > 1 group by f1,f2 having last(f6) > 0;
sql_error select avg(f1),spread(f1),spread(f2),spread(tb1.f1),f1,f6 from tb1 where f2 > 1 group by f1,f2 having last(f6) > 0;
sql_error select avg(f1),spread(f1,f2,tb1.f1),f1,f6 from tb1 where f2 > 1 group by f1,id1 having last(f6) > 0;
sql_error select avg(f1),spread(f1),spread(f2),spread(tb1.f1),f1,f6 from tb1 where f2 > 1 group by f1,id1 having last(f6) > 0;
sql_error select avg(f1),spread(f1,f2,tb1.f1),f1,f6 from tb1 where f2 > 1 group by id1 having last(f6) > 0;
sql_error select avg(f1),spread(f1),spread(f2),spread(tb1.f1),f1,f6 from tb1 where f2 > 1 group by id1 having last(f6) > 0;
sql select avg(f1),spread(f1,f2,tb1.f1) from tb1 where f2 > 1 and f2 < 4 group by f1 having last(f6) > 0 order by f1;
sql select avg(f1), spread(f1), spread(f2), spread(tb1.f1) from tb1 where f2 > 1 and f2 < 4 group by f1 having last(f6) > 0 order by f1;
if $rows != 2 then
return -1
endi
......
......@@ -7,8 +7,11 @@ sql drop database if exists indb
sql create database if not exists indb
sql use indb
$inFileName = '/tmp/data.csv'
$numOfRows = 10000
$inFileName = '/tmp/data.sql'
system_content printf %OS%
if $system_content == Windows_NT then
$inFileName = 'C:\\Windows\\Temp\\data.sql'
endi
system tsim/parser/gendata.sh
sql create table stbx (ts TIMESTAMP, collect_area NCHAR(12), device_id BINARY(16), imsi BINARY(16), imei BINARY(16), mdn BINARY(10), net_type BINARY(4), mno NCHAR(4), province NCHAR(10), city NCHAR(16), alarm BINARY(2)) tags(a int, b binary(12));
......@@ -16,8 +19,8 @@ sql create table stbx (ts TIMESTAMP, collect_area NCHAR(12), device_id BINARY(16
sql create table tbx (ts TIMESTAMP, collect_area NCHAR(12), device_id BINARY(16), imsi BINARY(16), imei BINARY(16), mdn BINARY(10), net_type BINARY(4), mno NCHAR(4), province NCHAR(10), city NCHAR(16), alarm BINARY(2))
print ====== create tables success, starting insert data
sql insert into tbx file '/tmp/data.sql'
sql import into tbx file '/tmp/data.sql'
sql insert into tbx file $inFileName
sql import into tbx file $inFileName
sql select count(*) from tbx
if $rows != 1 then
......@@ -31,8 +34,8 @@ endi
sql drop table tbx;
sql insert into tbx using stbx tags(1,'abc') file '/tmp/data.sql';
sql insert into tbx using stbx tags(1,'abc') file '/tmp/data.sql';
sql insert into tbx using stbx tags(1,'abc') file $inFileName ;
sql insert into tbx using stbx tags(1,'abc') file $inFileName ;
sql select count(*) from tbx
if $rows != 1 then
......@@ -44,7 +47,7 @@ if $data00 != 3 then
endi
sql drop table tbx;
sql insert into tbx using stbx(b) tags('abcf') file '/tmp/data.sql';
sql insert into tbx using stbx(b) tags('abcf') file $inFileName ;
sql select ts,a,b from tbx;
if $rows != 3 then
......@@ -64,6 +67,6 @@ if $data02 != @abcf@ then
return -1
endi
system rm -f /tmp/data.sql
system rm -f $inFileName
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
......@@ -64,21 +64,4 @@ sql connect
run tsim/parser/lastrow_query.sim
print =================== last_row + nested query
sql use $db
sql create table lr_nested(ts timestamp, f int)
sql insert into lr_nested values(now, 1)
sql insert into lr_nested values(now+1s, null)
sql select last_row(*) from (select * from lr_nested)
if $rows != 1 then
return -1
endi
if $data01 != NULL then
return -1
endi
sql select last_row(*) from (select f from lr_nested)
if $rows != 1 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
sql create database d1;
sql use d1;
print ========>td-1317, empty table last_row query crashed
sql drop table if exists m1;
sql create table m1(ts timestamp, k int) tags (a int);
sql create table t1 using m1 tags(1);
sql create table t2 using m1 tags(2);
sql select last_row(*) from t1
if $rows != 0 then
return -1
endi
sql select last_row(*) from m1
if $rows != 0 then
return -1
endi
sql select last_row(*) from m1 where tbname in ('t1')
if $rows != 0 then
return -1
endi
sql insert into t1 values('2019-1-1 1:1:1', 1);
print ===================> last_row query against normal table along with ts/tbname
sql select last_row(*),ts,'k' from t1;
if $rows != 1 then
return -1
endi
print ===================> last_row + user-defined column + normal tables
sql select last_row(ts), 'abc', 1234.9384, ts from t1
if $rows != 1 then
return -1
endi
if $data01 != @abc@ then
print expect abc, actual $data02
return -1
endi
if $data02 != 1234.938400000 then
return -1
endi
if $data03 != @19-01-01 01:01:01.000@ then
print expect 19-01-01 01:01:01.000, actual:$data03
return -1
endi
print ===================> last_row + stable + ts/tag column + condition + udf
sql select last_row(*), ts, 'abc', 123.981, tbname from m1
if $rows != 1 then
return -1
endi
if $data02 != @19-01-01 01:01:01.000@ then
return -1
endi
if $data03 != @abc@ then
return -1
endi
if $data04 != 123.981000000 then
print expect 123.981000000, actual: $data04
return -1
endi
sql create table tu(ts timestamp, k int)
sql select last_row(*) from tu
if $row != 0 then
return -1
endi
print =================== last_row + nested query
sql create table lr_nested(ts timestamp, f int)
sql insert into lr_nested values(now, 1)
sql insert into lr_nested values(now+1s, null)
sql select last_row(*) from (select * from lr_nested)
if $rows != 1 then
return -1
endi
if $data01 != NULL then
return -1
endi
#sql select last_row(*) from (select f from lr_nested)
#if $rows != 1 then
# return -1
#endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
......@@ -79,19 +79,6 @@ endi
if $data03 != NULL then
return -1
endi
if $data11 != 7 then
return -1
endi
if $data12 != 7 then
return -1
endi
if $data13 != 59 then
print expect 59, actual: $data03
return -1
endi
if $data14 != 7 then
return -1
endi
sql select t1,t1,count(*),t1,t1 from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' partition by t1 interval(1h) fill(NULL) limit 9
if $rows != 18 then
......@@ -129,43 +116,41 @@ if $rows != 1 then
endi
sql select count(*),tbname,t1,t1,tbname from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' partition by tbname, t1 interval(1d) fill(NULL) slimit 1 soffset 1
if $rows != 0 then
if $rows != 1 then
return -1
endi
sql select count(*),tbname,t1,t1,tbname from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' partition by tbname, t1 interval(1d) fill(NULL) slimit 1 soffset 0
if $rows != 0 then
if $rows != 1 then
return -1
endi
return
sql select t1,t1,count(*),tbname,t1,t1,tbname from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' partition by tbname, t1 interval(1s) fill(NULL) slimit 2 soffset 0 limit 250000 offset 1
if $rows != 172799 then
if $rows != 172798 then
return -1
endi
sql select t1,t1,count(*),tbname,t1,t1,tbname from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' partition by tbname, t1 interval(1s) fill(NULL) slimit 1 soffset 0 limit 250000 offset 1
if $rows != 86399 then
if $rows != 85648 then
return -1
endi
sql select t1,t1,count(*),t1,t1 from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' partition by t1 interval(1h) fill(NULL) order by ts DESC limit 30
if $rows != 30 then
sql select t1,t1,count(*),t1,t1 from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' partition by t1 interval(1h) fill(NULL) limit 30
if $rows != 48 then
return -1
endi
sql select t1,t1,count(*),t1,t1 from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' partition by t1 interval(1h) fill(NULL) limit 2
if $rows != 2 then
if $rows != 4 then
return -1
endi
sql select t1,t1,count(*),tbname,t1,t1,tbname from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' partition by tbname, t1 interval(1s) fill(NULL) slimit 1 soffset 1 limit 250000 offset 1
if $rows != 86399 then
if $rows != 87150 then
return -1
endi
sql select t1,t1,count(*),t1,t1 from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' partition by t1 interval(1h) fill(NULL) order by ts desc limit 1
sql select t1,t1,count(*),t1,t1 from lr_stb0 where ts>'2018-09-24 00:00:00.000' and ts<'2018-09-25 00:00:00.000' partition by t1 interval(1h) fill(NULL) limit 1
if $rows != 2 then
return -1
endi
......@@ -174,68 +159,3 @@ sql select t1,t1,count(*),t1,t1 from lr_stb0 where ts>'2018-09-24 00:00:00.000'
if $rows != 46 then
return -1
endi
print ========>td-1317, empty table last_row query crashed
sql drop table if exists m1;
sql create table m1(ts timestamp, k int) tags (a int);
sql create table t1 using m1 tags(1);
sql create table t2 using m1 tags(2);
sql select last_row(*) from t1
if $rows != 0 then
return -1
endi
sql select last_row(*) from m1
if $rows != 0 then
return -1
endi
sql select last_row(*) from m1 where tbname in ('t1')
if $rows != 0 then
return -1
endi
sql insert into t1 values('2019-1-1 1:1:1', 1);
print ===================> last_row query against normal table along with ts/tbname
sql select last_row(*),ts,'k' from t1;
if $rows != 1 then
return -1
endi
print ===================> last_row + user-defined column + normal tables
sql select last_row(ts), 'abc', 1234.9384, ts from t1
if $rows != 1 then
return -1
endi
if $data01 != @abc@ then
print expect abc, actual $data02
return -1
endi
if $data02 != 1234.938400000 then
return -1
endi
if $data03 != @19-01-01 01:01:01.000@ then
print expect 19-01-01 01:01:01.000, actual:$data03
return -1
endi
print ===================> last_row + stable + ts/tag column + condition + udf
sql select last_row(*), ts, 'abc', 123.981, tbname from m1
if $rows != 1 then
return -1
endi
if $data02 != @19-01-01 01:01:01.000@ then
return -1
endi
if $data03 != @abc@ then
return -1
endi
if $data04 != 123.981000000 then
print expect 123.981000000, actual: $data04
return -1
endi
sql create table tu(ts timestamp, k int)
sql select last_row(*) from tu
if $row != 0 then
return -1
endi
......@@ -285,7 +285,7 @@ if $data02 != 2147483647 then
return -1
endi
sql_error alter table st41 set tag tag_int = -2147483648
sql alter table st41 set tag tag_int = -2147483648
sql_error alter table st41 set tag tag_int = 2147483648
sql alter table st41 set tag tag_int = '-379'
......@@ -304,8 +304,8 @@ if $data02 != NULL then
print ==10== expect: NULL, actually: $data02
return -1
endi
sql alter table st41 set tag tag_int = 'NULL'
sql_error alter table st41 set tag tag_int = ''
sql_error alter table st41 set tag tag_int = 'NULL'
sql alter table st41 set tag tag_int = ''
sql_error alter table st41 set tag tag_int = abc379
################### bool
......@@ -331,8 +331,8 @@ if $data03 != 1 then
endi
sql alter table st41 set tag tag_bool = 'NULL'
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
if $data03 != NULL then
print ==14== expect: NULL, actually: $data03
if $data03 != 0 then
print ==14== expect: 0, actually: $data03
return -1
endi
sql alter table st41 set tag tag_bool = NULL
......@@ -341,8 +341,8 @@ if $data03 != NULL then
return -1
endi
sql_error alter table st41 set tag tag_bool = '123'
sql_error alter table st41 set tag tag_bool = ''
sql alter table st41 set tag tag_bool = '123'
sql alter table st41 set tag tag_bool = ''
sql_error alter table st41 set tag tag_bool = abc379
################### float
......@@ -378,8 +378,8 @@ if $data04 != NULL then
endi
sql alter table st41 set tag tag_float = 'NULL'
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
if $data04 != NULL then
print ==17== expect: NULL, actually : $data04
if $data04 != 0.00000 then
print ==17== expect: 0.00000, actually : $data04
return -1
endi
sql alter table st41 set tag tag_float = '54.123456'
......@@ -394,10 +394,10 @@ if $data04 != -54.12346 then
print ==19== expect: -54.12346, actually : $data04
return -1
endi
sql_error alter table st41 set tag tag_float = ''
sql alter table st41 set tag tag_float = ''
sql_error alter table st41 set tag tag_float = 'abc'
sql_error alter table st41 set tag tag_float = '123abc'
sql alter table st41 set tag tag_float = 'abc'
sql alter table st41 set tag tag_float = '123abc'
sql_error alter table st41 set tag tag_float = abc
################### double
......@@ -426,20 +426,20 @@ if $data05 != NULL then
endi
sql alter table st41 set tag tag_double = 'NULL'
sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41
if $data05 != NULL then
print ==20== expect: NULL, actually : $data05
if $data05 != 0.000000000 then
print ==20== expect: 0.000000000, actually : $data05
return -1
endi
sql_error alter table st41 set tag tag_double = ''
sql_error alter table st41 set tag tag_double = 'abc'
sql_error alter table st41 set tag tag_double = '123abc'
sql alter table st41 set tag tag_double = ''
sql alter table st41 set tag tag_double = 'abc'
sql alter table st41 set tag tag_double = '123abc'
sql_error alter table st41 set tag tag_double = abc
################### bigint smallint tinyint
sql create table mt5 (ts timestamp, c1 int) tags (tag_bigint bigint, tag_smallint smallint, tag_tinyint tinyint)
sql create table st51 using mt5 tags (1, 2, 3)
sql insert into st51 values(now, 1)
sql alter table st51 set tag tag_bigint = '-379'
sql alter table st51 set tag tag_bigint = -2000
sql alter table st51 set tag tag_bigint = NULL
......@@ -455,10 +455,10 @@ sql select tag_bigint, tag_smallint, tag_tinyint from st51
if $data00 != -9223372036854775807 then
return -1
endi
sql_error alter table st51 set tag tag_bigint = -9223372036854775808
sql alter table st51 set tag tag_bigint = -9223372036854775808
sql alter table st51 set tag tag_bigint = 'NULL'
sql_error alter table st51 set tag tag_bigint = ''
sql_error alter table st51 set tag tag_bigint = 'NULL'
sql alter table st51 set tag tag_bigint = ''
sql_error alter table st51 set tag tag_bigint = abc379
####
......@@ -476,10 +476,10 @@ sql select tag_bigint, tag_smallint, tag_tinyint from st51
if $data01 != -32767 then
return -1
endi
sql_error alter table st51 set tag tag_smallint = -32768
sql alter table st51 set tag tag_smallint = -32768
sql alter table st51 set tag tag_smallint = 'NULL'
sql_error alter table st51 set tag tag_smallint = ''
sql_error alter table st51 set tag tag_smallint = 'NULL'
sql alter table st51 set tag tag_smallint = ''
sql_error alter table st51 set tag tag_smallint = abc379
####
......@@ -495,15 +495,13 @@ sql select tag_bigint, tag_smallint, tag_tinyint from st51
if $data02 != -127 then
return -1
endi
sql_error alter table st51 set tag tag_tinyint = '-128'
sql alter table st51 set tag tag_tinyint = '-128'
sql_error alter table st51 set tag tag_tinyint = 128
sql alter table st51 set tag tag_tinyint = 'NULL'
sql_error alter table st51 set tag tag_tinyint = ''
sql_error alter table st51 set tag tag_tinyint = 'NULL'
sql alter table st51 set tag tag_tinyint = ''
sql_error alter table st51 set tag tag_tinyint = abc379
# test end
#sql drop database $db
system sh/exec.sh -n dnode1 -s stop -x SIGINT
......@@ -356,9 +356,6 @@ if $data03 != 0.000000000 then
return -1
endi
#TODO
return
sql select count(c2),last(c4),stddev(c3),spread(c3) from sliding_tb0 where c2 = 0 interval(30s) sliding(20s) order by _wstart desc limit 1 offset 15;
if $row != 1 then
return -1
......
......@@ -11,82 +11,54 @@ $db = $dbPrefix
sql use $db
#### group by t2,t1 + slimit
sql select count(*) from stb group by t2,t1 order by t2 asc slimit 5 soffset 6
#### partition by t2,t1 + slimit
sql select count(*) from stb partition by t2,t1 slimit 5 soffset 6
if $rows != 3 then
return -1
endi
if $data00 != $rowNum then
return -1
endi
if $data01 != 2 then
return -1
endi
if $data02 != 6 then
return -1
endi
if $data10 != $rowNum then
return -1
endi
if $data11 != 2 then
return -1
endi
if $data12 != 7 then
return -1
endi
$res = 2 * $rowNum
if $data20 != $res then
return -1
endi
if $data21 != 2 then
return -1
endi
if $data22 != 8 then
return -1
endi
## desc
sql select count(*) from stb group by t2,t1 order by t2 desc slimit 5 soffset 0
if $rows != 5 then
sql select count(*),t2,t1 from stb partition by t2,t1 order by t2,t1 asc slimit 5 soffset 0
if $rows != 9 then
return -1
endi
$res = 2 * $rowNum
if $data00 != $res then
if $data00 != 300 then
return -1
endi
if $data01 != 2 then
if $data01 != 0 then
return -1
endi
if $data02 != 8 then
if $data02 != 0 then
return -1
endi
if $data10 != $rowNum then
if $data10 != 300 then
return -1
endi
if $data11 != 2 then
if $data11 != 0 then
return -1
endi
if $data12 != 7 then
if $data12 != 1 then
return -1
endi
if $data20 != $rowNum then
if $data20 != 300 then
return -1
endi
if $data21 != 2 then
if $data21 != 0 then
return -1
endi
if $data22 != 6 then
if $data22 != 2 then
return -1
endi
if $data30 != $rowNum then
if $data30 != 300 then
return -1
endi
if $data31 != 1 then
return -1
endi
if $data32 != 5 then
if $data32 != 3 then
return -1
endi
if $data40 != $rowNum then
if $data40 != 300 then
return -1
endi
if $data41 != 1 then
......@@ -97,87 +69,70 @@ if $data42 != 4 then
endi
### empty result set
#sql select count(*) from stb group by t2,t1 order by t2 asc slimit 0 soffset 0
#if $rows != 0 then
# return -1
#endi
#sql select count(*) from stb group by t2,t1 order by t2 asc slimit 5 soffset 10
#if $rows != 0 then
# return -1
#endi
#### group by t2 + slimit
sql select count(*) from stb group by t2 order by t2 asc slimit 2 soffset 0
if $rows != 2 then
sql select count(*) from stb partition by t2,t1 order by t2 asc slimit 0 soffset 0
if $rows != 9 then
return -1
endi
$res = 3 * $rowNum
if $data00 != $res then
return -1
endi
if $data10 != $res then
sql select count(*) from stb partition by t2,t1 order by t2 asc slimit 5 soffset 10
if $rows != 0 then
return -1
endi
if $data01 != 0 then
#### partition by t2 + slimit
sql select t2, count(*) from stb partition by t2 order by t2 asc slimit 2 soffset 0
if $rows != 3 then
return -1
endi
if $data11 != 1 then
if $data00 != 0 then
return -1
endi
sql select count(*) from stb group by t2 order by t2 desc slimit 2 soffset 0
if $rows != 2 then
if $data10 != 1 then
return -1
endi
$res = 4 * $rowNum
if $data00 != $res then
if $data20 != 2 then
return -1
endi
$res = 3 * $rowNum
if $data10 != $res then
if $data01 != 900 then
return -1
endi
if $data01 != 2 then
if $data11 != 900 then
return -1
endi
if $data11 != 1 then
if $data21 != 1200 then
return -1
endi
sql select count(*) from stb group by t2 order by t2 asc slimit 2 soffset 1
if $rows != 2 then
sql select t2, count(*) from stb partition by t2 order by t2 desc slimit 2 soffset 0
if $rows != 3 then
return -1
endi
$res = 3 * $rowNum
if $data00 != $res then
if $data00 != 2 then
return -1
endi
$res = 4 * $rowNum
if $data10 != $res then
if $data10 != 1 then
return -1
endi
if $data01 != 1 then
if $data20 != 0 then
return -1
endi
if $data11 != 2 then
if $data01 != 1200 then
return -1
endi
sql select count(*) from stb group by t2 order by t2 desc slimit 2 soffset 1
if $rows != 2 then
if $data11 != 900 then
return -1
endi
$res = 3 * $rowNum
if $data00 != $res then
if $data21 != 900 then
return -1
endi
if $data10 != $res then
return -1
endi
if $data01 != 1 then
sql select count(*) from stb partition by t2 order by t2 asc slimit 2 soffset 1
if $rows != 0 then
return -1
endi
if $data11 != 0 then
sql select count(*) from stb partition by t2 order by t2 desc slimit 2 soffset 1
if $rows != 0 then
return -1
endi
......@@ -81,16 +81,15 @@ while $i < 10
endw
sql select t1,t2,tg_added from tb0
if $rows != 1 then
if $rows != 300 then
return -1
endi
if $data02 != tb0 then
return -1
endi
sql reset query cache
sql select count(*), first(ts) from stb group by tg_added order by tg_added asc slimit 5 soffset 3
sql select count(*), first(ts), tg_added from stb partition by tg_added slimit 5 soffset 3
if $rows != 5 then
print ===== result: $rows
return -1
......@@ -110,59 +109,12 @@ endi
if $data40 != $rowNum then
return -1
endi
if $data02 != tb3 then
return -1
endi
if $data12 != tb4 then
return -1
endi
if $data22 != tb5 then
return -1
endi
if $data32 != tb6 then
return -1
endi
if $data42 != tb7 then
return -1
endi
sql alter table tb9 set tag t2 = 3
sql select count(*), first(*) from stb group by t2 order by t2 slimit 6 soffset 1
sql select count(*), first(*) from stb partition by t2 slimit 6 soffset 1
if $rows != 3 then
return -1
endi
$res = 3 * $rowNum
if $data00 != $res then
return -1
endi
#if $data01 != @18-09-17 09:00:00.000@ then
# return -1
#endi
if $data02 != 3 then
return -1
endi
if $data05 != 1 then
return -1
endi
$res = 3 * $rowNum
if $data10 != $res then
return -1
endi
#if $data11 != @18-09-17 09:00:00.000@ then
# return -1
#endi
if $data15 != 2 then
return -1
endi
if $data20 != $rowNum then
return -1
endi
if $data24 != 9.000000000 then
return -1
endi
if $data25 != 3 then
return -1
endi
print ================== restart server to commit data into disk
system sh/exec.sh -n dnode1 -s stop -x SIGINT
......@@ -171,7 +123,7 @@ print ================== server restart completed
sql use $db
### repeat above queries
sql select count(*), first(ts) from stb group by tg_added order by tg_added asc slimit 5 soffset 3;
sql select count(*), first(ts) from stb partition by tg_added slimit 5 soffset 3;
if $rows != 5 then
return -1
endi
......@@ -190,63 +142,10 @@ endi
if $data40 != $rowNum then
return -1
endi
if $data02 != tb3 then
return -1
endi
if $data12 != tb4 then
return -1
endi
if $data22 != tb5 then
return -1
endi
if $data32 != tb6 then
return -1
endi
if $data42 != tb7 then
return -1
endi
sql select count(*), first(*) from stb group by t2 order by t2 slimit 6 soffset 1
sql select count(*), first(*) from stb partition by t2 slimit 6 soffset 1
if $rows != 3 then
return -1
endi
$res = 3 * $rowNum
if $data00 != $res then
return -1
endi
#if $data01 != @18-09-17 09:00:00.000@ then
# return -1
#endi
if $data02 != 3 then
return -1
endi
if $data05 != 1 then
return -1
endi
$res = 3 * $rowNum
if $data10 != $res then
return -1
endi
#if $data11 != @18-09-17 09:00:00.000@ then
# return -1
#endi
if $data15 != 2 then
return -1
endi
if $data20 != $rowNum then
return -1
endi
if $data24 != 9.000000000 then
return -1
endi
if $data25 != 3 then
return -1
endi
#sql drop database $db
#sql show databases
#if $rows != 0 then
# return -1
#endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
......@@ -30,449 +30,108 @@ $tsu = $tsu + $ts0
#sql_error select top(c1, 1) from $stb where ts >= $ts0 and ts <= $tsu slimit 5 offset 1
#sql_error select bottom(c1, 1) from $stb where ts >= $ts0 and ts <= $tsu slimit 5 offset 1
### select from stb + group by + slimit offset
sql select max(c1), min(c2), avg(c3), sum(c4), spread(c5), sum(c6), count(c7), first(c8), last(c9) from $stb group by t1 slimit 5 soffset 0
if $rows != 5 then
### select from stb + partition by + slimit offset
sql select t1, max(c1), min(c2), avg(c3), sum(c4), spread(c5), sum(c6), count(c7), first(c8), last(c9) from $stb partition by t1
if $rows != 10 then
return -1
endi
if $data(slm_tb0)[1] != 9 then
return -1
endi
#if $data08 != NULL then
#if $data08 != 涛思nchar9 then
# return -1
#endi
$res = $tbPrefix . 0
if $data09 != $res then
if $data(slm_tb0)[1] != 9 then
return -1
endi
$res = $tbPrefix . 1
if $data19 != $res then
if $data(slm_tb0)[2] != 0 then
return -1
endi
$res = $tbPrefix . 4
if $data49 != $res then
if $data(slm_tb0)[3] != 4.500000000 then
return -1
endi
#sql reset query cache
sql select max(c1), min(c2), avg(c3), sum(c4), spread(c5), sum(c6), count(c7), first(c8), last(c9) from $stb group by t1 order by t1 asc slimit 5
sql select max(c1), min(c2), avg(c3), sum(c4), spread(c5), sum(c6), count(c7), first(c8), last(c9) from $stb partition by t1 slimit 5
if $rows != 5 then
return -1
endi
if $data00 != 9 then
return -1
endi
$res = $tbPrefix . 0
print res = $res
if $data09 != $res then
return -1
endi
$res = $tbPrefix . 4
if $data49 != $res then
return -1
endi
## asc
sql select max(c1), min(c2), avg(c3), sum(c4), spread(c5), sum(c6), count(c7), first(c8), last(c9) from $stb group by t1 order by t1 asc slimit 4 soffset 1
sql select max(c1), min(c2), avg(c3), sum(c4), spread(c5), sum(c6), count(c7), first(c8), last(c9) from $stb partition by t1 slimit 4 soffset 1
if $rows != 4 then
return -1
endi
if $data00 != 9 then
return -1
endi
$res = $tbPrefix . 1
if $data09 != $res then
return -1
endi
$res = $tbPrefix . 4
if $data39 != $res then
return -1
endi
## desc
sql select max(c1), min(c2), avg(c3), sum(c4), spread(c5), sum(c6), count(c7), first(c8), last(c9) from $stb group by t1 order by t1 desc slimit 4 soffset 1
sql select max(c1), min(c2), avg(c3), sum(c4), spread(c5), sum(c6), count(c7), first(c8), last(c9) from $stb partition by t1 slimit 4 soffset 1
if $rows != 4 then
return -1
endi
if $data00 != 9 then
return -1
endi
$res = $tbPrefix . 8
if $data09 != $res then
return -1
endi
$res = $tbPrefix . 5
if $data39 != $res then
return -1
endi
### limit + slimit
sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb group by t1 order by t1 asc slimit 4 soffset 1 limit 0
sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb partition by t1 slimit 4 soffset 1 limit 0
if $rows != 0 then
return -1
endi
sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb group by t1 order by t1 asc slimit 4 soffset 1 limit 2 offset 1
sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb partition by t1 slimit 4 soffset 1 limit 2 offset 1
if $rows != 0 then
return -1
endi
sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb group by t1,t2 order by t1 asc slimit 4 soffset 1 limit 1 offset 0
sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb partition by t1,t2 slimit 4 soffset 1 limit 1 offset 0
if $rows != 4 then
return -1
endi
if $data00 != 9 then
return -1
endi
$res = $tbPrefix . 1
if $data08 != $res then
return -1
endi
print data09 = $data09
if $data09 != 1 then
return -1
endi
$res = $tbPrefix . 4
if $data38 != $res then
return -1
endi
if $data39 != 4 then
return -1
endi
sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb group by t1,t2 order by t1 desc slimit 4 soffset 1 limit 1 offset 0
sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb partition by t1,t2 slimit 4 soffset 1 limit 1 offset 0
if $rows != 4 then
return -1
endi
$res = $tbPrefix . 8
if $data08 != $res then
return -1
endi
if $data09 != 8 then
return -1
endi
$res = $tbPrefix . 5
if $data38 != $res then
return -1
endi
if $data39 != 5 then
return -1
endi
sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 5 group by t1,t2,t3 order by t1 asc slimit 3 soffset 1 limit 1 offset 0
sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 5 partition by t1,t2,t3 slimit 3 soffset 1 limit 1 offset 0
if $rows != 3 then
return -1
endi
if $data00 != 9 then
return -1
endi
$res = $tbPrefix . 3
if $data08 != $res then
return -1
endi
if $data09 != 3 then
return -1
endi
$res = $tbPrefix . 4
if $data18 != $res then
return -1
endi
if $data19 != 4 then
return -1
endi
$res = $tbPrefix . 5
if $data28 != $res then
return -1
endi
if $data29 != 5 then
return -1
endi
### slimit + fill
sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 5 interval(5m) fill(value, -1, -2) group by t1 slimit 4 soffset 4 limit 0 offset 0
sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 5 partition by t1 interval(5m) fill(value, -1, -2) slimit 4 soffset 4 limit 0 offset 0
if $rows != 0 then
return -1
endi
sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 9 interval(5m) fill(value, -1, -2) group by t1 slimit 4 soffset 4 limit 2 offset 0
print select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 9 interval(5m) fill(value, -1, -2) group by t1 slimit 4 soffset 4 limit 2 offset 0
sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 9 partition by t1 interval(5m) fill(value, -1, -2) slimit 4 soffset 4 limit 2 offset 0
print select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 9 partition by t1 interval(5m) fill(value, -1, -2) slimit 4 soffset 4 limit 2 offset 0
print $rows $data00 $data01 $data02 $data03
if $rows != 8 then
return -1
endi
if $data00 != @18-09-17 09:00:00.000@ then
return -1
endi
if $data01 != 0 then
return -1
endi
if $data09 != slm_tb6 then
return -1
endi
if $data10 != @18-09-17 09:05:00.000@ then
return -1
endi
if $data11 != -1 then
return -1
endi
if $data12 != -2 then
return -1
endi
if $data13 != -2.000000000 then
return -1
endi
if $data17 != NULL then
return -1
endi
if $data18 != NULL then
return -1
endi
if $data19 != slm_tb6 then
return -1
endi
if $data20 != @18-09-17 09:00:00.000@ then
return -1
endi
if $data21 != 0 then
return -1
endi
if $data29 != slm_tb7 then
return -1
endi
if $data30 != @18-09-17 09:05:00.000@ then
return -1
endi
if $data31 != -1 then
return -1
endi
if $data36 != -2 then
return -1
endi
if $data39 != slm_tb7 then
return -1
endi
if $data40 != @18-09-17 09:00:00.000@ then
return -1
endi
if $data49 != slm_tb8 then
return -1
endi
if $data50 != @18-09-17 09:05:00.000@ then
return -1
endi
if $data59 != slm_tb8 then
return -1
endi
if $data69 != slm_tb9 then
return -1
endi
if $data79 != slm_tb9 then
return -1
endi
# desc
sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 9 interval(5m) fill(value, -1, -2) group by t1 order by t1 desc slimit 4 soffset 4 limit 2 offset 0
sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 9 partition by t1 interval(5m) fill(value, -1, -2) slimit 4 soffset 4 limit 2 offset 0
if $rows != 8 then
return -1
endi
if $data00 != @18-09-17 09:00:00.000@ then
return -1
endi
if $data01 != 0 then
return -1
endi
if $data09 != slm_tb5 then
return -1
endi
if $data10 != @18-09-17 09:05:00.000@ then
return -1
endi
if $data11 != -1 then
return -1
endi
if $data12 != -2 then
return -1
endi
if $data13 != -2.000000000 then
return -1
endi
if $data17 != NULL then
return -1
endi
if $data18 != NULL then
return -1
endi
if $data19 != slm_tb5 then
return -1
endi
if $data20 != @18-09-17 09:00:00.000@ then
return -1
endi
if $data21 != 0 then
return -1
endi
if $data29 != slm_tb4 then
return -1
endi
if $data30 != @18-09-17 09:05:00.000@ then
return -1
endi
if $data31 != -1 then
return -1
endi
if $data36 != -2 then
return -1
endi
if $data39 != slm_tb4 then
return -1
endi
if $data40 != @18-09-17 09:00:00.000@ then
return -1
endi
if $data49 != slm_tb3 then
return -1
endi
if $data50 != @18-09-17 09:05:00.000@ then
return -1
endi
if $data59 != slm_tb3 then
return -1
endi
if $data69 != slm_tb2 then
return -1
endi
if $data79 != slm_tb2 then
return -1
endi
sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 9 interval(5m) fill(value, -1, -2) group by t1 order by t1 asc slimit 4 soffset 4 limit 2 offset 598
sql select max(c1), min(c2), avg(c3), sum(c4), sum(c6), count(c7), first(c8), last(c9) from $stb where ts >= $ts0 and ts <= $tsu and t2 >= 2 and t3 <= 9 partition by t1 interval(5m) fill(value, -1, -2) slimit 4 soffset 4 limit 2 offset 598
if $rows != 4 then
return -1
endi
if $data00 != @18-09-19 10:50:00.000@ then
return -1
endi
if $data01 != 9 then
return -1
endi
if $data09 != slm_tb6 then
return -1
endi
if $data10 != @18-09-19 10:50:00.000@ then
return -1
endi
if $data12 != 9 then
return -1
endi
if $data13 != 9.000000000 then
return -1
endi
if $data19 != slm_tb7 then
return -1
endi
if $data20 != @18-09-19 10:50:00.000@ then
return -1
endi
if $data24 != 9.000000000 then
return -1
endi
if $data29 != slm_tb8 then
return -1
endi
if $data30 != @18-09-19 10:50:00.000@ then
return -1
endi
if $data35 != 9 then
return -1
endi
if $data36 != 1 then
return -1
endi
if $data37 != binary9 then
return -1
endi
if $data38 != 涛思nchar9 then
return -1
endi
if $data39 != slm_tb9 then
return -1
endi
sql select count(ts) from $stb group by t1,t2,t3,t4,t5,t6 order by t1 desc
sql select count(ts) from $stb partition by t1,t2,t3,t4,t5,t6 order by t1 desc
if $rows != $tbNum then
return -1
endi
$res = $rowNum + 1
if $data00 != $res then
return -1
endi
if $data90 != $res then
return -1
endi
if $data01 != slm_tb9 then
return -1
endi
if $data12 != 8 then
return -1
endi
if $data23 != 7 then
return -1
endi
if $data34 != 涛思slm_tb6 then
return -1
endi
if $data45 != 5.000000000 then
return -1
endi
if $data56 != 1 then
return -1
endi
$res = $rowNum + 1
if $data60 != $res then
return -1
endi
if $data71 != slm_tb2 then
return -1
endi
sql select count(c1) from $stb group by t1,t2,t3,t4,t5,t6 order by t1 desc
sql select count(c1) from $stb partition by t1,t2,t3,t4,t5,t6 order by t1 desc
if $rows != 10 then
return -1
endi
if $data00 != $rowNum then
return -1
endi
if $data90 != $rowNum then
return -1
endi
if $data01 != slm_tb9 then
return -1
endi
if $data12 != 8 then
return -1
endi
if $data23 != 7 then
return -1
endi
if $data34 != 涛思slm_tb6 then
return -1
endi
if $data45 != 5.000000000 then
return -1
endi
if $data56 != 1 then
return -1
endi
if $data60 != $rowNum then
return -1
endi
if $data71 != slm_tb2 then
return -1
endi
## [TBASE-604]
#sql_error select count(tbname) from slm_stb0 group by t1
#sql_error select count(tbname) from slm_stb0 partition by t1
#sql show databases
## [TBASE-605]
sql_error select * from slm_stb0 where t2 >= 2 and t3 <= 9 group by tbname slimit 40 limit 1;
sql select * from slm_stb0 where t2 >= 2 and t3 <= 9 partition by tbname slimit 40 limit 1;
##################################################
# slm_db1 is a database that contains the exactly the same
......@@ -482,6 +141,7 @@ $db = $dbPrefix . 1
sql use $db
###
sql reset query cache
sql select count(*) from $stb
if $rows != 1 then
return -1
......@@ -491,45 +151,42 @@ if $data00 != $totalNum then
endi
sql select count(c1) from $stb
if $rows != 0 then
print $data00
if $data00 != 0 then
return -1
endi
sql select count(ts) from $stb group by t1,t2,t3,t4,t5,t6 order by t1 asc
sql select t1,t2,t3,t4,t5,t6,count(ts) from $stb partition by t1,t2,t3,t4,t5,t6
if $rows != $tbNum then
return -1
endi
if $data00 != $rowNum then
return -1
endi
if $data90 != $rowNum then
return -1
endi
if $data01 != slm_tb0 then
if $data(slm_tb1)[6] != $rowNum then
return -1
endi
if $data12 != 1 then
if $data(slm_tb2)[6] != $rowNum then
return -1
endi
if $data23 != 2 then
if $data(slm_tb3)[0] != slm_tb3 then
return -1
endi
if $data34 != 涛思slm_tb3 then
if $data(slm_tb4)[1] != 4 then
return -1
endi
if $data45 != 4.000000000 then
if $data(slm_tb5)[2] != 5 then
return -1
endi
if $data56 != 1 then
if $data(slm_tb6)[3] != 涛思slm_tb6 then
return -1
endi
if $data60 != $rowNum then
if $data(slm_tb7)[4] != 7.000000000 then
return -1
endi
if $data71 != slm_tb7 then
if $data(slm_tb8)[5] != 1 then
return -1
endi
sql select count(ts) from $stb group by t1,t2,t3,t4,t5,t6 order by t1 desc
sql select count(ts),t1,t2,t3,t4,t5,t6 from $stb partition by t1,t2,t3,t4,t5,t6 order by t1 desc
if $rows != $tbNum then
return -1
endi
......@@ -564,8 +221,8 @@ if $data71 != slm_tb2 then
return -1
endi
sql select count(c1) from $stb group by t1,t2,t3,t4,t5,t6 order by t1 desc
if $rows != 0 then
sql select count(c1) from $stb partition by t1,t2,t3,t4,t5,t6 order by t1 desc
if $rows != 10 then
return -1
endi
......@@ -89,10 +89,4 @@ endi
#TODO: MOVE IT TO NORMAL CASE
sql_error select * from tb1 where not (null);
sql select sum(1/0) from tb1;
if $rows != 1 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
......@@ -50,7 +50,6 @@ sql select avg(tbcol) from tb1
sql select avg(tbcol) from tb1 where ts <= 1601481840000
sql select avg(tbcol) as b from tb1
sql select avg(tbcol) as b from tb1 interval(1d)
goto _OVER
sql select avg(tbcol) as b from tb1 where ts <= 1601481840000s interval(1m)
sql select avg(tbcol) as c from stb
sql select avg(tbcol) as c from stb where ts <= 1601481840000
......
......@@ -253,6 +253,9 @@ class TDTestCase:
tdSql.execute(f'alter table {self.stbname}_{tb_no} set tag {tag} = {values}')
tdSql.query(f'select {tag} from {self.stbname}_{tb_no}')
tdSql.checkData(0,0,values)
tdSql.execute(f'alter table {self.stbname}_{tb_no} set tag {tag} = null')
tdSql.query(f'select {tag} from {self.stbname}_{tb_no}')
tdSql.checkData(0,0,None)
def alter_check_stb(self):
tdSql.prepare()
tdSql.execute(self.setsql.set_create_stable_sql(self.stbname,self.column_dict,self.tag_dict))
......
......@@ -91,4 +91,6 @@ goto :eof
:CheckSkipCase
set skipCase=false
if "%*" == "python3 ./test.py -f 1-insert/insertWithMoreVgroup.py" ( set skipCase=true )
if "%*" == "python3 ./test.py -f 2-query/queryQnode.py" ( set skipCase=true )
echo %* | grep "\-R" && set skipCase=true
:goto eof
\ No newline at end of file
......@@ -328,7 +328,7 @@ if __name__ == "__main__":
conn = taos.connect(host,config=tdDnodes.getSimCfgPath())
else:
conn = taosrest.connect(url=f"http://{host}:6041")
tdLog.info(tdDnodes.getSimCfgPath(),host)
# tdLog.info(tdDnodes.getSimCfgPath(),host)
if createDnodeNums == 1:
createDnodeNums=dnodeNums
else:
......
Subproject commit 0b8a3373bb7548f8106d13e7d3b0a988d3c4d48a
Subproject commit 9cfa195713d1cae9edf417a8d49bde87dd971016
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册