[td-1478]
This commit is contained in:
parent
4f83e11354
commit
e7fa1ad0b3
|
@ -351,7 +351,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
case TSDB_SQL_DESCRIBE_TABLE: {
|
case TSDB_SQL_DESCRIBE_TABLE: {
|
||||||
SStrToken* pToken = &pInfo->pDCLInfo->a[0];
|
SStrToken* pToken = &pInfo->pDCLInfo->a[0];
|
||||||
const char* msg1 = "invalid table name";
|
const char* msg1 = "invalid table name";
|
||||||
const char* msg2 = "table name is too long";
|
const char* msg2 = "table name too long";
|
||||||
|
|
||||||
if (tscValidateName(pToken) != TSDB_CODE_SUCCESS) {
|
if (tscValidateName(pToken) != TSDB_CODE_SUCCESS) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
||||||
|
@ -410,7 +410,6 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
const char* msg3 = "name too long";
|
const char* msg3 = "name too long";
|
||||||
|
|
||||||
pCmd->command = pInfo->type;
|
pCmd->command = pInfo->type;
|
||||||
// tDCLSQL* pDCL = pInfo->pDCLInfo;
|
|
||||||
|
|
||||||
SUserInfo* pUser = &pInfo->pDCLInfo->user;
|
SUserInfo* pUser = &pInfo->pDCLInfo->user;
|
||||||
SStrToken* pName = &pUser->user;
|
SStrToken* pName = &pUser->user;
|
||||||
|
@ -773,7 +772,7 @@ int32_t parseSlidingClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQu
|
||||||
|
|
||||||
int32_t tscSetTableFullName(STableMetaInfo* pTableMetaInfo, SStrToken* pzTableName, SSqlObj* pSql) {
|
int32_t tscSetTableFullName(STableMetaInfo* pTableMetaInfo, SStrToken* pzTableName, SSqlObj* pSql) {
|
||||||
const char* msg1 = "name too long";
|
const char* msg1 = "name too long";
|
||||||
const char* msg2 = "current database name is invalid";
|
const char* msg2 = "current database or database name invalid";
|
||||||
|
|
||||||
SSqlCmd* pCmd = &pSql->cmd;
|
SSqlCmd* pCmd = &pSql->cmd;
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
|
@ -73,12 +73,11 @@ typedef struct SDiskbasedResultBuf {
|
||||||
bool comp; // compressed before flushed to disk
|
bool comp; // compressed before flushed to disk
|
||||||
int32_t nextPos; // next page flush position
|
int32_t nextPos; // next page flush position
|
||||||
|
|
||||||
const void* handle; // for debug purpose
|
const void* handle; // for debug purpose
|
||||||
SResultBufStatis statis;
|
SResultBufStatis statis;
|
||||||
} SDiskbasedResultBuf;
|
} SDiskbasedResultBuf;
|
||||||
|
|
||||||
#define DEFAULT_INTERN_BUF_PAGE_SIZE (4096L)
|
#define DEFAULT_INTERN_BUF_PAGE_SIZE (256L) // in bytes
|
||||||
#define DEFAULT_INMEM_BUF_PAGES 10
|
|
||||||
#define PAGE_INFO_INITIALIZER (SPageDiskInfo){-1, -1}
|
#define PAGE_INFO_INITIALIZER (SPageDiskInfo){-1, -1}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -39,7 +39,6 @@ static FORCE_INLINE SWindowResult *getWindowResult(SWindowResInfo *pWindowResInf
|
||||||
}
|
}
|
||||||
|
|
||||||
#define curTimeWindowIndex(_winres) ((_winres)->curIndex)
|
#define curTimeWindowIndex(_winres) ((_winres)->curIndex)
|
||||||
#define GET_TIMEWINDOW(_winresInfo, _win) (STimeWindow) {(_win)->skey, ((_win)->skey + (_winresInfo)->interval - 1)}
|
|
||||||
#define GET_ROW_PARAM_FOR_MULTIOUTPUT(_q, tbq, sq) (((tbq) && (!sq))? (_q)->pSelectExpr[1].base.arg->argValue.i64:1)
|
#define GET_ROW_PARAM_FOR_MULTIOUTPUT(_q, tbq, sq) (((tbq) && (!sq))? (_q)->pSelectExpr[1].base.arg->argValue.i64:1)
|
||||||
|
|
||||||
bool isWindowResClosed(SWindowResInfo *pWindowResInfo, int32_t slot);
|
bool isWindowResClosed(SWindowResInfo *pWindowResInfo, int32_t slot);
|
||||||
|
|
|
@ -187,7 +187,7 @@ static void setExecParams(SQuery *pQuery, SQLFunctionCtx *pCtx, void* inputData,
|
||||||
SDataStatis *pStatis, void *param, int32_t colIndex);
|
SDataStatis *pStatis, void *param, int32_t colIndex);
|
||||||
|
|
||||||
static void initCtxOutputBuf(SQueryRuntimeEnv *pRuntimeEnv);
|
static void initCtxOutputBuf(SQueryRuntimeEnv *pRuntimeEnv);
|
||||||
static void destroyTableQueryInfo(STableQueryInfo *pTableQueryInfo);
|
static void destroyTableQueryInfoImpl(STableQueryInfo *pTableQueryInfo);
|
||||||
static void resetCtxOutputBuf(SQueryRuntimeEnv *pRuntimeEnv);
|
static void resetCtxOutputBuf(SQueryRuntimeEnv *pRuntimeEnv);
|
||||||
static bool hasMainOutput(SQuery *pQuery);
|
static bool hasMainOutput(SQuery *pQuery);
|
||||||
static void buildTagQueryResult(SQInfo *pQInfo);
|
static void buildTagQueryResult(SQInfo *pQInfo);
|
||||||
|
@ -1983,8 +1983,7 @@ static void changeExecuteScanOrder(SQInfo *pQInfo, SQueryTableMsg* pQueryMsg, bo
|
||||||
// todo handle the case the the order irrelevant query type mixed up with order critical query type
|
// todo handle the case the the order irrelevant query type mixed up with order critical query type
|
||||||
// descending order query for last_row query
|
// descending order query for last_row query
|
||||||
if (isFirstLastRowQuery(pQuery)) {
|
if (isFirstLastRowQuery(pQuery)) {
|
||||||
qDebug("QInfo:%p scan order changed for last_row query, old:%d, new:%d", GET_QINFO_ADDR(pQuery),
|
qDebug("QInfo:%p scan order changed for last_row query, old:%d, new:%d", pQInfo, pQuery->order.order, TSDB_ORDER_ASC);
|
||||||
pQuery->order.order, TSDB_ORDER_ASC);
|
|
||||||
|
|
||||||
pQuery->order.order = TSDB_ORDER_ASC;
|
pQuery->order.order = TSDB_ORDER_ASC;
|
||||||
if (pQuery->window.skey > pQuery->window.ekey) {
|
if (pQuery->window.skey > pQuery->window.ekey) {
|
||||||
|
@ -2086,13 +2085,14 @@ static int32_t getInitialPageNum(SQInfo *pQInfo) {
|
||||||
|
|
||||||
static void getIntermediateBufInfo(SQueryRuntimeEnv* pRuntimeEnv, int32_t* ps, int32_t* rowsize) {
|
static void getIntermediateBufInfo(SQueryRuntimeEnv* pRuntimeEnv, int32_t* ps, int32_t* rowsize) {
|
||||||
SQuery* pQuery = pRuntimeEnv->pQuery;
|
SQuery* pQuery = pRuntimeEnv->pQuery;
|
||||||
|
int32_t MIN_ROWS_PER_PAGE = 4;
|
||||||
|
|
||||||
*rowsize = (int32_t)(pQuery->rowSize * GET_ROW_PARAM_FOR_MULTIOUTPUT(pQuery, pRuntimeEnv->topBotQuery, pRuntimeEnv->stableQuery));
|
*rowsize = (int32_t)(pQuery->rowSize * GET_ROW_PARAM_FOR_MULTIOUTPUT(pQuery, pRuntimeEnv->topBotQuery, pRuntimeEnv->stableQuery));
|
||||||
int32_t overhead = sizeof(tFilePage);
|
int32_t overhead = sizeof(tFilePage);
|
||||||
|
|
||||||
// one page contains at least two rows
|
// one page contains at least two rows
|
||||||
*ps = DEFAULT_INTERN_BUF_PAGE_SIZE;
|
*ps = DEFAULT_INTERN_BUF_PAGE_SIZE;
|
||||||
while(((*rowsize) * 2) > (*ps) - overhead) {
|
while(((*rowsize) * MIN_ROWS_PER_PAGE) > (*ps) - overhead) {
|
||||||
*ps = (*ps << 1u);
|
*ps = (*ps << 1u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3715,7 +3715,7 @@ static STableQueryInfo *createTableQueryInfo(SQueryRuntimeEnv *pRuntimeEnv, void
|
||||||
return pTableQueryInfo;
|
return pTableQueryInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroyTableQueryInfo(STableQueryInfo *pTableQueryInfo) {
|
void destroyTableQueryInfoImpl(STableQueryInfo *pTableQueryInfo) {
|
||||||
if (pTableQueryInfo == NULL) {
|
if (pTableQueryInfo == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4391,6 +4391,8 @@ static bool skipTimeInterval(SQueryRuntimeEnv *pRuntimeEnv, TSKEY* start) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void doDestroyTableQueryInfo(STableGroupInfo* pTableqinfoGroupInfo);
|
||||||
|
|
||||||
static int32_t setupQueryHandle(void* tsdb, SQInfo* pQInfo, bool isSTableQuery) {
|
static int32_t setupQueryHandle(void* tsdb, SQInfo* pQInfo, bool isSTableQuery) {
|
||||||
SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv;
|
SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv;
|
||||||
SQuery *pQuery = pQInfo->runtimeEnv.pQuery;
|
SQuery *pQuery = pQInfo->runtimeEnv.pQuery;
|
||||||
|
@ -4430,16 +4432,20 @@ static int32_t setupQueryHandle(void* tsdb, SQInfo* pQInfo, bool isSTableQuery)
|
||||||
// update the query time window
|
// update the query time window
|
||||||
pQuery->window = cond.twindow;
|
pQuery->window = cond.twindow;
|
||||||
|
|
||||||
size_t numOfGroups = GET_NUM_OF_TABLEGROUP(pQInfo);
|
if (pQInfo->tableGroupInfo.numOfTables == 0) {
|
||||||
for(int32_t i = 0; i < numOfGroups; ++i) {
|
doDestroyTableQueryInfo(&pQInfo->tableqinfoGroupInfo);
|
||||||
SArray *group = GET_TABLEGROUP(pQInfo, i);
|
} else {
|
||||||
|
size_t numOfGroups = GET_NUM_OF_TABLEGROUP(pQInfo);
|
||||||
|
for(int32_t i = 0; i < numOfGroups; ++i) {
|
||||||
|
SArray *group = GET_TABLEGROUP(pQInfo, i);
|
||||||
|
|
||||||
size_t t = taosArrayGetSize(group);
|
size_t t = taosArrayGetSize(group);
|
||||||
for (int32_t j = 0; j < t; ++j) {
|
for (int32_t j = 0; j < t; ++j) {
|
||||||
STableQueryInfo *pCheckInfo = taosArrayGetP(group, j);
|
STableQueryInfo *pCheckInfo = taosArrayGetP(group, j);
|
||||||
|
|
||||||
pCheckInfo->win = pQuery->window;
|
pCheckInfo->win = pQuery->window;
|
||||||
pCheckInfo->lastKey = pCheckInfo->win.skey;
|
pCheckInfo->lastKey = pCheckInfo->win.skey;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (isPointInterpoQuery(pQuery)) {
|
} else if (isPointInterpoQuery(pQuery)) {
|
||||||
|
@ -6324,17 +6330,43 @@ _error:
|
||||||
}
|
}
|
||||||
|
|
||||||
static void freeColumnFilterInfo(SColumnFilterInfo* pFilter, int32_t numOfFilters) {
|
static void freeColumnFilterInfo(SColumnFilterInfo* pFilter, int32_t numOfFilters) {
|
||||||
if (pFilter == NULL) {
|
if (pFilter == NULL || numOfFilters == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfFilters; i++) {
|
for (int32_t i = 0; i < numOfFilters; i++) {
|
||||||
if (pFilter[i].filterstr) {
|
if (pFilter[i].filterstr) {
|
||||||
free((void*)(pFilter[i].pz));
|
free((void*)(pFilter[i].pz));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(pFilter);
|
free(pFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void doDestroyTableQueryInfo(STableGroupInfo* pTableqinfoGroupInfo) {
|
||||||
|
if (pTableqinfoGroupInfo->pGroupList != NULL) {
|
||||||
|
int32_t numOfGroups = taosArrayGetSize(pTableqinfoGroupInfo->pGroupList);
|
||||||
|
for (int32_t i = 0; i < numOfGroups; ++i) {
|
||||||
|
SArray *p = taosArrayGetP(pTableqinfoGroupInfo->pGroupList, i);
|
||||||
|
|
||||||
|
size_t num = taosArrayGetSize(p);
|
||||||
|
for(int32_t j = 0; j < num; ++j) {
|
||||||
|
STableQueryInfo* item = taosArrayGetP(p, j);
|
||||||
|
destroyTableQueryInfoImpl(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayDestroy(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayDestroy(pTableqinfoGroupInfo->pGroupList);
|
||||||
|
taosHashCleanup(pTableqinfoGroupInfo->map);
|
||||||
|
|
||||||
|
pTableqinfoGroupInfo->pGroupList = NULL;
|
||||||
|
pTableqinfoGroupInfo->map = NULL;
|
||||||
|
pTableqinfoGroupInfo->numOfTables = 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void freeQInfo(SQInfo *pQInfo) {
|
static void freeQInfo(SQInfo *pQInfo) {
|
||||||
if (!isValidQInfo(pQInfo)) {
|
if (!isValidQInfo(pQInfo)) {
|
||||||
return;
|
return;
|
||||||
|
@ -6395,25 +6427,9 @@ static void freeQInfo(SQInfo *pQInfo) {
|
||||||
taosTFree(pQuery);
|
taosTFree(pQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo refactor, extract method to destroytableDataInfo
|
doDestroyTableQueryInfo(&pQInfo->tableqinfoGroupInfo);
|
||||||
if (pQInfo->tableqinfoGroupInfo.pGroupList != NULL) {
|
|
||||||
int32_t numOfGroups = (int32_t)(GET_NUM_OF_TABLEGROUP(pQInfo));
|
|
||||||
for (int32_t i = 0; i < numOfGroups; ++i) {
|
|
||||||
SArray *p = GET_TABLEGROUP(pQInfo, i);
|
|
||||||
|
|
||||||
size_t num = taosArrayGetSize(p);
|
|
||||||
for(int32_t j = 0; j < num; ++j) {
|
|
||||||
STableQueryInfo* item = taosArrayGetP(p, j);
|
|
||||||
destroyTableQueryInfo(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
taosArrayDestroy(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
taosTFree(pQInfo->pBuf);
|
taosTFree(pQInfo->pBuf);
|
||||||
taosArrayDestroy(pQInfo->tableqinfoGroupInfo.pGroupList);
|
|
||||||
taosHashCleanup(pQInfo->tableqinfoGroupInfo.map);
|
|
||||||
tsdbDestroyTableGroup(&pQInfo->tableGroupInfo);
|
tsdbDestroyTableGroup(&pQInfo->tableGroupInfo);
|
||||||
taosArrayDestroy(pQInfo->arrTableIdInfo);
|
taosArrayDestroy(pQInfo->arrTableIdInfo);
|
||||||
|
|
||||||
|
|
|
@ -2707,4 +2707,5 @@ void tsdbDestroyTableGroup(STableGroupInfo *pGroupList) {
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(pGroupList->pGroupList);
|
taosArrayDestroy(pGroupList->pGroupList);
|
||||||
|
pGroupList->numOfTables = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,4 +218,10 @@ endi
|
||||||
if $data04 != 123.981000000 then
|
if $data04 != 123.981000000 then
|
||||||
print expect 123.981000000, actual: $data04
|
print expect 123.981000000, actual: $data04
|
||||||
return -1
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql create table tu(ts timestamp, k int)
|
||||||
|
sql select last_row(*) from tu
|
||||||
|
if $row != 0 then
|
||||||
|
return -1
|
||||||
endi
|
endi
|
Loading…
Reference in New Issue