提交 c8946cdd 编写于 作者: B Benguang Zhao

fix: Support backquote escape for db names

上级 0797d353
......@@ -5,6 +5,7 @@ build/
cmake-build-debug/
cmake-build-release/
cscope.out
cscope.files
.DS_Store
debug/
release/
......
......@@ -606,8 +606,7 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
case TSDB_SQL_DROP_TABLE:
case TSDB_SQL_DROP_USER:
case TSDB_SQL_DROP_ACCT:
case TSDB_SQL_DROP_DNODE:
case TSDB_SQL_DROP_DB: {
case TSDB_SQL_DROP_DNODE: {
const char* msg2 = "invalid name";
const char* msg3 = "param name too long";
......@@ -626,14 +625,7 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
}
if (pInfo->type == TSDB_SQL_DROP_DB) {
assert(taosArrayGetSize(pInfo->pMiscInfo->a) == 1);
code = tNameSetDbName(&pTableMetaInfo->name, getAccountId(pSql), pzName);
if (code != TSDB_CODE_SUCCESS) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2);
}
} else if (pInfo->type == TSDB_SQL_DROP_TABLE) {
if (pInfo->type == TSDB_SQL_DROP_TABLE) {
assert(taosArrayGetSize(pInfo->pMiscInfo->a) == 1);
code = tscSetTableFullName(&pTableMetaInfo->name, &sTblToken, pSql, dbIncluded);
......@@ -656,11 +648,12 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
break;
}
case TSDB_SQL_DROP_DB:
case TSDB_SQL_USE_DB: {
const char* msg = "invalid db name";
SStrToken* pToken = taosArrayGet(pInfo->pMiscInfo->a, 0);
if (tscValidateName(pToken, false, NULL) != TSDB_CODE_SUCCESS) {
if (tscValidateName(pToken, true, NULL) != TSDB_CODE_SUCCESS) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg);
}
......@@ -707,7 +700,7 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
char buf[TSDB_DB_NAME_LEN] = {0};
SStrToken token = taosTokenDup(&pCreateDB->dbname, buf, tListLen(buf));
if (tscValidateName(&token, false, NULL) != TSDB_CODE_SUCCESS) {
if (tscValidateName(&token, true, NULL) != TSDB_CODE_SUCCESS) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1);
}
......@@ -816,7 +809,7 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
SStrToken* pToken = taosArrayGet(pInfo->pMiscInfo->a, 0);
if (tscValidateName(pToken, false, NULL) != TSDB_CODE_SUCCESS) {
if (tscValidateName(pToken, true, NULL) != TSDB_CODE_SUCCESS) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1);
}
......@@ -1088,7 +1081,7 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
if (code != TSDB_CODE_SUCCESS) {
return code ; // async load table meta
}
// vgroupInfo if super
if (code == 0 && UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
code = tscGetSTableVgroupInfo(pSql, pQueryInfo);
......@@ -1124,7 +1117,7 @@ int32_t tscValidateSqlInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
*/
static bool isTopBottomUniqueQuery(SQueryInfo* pQueryInfo) {
size_t size = tscNumOfExprs(pQueryInfo);
for (int32_t i = 0; i < size; ++i) {
int32_t functionId = tscExprGet(pQueryInfo, i)->base.functionId;
......@@ -1235,7 +1228,7 @@ int32_t validateIntervalNode(SSqlObj* pSql, SQueryInfo* pQueryInfo, SSqlNode* pS
if (interpQuery) {
return addPrimaryTsColumnForTimeWindowQuery(pQueryInfo, pCmd);
}
return TSDB_CODE_SUCCESS;
}
......@@ -1351,7 +1344,7 @@ static int32_t validateStateWindowNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SS
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg6);
}
}
tscColumnListInsert(pQueryInfo->colList, index.columnIndex, pTableMeta->id.uid, pSchema);
SColIndex colIndex = { .colIndex = index.columnIndex, .flag = TSDB_COL_NORMAL, .colId = pSchema->colId };
taosArrayPush(pGroupExpr->columnInfo, &colIndex);
......@@ -1522,11 +1515,11 @@ int32_t tscSetTableFullName(SName* pName, SStrToken* pTableName, SSqlObj* pSql,
SSqlCmd* pCmd = &pSql->cmd;
int32_t code = TSDB_CODE_SUCCESS;
int32_t idx = -1;
if (dbIncluded) {
idx = getDelimiterIndex(pTableName);
}
if (idx != -1) { // db has been specified in sql string so we ignore current db path
char* acctId = getAccountId(pSql);
if (acctId == NULL || strlen(acctId) <= 0) {
......@@ -1829,10 +1822,10 @@ int32_t validateOneColumn(SSqlCmd* pCmd, TAOS_FIELD* pColField) {
// assert(pCmd->numOfClause == 1);
STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, 0);
STableMeta* pTableMeta = pTableMetaInfo->pTableMeta;
int32_t numOfTags = tscGetNumOfTags(pTableMeta);
int32_t numOfCols = tscGetNumOfColumns(pTableMeta);
// no more max columns
if (numOfCols >= TSDB_MAX_COLUMNS || numOfTags + numOfCols >= TSDB_MAX_COLUMNS) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1);
......@@ -2249,7 +2242,7 @@ int32_t validateSelectNodeList(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SArray* pS
const char* msg3 = "not support query expression";
const char* msg4 = "not support distinct mixed with proj/agg func";
const char* msg5 = "invalid function name";
const char* msg6 = "not support distinct mixed with join";
const char* msg6 = "not support distinct mixed with join";
const char* msg7 = "not support distinct mixed with groupby";
const char* msg8 = "not support distinct in nest query";
const char* msg9 = "_block_dist not support subquery, only support stable/table";
......@@ -2390,11 +2383,11 @@ int32_t insertResultField(SQueryInfo* pQueryInfo, int32_t outputIndex, SColumnLi
SSchema* pSchema = tscGetTableSchema(pTableMeta);
tscColumnListInsert(pQueryInfo->colList, pColList->ids[i].columnIndex, uid, &pSchema[pColList->ids[i].columnIndex]);
}
TAOS_FIELD f = tscCreateField(type, fieldName, bytes);
SInternalField* pInfo = tscFieldInfoInsert(&pQueryInfo->fieldsInfo, outputIndex, &f);
pInfo->pExpr = pSqlExpr;
return TSDB_CODE_SUCCESS;
}
......@@ -2402,12 +2395,12 @@ SExprInfo* doAddProjectCol(SQueryInfo* pQueryInfo, int32_t colIndex, int32_t tab
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, tableIndex);
STableMeta* pTableMeta = pTableMetaInfo->pTableMeta;
int32_t numOfCols = tscGetNumOfColumns(pTableMeta);
SSchema* pSchema = tscGetTableColumnSchema(pTableMeta, colIndex);
int16_t functionId = (int16_t)((colIndex >= numOfCols) ? TSDB_FUNC_TAGPRJ : TSDB_FUNC_PRJ);
SColumnIndex index = {.tableIndex = tableIndex,};
if (functionId == TSDB_FUNC_TAGPRJ) {
index.columnIndex = colIndex - tscGetNumOfColumns(pTableMeta);
tscColumnListInsert(pTableMetaInfo->tagColList, index.columnIndex, pTableMeta->id.uid, pSchema);
......@@ -2435,7 +2428,7 @@ SExprInfo* tscAddFuncInSelectClause(SQueryInfo* pQueryInfo, int32_t outputColInd
pExpr->base.colInfo.flag = flag;
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, pIndex->tableIndex);
if (TSDB_COL_IS_TAG(flag)) {
tscColumnListInsert(pTableMetaInfo->tagColList, pIndex->columnIndex, pTableMetaInfo->pTableMeta->id.uid, pColSchema);
}
......@@ -2451,7 +2444,7 @@ static int32_t doAddProjectionExprAndResultFields(SQueryInfo* pQueryInfo, SColum
SSchema* pSchema = tscGetTableSchema(pTableMeta);
STableComInfo tinfo = tscGetTableInfo(pTableMeta);
if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
numOfTotalColumns = tinfo.numOfColumns + tinfo.numOfTags;
} else {
......@@ -2681,7 +2674,7 @@ static int32_t setExprInfoForFunctions(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SS
pExpr->base.param[0].i64 = TSDB_ORDER_DESC;
pExpr->base.param[0].nType = TSDB_DATA_TYPE_INT;
}
// for all queries, the timestamp column needs to be loaded
SSchema s = {.colId = PRIMARYKEY_TIMESTAMP_COL_INDEX, .bytes = TSDB_KEYSIZE, .type = TSDB_DATA_TYPE_TIMESTAMP,};
tscColumnListInsert(pQueryInfo->colList, PRIMARYKEY_TIMESTAMP_COL_INDEX, pExpr->base.uid, &s);
......@@ -3956,7 +3949,7 @@ static int16_t doGetColumnIndex(SQueryInfo* pQueryInfo, int32_t index, SStrToken
char tmpTokenBuf[TSDB_MAX_BYTES_PER_ROW] = {0}; // create tmp buf to avoid alter orginal sqlstr
strncpy(tmpTokenBuf, pToken->z, pToken->n);
pToken->z = tmpTokenBuf;
pToken->n = stringProcess(pToken->z, pToken->n);
......@@ -4110,7 +4103,7 @@ int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
if (pDbPrefixToken->n <= 0) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg5);
}
if (tscValidateName(pDbPrefixToken, false, NULL) != TSDB_CODE_SUCCESS) {
if (tscValidateName(pDbPrefixToken, true, NULL) != TSDB_CODE_SUCCESS) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1);
}
......@@ -4147,7 +4140,7 @@ int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
if (pShowInfo->prefix.n <= 0) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg6);
}
}
}
return TSDB_CODE_SUCCESS;
}
......@@ -4158,7 +4151,7 @@ int32_t setKillInfo(SSqlObj* pSql, struct SSqlInfo* pInfo, int32_t killType) {
SSqlCmd* pCmd = &pSql->cmd;
pCmd->command = pInfo->type;
SStrToken* idStr = &(pInfo->pMiscInfo->id);
if (idStr->n > TSDB_KILL_MSG_LEN) {
return TSDB_CODE_TSC_INVALID_OPERATION;
......@@ -4191,7 +4184,7 @@ int32_t setKillInfo(SSqlObj* pSql, struct SSqlInfo* pInfo, int32_t killType) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3);
}
}
return TSDB_CODE_SUCCESS;
}
static int32_t setCompactVnodeInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
......@@ -4213,7 +4206,7 @@ int32_t tscTansformFuncForSTableQuery(SQueryInfo* pQueryInfo) {
int32_t bytes = 0;
int16_t type = 0;
int32_t interBytes = 0;
size_t size = tscNumOfExprs(pQueryInfo);
for (int32_t k = 0; k < size; ++k) {
SExprInfo* pExpr = tscExprGet(pQueryInfo, k);
......@@ -4225,7 +4218,7 @@ int32_t tscTansformFuncForSTableQuery(SQueryInfo* pQueryInfo) {
int32_t colIndex = pExpr->base.colInfo.colIndex;
SSchema* pSrcSchema = tscGetTableColumnSchema(pTableMetaInfo->pTableMeta, colIndex);
if ((functionId >= TSDB_FUNC_SUM && functionId <= TSDB_FUNC_TWA) ||
(functionId >= TSDB_FUNC_FIRST_DST && functionId <= TSDB_FUNC_STDDEV_DST) ||
(functionId >= TSDB_FUNC_RATE && functionId <= TSDB_FUNC_IRATE) ||
......@@ -4257,16 +4250,16 @@ void tscRestoreFuncForSTableQuery(SQueryInfo* pQueryInfo) {
if (!UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
return;
}
size_t size = tscNumOfExprs(pQueryInfo);
for (int32_t i = 0; i < size; ++i) {
SExprInfo* pExpr = tscExprGet(pQueryInfo, i);
SSchema* pSchema = tscGetTableColumnSchema(pTableMetaInfo->pTableMeta, pExpr->base.colInfo.colIndex);
// the final result size and type in the same as query on single table.
// so here, set the flag to be false;
int32_t inter = 0;
int32_t functionId = pExpr->base.functionId;
if (functionId < 0) {
continue;
......@@ -4275,7 +4268,7 @@ void tscRestoreFuncForSTableQuery(SQueryInfo* pQueryInfo) {
if (functionId >= TSDB_FUNC_TS && functionId <= TSDB_FUNC_DIFF) {
continue;
}
if (functionId == TSDB_FUNC_FIRST_DST) {
functionId = TSDB_FUNC_FIRST;
} else if (functionId == TSDB_FUNC_LAST_DST) {
......@@ -4330,7 +4323,7 @@ bool hasUnsupportFunctionsForSTableQuery(SSqlCmd* pCmd, SQueryInfo* pQueryInfo)
return true;
}
}
if (tscIsSessionWindowQuery(pQueryInfo)) {
invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3);
return true;
......@@ -4679,7 +4672,7 @@ static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo,
}
if (pExpr->tokenId == TK_IN) {
tVariant *pVal;
tVariant* pVal;
if (pRight->tokenId != TK_SET || !serializeExprListToVariant(pRight->Expr.paramList, &pVal, colType, timePrecision)) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg);
}
......@@ -4714,7 +4707,7 @@ static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo,
if (retVal != TSDB_CODE_SUCCESS) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg);
}
}
switch (pExpr->tokenId) {
case TK_LE:
......@@ -4779,7 +4772,7 @@ enum {
TSQL_EXPR_TAG = 2,
TSQL_EXPR_COLUMN = 4,
TSQL_EXPR_TBNAME = 8,
TSQL_EXPR_JOIN = 16,
TSQL_EXPR_JOIN = 16,
};
#define GET_MIXED_TYPE(t) (((t) >= TSQL_EXPR_JOIN) || ((t) > TSQL_EXPR_COLUMN && (t) < TSQL_EXPR_TBNAME) || ((t) == (TSQL_EXPR_TS|TSQL_EXPR_TAG)))
......@@ -4811,7 +4804,7 @@ static int32_t checkColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCol
ret = invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1);
goto _err_ret;
}
if (pSchema->type == TSDB_DATA_TYPE_BOOL) {
int32_t t = pExpr->tokenId;
if (t != TK_EQ && t != TK_NE && t != TK_NOTNULL && t != TK_ISNULL && t != TK_IN) {
......@@ -4831,7 +4824,7 @@ static int32_t checkColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCol
_err_ret:
freeColumnFilterInfo(pColFilter, 1);
return ret;
}
......@@ -4861,7 +4854,7 @@ static int32_t addAllColumn(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr* pEx
static int32_t getColQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr** pExpr) {
int32_t ret = TSDB_CODE_SUCCESS;
const char* msg6 = "illegal condition expression";
for (int32_t i = 0; i < pQueryInfo->numOfTables; ++i) {
tSqlExpr* p1 = extractExprForSTable(pCmd, pExpr, pQueryInfo, i);
if (p1 == NULL) { // no query condition on this table
......@@ -4870,7 +4863,7 @@ static int32_t getColQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlEx
tExprNode* p = NULL;
SArray* colList = taosArrayInit(10, sizeof(SColIndex));
SArray* colList = taosArrayInit(10, sizeof(SColIndex));
ret = exprTreeFromSqlExpr(pCmd, &p, p1, pQueryInfo, colList, NULL);
size_t colNum = taosArrayGetSize(colList);
for (int32_t k = 0; k < colNum; k++) {
......@@ -4909,12 +4902,12 @@ static int32_t getColQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlEx
if (pQueryInfo->colCond == NULL) {
pQueryInfo->colCond = taosArrayInit(2, sizeof(STblCond));
}
taosArrayPush(pQueryInfo->colCond, &cond);
taosArrayPush(pQueryInfo->colCond, &cond);
tSqlExprDestroy(p1);
tExprTreeDestroy(p, NULL);
if (ret) {
break;
}
......@@ -5040,7 +5033,7 @@ static int32_t checkAndSetJoinCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tS
tscColumnListInsert(pTableMetaInfo->tagColList, index.columnIndex, pTableMeta->id.uid, pTagSchema2);
atomic_add_fetch_32(&pTableMetaInfo->joinTagNum, 1);
if (pTableMetaInfo->joinTagNum > 1) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2);
}
......@@ -5084,9 +5077,9 @@ static int32_t validateSQLExprItemSQLFunc(SSqlCmd* pCmd, tSqlExpr* pExpr,
int32_t code = TSDB_CODE_SUCCESS;
const char* msg1 = "invalid function parameters";
const char* msg2 = "not supported functions in arithmetic expression";
int32_t functionId = isValidFunction(pExpr->Expr.operand.z, pExpr->Expr.operand.n);
pExpr->functionId = functionId;
if (pExpr->Expr.paramList != NULL) {
size_t numChildren = taosArrayGetSize(pExpr->Expr.paramList);
......@@ -6052,7 +6045,7 @@ static void doExtractExprForSTable(SSqlCmd* pCmd, tSqlExpr** pExpr, SQueryInfo*
*pOut = NULL;
return;
}
if (!isLogicalOperator(*pExpr)) {
tSqlExpr* pLeft = (*pExpr)->pLeft;
......@@ -6110,17 +6103,17 @@ int32_t mergeTimeRange(SSqlCmd* pCmd, STimeWindow* res, STimeWindow* win, int32_
#define SET_EMPTY_RANGE(w) do { (w)->skey = INT64_MAX; (w)->ekey = INT64_MIN; } while (0)
#define IS_EMPTY_RANGE(w) ((w)->skey == INT64_MAX && (w)->ekey == INT64_MIN)
if (optr == TSDB_RELATION_AND) {
if (res->skey > win->ekey || win->skey > res->ekey) {
SET_EMPTY_RANGE(res);
return TSDB_CODE_SUCCESS;
}
if (res->skey < win->skey) {
res->skey = win->skey;
}
if (res->ekey > win->ekey) {
res->ekey = win->ekey;
}
......@@ -6145,7 +6138,7 @@ int32_t mergeTimeRange(SSqlCmd* pCmd, STimeWindow* res, STimeWindow* win, int32_
if (res->skey > win->skey) {
res->skey = win->skey;
}
if (res->ekey < win->ekey) {
res->ekey = win->ekey;
}
......@@ -6155,7 +6148,7 @@ int32_t mergeTimeRange(SSqlCmd* pCmd, STimeWindow* res, STimeWindow* win, int32_
static int32_t createTimeRangeExpr(tSqlExpr** pExpr, STimeWindow* win, uint32_t tokenId) {
*pExpr = calloc(1, sizeof(tSqlExpr));
(*pExpr)->type = SQL_NODE_VALUE;
(*pExpr)->tokenId = tokenId;
(*pExpr)->value.nType = TSDB_DATA_TYPE_VALUE_ARRAY;
......@@ -6178,7 +6171,6 @@ static int32_t convertTimeRangeFromExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t
return TSDB_CODE_SUCCESS;
}
pQueryInfo->onlyHasTagCond &= false;
if (!tSqlExprIsParentOfLeaf(pExpr)) {
code = convertTimeRangeFromExpr(pCmd, pQueryInfo, pExpr->pLeft);
......@@ -6198,7 +6190,7 @@ static int32_t convertTimeRangeFromExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, index.tableIndex);
STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta);
tSqlExpr* pRight = pExpr->pRight;
if (getTimeRange(&win, pRight, pExpr->tokenId, tinfo.precision) != TSDB_CODE_SUCCESS) {
......@@ -6275,7 +6267,7 @@ static void doAddJoinTagsColumnsIntoTagList(SSqlCmd* pCmd, SQueryInfo* pQueryInf
SSchema* pSchema = tscGetTableTagSchema(pTableMetaInfo->pTableMeta);
tscColumnListInsert(pTableMetaInfo->tagColList, &index, &pSchema[index.columnIndex]);
if (getColumnIndexByName(pCmd, &pCondExpr->pJoinExpr->pRight->ColName, pQueryInfo, &index) != TSDB_CODE_SUCCESS) {
tscError("%p: invalid column name (right)", pQueryInfo);
}
......@@ -6381,7 +6373,7 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE
if (pCondExpr->pTagCond == NULL) {
return ret;
}
for (int32_t i = 0; i < pQueryInfo->numOfTables; ++i) {
tSqlExpr* p1 = extractExprForSTable(pCmd, &pCondExpr->pTagCond, pQueryInfo, i);
if (p1 == NULL) { // no query condition on this table
......@@ -6389,7 +6381,7 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE
}
tExprNode* p = NULL;
SArray* colList = taosArrayInit(10, sizeof(SColIndex));
ret = exprTreeFromSqlExpr(pCmd, &p, p1, pQueryInfo, colList, NULL);
size_t colNum = taosArrayGetSize(colList);
......@@ -6406,7 +6398,7 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE
//if (ret == TSDB_CODE_SUCCESS) {
// ret = filterInitFromTree(p, &pQueryInfo->tagFilter, (int32_t)taosArrayGetSize(colList), NULL);
//}
SBufferWriter bw = tbufInitWriter(NULL, false);
TRY(0) {
......@@ -6421,7 +6413,7 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, i);
int64_t uid = pTableMetaInfo->pTableMeta->id.uid;
int32_t numOfCols = tscGetNumOfColumns(pTableMetaInfo->pTableMeta);
size_t num = taosArrayGetSize(colList);
for(int32_t j = 0; j < num; ++j) {
SColIndex* pIndex = taosArrayGet(colList, j);
......@@ -6431,7 +6423,7 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE
tscColumnListInsert(pTableMetaInfo->tagColList, index.columnIndex, pTableMetaInfo->pTableMeta->id.uid,
&s[pIndex->colIndex]);
}
tsSetSTableQueryCond(&pQueryInfo->tagCond, uid, &bw);
tSqlExprCompact(&pCondExpr->pTagCond);
......@@ -6441,7 +6433,7 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE
tSqlExprDestroy(p1);
tExprTreeDestroy(p, NULL); //TODO
taosArrayDestroy(&colList);
if (pQueryInfo->tagCond.pCond != NULL && taosArrayGetSize(pQueryInfo->tagCond.pCond) > 0 && !UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), "filter on tag not supported for normal table");
......@@ -6556,13 +6548,13 @@ static int32_t getQueryTimeRange(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr
if (*pExpr == NULL) {
return ret;
}
//multiple tables's query time range mixed together
tExprNode* p = NULL;
void *filter = NULL;
SArray* colList = taosArrayInit(10, sizeof(SColIndex));
SArray* colList = taosArrayInit(10, sizeof(SColIndex));
ret = exprTreeFromSqlExpr(pCmd, &p, *pExpr, pQueryInfo, colList, NULL);
taosArrayDestroy(&colList);
......@@ -6819,7 +6811,7 @@ int32_t validateFillNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSqlNo
if ((!isTimeWindowQuery(pQueryInfo)) && (!pointInterp)) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg5);
}
if (QUERY_IS_JOIN_QUERY(pQueryInfo->type) && (!pointInterp)) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg7);
}
......@@ -6835,9 +6827,9 @@ int32_t validateFillNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSqlNo
if (pItem->pVar.nType != TSDB_DATA_TYPE_BINARY) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2);
}
size_t numOfFields = tscNumOfFields(pQueryInfo);
if (pQueryInfo->fillVal == NULL) {
pQueryInfo->fillVal = calloc(numOfFields, sizeof(int64_t));
pQueryInfo->numOfFillVal = (int32_t)numOfFields;
......@@ -6898,7 +6890,7 @@ int32_t validateFillNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSqlNo
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4);
}
}
if ((num < numOfFields) || ((num - 1 < numOfFields) && pointInterp)) {
tVariantListItem* lastItem = taosArrayGetLast(pFillToken);
......@@ -6934,13 +6926,13 @@ int32_t validateRangeNode(SSqlObj* pSql, SQueryInfo* pQueryInfo, SSqlNode* pSqlN
const char *msg0 = "invalid usage of range clause";
const char* msg1 = "invalid timestamp in range";
SSqlCmd* pCmd = &pSql->cmd;
bool interpQuery = tscIsPointInterpQuery(pQueryInfo);
if ((!interpQuery) && (pSqlNode->pRange.start || pSqlNode->pRange.end)) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg0);
}
if (pSqlNode->pRange.start == NULL || pSqlNode->pRange.end == NULL) {
pQueryInfo->range.skey = INT64_MIN;
pQueryInfo->range.ekey = INT64_MIN;
......@@ -7018,8 +7010,8 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
setDefaultOrderInfo(pQueryInfo);
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
if (pSqlNode->pSortOrder == NULL) {
return TSDB_CODE_SUCCESS;
}
return TSDB_CODE_SUCCESS;
}
char* pMsgBuf = tscGetErrorMsgPayload(pCmd);
SArray* pSortOrder = pSqlNode->pSortOrder;
......@@ -7590,12 +7582,12 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
len = varDataTLen(pUpdateMsg->data + schemaLen);
if(len > pTagsSchema->bytes) return invalidOperationMsg(pMsg, msg14);
}
pUpdateMsg->tagValLen = htonl(len); // length may be changed after dump data
int32_t total = sizeof(SUpdateTableTagValMsg) + len + schemaLen;
pUpdateMsg->head.contLen = htonl(total);
} else if (pAlterSQL->type == TSDB_ALTER_TABLE_ADD_COLUMN) {
SArray* pFieldList = pAlterSQL->pAddColumns;
if (taosArrayGetSize(pFieldList) > 1) {
......@@ -7608,7 +7600,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
if (ret != TSDB_CODE_SUCCESS) {
return ret;
}
tscFieldInfoAppend(&pQueryInfo->fieldsInfo, p);
} else if (pAlterSQL->type == TSDB_ALTER_TABLE_DROP_COLUMN) {
if (tscGetNumOfColumns(pTableMeta) == TSDB_MIN_COLUMNS) { //
......@@ -7761,7 +7753,7 @@ int32_t validateSqlFunctionInStreamSql(SSqlCmd* pCmd, SQueryInfo* pQueryInfo) {
pQueryInfo->interval.intervalUnit != 'y') {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg0);
}
size_t size = taosArrayGetSize(pQueryInfo->exprList);
for (int32_t i = 0; i < size; ++i) {
int32_t functId = tscExprGet(pQueryInfo, i)->base.functionId;
......@@ -7782,7 +7774,7 @@ int32_t validateFunctionsInIntervalOrGroupbyQuery(SSqlCmd* pCmd, SQueryInfo* pQu
// multi-output set/ todo refactor
size_t size = taosArrayGetSize(pQueryInfo->exprList);
for (int32_t k = 0; k < size; ++k) {
SExprInfo* pExpr = tscExprGet(pQueryInfo, k);
......@@ -7840,8 +7832,7 @@ typedef struct SDNodeDynConfOption {
int32_t len; // name string length
} SDNodeDynConfOption;
int32_t validateEp(char* ep) {
int32_t validateEp(char* ep) {
char buf[TSDB_EP_LEN + 1] = {0};
tstrncpy(buf, ep, TSDB_EP_LEN);
......@@ -8044,10 +8035,10 @@ int32_t validateLimitNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSqlN
pQueryInfo->limit = pSqlNode->limit;
pQueryInfo->clauseLimit = pQueryInfo->limit.limit;
pQueryInfo->slimit = pSqlNode->slimit;
tscDebug("0x%"PRIx64" limit:%" PRId64 ", offset:%" PRId64 " slimit:%" PRId64 ", soffset:%" PRId64, pSql->self,
pQueryInfo->limit.limit, pQueryInfo->limit.offset, pQueryInfo->slimit.limit, pQueryInfo->slimit.offset);
if (pQueryInfo->slimit.offset < 0 || pQueryInfo->limit.offset < 0) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg0);
}
......@@ -8342,7 +8333,7 @@ static void doUpdateSqlFunctionForTagPrj(SQueryInfo* pQueryInfo) {
static int32_t doUpdateSqlFunctionForColPrj(SQueryInfo* pQueryInfo) {
size_t size = taosArrayGetSize(pQueryInfo->exprList);
for (int32_t i = 0; i < size; ++i) {
SExprInfo* pExpr = tscExprGet(pQueryInfo, i);
......@@ -8350,7 +8341,7 @@ static int32_t doUpdateSqlFunctionForColPrj(SQueryInfo* pQueryInfo) {
bool qualifiedCol = false;
for (int32_t j = 0; j < pQueryInfo->groupbyExpr.numOfGroupCols; ++j) {
SColIndex* pColIndex = taosArrayGet(pQueryInfo->groupbyExpr.columnInfo, j);
if (pExpr->base.colInfo.colId == pColIndex->colId) {
qualifiedCol = true;
doLimitOutputNormalColOfGroupby(pExpr);
......@@ -8390,7 +8381,7 @@ static bool tagColumnInGroupby(SGroupbyExpr* pGroupbyExpr, int16_t columnId, int
static bool onlyTagPrjFunction(SQueryInfo* pQueryInfo) {
bool hasTagPrj = false;
bool hasColumnPrj = false;
size_t size = taosArrayGetSize(pQueryInfo->exprList);
for (int32_t i = 0; i < size; ++i) {
SExprInfo* pExpr = tscExprGet(pQueryInfo, i);
......@@ -8428,7 +8419,7 @@ static bool allTagPrjInGroupby(SQueryInfo* pQueryInfo) {
static void updateTagPrjFunction(SQueryInfo* pQueryInfo) {
size_t size = taosArrayGetSize(pQueryInfo->exprList);
for (int32_t i = 0; i < size; ++i) {
SExprInfo* pExpr = tscExprGet(pQueryInfo, i);
if (pExpr->base.functionId == TSDB_FUNC_TAGPRJ) {
......@@ -8618,7 +8609,7 @@ static int32_t doAddGroupbyColumnsOnDemand(SSqlCmd* pCmd, SQueryInfo* pQueryInfo
s = &pSchema[colIndex];
}
}
if (TSDB_COL_IS_TAG(pColIndex->flag)) {
int32_t f = TSDB_FUNC_TAG;
......@@ -8626,7 +8617,7 @@ static int32_t doAddGroupbyColumnsOnDemand(SSqlCmd* pCmd, SQueryInfo* pQueryInfo
f = TSDB_FUNC_TAGPRJ;
}
int32_t pos = tscGetFirstInvisibleFieldPos(pQueryInfo);
int32_t pos = tscGetFirstInvisibleFieldPos(pQueryInfo);
SColumnIndex index = {.tableIndex = pQueryInfo->groupbyExpr.tableIndex, .columnIndex = colIndex};
SExprInfo* pExpr = tscExprInsert(pQueryInfo, pos, f, &index, s->type, s->bytes, getNewResColId(pCmd), s->bytes, true);
......@@ -8816,10 +8807,10 @@ int32_t validateFunctionFromUpstream(SQueryInfo* pQueryInfo, char* msg) {
int32_t numOfExprs = (int32_t)tscNumOfExprs(pQueryInfo);
size_t upNum = taosArrayGetSize(pQueryInfo->pUpstream);
for (int32_t i = 0; i < numOfExprs; ++i) {
SExprInfo* pExpr = tscExprGet(pQueryInfo, i);
int32_t f = pExpr->base.functionId;
if (f == TSDB_FUNC_DERIVATIVE ||
f == TSDB_FUNC_TWA ||
......@@ -8836,7 +8827,7 @@ int32_t validateFunctionFromUpstream(SQueryInfo* pQueryInfo, char* msg) {
return TSDB_CODE_SUCCESS;
}
}
return invalidOperationMsg(msg, msg1);
} else if (f == TSDB_FUNC_INTERP) {
if (pQueryInfo->groupbyExpr.columnInfo) {
......@@ -8852,7 +8843,7 @@ int32_t validateFunctionFromUpstream(SQueryInfo* pQueryInfo, char* msg) {
if (pUp->groupbyExpr.columnInfo) {
return invalidOperationMsg(msg, msg2);
}
if (pUp->order.order == TSDB_ORDER_DESC || (pUp->order.orderColId != INT32_MIN && pUp->order.orderColId != PRIMARYKEY_TIMESTAMP_COL_INDEX)) {
return invalidOperationMsg(msg, msg3);
}
......@@ -8873,7 +8864,7 @@ int32_t validateFunctionFromUpstream(SQueryInfo* pQueryInfo, char* msg) {
if (TSDB_QUERY_HAS_TYPE(pUp->type, TSDB_QUERY_TYPE_PROJECTION_QUERY)) {
return invalidOperationMsg(msg, msg5);
}
for (int32_t n = 0; n < exprNum; ++n) {
expr = taosArrayGetP(pUp->exprList, n);
if (expr->functionId == TSDB_FUNC_TOP ||
......@@ -8910,11 +8901,11 @@ int32_t doLocalQueryProcess(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
if (pExpr->Expr.operand.z == NULL) {
//handle 'select 1'
if (pExpr->exprToken.n == 1 && 0 == strncasecmp(pExpr->exprToken.z, "1", 1)) {
server_status = true;
server_status = true;
} else {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2);
}
}
}
}
// TODO redefine the function
SDNodeDynConfOption functionsInfo[5] = {{"database()", 10},
{"server_version()", 16},
......@@ -8948,7 +8939,7 @@ int32_t doLocalQueryProcess(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
pQueryInfo->command = TSDB_SQL_CURRENT_USER;break;
default: { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); }
}
SColumnIndex ind = {0};
SExprInfo* pExpr1 = tscExprAppend(pQueryInfo, TSDB_FUNC_TAG_DUMMY, &ind, TSDB_DATA_TYPE_INT,
tDataTypes[TSDB_DATA_TYPE_INT].bytes, getNewResColId(pCmd), tDataTypes[TSDB_DATA_TYPE_INT].bytes, false);
......@@ -8956,7 +8947,7 @@ int32_t doLocalQueryProcess(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq
tSqlExprItem* item = taosArrayGet(pExprList, 0);
const char* name = (item->aliasName != NULL)? item->aliasName:functionsInfo[index].name;
tstrncpy(pExpr1->base.aliasName, name, tListLen(pExpr1->base.aliasName));
return TSDB_CODE_SUCCESS;
}
......@@ -9117,7 +9108,7 @@ int32_t doCheckForCreateTable(SSqlObj* pSql, int32_t subClauseIndex, SSqlInfo* p
// if sql specifies db, use it, otherwise use default db
SStrToken* pzTableName = &(pCreateTable->name);
bool dbIncluded = false;
if (tscValidateName(pzTableName, true, &dbIncluded) != TSDB_CODE_SUCCESS) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1);
......@@ -9395,7 +9386,7 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
kvRowCpy(pTag->data, row);
free(row);
bool dbIncluded2 = false;
char tmp[TSDB_TABLE_FNAME_LEN] = {0};
SStrToken tbName = taosTokenDup(&pCreateTableInfo->name, tmp, tListLen(tmp));
......@@ -9447,7 +9438,7 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) {
if (tscValidateName(pName, true, &dbIncluded1) != TSDB_CODE_SUCCESS) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), STR_INVALID_TABLE_NAME);
}
// check to valid and create to name
if(pInfo->pCreateTableInfo->to.n > 0) {
bool dbInclude = false;
......@@ -9922,12 +9913,12 @@ static int32_t getTableNameFromSqlNode(SSqlNode* pSqlNode, SArray* tableNameList
if (t->type == TK_INTEGER || t->type == TK_FLOAT) {
return invalidOperationMsg(msgBuf, STR_INVALID_TABLE_NAME);
}
bool dbIncluded = false;
char buf[TSDB_TABLE_FNAME_LEN];
SStrToken sTblToken;
sTblToken.z = buf;
if (validateTableName(t->z, t->n, &sTblToken, &dbIncluded) != TSDB_CODE_SUCCESS) {
return invalidOperationMsg(msgBuf, STR_INVALID_TABLE_NAME);
}
......@@ -9956,7 +9947,7 @@ static int32_t getTableNameFromSubquery(SSqlNode* pSqlNode, SArray* tableNameLis
if (p->from == NULL) {
return TSDB_CODE_TSC_INVALID_OPERATION;
}
if (p->from->type == SQL_NODE_FROM_TABLELIST) {
int32_t code = getTableNameFromSqlNode(p, tableNameList, msgBuf, pSql);
if (code != TSDB_CODE_SUCCESS) {
......@@ -10054,7 +10045,7 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) {
tNameExtractFullName(pname, name);
size_t len = strlen(name);
if (NULL == taosHashGetCloneExt(UTIL_GET_TABLEMETA(pSql), name, len, NULL, (void **)&pTableMeta, &tableMetaCapacity)) {
// not found
tfree(pTableMeta);
......@@ -10067,7 +10058,7 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) {
void* pVgroupIdList = NULL;
if (pTableMeta->tableType == TSDB_CHILD_TABLE) {
code = tscCreateTableMetaFromSTableMeta(pSql, (STableMeta **)(&pTableMeta), name, &tableMetaCapacity, (STableMeta **)(&pSTMeta));
pSql->pBuf = (void *)pSTMeta;
pSql->pBuf = (void*)pSTMeta;
// create the child table meta from super table failed, try load it from mnode
if (code != TSDB_CODE_SUCCESS) {
......@@ -10148,7 +10139,7 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) {
} else if (taosArrayGetSize(pQueryInfo->pUdfInfo) > 0) {
int32_t usize = (int32_t)taosArrayGetSize(pQueryInfo->pUdfInfo);
int32_t exist = 0;
for (int32_t j = 0; j < usize; ++j) {
SUdfInfo* pUdfInfo = taosArrayGet(pQueryInfo->pUdfInfo, j);
int32_t len = (int32_t)strlen(pUdfInfo->name);
......@@ -10168,7 +10159,7 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) {
if (taosArrayGetSize(pQueryInfo->pUdfInfo) > 1) {
code = tscInvalidOperationMsg(pCmd->payload, "only one udf allowed", NULL);
goto _end;
}
}
}
}
}
......@@ -10826,9 +10817,9 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS
*pExpr = calloc(1, sizeof(tExprNode));
(*pExpr)->nodeType = TSQL_NODE_TYPE;
(*pExpr)->pType = calloc(1, sizeof(TAOS_FIELD));
*(*pExpr)->pType = pSqlExpr->dataType;
*(*pExpr)->pType = pSqlExpr->dataType;
return TSDB_CODE_SUCCESS;
} else if (pSqlExpr->tokenId == TK_SET) {
int32_t colType = -1;
......
......@@ -1418,7 +1418,7 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue
};
SUdfInfo* pUdfInfo = NULL;
size_t size = tscNumOfExprs(px);
for (int32_t j = 0; j < size; ++j) {
SExprInfo* pExprInfo = tscExprGet(px, j);
......@@ -1429,7 +1429,7 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue
pSql->res.code = tscInvalidOperationMsg(pSql->cmd.payload, "only one udf allowed", NULL);
return;
}
pUdfInfo = taosArrayGet(px->pUdfInfo, -1 * functionId - 1);
int32_t code = initUdfInfo(pUdfInfo);
if (code != TSDB_CODE_SUCCESS) {
......@@ -1537,7 +1537,7 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue
px->pQInfo->runtimeEnv.udfIsCopy = true;
px->pQInfo->runtimeEnv.pUdfInfo = pUdfInfo;
tfree(schema);
// set the pRuntimeEnv for pSourceOperator
......@@ -2702,11 +2702,9 @@ int32_t tscExprTopBottomIndex(SQueryInfo* pQueryInfo){
SExprInfo* pExpr = tscExprGet(pQueryInfo, i);
if (pExpr == NULL)
continue;
if (pExpr->base.functionId == TSDB_FUNC_TOP
|| pExpr->base.functionId == TSDB_FUNC_BOTTOM
|| pExpr->base.functionId == TSDB_FUNC_SAMPLE
|| pExpr->base.functionId == TSDB_FUNC_UNIQUE
|| pExpr->base.functionId == TSDB_FUNC_TAIL) {
if (pExpr->base.functionId == TSDB_FUNC_TOP || pExpr->base.functionId == TSDB_FUNC_BOTTOM ||
pExpr->base.functionId == TSDB_FUNC_SAMPLE || pExpr->base.functionId == TSDB_FUNC_UNIQUE ||
pExpr->base.functionId == TSDB_FUNC_TAIL) {
return i;
}
}
......@@ -3068,6 +3066,12 @@ int32_t tscValidateName(SStrToken* pToken, bool escapeEnabled, bool *dbIncluded)
}
}
if (escapeEnabled && pToken->type == TK_ID) {
if (pToken->z[0] == TS_BACKQUOTE_CHAR) {
pToken->n = stringProcess(pToken->z, pToken->n);
firstPartQuote = true;
}
}
int32_t firstPartLen = pToken->n;
pToken->z = sep + 1;
......@@ -4191,20 +4195,20 @@ static void tscSubqueryCompleteCallback(void* param, TAOS_RES* tres, int code) {
}
int32_t doInitSubState(SSqlObj* pSql, int32_t numOfSubqueries) {
//bug fix. Above doInitSubState level, the loop invocation with the same SSqlObj will be fail.
//assert(pSql->subState.numOfSub == 0 && pSql->pSubs == NULL && pSql->subState.states == NULL);
// bug fix. Above doInitSubState level, the loop invocation with the same SSqlObj will be fail.
// assert(pSql->subState.numOfSub == 0 && pSql->pSubs == NULL && pSql->subState.states == NULL);
if(pSql->pSubs) {
free(pSql->pSubs);
pSql->pSubs = NULL;
}
if(pSql->subState.states) {
free(pSql->subState.states);
pSql->subState.states = NULL;
}
pSql->subState.numOfSub = numOfSubqueries;
pSql->pSubs = calloc(pSql->subState.numOfSub, POINTER_BYTES);
pSql->subState.states = calloc(pSql->subState.numOfSub, sizeof(int8_t));
......@@ -4230,7 +4234,7 @@ void executeQuery(SSqlObj* pSql, SQueryInfo* pQueryInfo) {
(*pSql->fp)(pSql->param, pSql, 0);
}
return ;
}
}
if (pSql->cmd.command == TSDB_SQL_SELECT) {
tscAddIntoSqlList(pSql);
......
......@@ -148,7 +148,7 @@ void shellInit(SShellArguments *_args) {
exit(EXIT_SUCCESS);
}
#endif
return;
}
......@@ -335,7 +335,7 @@ void shellRunCommandOnServer(TAOS *con, char command[]) {
int64_t oresult = atomic_load_64(&result);
if (regex_match(command, "^\\s*use\\s+[a-zA-Z0-9_]+\\s*;\\s*$", REG_EXTENDED | REG_ICASE)) {
if (regex_match(command, "^\\s*use\\s+([a-zA-Z0-9_]+|`.+`)\\s*;\\s*$", REG_EXTENDED | REG_ICASE)) {
fprintf(stdout, "Database changed.\n\n");
fflush(stdout);
......@@ -1520,7 +1520,7 @@ int wsclient_print_data(int rows, TAOS_FIELD *fields, int cols, int64_t id, int
if (*pshowed_rows == DEFAULT_RES_SHOW_NUM) {
free(recv_buffer);
return 0;
}
}
for (int c = 0; c < cols; c++) {
pos = start;
pos += i * fields[c].bytes;
......
......@@ -719,13 +719,14 @@ static int32_t monBuildMnodesTotalSql(char *sql) {
static int32_t monGetVgroupsTotalStats(char *dbName, int32_t *totalVgroups,
int32_t *totalVgroupsAlive) {
char subsql[TSDB_DB_NAME_LEN + 14];
int bufLen = TSDB_DB_NAME_LEN + 16;
char subsql[bufLen];
memset(subsql, 0, sizeof(subsql));
snprintf(subsql, TSDB_DB_NAME_LEN + 13, "show %s.vgroups", dbName);
snprintf(subsql, bufLen - 1, "show `%s`.vgroups", dbName);
TAOS_RES *result = taos_query(tsMonitor.conn, subsql);
int32_t code = taos_errno(result);
if (code != TSDB_CODE_SUCCESS) {
monError("failed to execute cmd: show %s.vgroups, reason:%s", dbName, tstrerror(code));
monError("failed to execute cmd: show `%s`.vgroups, reason:%s", dbName, tstrerror(code));
}
TAOS_ROW row;
......@@ -1110,11 +1111,11 @@ static uint32_t monBuildVgroupsInfoSql(char *sql, char *dbName) {
int64_t ts = taosGetTimestampUs();
memset(sql, 0, SQL_LENGTH + 1);
snprintf(sql, SQL_LENGTH, "show %s.vgroups", dbName);
snprintf(sql, SQL_LENGTH, "show `%s`.vgroups", dbName);
TAOS_RES *result = taos_query(tsMonitor.conn, sql);
int32_t code = taos_errno(result);
if (code != TSDB_CODE_SUCCESS) {
monError("failed to execute cmd: show %s.vgroups, reason:%s", dbName, tstrerror(code));
monError("failed to execute cmd: show `%s`.vgroups, reason:%s", dbName, tstrerror(code));
}
TAOS_ROW row;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册