add the union support in sql parser: refactor some codes. #1032. [TBASE-1140]
This commit is contained in:
parent
82706e1b41
commit
3cc8eb0917
|
@ -252,7 +252,6 @@ typedef struct {
|
||||||
uint32_t allocSize;
|
uint32_t allocSize;
|
||||||
char * payload;
|
char * payload;
|
||||||
int payloadLen;
|
int payloadLen;
|
||||||
int64_t globalLimit;
|
|
||||||
SQueryInfo **pQueryInfo;
|
SQueryInfo **pQueryInfo;
|
||||||
int32_t numOfClause;
|
int32_t numOfClause;
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,7 @@ static void tscProcessAsyncFetchRowsProxy(void *param, TAOS_RES *tres, int numOf
|
||||||
|
|
||||||
// local reducer has handle this situation during super table non-projection query.
|
// local reducer has handle this situation during super table non-projection query.
|
||||||
if (pCmd->command != TSDB_SQL_RETRIEVE_METRIC) {
|
if (pCmd->command != TSDB_SQL_RETRIEVE_METRIC) {
|
||||||
pRes->numOfTotal += pRes->numOfRows;
|
pRes->numOfTotalInCurrentClause += pRes->numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
(*pSql->fetchFp)(param, tres, numOfRows);
|
(*pSql->fetchFp)(param, tres, numOfRows);
|
||||||
|
|
|
@ -521,11 +521,6 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
pCmd->command = pQueryInfo1->command;
|
pCmd->command = pQueryInfo1->command;
|
||||||
|
|
||||||
// if there is only one element, the limit of clause is the limit of global result.
|
// if there is only one element, the limit of clause is the limit of global result.
|
||||||
if (pCmd->numOfClause == 1) {
|
|
||||||
pCmd->globalLimit = pQueryInfo1->clauseLimit;
|
|
||||||
} else { // check the output fields information, column name and column type
|
|
||||||
pCmd->globalLimit = -1;
|
|
||||||
|
|
||||||
for(int32_t i = 1; i < pCmd->numOfClause; ++i) {
|
for(int32_t i = 1; i < pCmd->numOfClause; ++i) {
|
||||||
SQueryInfo* pQueryInfo2 = tscGetQueryInfoDetail(pCmd, i);
|
SQueryInfo* pQueryInfo2 = tscGetQueryInfoDetail(pCmd, i);
|
||||||
|
|
||||||
|
@ -534,7 +529,6 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS; // do not build query message here
|
return TSDB_CODE_SUCCESS; // do not build query message here
|
||||||
}
|
}
|
||||||
|
|
|
@ -543,12 +543,12 @@ static void **tscBuildResFromSubqueries(SSqlObj *pSql) {
|
||||||
pRes->numOfTotalInCurrentClause++;
|
pRes->numOfTotalInCurrentClause++;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
} else { // continue retrieve data from vnode
|
} else {// continue retrieve data from vnode
|
||||||
if (!tscHashRemainDataInSubqueryResultSet(pSql)) { // free all sub sqlobj
|
if (!tscHashRemainDataInSubqueryResultSet(pSql)) {
|
||||||
tscTrace("%p at least one subquery exhausted, free all other %d subqueries", pSql, pSql->numOfSubs - 1);
|
tscTrace("%p at least one subquery exhausted, free all other %d subqueries", pSql, pSql->numOfSubs - 1);
|
||||||
|
|
||||||
SSubqueryState *pState = NULL;
|
SSubqueryState *pState = NULL;
|
||||||
|
|
||||||
|
// free all sub sqlobj
|
||||||
for (int32_t i = 0; i < pSql->numOfSubs; ++i) {
|
for (int32_t i = 0; i < pSql->numOfSubs; ++i) {
|
||||||
SSqlObj *pChildObj = pSql->pSubs[i];
|
SSqlObj *pChildObj = pSql->pSubs[i];
|
||||||
if (pChildObj == NULL) {
|
if (pChildObj == NULL) {
|
||||||
|
@ -716,7 +716,7 @@ int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int taos_select_db(TAOS *taos, const char *db) {
|
int taos_select_db(TAOS *taos, const char *db) {
|
||||||
char sql[64];
|
char sql[256] = {0};
|
||||||
|
|
||||||
STscObj *pObj = (STscObj *)taos;
|
STscObj *pObj = (STscObj *)taos;
|
||||||
if (pObj == NULL || pObj->signature != pObj) {
|
if (pObj == NULL || pObj->signature != pObj) {
|
||||||
|
@ -724,8 +724,7 @@ int taos_select_db(TAOS *taos, const char *db) {
|
||||||
return TSDB_CODE_DISCONNECTED;
|
return TSDB_CODE_DISCONNECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(sql, "use %s", db);
|
snprintf(sql, tListLen(sql), "use %s", db);
|
||||||
|
|
||||||
return taos_query(taos, sql);
|
return taos_query(taos, sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2057,12 +2057,15 @@ void tscTryQueryNextVnode(SSqlObj *pSql, __async_cb_func_t fp) {
|
||||||
|
|
||||||
// in case of async query, set the callback function
|
// in case of async query, set the callback function
|
||||||
void* fp1 = pSql->fp;
|
void* fp1 = pSql->fp;
|
||||||
|
pSql->fp = fp;
|
||||||
|
|
||||||
if (fp1 != NULL) {
|
if (fp1 != NULL) {
|
||||||
assert(fp != NULL);
|
assert(fp != NULL);
|
||||||
pSql->fp = fp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ret = tscProcessSql(pSql); // todo check for failure
|
int32_t ret = tscProcessSql(pSql); // todo check for failure
|
||||||
|
|
||||||
|
// in case of async query, return now
|
||||||
if (fp != NULL) {
|
if (fp != NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue