[td-3299]
This commit is contained in:
parent
77d95c2762
commit
c36a71e8eb
|
@ -36,6 +36,9 @@ extern "C" {
|
|||
#define UTIL_TABLE_IS_NORMAL_TABLE(metaInfo)\
|
||||
(!(UTIL_TABLE_IS_SUPER_TABLE(metaInfo) || UTIL_TABLE_IS_CHILD_TABLE(metaInfo)))
|
||||
|
||||
#define UTIL_TABLE_IS_TMP_TABLE(metaInfo) \
|
||||
(((metaInfo)->pTableMeta != NULL) && ((metaInfo)->pTableMeta->tableType == TSDB_TEMP_TABLE))
|
||||
|
||||
#pragma pack(push,1)
|
||||
// this struct is transfered as binary, padding two bytes to avoid
|
||||
// an 'uid' whose low bytes is 0xff being recoginized as NULL,
|
||||
|
|
|
@ -1859,7 +1859,9 @@ int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t
|
|||
|
||||
// add the primary timestamp column even though it is not required by user
|
||||
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, index.tableIndex);
|
||||
tscInsertPrimaryTsSourceColumn(pQueryInfo, pTableMetaInfo->pTableMeta->id.uid);
|
||||
if (!UTIL_TABLE_IS_TMP_TABLE(pTableMetaInfo)) {
|
||||
tscInsertPrimaryTsSourceColumn(pQueryInfo, pTableMetaInfo->pTableMeta->id.uid);
|
||||
}
|
||||
} else {
|
||||
return TSDB_CODE_TSC_INVALID_SQL;
|
||||
}
|
||||
|
@ -7221,6 +7223,23 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf
|
|||
return TSDB_CODE_TSC_INVALID_SQL;
|
||||
}
|
||||
|
||||
// all columns are added into the table column list
|
||||
for(int32_t i = 0; i < pTableMeta->tableInfo.numOfColumns; ++i) {
|
||||
tscColumnListInsert(current->colList, i, pTableMetaInfo1->pTableMeta->id.uid,
|
||||
&pTableMetaInfo1->pTableMeta->schema[i]);
|
||||
}
|
||||
|
||||
if (pSqlNode->pWhere != NULL) {
|
||||
if (validateWhereNode(current, &pSqlNode->pWhere, pSql) != TSDB_CODE_SUCCESS) {
|
||||
return TSDB_CODE_TSC_INVALID_SQL;
|
||||
}
|
||||
|
||||
pSqlNode->pWhere = NULL;
|
||||
if (pTableMeta->tableInfo.precision == TSDB_TIME_PRECISION_MILLI) {
|
||||
current->window.skey = current->window.skey / 1000;
|
||||
current->window.ekey = current->window.ekey / 1000;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
pQueryInfo->command = TSDB_SQL_SELECT;
|
||||
|
||||
|
|
|
@ -378,6 +378,10 @@ int taos_num_fields(TAOS_RES *res) {
|
|||
return num;
|
||||
}
|
||||
|
||||
while(pQueryInfo->pDownstream != NULL) {
|
||||
pQueryInfo = pQueryInfo->pDownstream;
|
||||
}
|
||||
|
||||
size_t numOfCols = tscNumOfFields(pQueryInfo);
|
||||
for(int32_t i = 0; i < numOfCols; ++i) {
|
||||
SInternalField* pInfo = taosArrayGet(pQueryInfo->fieldsInfo.internalField, i);
|
||||
|
|
|
@ -3580,6 +3580,8 @@ void* createQueryInfoFromQueryNode(SQueryInfo* pQueryInfo, SExprInfo* pExprs, ST
|
|||
|
||||
tfree(pExprs);
|
||||
|
||||
createFilterInfo(pQueryAttr, 0);
|
||||
|
||||
SArray* pa = NULL;
|
||||
if (stage == MASTER_SCAN) {
|
||||
pa = createExecOperatorPlan(pQueryAttr);
|
||||
|
|
|
@ -479,9 +479,9 @@ void tscClearInterpInfo(SQueryInfo* pQueryInfo) {
|
|||
}
|
||||
|
||||
int32_t tscCreateResPointerInfo(SSqlRes* pRes, SQueryInfo* pQueryInfo) {
|
||||
if (pRes->tsrow == NULL) {
|
||||
pRes->numOfCols = pQueryInfo->fieldsInfo.numOfOutput;
|
||||
pRes->numOfCols = pQueryInfo->fieldsInfo.numOfOutput;
|
||||
|
||||
if (pRes->tsrow == NULL) {
|
||||
pRes->tsrow = calloc(pRes->numOfCols, POINTER_BYTES);
|
||||
pRes->urow = calloc(pRes->numOfCols, POINTER_BYTES);
|
||||
pRes->length = calloc(pRes->numOfCols, sizeof(int32_t));
|
||||
|
@ -704,8 +704,7 @@ SOperatorInfo* createDummyInputOperator(char* pResult, SSchema* pSchema, int32_t
|
|||
assert(numOfCols > 0);
|
||||
SDummyInputInfo* pInfo = calloc(1, sizeof(SDummyInputInfo));
|
||||
|
||||
pInfo->pRes = (SSqlRes*) pResult;
|
||||
|
||||
pInfo->pRes = (SSqlRes*) pResult;
|
||||
pInfo->block = calloc(numOfCols, sizeof(SSDataBlock));
|
||||
pInfo->block->info.numOfCols = numOfCols;
|
||||
|
||||
|
|
|
@ -543,6 +543,7 @@ SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SGroupbyExpr *pGroupbyExpr, S
|
|||
int32_t initQInfo(STsBufInfo* pTsBufInfo, void* tsdb, void* sourceOptr, SQInfo* pQInfo, SQueryParam* param, char* start,
|
||||
int32_t prevResultLen, void* merger);
|
||||
|
||||
int32_t createFilterInfo(SQueryAttr* pQueryAttr, uint64_t qId);
|
||||
void freeColumnFilterInfo(SColumnFilterInfo* pFilter, int32_t numOfFilters);
|
||||
|
||||
STableQueryInfo *createTableQueryInfo(SQueryAttr* pQueryAttr, void* pTable, bool groupbyColumn, STimeWindow win, void* buf);
|
||||
|
|
|
@ -1748,7 +1748,7 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int32_t numOf
|
|||
SOperatorInfo* prev = pRuntimeEnv->proot;
|
||||
if (i == 0) {
|
||||
pRuntimeEnv->proot = createArithOperatorInfo(pRuntimeEnv, prev, pQueryAttr->pExpr1, pQueryAttr->numOfOutput);
|
||||
if (pRuntimeEnv->proot != NULL && pRuntimeEnv->proot->operatorType != OP_DummyInput) { // TODO refactor
|
||||
if (pRuntimeEnv->proot != NULL && prev->operatorType != OP_DummyInput) { // TODO refactor
|
||||
setTableScanFilterOperatorInfo(prev->info, pRuntimeEnv->proot);
|
||||
}
|
||||
} else {
|
||||
|
@ -1765,12 +1765,12 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int32_t numOf
|
|||
}
|
||||
|
||||
case OP_Filter: { // todo refactor
|
||||
assert(pQueryAttr->havingNum > 0);
|
||||
if (pQueryAttr->stableQuery) {
|
||||
pRuntimeEnv->proot = createFilterOperatorInfo(pRuntimeEnv, pRuntimeEnv->proot, pQueryAttr->pExpr3, pQueryAttr->numOfExpr3);
|
||||
} else {
|
||||
pRuntimeEnv->proot = createFilterOperatorInfo(pRuntimeEnv, pRuntimeEnv->proot, pQueryAttr->pExpr1, pQueryAttr->numOfOutput);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -4141,12 +4141,12 @@ static void doCloseAllTimeWindow(SQueryRuntimeEnv* pRuntimeEnv) {
|
|||
}
|
||||
|
||||
static SSDataBlock* doTableScanImpl(void* param, bool* newgroup) {
|
||||
SOperatorInfo* pOperator = (SOperatorInfo*) param;
|
||||
SOperatorInfo *pOperator = (SOperatorInfo*) param;
|
||||
|
||||
STableScanInfo* pTableScanInfo = pOperator->info;
|
||||
SSDataBlock* pBlock = &pTableScanInfo->block;
|
||||
STableScanInfo *pTableScanInfo = pOperator->info;
|
||||
SSDataBlock *pBlock = &pTableScanInfo->block;
|
||||
SQueryRuntimeEnv *pRuntimeEnv = pOperator->pRuntimeEnv;
|
||||
SQueryAttr* pQueryAttr = pRuntimeEnv->pQueryAttr;
|
||||
SQueryAttr *pQueryAttr = pRuntimeEnv->pQueryAttr;
|
||||
STableGroupInfo *pTableGroupInfo = &pOperator->pRuntimeEnv->tableqinfoGroupInfo;
|
||||
|
||||
*newgroup = false;
|
||||
|
@ -5410,7 +5410,7 @@ SOperatorInfo* createArithOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorI
|
|||
}
|
||||
|
||||
SOperatorInfo* createFilterOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorInfo* upstream, SExprInfo* pExpr,
|
||||
int32_t numOfOutput) {
|
||||
int32_t numOfOutput) {
|
||||
SFilterOperatorInfo* pInfo = calloc(1, sizeof(SFilterOperatorInfo));
|
||||
|
||||
{
|
||||
|
@ -5444,7 +5444,7 @@ SOperatorInfo* createFilterOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperator
|
|||
|
||||
SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo));
|
||||
|
||||
pOperator->name = "ConditionOperator";
|
||||
pOperator->name = "FilterOperator";
|
||||
pOperator->operatorType = OP_Filter;
|
||||
pOperator->blockingOptr = false;
|
||||
pOperator->status = OP_IN_EXECUTING;
|
||||
|
@ -6685,7 +6685,7 @@ void* doDestroyFilterInfo(SSingleColumnFilterInfo* pFilterInfo, int32_t numOfFil
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static int32_t createFilterInfo(SQueryAttr* pQueryAttr, uint64_t qId) {
|
||||
int32_t createFilterInfo(SQueryAttr* pQueryAttr, uint64_t qId) {
|
||||
for (int32_t i = 0; i < pQueryAttr->numOfCols; ++i) {
|
||||
if (pQueryAttr->tableCols[i].flist.numOfFilters > 0) {
|
||||
pQueryAttr->numOfFilterCols++;
|
||||
|
|
Loading…
Reference in New Issue