[td-10564] Refactor.
This commit is contained in:
parent
52f952f97c
commit
b7f8ee3721
|
@ -2652,19 +2652,19 @@ static int32_t validateScalarFunctionParamNum(tSqlExpr* pSqlExpr, int32_t functi
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t doAddProjectCol(SQueryStmtInfo* pQueryInfo, int32_t outputColIndex, SSchema* pSchema, const char* aliasName,
|
int32_t doAddOneProjectCol(SQueryStmtInfo* pQueryInfo, int32_t outputColIndex, SSchema* pSchema, const char* aliasName,
|
||||||
int32_t colId, SMsgBuf* pMsgBuf) {
|
int32_t colId, SMsgBuf* pMsgBuf) {
|
||||||
const char* name = (aliasName == NULL)? pSchema->name:aliasName;
|
const char* name = (aliasName == NULL)? pSchema->name:aliasName;
|
||||||
SSchema s = createSchema(pSchema->type, pSchema->bytes, colId, name);
|
SSchema s = createSchema(pSchema->type, pSchema->bytes, colId, name);
|
||||||
|
|
||||||
tExprNode *pNode = NULL;
|
tExprNode *pNode = NULL;
|
||||||
bool keepTableCols = true;
|
bool keepTableCols = true;
|
||||||
|
|
||||||
SArray* pColumnList = taosArrayInit(4, sizeof(SColumn));
|
SArray* pColumnList = taosArrayInit(4, sizeof(SColumn));
|
||||||
|
SToken colNameToken = {.z = pSchema->name, .n = strlen(pSchema->name)};
|
||||||
|
|
||||||
tSqlExpr sqlNode = {0};
|
tSqlExpr sqlNode = {0};
|
||||||
sqlNode.type = SQL_NODE_TABLE_COLUMN;
|
sqlNode.type = SQL_NODE_TABLE_COLUMN;
|
||||||
|
|
||||||
SToken colNameToken = {.z = pSchema->name, .n = strlen(pSchema->name)};
|
|
||||||
sqlNode.columnName = colNameToken;
|
sqlNode.columnName = colNameToken;
|
||||||
|
|
||||||
int32_t ret = sqlExprToExprNode(&pNode, &sqlNode, pQueryInfo, pColumnList, &keepTableCols, pMsgBuf);
|
int32_t ret = sqlExprToExprNode(&pNode, &sqlNode, pQueryInfo, pColumnList, &keepTableCols, pMsgBuf);
|
||||||
|
@ -2692,7 +2692,7 @@ int32_t doAddProjectCol(SQueryStmtInfo* pQueryInfo, int32_t outputColIndex, SSch
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t doAddProjectionExprAndResColumn(SQueryStmtInfo* pQueryInfo, SColumnIndex* pIndex, int32_t startPos, SMsgBuf* pMsgBuf) {
|
static int32_t doAddMultipleProjectExprAndResColumns(SQueryStmtInfo* pQueryInfo, SColumnIndex* pIndex, int32_t startPos, SMsgBuf* pMsgBuf) {
|
||||||
STableMetaInfo* pTableMetaInfo = getMetaInfo(pQueryInfo, pIndex->tableIndex);
|
STableMetaInfo* pTableMetaInfo = getMetaInfo(pQueryInfo, pIndex->tableIndex);
|
||||||
|
|
||||||
STableMeta* pTableMeta = pTableMetaInfo->pTableMeta;
|
STableMeta* pTableMeta = pTableMetaInfo->pTableMeta;
|
||||||
|
@ -2705,7 +2705,7 @@ static int32_t doAddProjectionExprAndResColumn(SQueryStmtInfo* pQueryInfo, SColu
|
||||||
|
|
||||||
for (int32_t j = 0; j < numOfTotalColumns; ++j) {
|
for (int32_t j = 0; j < numOfTotalColumns; ++j) {
|
||||||
SSchema* pSchema = getOneColumnSchema(pTableMetaInfo->pTableMeta, j);
|
SSchema* pSchema = getOneColumnSchema(pTableMetaInfo->pTableMeta, j);
|
||||||
doAddProjectCol(pQueryInfo, startPos + j, pSchema, NULL, getNewResColId(), pMsgBuf);
|
doAddOneProjectCol(pQueryInfo, startPos + j, pSchema, NULL, getNewResColId(), pMsgBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
return numOfTotalColumns;
|
return numOfTotalColumns;
|
||||||
|
@ -2771,7 +2771,7 @@ static int32_t handleTbnameProjection(SQueryStmtInfo* pQueryInfo, tSqlExprItem*
|
||||||
colSchema = *getTbnameColumnSchema();
|
colSchema = *getTbnameColumnSchema();
|
||||||
}
|
}
|
||||||
|
|
||||||
return doAddProjectCol(pQueryInfo, startPos, &colSchema, pItem->aliasName, getNewResColId(), pMsgBuf);
|
return doAddOneProjectCol(pQueryInfo, startPos, &colSchema, pItem->aliasName, getNewResColId(), pMsgBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t addProjectionExprAndResColumn(SQueryStmtInfo* pQueryInfo, tSqlExprItem* pItem, bool outerQuery, SMsgBuf* pMsgBuf) {
|
int32_t addProjectionExprAndResColumn(SQueryStmtInfo* pQueryInfo, tSqlExprItem* pItem, bool outerQuery, SMsgBuf* pMsgBuf) {
|
||||||
|
@ -2796,11 +2796,11 @@ int32_t addProjectionExprAndResColumn(SQueryStmtInfo* pQueryInfo, tSqlExprItem*
|
||||||
if (index.tableIndex == COLUMN_INDEX_INITIAL_VAL) { // all table columns are required.
|
if (index.tableIndex == COLUMN_INDEX_INITIAL_VAL) { // all table columns are required.
|
||||||
for (int32_t i = 0; i < pQueryInfo->numOfTables; ++i) {
|
for (int32_t i = 0; i < pQueryInfo->numOfTables; ++i) {
|
||||||
index.tableIndex = i;
|
index.tableIndex = i;
|
||||||
int32_t inc = doAddProjectionExprAndResColumn(pQueryInfo, &index, startPos, pMsgBuf);
|
int32_t inc = doAddMultipleProjectExprAndResColumns(pQueryInfo, &index, startPos, pMsgBuf);
|
||||||
startPos += inc;
|
startPos += inc;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
doAddProjectionExprAndResColumn(pQueryInfo, &index, startPos, pMsgBuf);
|
doAddMultipleProjectExprAndResColumns(pQueryInfo, &index, startPos, pMsgBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the primary timestamp column even though it is not required by user
|
// add the primary timestamp column even though it is not required by user
|
||||||
|
@ -2840,7 +2840,7 @@ int32_t addProjectionExprAndResColumn(SQueryStmtInfo* pQueryInfo, tSqlExprItem*
|
||||||
}
|
}
|
||||||
|
|
||||||
SSchema* pSchema = getOneColumnSchema(pTableMetaInfo->pTableMeta, index.columnIndex);
|
SSchema* pSchema = getOneColumnSchema(pTableMetaInfo->pTableMeta, index.columnIndex);
|
||||||
doAddProjectCol(pQueryInfo, startPos, pSchema, pItem->aliasName, getNewResColId(), pMsgBuf);
|
doAddOneProjectCol(pQueryInfo, startPos, pSchema, pItem->aliasName, getNewResColId(), pMsgBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the primary timestamp column even though it is not required by user
|
// add the primary timestamp column even though it is not required by user
|
||||||
|
|
|
@ -63,7 +63,7 @@ typedef struct SConvertFunc {
|
||||||
int32_t execFuncId;
|
int32_t execFuncId;
|
||||||
} SConvertFunc;
|
} SConvertFunc;
|
||||||
|
|
||||||
static SExprInfo* doAddProjectCol(SQueryInfo* pQueryInfo, int32_t colIndex, int32_t tableIndex, int32_t colId);
|
static SExprInfo* doAddOneProjectCol(SQueryInfo* pQueryInfo, int32_t colIndex, int32_t tableIndex, int32_t colId);
|
||||||
|
|
||||||
static int32_t setShowInfo(SSqlObj* pSql, SSqlInfo* pInfo);
|
static int32_t setShowInfo(SSqlObj* pSql, SSqlInfo* pInfo);
|
||||||
static char* getAccountId(SSqlObj* pSql);
|
static char* getAccountId(SSqlObj* pSql);
|
||||||
|
@ -1890,7 +1890,7 @@ static int32_t handleArithmeticExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32
|
||||||
}
|
}
|
||||||
|
|
||||||
static void addProjectQueryCol(SQueryInfo* pQueryInfo, int32_t startPos, SColumnIndex* pIndex, tSqlExprItem* pItem, int32_t colId) {
|
static void addProjectQueryCol(SQueryInfo* pQueryInfo, int32_t startPos, SColumnIndex* pIndex, tSqlExprItem* pItem, int32_t colId) {
|
||||||
SExprInfo* pExpr = doAddProjectCol(pQueryInfo, pIndex->columnIndex, pIndex->tableIndex, colId);
|
SExprInfo* pExpr = doAddOneProjectCol(pQueryInfo, pIndex->columnIndex, pIndex->tableIndex, colId);
|
||||||
|
|
||||||
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, pIndex->tableIndex);
|
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, pIndex->tableIndex);
|
||||||
STableMeta* pTableMeta = pTableMetaInfo->pTableMeta;
|
STableMeta* pTableMeta = pTableMetaInfo->pTableMeta;
|
||||||
|
@ -2157,7 +2157,7 @@ int32_t insertResultField(SQueryInfo* pQueryInfo, int32_t outputIndex, SColumnLi
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SExprInfo* doAddProjectCol(SQueryInfo* pQueryInfo, int32_t colIndex, int32_t tableIndex, int32_t colId) {
|
SExprInfo* doAddOneProjectCol(SQueryInfo* pQueryInfo, int32_t colIndex, int32_t tableIndex, int32_t colId) {
|
||||||
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, tableIndex);
|
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, tableIndex);
|
||||||
STableMeta* pTableMeta = pTableMetaInfo->pTableMeta;
|
STableMeta* pTableMeta = pTableMetaInfo->pTableMeta;
|
||||||
int32_t numOfCols = tscGetNumOfColumns(pTableMeta);
|
int32_t numOfCols = tscGetNumOfColumns(pTableMeta);
|
||||||
|
@ -2218,7 +2218,7 @@ static int32_t doAddProjectionExprAndResultFields(SQueryInfo* pQueryInfo, SColum
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t j = 0; j < numOfTotalColumns; ++j) {
|
for (int32_t j = 0; j < numOfTotalColumns; ++j) {
|
||||||
SExprInfo* pExpr = doAddProjectCol(pQueryInfo, j, pIndex->tableIndex, getNewResColId(pCmd));
|
SExprInfo* pExpr = doAddOneProjectCol(pQueryInfo, j, pIndex->tableIndex, getNewResColId(pCmd));
|
||||||
tstrncpy(pExpr->base.aliasName, pSchema[j].name, sizeof(pExpr->base.aliasName));
|
tstrncpy(pExpr->base.aliasName, pSchema[j].name, sizeof(pExpr->base.aliasName));
|
||||||
|
|
||||||
pIndex->columnIndex = j;
|
pIndex->columnIndex = j;
|
||||||
|
|
Loading…
Reference in New Issue