[TD-225] fix bugs.
This commit is contained in:
parent
922497b3c2
commit
80323814b7
|
@ -41,7 +41,8 @@ int32_t tscHandleInsertRetry(SSqlObj* pSql);
|
|||
void tscBuildResFromSubqueries(SSqlObj *pSql);
|
||||
TAOS_ROW doSetResultRowData(SSqlObj *pSql);
|
||||
|
||||
char *getArithemicInputSrc(void *param, const char *name, int32_t colId);
|
||||
char *getArithmeticInputSrc(void *param, const char *name, int32_t colId);
|
||||
void doArithmeticCalculate(SQueryInfo* pQueryInfo, tFilePage* pOutput, int32_t rowSize, int32_t finalRowSize);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -30,8 +30,6 @@ typedef struct SCompareParam {
|
|||
int32_t groupOrderType;
|
||||
} SCompareParam;
|
||||
|
||||
static void doArithmeticCalculate(SQueryInfo* pQueryInfo, tFilePage* pOutput, int32_t rowSize, int32_t finalRowSize);
|
||||
|
||||
int32_t treeComparator(const void *pLeft, const void *pRight, void *param) {
|
||||
int32_t pLeftIdx = *(int32_t *)pLeft;
|
||||
int32_t pRightIdx = *(int32_t *)pRight;
|
||||
|
@ -1637,7 +1635,7 @@ void doArithmeticCalculate(SQueryInfo* pQueryInfo, tFilePage* pOutput, int32_t r
|
|||
// calculate the result from several other columns
|
||||
if (pSup->pArithExprInfo != NULL) {
|
||||
arithSup.pArithExpr = pSup->pArithExprInfo;
|
||||
tExprTreeCalcTraverse(arithSup.pArithExpr->pExpr, (int32_t) pOutput->num, pbuf + pOutput->num*offset, &arithSup, TSDB_ORDER_ASC, getArithemicInputSrc);
|
||||
tExprTreeCalcTraverse(arithSup.pArithExpr->pExpr, (int32_t) pOutput->num, pbuf + pOutput->num*offset, &arithSup, TSDB_ORDER_ASC, getArithmeticInputSrc);
|
||||
} else {
|
||||
SSqlExpr* pExpr = pSup->pSqlExpr;
|
||||
memcpy(pbuf + pOutput->num * offset, pExpr->offset * pOutput->num + pOutput->data, pExpr->resBytes * pOutput->num);
|
||||
|
|
|
@ -2187,11 +2187,25 @@ int tscProcessRetrieveRspFromNode(SSqlObj *pSql) {
|
|||
return pRes->code;
|
||||
}
|
||||
|
||||
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||
if (!UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo) || tscNonOrderedProjectionQueryOnSTable(pQueryInfo, 0) || pCmd->command == TSDB_SQL_RETRIEVE) {
|
||||
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||
if (pCmd->command == TSDB_SQL_RETRIEVE) {
|
||||
tscSetResRawPtr(pRes, pQueryInfo);
|
||||
} else if ((UTIL_TABLE_IS_CHILD_TABLE(pTableMetaInfo) || UTIL_TABLE_IS_NORMAL_TABLE(pTableMetaInfo)) && !TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_SUBQUERY)) {
|
||||
tscSetResRawPtr(pRes, pQueryInfo);
|
||||
} else if (tscNonOrderedProjectionQueryOnSTable(pQueryInfo, 0) && !TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_JOIN_QUERY) && !TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_JOIN_SEC_STAGE)) {
|
||||
tscSetResRawPtr(pRes, pQueryInfo);
|
||||
}
|
||||
|
||||
// if (TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_TAG_FILTER_QUERY)) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// if (tscNonOrderedProjectionQueryOnSTable(pQueryInfo, 0) && !TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_TAG_FILTER_QUERY) ||
|
||||
// ((!UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo) || pCmd->command == TSDB_SQL_RETRIEVE) &&
|
||||
// !(TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_SUBQUERY)))) {
|
||||
// tscSetResRawPtr(pRes, pQueryInfo);
|
||||
// }
|
||||
|
||||
if (pSql->pSubscription != NULL) {
|
||||
int32_t numOfCols = pQueryInfo->fieldsInfo.numOfOutput;
|
||||
|
||||
|
|
|
@ -787,6 +787,25 @@ void taos_stop_query(TAOS_RES *res) {
|
|||
tscDebug("%p query is cancelled", res);
|
||||
}
|
||||
|
||||
bool taos_is_null(TAOS_RES *res, int32_t row, int32_t col) {
|
||||
SSqlObj *pSql = (SSqlObj *)res;
|
||||
if (pSql == NULL || pSql->signature != pSql) {
|
||||
return true;
|
||||
}
|
||||
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0);
|
||||
if (pQueryInfo == NULL) {
|
||||
return true;
|
||||
}
|
||||
|
||||
SInternalField* pInfo = (SInternalField*)TARRAY_GET_ELEM(pQueryInfo->fieldsInfo.internalField, col);
|
||||
if (col < 0 || col >= tscNumOfFields(pQueryInfo) || row < 0 || row > pSql->res.numOfRows) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return isNull(pSql->res.urow[col] + row * pInfo->field.bytes, pInfo->field.type);
|
||||
}
|
||||
|
||||
int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields) {
|
||||
int len = 0;
|
||||
for (int i = 0; i < num_fields; ++i) {
|
||||
|
|
|
@ -2312,10 +2312,10 @@ static void doBuildResFromSubqueries(SSqlObj* pSql) {
|
|||
return;
|
||||
}
|
||||
|
||||
int32_t totalSize = tscGetResRowLength(pQueryInfo->exprList);
|
||||
int32_t rowSize = tscGetResRowLength(pQueryInfo->exprList);
|
||||
|
||||
assert(numOfRes * totalSize > 0);
|
||||
char* tmp = realloc(pRes->pRsp, numOfRes * totalSize);
|
||||
assert(numOfRes * rowSize > 0);
|
||||
char* tmp = realloc(pRes->pRsp, numOfRes * rowSize + sizeof(tFilePage));
|
||||
if (tmp == NULL) {
|
||||
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
return;
|
||||
|
@ -2323,9 +2323,12 @@ static void doBuildResFromSubqueries(SSqlObj* pSql) {
|
|||
pRes->pRsp = tmp;
|
||||
}
|
||||
|
||||
pRes->data = pRes->pRsp;
|
||||
tFilePage* pFilePage = (tFilePage*) pRes->pRsp;
|
||||
pFilePage->num = numOfRes;
|
||||
|
||||
pRes->data = pFilePage->data;
|
||||
char* data = pRes->data;
|
||||
|
||||
int16_t bytes = 0;
|
||||
|
||||
size_t numOfExprs = tscSqlExprNumOfExprs(pQueryInfo);
|
||||
|
@ -2352,6 +2355,17 @@ static void doBuildResFromSubqueries(SSqlObj* pSql) {
|
|||
|
||||
pRes->numOfRows = numOfRes;
|
||||
pRes->numOfClauseTotal += numOfRes;
|
||||
|
||||
int32_t finalRowSize = 0;
|
||||
for(int32_t i = 0; i < tscNumOfFields(pQueryInfo); ++i) {
|
||||
TAOS_FIELD* pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, i);
|
||||
finalRowSize += pField->bytes;
|
||||
}
|
||||
|
||||
doArithmeticCalculate(pQueryInfo, pFilePage, rowSize, finalRowSize);
|
||||
|
||||
pRes->data = pFilePage->data;
|
||||
tscSetResRawPtr(pRes, pQueryInfo);
|
||||
}
|
||||
|
||||
void tscBuildResFromSubqueries(SSqlObj *pSql) {
|
||||
|
@ -2364,13 +2378,12 @@ void tscBuildResFromSubqueries(SSqlObj *pSql) {
|
|||
|
||||
if (pRes->tsrow == NULL) {
|
||||
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, pSql->cmd.clauseIndex);
|
||||
pRes->numOfCols = (int16_t) tscSqlExprNumOfExprs(pQueryInfo);
|
||||
|
||||
size_t numOfExprs = tscSqlExprNumOfExprs(pQueryInfo);
|
||||
pRes->numOfCols = (int16_t)numOfExprs;
|
||||
|
||||
pRes->tsrow = calloc(numOfExprs, POINTER_BYTES);
|
||||
pRes->buffer = calloc(numOfExprs, POINTER_BYTES);
|
||||
pRes->length = calloc(numOfExprs, sizeof(int32_t));
|
||||
pRes->tsrow = calloc(pRes->numOfCols, POINTER_BYTES);
|
||||
pRes->urow = calloc(pRes->numOfCols, POINTER_BYTES);
|
||||
pRes->buffer = calloc(pRes->numOfCols, POINTER_BYTES);
|
||||
pRes->length = calloc(pRes->numOfCols, sizeof(int32_t));
|
||||
|
||||
if (pRes->tsrow == NULL || pRes->buffer == NULL || pRes->length == NULL) {
|
||||
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
|
@ -2414,7 +2427,7 @@ static UNUSED_FUNC void transferNcharData(SSqlObj *pSql, int32_t columnIndex, TA
|
|||
}
|
||||
}
|
||||
|
||||
char *getArithemicInputSrc(void *param, const char *name, int32_t colId) {
|
||||
char *getArithmeticInputSrc(void *param, const char *name, int32_t colId) {
|
||||
SArithmeticSupport *pSupport = (SArithmeticSupport *) param;
|
||||
|
||||
int32_t index = -1;
|
||||
|
|
|
@ -109,13 +109,14 @@ DLL_EXPORT TAOS_RES *taos_query(TAOS *taos, const char *sql);
|
|||
DLL_EXPORT TAOS_ROW taos_fetch_row(TAOS_RES *res);
|
||||
DLL_EXPORT int taos_result_precision(TAOS_RES *res); // get the time precision of result
|
||||
DLL_EXPORT void taos_free_result(TAOS_RES *res);
|
||||
DLL_EXPORT int taos_field_count(TAOS_RES *tres);
|
||||
DLL_EXPORT int taos_field_count(TAOS_RES *res);
|
||||
DLL_EXPORT int taos_num_fields(TAOS_RES *res);
|
||||
DLL_EXPORT int taos_affected_rows(TAOS_RES *res);
|
||||
DLL_EXPORT TAOS_FIELD *taos_fetch_fields(TAOS_RES *res);
|
||||
DLL_EXPORT int taos_select_db(TAOS *taos, const char *db);
|
||||
DLL_EXPORT int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields);
|
||||
DLL_EXPORT void taos_stop_query(TAOS_RES *res);
|
||||
DLL_EXPORT bool taos_is_null(TAOS_RES *res, int32_t row, int32_t col);
|
||||
|
||||
int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows);
|
||||
int taos_validate_sql(TAOS *taos, const char *sql);
|
||||
|
|
|
@ -360,9 +360,7 @@ endi
|
|||
sql select join_mt1.* from join_mt1
|
||||
|
||||
print $rows
|
||||
|
||||
$val = 2000
|
||||
if $rows != $val then
|
||||
if $rows != 2000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
|
|
@ -136,9 +136,8 @@ sql select join_mt0.ts, join_mt1.t1, join_mt0.t1, join_mt1.tbname, join_mt0.tbna
|
|||
#1970-01-01 08:01:40.790 | 10 | 945.000000000 | 90 | true | true | 0 |
|
||||
sql_error select count(join_mt0.c1), sum(join_mt1.c2), first(join_mt0.c5), last(join_mt1.c7), first(join_mt1.c7) from join_mt0, join_mt1 where join_mt0.t1=join_mt1.t1 and join_mt0.ts=join_mt1.ts interval(10a) group by join_mt0.t1 order by join_mt0.ts desc limit 20 offset 19;
|
||||
|
||||
|
||||
sql select count(join_mt0.c1), sum(join_mt0.c2)/count(*), avg(c2), first(join_mt0.c5), last(c7) from join_mt0 interval(10a) group by join_mt0.t1 order by join_mt0.ts desc;
|
||||
if $rows != 100 then
|
||||
if $rows != 300 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
@ -147,7 +146,7 @@ if $data00 != @70-01-01 08:01:40.990@ then
|
|||
return -1
|
||||
endi
|
||||
|
||||
if $data01 != 30 then
|
||||
if $data01 != 10 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
@ -168,7 +167,7 @@ if $data05 != 1 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
if $data06 != 2 then
|
||||
if $data06 != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
@ -177,7 +176,7 @@ if $data10 != @70-01-01 08:01:40.980@ then
|
|||
return -1
|
||||
endi
|
||||
|
||||
if $data11 != 30 then
|
||||
if $data11 != 10 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
@ -198,7 +197,7 @@ if $data15 != 1 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
if $data16 != 2 then
|
||||
if $data16 != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
|
|
@ -1,59 +1,59 @@
|
|||
#sleep 1000
|
||||
#run general/parser/alter.sim
|
||||
#sleep 1000
|
||||
#run general/parser/alter1.sim
|
||||
#sleep 1000
|
||||
#run general/parser/alter_stable.sim
|
||||
#sleep 1000
|
||||
#run general/parser/auto_create_tb.sim
|
||||
#sleep 1000
|
||||
#run general/parser/auto_create_tb_drop_tb.sim
|
||||
#sleep 1000
|
||||
#run general/parser/col_arithmetic_operation.sim
|
||||
#sleep 1000
|
||||
#run general/parser/columnValue.sim
|
||||
#sleep 1000
|
||||
#run general/parser/commit.sim
|
||||
#sleep 1000
|
||||
#run general/parser/create_db.sim
|
||||
#sleep 1000
|
||||
#run general/parser/create_mt.sim
|
||||
#sleep 1000
|
||||
#run general/parser/create_tb.sim
|
||||
#sleep 1000
|
||||
#run general/parser/dbtbnameValidate.sim
|
||||
#sleep 1000
|
||||
#run general/parser/fill.sim
|
||||
#sleep 1000
|
||||
#run general/parser/fill_stb.sim
|
||||
#sleep 1000
|
||||
##run general/parser/fill_us.sim #
|
||||
#sleep 1000
|
||||
#run general/parser/first_last.sim
|
||||
#sleep 1000
|
||||
#run general/parser/import_commit1.sim
|
||||
#sleep 1000
|
||||
#run general/parser/import_commit2.sim
|
||||
#sleep 1000
|
||||
#run general/parser/import_commit3.sim
|
||||
#sleep 1000
|
||||
##run general/parser/import_file.sim
|
||||
#sleep 1000
|
||||
#run general/parser/insert_tb.sim
|
||||
#sleep 1000
|
||||
#run general/parser/tags_dynamically_specifiy.sim
|
||||
#sleep 1000
|
||||
#run general/parser/interp.sim
|
||||
#sleep 1000
|
||||
#run general/parser/lastrow.sim
|
||||
#sleep 1000
|
||||
#run general/parser/limit.sim
|
||||
#sleep 1000
|
||||
#run general/parser/limit1.sim
|
||||
#sleep 1000
|
||||
#run general/parser/limit1_tblocks100.sim
|
||||
#sleep 1000
|
||||
#run general/parser/limit2.sim
|
||||
sleep 1000
|
||||
run general/parser/alter.sim
|
||||
sleep 1000
|
||||
run general/parser/alter1.sim
|
||||
sleep 1000
|
||||
run general/parser/alter_stable.sim
|
||||
sleep 1000
|
||||
run general/parser/auto_create_tb.sim
|
||||
sleep 1000
|
||||
run general/parser/auto_create_tb_drop_tb.sim
|
||||
sleep 1000
|
||||
run general/parser/col_arithmetic_operation.sim
|
||||
sleep 1000
|
||||
run general/parser/columnValue.sim
|
||||
sleep 1000
|
||||
run general/parser/commit.sim
|
||||
sleep 1000
|
||||
run general/parser/create_db.sim
|
||||
sleep 1000
|
||||
run general/parser/create_mt.sim
|
||||
sleep 1000
|
||||
run general/parser/create_tb.sim
|
||||
sleep 1000
|
||||
run general/parser/dbtbnameValidate.sim
|
||||
sleep 1000
|
||||
run general/parser/fill.sim
|
||||
sleep 1000
|
||||
run general/parser/fill_stb.sim
|
||||
sleep 1000
|
||||
#run general/parser/fill_us.sim #
|
||||
sleep 1000
|
||||
run general/parser/first_last.sim
|
||||
sleep 1000
|
||||
run general/parser/import_commit1.sim
|
||||
sleep 1000
|
||||
run general/parser/import_commit2.sim
|
||||
sleep 1000
|
||||
run general/parser/import_commit3.sim
|
||||
sleep 1000
|
||||
#run general/parser/import_file.sim
|
||||
sleep 1000
|
||||
run general/parser/insert_tb.sim
|
||||
sleep 1000
|
||||
run general/parser/tags_dynamically_specifiy.sim
|
||||
sleep 1000
|
||||
run general/parser/interp.sim
|
||||
sleep 1000
|
||||
run general/parser/lastrow.sim
|
||||
sleep 1000
|
||||
run general/parser/limit.sim
|
||||
sleep 1000
|
||||
run general/parser/limit1.sim
|
||||
sleep 1000
|
||||
run general/parser/limit1_tblocks100.sim
|
||||
sleep 1000
|
||||
run general/parser/limit2.sim
|
||||
sleep 1000
|
||||
run general/parser/mixed_blocks.sim
|
||||
sleep 1000
|
||||
|
|
Loading…
Reference in New Issue