未验证 提交 d0e003b9 编写于 作者: S slguan 提交者: GitHub

Merge pull request #195 from localvar/master

minor improvements to 'setErrMsg'
......@@ -345,7 +345,7 @@ int32_t tsParseOneColumnData(SSchema* pSchema, char* value, int valuelen, char*
// todo merge the error msg function with tSQLParser
static void setErrMsg(char* msg, char* sql) {
char msgFormat[] = "near \"%s\" syntax error";
const char* msgFormat = "near \"%s\" syntax error";
const int32_t BACKWARD_CHAR_STEP = 15;
// only extract part of sql string,avoid too long sql string cause stack over flow
......
......@@ -75,7 +75,7 @@ static int32_t insertResultField(SSqlCmd* pCmd, int32_t fieldIDInResult, SColumn
int8_t type, char* fieldName);
static int32_t changeFunctionID(int32_t optr, int16_t* pExpr);
static void setErrMsg(SSqlCmd* pCmd, char* pzErrMsg, int32_t maxLen);
static void setErrMsg(SSqlCmd* pCmd, const char* pzErrMsg);
static int32_t buildSelectionClause(SSqlCmd* pCmd, tSQLExprList* pSelection, bool isMetric);
......@@ -139,7 +139,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
SSqlCmd* pCmd = &(pSql->cmd);
if (!pInfo->validSql) {
setErrMsg(pCmd, pInfo->pzErrMsg, tListLen(pInfo->pzErrMsg));
setErrMsg(pCmd, pInfo->pzErrMsg);
return TSDB_CODE_INVALID_SQL;
}
......@@ -152,13 +152,13 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
case DROP_USER:
case DROP_ACCOUNT:
case DROP_DATABASE: {
char msg[] = "param name too long";
char msg1[] = "invalid ip address";
char msg2[] = "invalid name";
const char* msg = "param name too long";
const char* msg1 = "invalid ip address";
const char* msg2 = "invalid name";
SSQLToken* pzName = &pInfo->pDCLInfo->a[0];
if ((pInfo->sqlType != DROP_DNODE) && (tscValidateName(pzName) != TSDB_CODE_SUCCESS)) {
setErrMsg(pCmd, msg2, tListLen(msg2));
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
}
......@@ -170,7 +170,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
int32_t code = setObjFullName(pCmd->name, getAccountId(pSql), pzName, NULL, NULL);
if (code != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg2, tListLen(msg2));
setErrMsg(pCmd, msg2);
}
return code;
......@@ -182,12 +182,12 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
int32_t ret = setMeterID(pSql, pzName);
if (ret != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg, tListLen(msg));
setErrMsg(pCmd, msg);
}
return ret;
} else {
if (pzName->n > TSDB_USER_LEN) {
setErrMsg(pCmd, msg, tListLen(msg));
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
......@@ -201,19 +201,19 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
case USE_DATABASE: {
char msg[] = "db name too long";
const char* msg = "db name too long";
pCmd->command = TSDB_SQL_USE_DB;
SSQLToken* pToken = &pInfo->pDCLInfo->a[0];
if (tscValidateName(pToken) != TSDB_CODE_SUCCESS) {
char msg1[] = "invalid db name";
setErrMsg(pCmd, msg1, tListLen(msg1));
const char* msg1 = "invalid db name";
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
}
if (pToken->n > TSDB_DB_NAME_LEN) {
setErrMsg(pCmd, msg, tListLen(msg));
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
......@@ -246,8 +246,8 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
case ALTER_DATABASE:
case CREATE_DATABASE: {
char msg2[] = "name too long";
char msg3[] = "invalid db name";
const char* msg2 = "name too long";
const char* msg3 = "invalid db name";
if (pInfo->sqlType == ALTER_DATABASE) {
pCmd->command = TSDB_SQL_ALTER_DB;
......@@ -258,13 +258,13 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
SCreateDBInfo* pCreateDB = &(pInfo->pDCLInfo->dbOpt);
if (tscValidateName(&pCreateDB->dbname) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg3, tListLen(msg3));
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
}
int32_t ret = setObjFullName(pCmd->name, getAccountId(pSql), &(pCreateDB->dbname), NULL, NULL);
if (ret != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg2, tListLen(msg2));
setErrMsg(pCmd, msg2);
return ret;
}
......@@ -279,14 +279,14 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
pCmd->command = (pInfo->sqlType == CREATE_USER) ? TSDB_SQL_CREATE_USER : TSDB_SQL_CREATE_ACCT;
assert(pInfo->pDCLInfo->nTokens >= 2);
char msg[] = "name or password too long";
char msg1[] = "password can not be empty";
char msg2[] = "invalid user/account name";
char msg3[] = "password needs single quote marks enclosed";
char msg4[] = "invalid state option, available options[no, r, w, all]";
const char* msg = "name or password too long";
const char* msg1 = "password can not be empty";
const char* msg2 = "invalid user/account name";
const char* msg3 = "password needs single quote marks enclosed";
const char* msg4 = "invalid state option, available options[no, r, w, all]";
if (pInfo->pDCLInfo->a[1].type != TK_STRING) {
setErrMsg(pCmd, msg3, tListLen(msg3));
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
}
......@@ -295,17 +295,17 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
pInfo->pDCLInfo->a[1].n = strlen(pInfo->pDCLInfo->a[1].z);
if (pInfo->pDCLInfo->a[1].n <= 0) {
setErrMsg(pCmd, msg1, tListLen(msg1));
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
}
if (pInfo->pDCLInfo->a[0].n > TSDB_USER_LEN || pInfo->pDCLInfo->a[1].n > TSDB_PASSWORD_LEN) {
setErrMsg(pCmd, msg, tListLen(msg));
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
if (tscValidateName(&pInfo->pDCLInfo->a[0]) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg2, tListLen(msg2));
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
}
......@@ -318,15 +318,15 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
int32_t num = pInfo->pDCLInfo->nTokens;
assert(num >= 1 && num <= 2);
char msg[] = "password too long";
char msg1[] = "password can not be empty";
char msg2[] = "invalid user/account name";
char msg3[] = "password needs single quote marks enclosed";
char msg4[] = "invalid state option, available options[no, r, w, all]";
const char* msg = "password too long";
const char* msg1 = "password can not be empty";
const char* msg2 = "invalid user/account name";
const char* msg3 = "password needs single quote marks enclosed";
const char* msg4 = "invalid state option, available options[no, r, w, all]";
if (num == 2) {
if (pInfo->pDCLInfo->a[1].type != TK_STRING) {
setErrMsg(pCmd, msg3, tListLen(msg3));
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
}
......@@ -335,12 +335,12 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
pInfo->pDCLInfo->a[1].n = strlen(pInfo->pDCLInfo->a[1].z);
if (pInfo->pDCLInfo->a[1].n <= 0) {
setErrMsg(pCmd, msg1, tListLen(msg1));
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
}
if (pInfo->pDCLInfo->a[1].n > TSDB_PASSWORD_LEN) {
setErrMsg(pCmd, msg, tListLen(msg));
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
......@@ -348,12 +348,12 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
if (pInfo->pDCLInfo->a[0].n > TSDB_USER_LEN) {
setErrMsg(pCmd, msg, tListLen(msg));
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
if (tscValidateName(&pInfo->pDCLInfo->a[0]) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg2, tListLen(msg2));
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
}
......@@ -384,7 +384,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
} else if (strncmp(pAcctOpt->stat.z, "no", 2) == 0 && pAcctOpt->stat.n == 2) {
pCmd->defaultVal[8] = 0;
} else {
setErrMsg(pCmd, msg4, tListLen(msg4));
setErrMsg(pCmd, msg4);
return TSDB_CODE_INVALID_SQL;
}
}
......@@ -394,21 +394,21 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
pCmd->command = TSDB_SQL_DESCRIBE_TABLE;
SSQLToken* pToken = &pInfo->pDCLInfo->a[0];
char msg[] = "table name is too long";
const char* msg = "table name is too long";
if (tscValidateName(pToken) != TSDB_CODE_SUCCESS) {
char msg1[] = "invalid table name";
setErrMsg(pCmd, msg1, tListLen(msg1));
const char* msg1 = "invalid table name";
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
}
if (pToken->n > TSDB_METER_NAME_LEN) {
setErrMsg(pCmd, msg, tListLen(msg));
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
if (setMeterID(pSql, pToken) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg, tListLen(msg));
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
......@@ -426,10 +426,10 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
tDCLSQL* pDCL = pInfo->pDCLInfo;
char msg[] = "parameters too long";
char msg1[] = "invalid ip address";
char msg2[] = "invalid configure options or values";
char msg3[] = "password can not be empty";
const char* msg = "parameters too long";
const char* msg1 = "invalid ip address";
const char* msg2 = "invalid configure options or values";
const char* msg3 = "password can not be empty";
if (pInfo->sqlType != ALTER_DNODE) {
strdequote(pDCL->a[1].z);
......@@ -438,12 +438,12 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
if (pDCL->a[1].n <= 0) {
setErrMsg(pCmd, msg3, tListLen(msg3));
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
}
if (pDCL->a[0].n > TSDB_METER_NAME_LEN || pDCL->a[1].n > TSDB_PASSWORD_LEN) {
setErrMsg(pCmd, msg, tListLen(msg));
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
......@@ -453,7 +453,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
/* validate the ip address */
if (!validateIpAddress(ip)) {
setErrMsg(pCmd, msg1, tListLen(msg1));
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
}
......@@ -461,7 +461,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
/* validate the parameter names and options */
if (validateDNodeConfig(pDCL) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg2, tListLen(msg2));
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
}
......@@ -472,8 +472,8 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
strncpy(&pCmd->payload[pDCL->a[1].n + 1], pDCL->a[2].z, pDCL->a[2].n);
}
} else {
char msg[] = "invalid user rights";
char msg1[] = "password can not be empty or larger than 24 characters";
const char* msg = "invalid user rights";
const char* msg1 = "password can not be empty or larger than 24 characters";
strncpy(pCmd->name, pDCL->a[0].z, pDCL->a[0].n);
......@@ -486,7 +486,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
if (pDCL->a[1].n <= 0 || pInfo->pDCLInfo->a[1].n > TSDB_PASSWORD_LEN) {
/* password cannot be empty string */
setErrMsg(pCmd, msg1, tListLen(msg1));
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
}
......@@ -501,7 +501,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
} else if (strncasecmp(pDCL->a[1].z, "write", 5) == 0 && pDCL->a[1].n == 5) {
pCmd->count = 3;
} else {
setErrMsg(pCmd, msg, tListLen(msg));
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
} else {
......@@ -512,9 +512,9 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
case ALTER_LOCAL: {
pCmd->command = TSDB_SQL_CFG_LOCAL;
char msg[] = "parameter too long";
const char* msg = "parameter too long";
if (pInfo->pDCLInfo->a[0].n > TSDB_METER_ID_LEN) {
setErrMsg(pCmd, msg, tListLen(msg));
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
......@@ -523,8 +523,8 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
case TSQL_CREATE_NORMAL_METER:
case TSQL_CREATE_NORMAL_METRIC: {
char msg[] = "table name too long";
char msg1[] = "invalid table name";
const char* msg = "table name too long";
const char* msg1 = "invalid table name";
tFieldList* pFieldList = pInfo->pCreateTableInfo->colInfo.pColumns;
tFieldList* pTagList = pInfo->pCreateTableInfo->colInfo.pTagColumns;
......@@ -537,12 +537,12 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
SSQLToken* pzTableName = &(pInfo->pCreateTableInfo->name);
if (tscValidateName(pzTableName) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg1, tListLen(msg1));
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
}
if (setMeterID(pSql, pzTableName) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg, tListLen(msg));
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
......@@ -570,16 +570,16 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
pCmd->command = TSDB_SQL_CREATE_TABLE;
pCmd->existsCheck = pInfo->pCreateTableInfo->existCheck;
char msg[] = "invalid table name";
char msg1[] = "illegal value or data overflow";
char msg2[] = "illegal number of tags";
const char* msg = "invalid table name";
const char* msg1 = "illegal value or data overflow";
const char* msg2 = "illegal number of tags";
// table name
// metric name, create table by using dst
SSQLToken* pToken = &(pInfo->pCreateTableInfo->usingInfo.metricName);
if (tscValidateName(pToken) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg, tListLen(msg));
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
......@@ -600,7 +600,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
if (pSql->cmd.pMeterMeta->numOfTags != pList->nExpr) {
setErrMsg(pCmd, msg2, tListLen(msg2));
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
}
......@@ -611,7 +611,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
for (int32_t i = 0; i < pList->nExpr; ++i) {
int32_t ret = tVariantDump(&(pList->a[i].pVar), tagVal, pTagSchema[i].type);
if (ret != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg1, tListLen(msg1));
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
}
......@@ -619,7 +619,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
if (tscValidateName(&pInfo->pCreateTableInfo->name) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg, tListLen(msg));
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
......@@ -634,26 +634,26 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
case TSQL_CREATE_STREAM: {
pCmd->command = TSDB_SQL_CREATE_TABLE;
char msg[] = "table name too long";
char msg1[] = "invalid table name";
const char* msg = "table name too long";
const char* msg1 = "invalid table name";
// if sql specifies db, use it, otherwise use default db
SSQLToken* pzTableName = &(pInfo->pCreateTableInfo->name);
SQuerySQL* pQuerySql = pInfo->pCreateTableInfo->pSelect;
if (tscValidateName(pzTableName) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg1, tListLen(msg1));
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
}
SSQLToken* pSrcMeterName = &pInfo->pCreateTableInfo->pSelect->from;
if (tscValidateName(pSrcMeterName) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg1, tListLen(msg1));
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
}
if (setMeterID(pSql, pSrcMeterName) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg, tListLen(msg));
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
......@@ -688,7 +688,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
// set the created table[stream] name
if (setMeterID(pSql, pzTableName) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg, tListLen(msg));
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
......@@ -697,8 +697,8 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
strncpy(pCmd->payload, pQuerySql->selectToken.z, pQuerySql->selectToken.n);
if (pQuerySql->selectToken.n > TSDB_MAX_SAVED_SQL_LEN) {
char msg4[] = "sql too long"; // todo ADD support
setErrMsg(pCmd, msg, tListLen(msg4));
const char* msg4 = "sql too long"; // todo ADD support
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
......@@ -717,8 +717,8 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
*/
if (pQuerySql->fillType != NULL) {
if (pCmd->nAggTimeInterval == 0) {
char msg1[] = "fill only available for interval query";
setErrMsg(pCmd, msg1, tListLen(msg1));
const char* msg1 = "fill only available for interval query";
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
}
......@@ -727,8 +727,8 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
if (pItem->pVar.nType == TSDB_DATA_TYPE_BINARY) {
if (!((strncmp(pItem->pVar.pz, "none", 4) == 0 && pItem->pVar.nLen == 4) ||
(strncmp(pItem->pVar.pz, "null", 4) == 0 && pItem->pVar.nLen == 4))) {
char msg2[] = "fill option not supported in stream computing";
setErrMsg(pCmd, msg2, tListLen(msg2));
const char* msg2 = "fill option not supported in stream computing";
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
}
......@@ -744,20 +744,20 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
// too many result columns not support order by in query
if (pQuerySql->pSelection->nExpr > TSDB_MAX_COLUMNS) {
char msg[] = "too many columns in selection clause";
setErrMsg(pCmd, msg, tListLen(msg));
const char* msg = "too many columns in selection clause";
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
if (tscValidateName(&(pQuerySql->from)) != TSDB_CODE_SUCCESS) {
char msg[] = "invalid table name";
setErrMsg(pCmd, msg, tListLen(msg));
const char* msg = "invalid table name";
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
if (setMeterID(pSql, &pQuerySql->from) != TSDB_CODE_SUCCESS) {
char msg[] = "table name too long";
setErrMsg(pCmd, msg, tListLen(msg));
const char* msg = "table name too long";
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
......@@ -786,8 +786,8 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
SSQLToken* pSliding = &pQuerySql->sliding;
if (pSliding->n != 0) {
if (!tscEmbedded) {
char msg[] = "not support sliding in query";
setErrMsg(pCmd, msg, tListLen(msg));
const char* msg = "not support sliding in query";
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
......@@ -796,16 +796,16 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
pCmd->nSlidingTime /= 1000;
}
char msg3[] = "sliding value too small";
char msg4[] = "sliding value no larger than the interval value";
const char* msg3 = "sliding value too small";
const char* msg4 = "sliding value no larger than the interval value";
if (pCmd->nSlidingTime < tsMinSlidingTime) {
setErrMsg(pCmd, msg3, tListLen(msg3));
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
}
if (pCmd->nSlidingTime > pCmd->nAggTimeInterval) {
setErrMsg(pCmd, msg4, tListLen(msg4));
setErrMsg(pCmd, msg4);
return TSDB_CODE_INVALID_SQL;
}
}
......@@ -842,17 +842,17 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
if (!hasTimestampForPointInterpQuery(pCmd)) {
char msg[] = "point interpolation query needs timestamp";
setErrMsg(pCmd, msg, tListLen(msg));
const char* msg = "point interpolation query needs timestamp";
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
if (pQuerySql->fillType != NULL) {
char msg1[] = "fill only available for interval query";
char msg2[] = "start(end) time of query range required or time range too large";
const char* msg1 = "fill only available for interval query";
const char* msg2 = "start(end) time of query range required or time range too large";
if (pCmd->nAggTimeInterval == 0 && (!tscIsPointInterpQuery(pCmd))) {
setErrMsg(pCmd, msg1, tListLen(msg1));
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
}
......@@ -862,7 +862,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
// TODO define macro
if ((timeRange == 0) || (timeRange / pCmd->nAggTimeInterval) > 10000000) {
setErrMsg(pCmd, msg2, tListLen(msg2));
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
}
}
......@@ -941,8 +941,8 @@ int32_t setIntervalClause(SSqlCmd* pCmd, SQuerySQL* pQuerySql) {
// interval cannot be less than 10 milliseconds
if (pCmd->nAggTimeInterval < tsMinIntervalTime) {
char msg[] = "interval cannot be less than 10 ms";
setErrMsg(pCmd, msg, tListLen(msg));
const char* msg = "interval cannot be less than 10 ms";
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
......@@ -961,8 +961,8 @@ int32_t setIntervalClause(SSqlCmd* pCmd, SQuerySQL* pQuerySql) {
}
int32_t setSlidingClause(SSqlCmd* pCmd, SQuerySQL* pQuerySql) {
char msg0[] = "sliding value too small";
char msg1[] = "sliding value no larger than the interval value";
const char* msg0 = "sliding value too small";
const char* msg1 = "sliding value no larger than the interval value";
SSQLToken* pSliding = &pQuerySql->sliding;
......@@ -973,12 +973,12 @@ int32_t setSlidingClause(SSqlCmd* pCmd, SQuerySQL* pQuerySql) {
}
if (pCmd->nSlidingTime < tsMinSlidingTime) {
setErrMsg(pCmd, msg0, tListLen(msg0));
setErrMsg(pCmd, msg0);
return TSDB_CODE_INVALID_SQL;
}
if (pCmd->nSlidingTime > pCmd->nAggTimeInterval) {
setErrMsg(pCmd, msg1, tListLen(msg1));
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
}
}
......@@ -992,7 +992,7 @@ int32_t setMeterID(SSqlObj *pSql, SSQLToken *pzTableName) {
//clear array
memset(pCmd->name, 0, tListLen(pCmd->name));
char msg[] = "name too long";
const char* msg = "name too long";
if (hasSpecifyDB(pzTableName)) {
/*
......@@ -1009,7 +1009,7 @@ int32_t setMeterID(SSqlObj *pSql, SSQLToken *pzTableName) {
}
if (ret != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg, tListLen(msg));
setErrMsg(pCmd, msg);
}
return ret;
......@@ -1018,23 +1018,23 @@ int32_t setMeterID(SSqlObj *pSql, SSQLToken *pzTableName) {
static bool validateTableColumnInfo(tFieldList* pFieldList, SSqlCmd* pCmd) {
assert(pFieldList != NULL);
char msg[] = "illegal number of columns";
char msg1[] = "first column must be timestamp";
char msg2[] = "row length exceeds max length";
char msg3[] = "duplicated column names";
char msg4[] = "invalid data types";
char msg5[] = "invalid binary/nchar column length";
char msg6[] = "invalid column name";
const char* msg = "illegal number of columns";
const char* msg1 = "first column must be timestamp";
const char* msg2 = "row length exceeds max length";
const char* msg3 = "duplicated column names";
const char* msg4 = "invalid data types";
const char* msg5 = "invalid binary/nchar column length";
const char* msg6 = "invalid column name";
// number of fields no less than 2
if (pFieldList->nField <= 1 || pFieldList->nField > TSDB_MAX_COLUMNS) {
setErrMsg(pCmd, msg, tListLen(msg));
setErrMsg(pCmd, msg);
return false;
}
// first column must be timestamp
if (pFieldList->p[0].type != TSDB_DATA_TYPE_TIMESTAMP) {
setErrMsg(pCmd, msg1, tListLen(msg1));
setErrMsg(pCmd, msg1);
return false;
}
......@@ -1045,7 +1045,7 @@ static bool validateTableColumnInfo(tFieldList* pFieldList, SSqlCmd* pCmd) {
// max row length must be less than TSDB_MAX_BYTES_PER_ROW
if (nLen > TSDB_MAX_BYTES_PER_ROW) {
setErrMsg(pCmd, msg2, tListLen(msg2));
setErrMsg(pCmd, msg2);
return false;
}
......@@ -1053,23 +1053,23 @@ static bool validateTableColumnInfo(tFieldList* pFieldList, SSqlCmd* pCmd) {
for (int32_t i = 0; i < pFieldList->nField; ++i) {
TAOS_FIELD* pField = &pFieldList->p[i];
if (pField->type < TSDB_DATA_TYPE_BOOL || pField->type > TSDB_DATA_TYPE_NCHAR) {
setErrMsg(pCmd, msg4, tListLen(msg4));
setErrMsg(pCmd, msg4);
return false;
}
if ((pField->type == TSDB_DATA_TYPE_BINARY && (pField->bytes <= 0 || pField->bytes > TSDB_MAX_BINARY_LEN)) ||
(pField->type == TSDB_DATA_TYPE_NCHAR && (pField->bytes <= 0 || pField->bytes > TSDB_MAX_NCHAR_LEN))) {
setErrMsg(pCmd, msg5, tListLen(msg5));
setErrMsg(pCmd, msg5);
return false;
}
if (validateColumnName(pField->name) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg6, tListLen(msg6));
setErrMsg(pCmd, msg6);
return false;
}
if (has(pFieldList, i + 1, pFieldList->p[i].name) == true) {
setErrMsg(pCmd, msg3, tListLen(msg3));
setErrMsg(pCmd, msg3);
return false;
}
}
......@@ -1080,17 +1080,17 @@ static bool validateTableColumnInfo(tFieldList* pFieldList, SSqlCmd* pCmd) {
static bool validateTagParams(tFieldList* pTagsList, tFieldList* pFieldList, SSqlCmd* pCmd) {
assert(pTagsList != NULL);
char msg1[] = "invalid number of tag columns";
char msg2[] = "tag length too long";
char msg3[] = "duplicated column names";
char msg4[] = "timestamp not allowed in tags";
char msg5[] = "invalid data type in tags";
char msg6[] = "invalid tag name";
char msg7[] = "invalid binary/nchar tag length";
const char* msg1 = "invalid number of tag columns";
const char* msg2 = "tag length too long";
const char* msg3 = "duplicated column names";
const char* msg4 = "timestamp not allowed in tags";
const char* msg5 = "invalid data type in tags";
const char* msg6 = "invalid tag name";
const char* msg7 = "invalid binary/nchar tag length";
// number of fields at least 1
if (pTagsList->nField < 1 || pTagsList->nField > TSDB_MAX_TAGS) {
setErrMsg(pCmd, msg1, tListLen(msg1));
setErrMsg(pCmd, msg1);
return false;
}
......@@ -1101,14 +1101,14 @@ static bool validateTagParams(tFieldList* pTagsList, tFieldList* pFieldList, SSq
// max tag row length must be less than TSDB_MAX_TAGS_LEN
if (nLen > TSDB_MAX_TAGS_LEN) {
setErrMsg(pCmd, msg2, tListLen(msg2));
setErrMsg(pCmd, msg2);
return false;
}
// field name must be unique
for (int32_t i = 0; i < pTagsList->nField; ++i) {
if (has(pFieldList, 0, pTagsList->p[i].name) == true) {
setErrMsg(pCmd, msg3, tListLen(msg3));
setErrMsg(pCmd, msg3);
return false;
}
}
......@@ -1116,28 +1116,28 @@ static bool validateTagParams(tFieldList* pTagsList, tFieldList* pFieldList, SSq
/* timestamp in tag is not allowed */
for (int32_t i = 0; i < pTagsList->nField; ++i) {
if (pTagsList->p[i].type == TSDB_DATA_TYPE_TIMESTAMP) {
setErrMsg(pCmd, msg4, tListLen(msg4));
setErrMsg(pCmd, msg4);
return false;
}
if (pTagsList->p[i].type < TSDB_DATA_TYPE_BOOL || pTagsList->p[i].type > TSDB_DATA_TYPE_NCHAR) {
setErrMsg(pCmd, msg5, tListLen(msg5));
setErrMsg(pCmd, msg5);
return false;
}
if ((pTagsList->p[i].type == TSDB_DATA_TYPE_BINARY && pTagsList->p[i].bytes <= 0) ||
(pTagsList->p[i].type == TSDB_DATA_TYPE_NCHAR && pTagsList->p[i].bytes <= 0)) {
setErrMsg(pCmd, msg7, tListLen(msg7));
setErrMsg(pCmd, msg7);
return false;
}
if (validateColumnName(pTagsList->p[i].name) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg6, tListLen(msg6));
setErrMsg(pCmd, msg6);
return false;
}
if (has(pTagsList, i + 1, pTagsList->p[i].name) == true) {
setErrMsg(pCmd, msg3, tListLen(msg3));
setErrMsg(pCmd, msg3);
return false;
}
}
......@@ -1149,12 +1149,12 @@ static bool validateTagParams(tFieldList* pTagsList, tFieldList* pFieldList, SSq
* tags name /column name is truncated in sql.y
*/
bool validateOneTags(SSqlCmd* pCmd, TAOS_FIELD* pTagField) {
char msg1[] = "timestamp not allowed in tags";
char msg2[] = "duplicated column names";
char msg3[] = "tag length too long";
char msg4[] = "invalid tag name";
char msg5[] = "invalid binary/nchar tag length";
char msg6[] = "invalid data type in tags";
const char* msg1 = "timestamp not allowed in tags";
const char* msg2 = "duplicated column names";
const char* msg3 = "tag length too long";
const char* msg4 = "invalid tag name";
const char* msg5 = "invalid binary/nchar tag length";
const char* msg6 = "invalid data type in tags";
SMeterMeta* pMeterMeta = pCmd->pMeterMeta;
......@@ -1163,18 +1163,18 @@ bool validateOneTags(SSqlCmd* pCmd, TAOS_FIELD* pTagField) {
char msg[128] = {0};
sprintf(msg, "tags no more than %d", TSDB_MAX_TAGS);
setErrMsg(pCmd, msg, strlen(msg));
setErrMsg(pCmd, msg);
return false;
}
// no timestamp allowable
if (pTagField->type == TSDB_DATA_TYPE_TIMESTAMP) {
setErrMsg(pCmd, msg1, tListLen(msg1));
setErrMsg(pCmd, msg1);
return false;
}
if (pTagField->type < TSDB_DATA_TYPE_BOOL && pTagField->type > TSDB_DATA_TYPE_NCHAR) {
setErrMsg(pCmd, msg6, tListLen(msg6));
setErrMsg(pCmd, msg6);
return false;
}
......@@ -1187,19 +1187,19 @@ bool validateOneTags(SSqlCmd* pCmd, TAOS_FIELD* pTagField) {
// length less than TSDB_MAX_TASG_LEN
if (nLen + pTagField->bytes > TSDB_MAX_TAGS_LEN) {
setErrMsg(pCmd, msg3, tListLen(msg3));
setErrMsg(pCmd, msg3);
return false;
}
// tags name can not be a keyword
if (validateColumnName(pTagField->name) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg4, tListLen(msg4));
setErrMsg(pCmd, msg4);
return false;
}
// binary(val), val can not be equalled to or less than 0
if ((pTagField->type == TSDB_DATA_TYPE_BINARY || pTagField->type == TSDB_DATA_TYPE_NCHAR) && pTagField->bytes <= 0) {
setErrMsg(pCmd, msg5, tListLen(msg5));
setErrMsg(pCmd, msg5);
return false;
}
......@@ -1208,7 +1208,7 @@ bool validateOneTags(SSqlCmd* pCmd, TAOS_FIELD* pTagField) {
for (int32_t i = 0; i < pMeterMeta->numOfTags + pMeterMeta->numOfColumns; ++i) {
if (strncasecmp(pTagField->name, pSchema[i].name, TSDB_COL_NAME_LEN) == 0) {
setErrMsg(pCmd, msg2, tListLen(msg2));
setErrMsg(pCmd, msg2);
return false;
}
}
......@@ -1217,29 +1217,29 @@ bool validateOneTags(SSqlCmd* pCmd, TAOS_FIELD* pTagField) {
}
bool validateOneColumn(SSqlCmd* pCmd, TAOS_FIELD* pColField) {
char msg1[] = "too many columns";
char msg2[] = "duplicated column names";
char msg3[] = "column length too long";
char msg4[] = "invalid data types";
char msg5[] = "invalid column name";
char msg6[] = "invalid column length";
const char* msg1 = "too many columns";
const char* msg2 = "duplicated column names";
const char* msg3 = "column length too long";
const char* msg4 = "invalid data types";
const char* msg5 = "invalid column name";
const char* msg6 = "invalid column length";
SMeterMeta* pMeterMeta = pCmd->pMeterMeta;
// no more max columns
if (pMeterMeta->numOfColumns >= TSDB_MAX_COLUMNS ||
pMeterMeta->numOfTags + pMeterMeta->numOfColumns >= TSDB_MAX_COLUMNS) {
setErrMsg(pCmd, msg1, tListLen(msg1));
setErrMsg(pCmd, msg1);
return false;
}
if (pColField->type < TSDB_DATA_TYPE_BOOL || pColField->type > TSDB_DATA_TYPE_NCHAR) {
setErrMsg(pCmd, msg4, tListLen(msg4));
setErrMsg(pCmd, msg4);
return false;
}
if (validateColumnName(pColField->name) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg5, tListLen(msg5));
setErrMsg(pCmd, msg5);
return false;
}
......@@ -1251,20 +1251,20 @@ bool validateOneColumn(SSqlCmd* pCmd, TAOS_FIELD* pColField) {
}
if (pColField->bytes <= 0) {
setErrMsg(pCmd, msg6, tListLen(msg6));
setErrMsg(pCmd, msg6);
return false;
}
// length less than TSDB_MAX_BYTES_PER_ROW
if (nLen + pColField->bytes > TSDB_MAX_BYTES_PER_ROW) {
setErrMsg(pCmd, msg3, tListLen(msg3));
setErrMsg(pCmd, msg3);
return false;
}
// field name must be unique
for (int32_t i = 0; i < pMeterMeta->numOfTags + pMeterMeta->numOfColumns; ++i) {
if (strncasecmp(pColField->name, pSchema[i].name, TSDB_COL_NAME_LEN) == 0) {
setErrMsg(pCmd, msg2, tListLen(msg2));
setErrMsg(pCmd, msg2);
return false;
}
}
......@@ -1365,10 +1365,10 @@ static void extractColumnNameFromString(tSQLExprItem* pItem, char* tmpBuf) {
int32_t buildSelectionClause(SSqlCmd* pCmd, tSQLExprList* pSelection, bool isMetric) {
assert(pSelection != NULL && pCmd != NULL);
char msg1[] = "invalid column name/illegal column type in arithmetic expression";
char msg2[] = "functions can not be mixed up";
char msg3[] = "not support query expression";
char msg4[] = "function not support in STable query";
const char* msg1 = "invalid column name/illegal column type in arithmetic expression";
const char* msg2 = "functions can not be mixed up";
const char* msg3 = "not support query expression";
const char* msg4 = "function not support in STable query";
SSchema* pSchema = tsGetSchema(pCmd->pMeterMeta);
......@@ -1405,7 +1405,7 @@ int32_t buildSelectionClause(SSqlCmd* pCmd, tSQLExprList* pSelection, bool isMet
/* arithmetic function in select*/
int32_t ret = validateArithmeticSQLExpr(pItem->pNode, pSchema, pCmd->pMeterMeta->numOfColumns);
if (ret != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg1, tListLen(msg1));
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
}
......@@ -1440,7 +1440,7 @@ int32_t buildSelectionClause(SSqlCmd* pCmd, tSQLExprList* pSelection, bool isMet
* not support such expression
* e.g., select 12+5 from table_name
*/
setErrMsg(pCmd, msg3, tListLen(msg3));
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
}
......@@ -1450,7 +1450,7 @@ int32_t buildSelectionClause(SSqlCmd* pCmd, tSQLExprList* pSelection, bool isMet
}
if (!functionCompatibleCheck(pCmd)) {
setErrMsg(pCmd, msg2, tListLen(msg2));
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
}
......@@ -1469,7 +1469,7 @@ int32_t buildSelectionClause(SSqlCmd* pCmd, tSQLExprList* pSelection, bool isMet
tscTansformSQLFunctionForMetricQuery(pCmd);
if (hasUnsupportFunctionsForMetricQuery(pCmd)) {
setErrMsg(pCmd, msg4, tListLen(msg4));
setErrMsg(pCmd, msg4);
return TSDB_CODE_INVALID_SQL;
}
}
......@@ -1577,8 +1577,8 @@ int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SSchema* pSchema, tSQLExp
addRequiredTagColumn(pCmd, -1);
pExpr->colInfo.isTag = true;
} else {
char msg[] = "invalid column name";
setErrMsg(pCmd, msg, tListLen(msg));
const char* msg = "invalid column name";
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
} else {
......@@ -1610,12 +1610,12 @@ static int32_t setExprInfoForFunctions(SSqlCmd* pCmd, SSchema* pSchema, int32_t
int16_t bytes = 0;
char columnName[TSDB_COL_NAME_LEN] = {0};
char msg1[] = "not support column types";
const char* msg1 = "not support column types";
if (functionID == TSDB_FUNC_SPREAD) {
if (pSchema[idx].type == TSDB_DATA_TYPE_BINARY || pSchema[idx].type == TSDB_DATA_TYPE_NCHAR ||
pSchema[idx].type == TSDB_DATA_TYPE_BOOL) {
setErrMsg(pCmd, msg1, tListLen(msg1));
setErrMsg(pCmd, msg1);
return -1;
} else {
type = TSDB_DATA_TYPE_DOUBLE;
......@@ -1651,16 +1651,16 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, int32_t colIdx, tSQLExprItem* pItem
SSchema* pSchema = tsGetSchema(pCmd->pMeterMeta);
int32_t numOfAddedColumn = 1;
char msg[] = "invalid parameters";
char msg1[] = "not support column types";
char msg3[] = "illegal column name";
char msg5[] = "parameter is out of range [0, 100]";
const char* msg = "invalid parameters";
const char* msg1 = "not support column types";
const char* msg3 = "illegal column name";
const char* msg5 = "parameter is out of range [0, 100]";
switch (optr) {
case TK_COUNT: {
if (pItem->pNode->pParam != NULL && pItem->pNode->pParam->nExpr != 1) {
/* more than one parameter for count() function */
setErrMsg(pCmd, msg, tListLen(msg));
setErrMsg(pCmd, msg);
return -1;
}
......@@ -1674,7 +1674,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, int32_t colIdx, tSQLExprItem* pItem
if (pItem->pNode->pParam != NULL) {
SSQLToken* pToken = &pItem->pNode->pParam->a[0].pNode->colInfo;
if (pToken->z == NULL || pToken->n == 0) {
setErrMsg(pCmd, msg3, tListLen(msg3));
setErrMsg(pCmd, msg3);
return -1;
}
......@@ -1685,7 +1685,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, int32_t colIdx, tSQLExprItem* pItem
} else {
columnId = getColumnIndexByName(pToken, pSchema, pCmd->pMeterMeta->numOfColumns);
if (columnId < 0) { // invalid column name
setErrMsg(pCmd, msg3, tListLen(msg3));
setErrMsg(pCmd, msg3);
return -1;
}
......@@ -1718,26 +1718,26 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, int32_t colIdx, tSQLExprItem* pItem
if (pItem->pNode->pParam == NULL || (optr != TK_LEASTSQUARES && pItem->pNode->pParam->nExpr != 1) ||
(optr == TK_LEASTSQUARES && pItem->pNode->pParam->nExpr != 3)) {
/* no parameters or more than one parameter for function */
setErrMsg(pCmd, msg, tListLen(msg));
setErrMsg(pCmd, msg);
return -1;
}
tSQLExprItem* pParamElem = &(pItem->pNode->pParam->a[0]);
if (pParamElem->pNode->nSQLOptr != TK_ALL && pParamElem->pNode->nSQLOptr != TK_ID) {
setErrMsg(pCmd, msg, tListLen(msg));
setErrMsg(pCmd, msg);
return -1;
}
int32_t idx = getColumnIndexByName(&pParamElem->pNode->colInfo, pSchema, pCmd->pMeterMeta->numOfColumns);
if (idx < 0) { // invalid column name
setErrMsg(pCmd, msg3, tListLen(msg3));
setErrMsg(pCmd, msg3);
return -1;
}
// 2. check if sql function can be applied on this column data type
int16_t colType = pSchema[idx].type;
if (colType == TSDB_DATA_TYPE_BOOL || colType >= TSDB_DATA_TYPE_BINARY) {
setErrMsg(pCmd, msg1, tListLen(msg1));
setErrMsg(pCmd, msg1);
return -1;
}
......@@ -1799,7 +1799,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, int32_t colIdx, tSQLExprItem* pItem
if (!requireAllFields) {
if (pItem->pNode->pParam->nExpr < 1) {
setErrMsg(pCmd, msg3, tListLen(msg3));
setErrMsg(pCmd, msg3);
return -1;
}
......@@ -1808,7 +1808,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, int32_t colIdx, tSQLExprItem* pItem
for (int32_t i = 0; i < pItem->pNode->pParam->nExpr; ++i) {
tSQLExprItem* pParamElem = &(pItem->pNode->pParam->a[i]);
if (pParamElem->pNode->nSQLOptr != TK_ALL && pParamElem->pNode->nSQLOptr != TK_ID) {
setErrMsg(pCmd, msg3, tListLen(msg3));
setErrMsg(pCmd, msg3);
return -1;
}
......@@ -1840,13 +1840,13 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, int32_t colIdx, tSQLExprItem* pItem
// 1. valid the number of parameters
if (pItem->pNode->pParam == NULL || pItem->pNode->pParam->nExpr != 2) {
/* no parameters or more than one parameter for function */
setErrMsg(pCmd, msg, tListLen(msg));
setErrMsg(pCmd, msg);
return -1;
}
tSQLExprItem* pParamElem = &(pItem->pNode->pParam->a[0]);
if (pParamElem->pNode->nSQLOptr != TK_ID) {
setErrMsg(pCmd, msg, tListLen(msg));
setErrMsg(pCmd, msg);
}
char columnName[TSDB_COL_NAME_LEN] = {0};
......@@ -1860,13 +1860,13 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, int32_t colIdx, tSQLExprItem* pItem
// 2. valid the column type
int16_t colType = pSchema[idx].type;
if (colType == TSDB_DATA_TYPE_BOOL || colType >= TSDB_DATA_TYPE_BINARY) {
setErrMsg(pCmd, msg1, tListLen(msg1));
setErrMsg(pCmd, msg1);
return -1;
}
// 3. valid the parameters
if (pParamElem[1].pNode->nSQLOptr == TK_ID) {
setErrMsg(pCmd, msg, tListLen(msg));
setErrMsg(pCmd, msg);
return -1;
}
......@@ -1881,7 +1881,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, int32_t colIdx, tSQLExprItem* pItem
double dp = *((double*)val);
if (dp < 0 || dp > 100) { // todo use macro
setErrMsg(pCmd, msg5, tListLen(msg5));
setErrMsg(pCmd, msg5);
return -1;
}
......@@ -2037,9 +2037,9 @@ int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
pCmd->command = TSDB_SQL_SHOW;
int8_t type = pInfo->sqlType;
char msg[] = "database name too long";
char msg1[] = "invalid database name";
char msg2[] = "pattern filter string too long";
const char* msg = "database name too long";
const char* msg1 = "invalid database name";
const char* msg2 = "pattern filter string too long";
switch (type) {
case SHOW_VGROUPS:
......@@ -2084,12 +2084,12 @@ int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
SSQLToken* pDbPrefixToken = &pInfo->pDCLInfo->a[0];
if (pDbPrefixToken->n > TSDB_DB_NAME_LEN) { // db name is too long
setErrMsg(pCmd, msg, tListLen(msg));
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
if (pDbPrefixToken->n > 0 && tscValidateName(pDbPrefixToken) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg1, tListLen(msg1));
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
}
......@@ -2116,7 +2116,7 @@ int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
pCmd->payloadLen = strlen(pCmd->payload);
if (pCmd->payloadLen > TSDB_METER_NAME_LEN) {
setErrMsg(pCmd, msg2, tListLen(msg2));
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL; // wildcard is too long
}
}
......@@ -2157,8 +2157,8 @@ int32_t setKillInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
if (!validateIpAddress(ipStr)) {
memset(pCmd->payload, 0, tListLen(pCmd->payload));
char msg[] = "invalid ip address";
setErrMsg(pCmd, msg, tListLen(msg));
const char* msg = "invalid ip address";
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
......@@ -2166,18 +2166,17 @@ int32_t setKillInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
if (port <= 0 || port > 65535) {
memset(pCmd->payload, 0, tListLen(pCmd->payload));
char msg[] = "invalid port";
setErrMsg(pCmd, msg, tListLen(msg));
const char* msg = "invalid port";
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
return TSDB_CODE_SUCCESS;
}
void setErrMsg(SSqlCmd* pCmd, char* pzErrMsg, int32_t maxLen) {
int32_t validLen = (maxLen > pCmd->allocSize) ? pCmd->allocSize : maxLen;
strncpy(pCmd->payload, pzErrMsg, validLen);
pCmd->payload[validLen - 1] = 0;
void setErrMsg(SSqlCmd* pCmd, const char* pzErrMsg) {
strncpy(pCmd->payload, pzErrMsg, pCmd->allocSize);
pCmd->payload[pCmd->allocSize - 1] = 0;
}
bool validateIpAddress(char* ip) {
......@@ -2305,16 +2304,16 @@ void updateTagColumnIndex(SSqlCmd* pCmd) {
}
int32_t setGroupByClause(SSqlCmd* pCmd, tVariantList* pList) {
char msg1[] = "too many columns in group by clause";
char msg2[] = "invalid column name in group by clause";
char msg3[] = "functions are not available in group by query";
char msg4[] = "group by only available for STable query";
const char* msg1 = "too many columns in group by clause";
const char* msg2 = "invalid column name in group by clause";
const char* msg3 = "functions are not available in group by query";
const char* msg4 = "group by only available for STable query";
if (UTIL_METER_IS_NOMRAL_METER(pCmd)) {
if (pList == NULL) {
return TSDB_CODE_SUCCESS;
} else {
setErrMsg(pCmd, msg4, tListLen(msg4));
setErrMsg(pCmd, msg4);
return TSDB_CODE_INVALID_SQL;
}
}
......@@ -2325,7 +2324,7 @@ int32_t setGroupByClause(SSqlCmd* pCmd, tVariantList* pList) {
pCmd->groupbyExpr.numOfGroupbyCols = pList->nExpr;
if (pList->nExpr > TSDB_MAX_TAGS) {
setErrMsg(pCmd, msg1, tListLen(msg1));
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
}
......@@ -2352,7 +2351,7 @@ int32_t setGroupByClause(SSqlCmd* pCmd, tVariantList* pList) {
} else {
colIdx = getColumnIndexByName(&token, pSchema, pMeterMeta->numOfTags + pMeterMeta->numOfColumns);
if (colIdx < pMeterMeta->numOfColumns || colIdx > TSDB_MAX_TAGS + pMeterMeta->numOfColumns) {
setErrMsg(pCmd, msg2, tListLen(msg2));
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
}
......@@ -2390,12 +2389,12 @@ int32_t setGroupByClause(SSqlCmd* pCmd, tVariantList* pList) {
int32_t functId = tscSqlExprGet(pCmd, i)->sqlFuncId;
if (IS_MULTIOUTPUT(aAggs[functId].nStatus) && functId != TSDB_FUNC_TOP_DST && functId != TSDB_FUNC_BOTTOM_DST &&
functId != TSDB_FUNC_TOP && functId != TSDB_FUNC_BOTTOM) {
setErrMsg(pCmd, msg3, tListLen(msg3));
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
}
if (functId == TSDB_FUNC_COUNT && tscSqlExprGet(pCmd, i)->colInfo.colIdx == -1) {
setErrMsg(pCmd, msg3, tListLen(msg3));
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
}
}
......@@ -2591,15 +2590,15 @@ static int32_t buildTagQueryCondString(SSqlCmd* pCmd, tSQLExpr* pExpr, char** qu
tSQLExpr* pLeft = pExpr->pLeft;
tSQLExpr* pRight = pExpr->pRight;
char msg0[] = "invalid table name list";
char msg1[] = "like operation is not allowed on numeric tags";
char msg2[] = "in and query condition cannot be mixed up";
const char* msg0 = "invalid table name list";
const char* msg1 = "like operation is not allowed on numeric tags";
const char* msg2 = "in and query condition cannot be mixed up";
STagCond* pCond = &pCmd->tagCond;
if (pExpr->nSQLOptr == TK_IN && pRight->nSQLOptr == TK_SET) {
/* table name array list, invoke another routine */
if (pCond->type == TSQL_STABLE_QTYPE_COND) {
setErrMsg(pCmd, msg2, tListLen(msg2));
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
}
......@@ -2611,14 +2610,14 @@ static int32_t buildTagQueryCondString(SSqlCmd* pCmd, tSQLExpr* pExpr, char** qu
int32_t ret = createTableNameList(pRight, queryStr);
if (ret != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg0, tListLen(msg0));
setErrMsg(pCmd, msg0);
}
return ret;
}
// already use IN predicates
if (pCond->type == TSQL_STABLE_QTYPE_SET) {
setErrMsg(pCmd, msg2, tListLen(msg2));
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
} else {
pCond->type = TSQL_STABLE_QTYPE_COND;
......@@ -2646,7 +2645,7 @@ static int32_t buildTagQueryCondString(SSqlCmd* pCmd, tSQLExpr* pExpr, char** qu
int32_t colIdx = getColumnIndexByName(&pLeft->colInfo, pSchema, numOfCols + numOfTags);
if ((!isTbnameToken(&pLeft->colInfo)) && pSchema[colIdx].type != TSDB_DATA_TYPE_BINARY &&
pSchema[colIdx].type != TSDB_DATA_TYPE_NCHAR) {
setErrMsg(pCmd, msg1, tListLen(msg1));
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
}
}
......@@ -2780,18 +2779,18 @@ static int32_t getColumnFilterInfo(SSqlCmd* pCmd, int32_t colIdx, tSQLExpr* pExp
SMeterMeta* pMeterMeta = pCmd->pMeterMeta;
SSchema* pSchema = tsGetSchema(pMeterMeta);
char msg[] = "nchar column not available for filter";
char msg1[] = "non binary column not support like operator";
char msg2[] = "binary column not support this operator";
char msg3[] = "column not support in operator";
const char* msg = "nchar column not available for filter";
const char* msg1 = "non binary column not support like operator";
const char* msg2 = "binary column not support this operator";
const char* msg3 = "column not support in operator";
if (pSchema[colIdx].type == TSDB_DATA_TYPE_NCHAR) {
setErrMsg(pCmd, msg, tListLen(msg));
setErrMsg(pCmd, msg);
return -1;
}
if (pExpr->nSQLOptr == TK_IN) {
setErrMsg(pCmd, msg3, tListLen(msg3));
setErrMsg(pCmd, msg3);
return -1;
}
......@@ -2801,12 +2800,12 @@ static int32_t getColumnFilterInfo(SSqlCmd* pCmd, int32_t colIdx, tSQLExpr* pExp
if (pColFilter->filterOnBinary) {
if (pExpr->nSQLOptr != TK_EQ && pExpr->nSQLOptr != TK_NE && pExpr->nSQLOptr != TK_LIKE) {
setErrMsg(pCmd, msg2, tListLen(msg2));
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
}
} else {
if (pExpr->nSQLOptr == TK_LIKE) {
setErrMsg(pCmd, msg1, tListLen(msg1));
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
}
}
......@@ -2826,27 +2825,27 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, bool* queryTimeRangeIsSet, c
int32_t numOfCols = pMeterMeta->numOfColumns;
int32_t numOfTags = pMeterMeta->numOfTags;
char msg[] = "meter query cannot use tags filter";
char msg1[] = "illegal column name";
char msg2[] = "invalid timestamp";
const char* msg = "meter query cannot use tags filter";
const char* msg1 = "illegal column name";
const char* msg2 = "invalid timestamp";
int32_t colIdx = getColumnIndexByName(&pLeft->colInfo, pSchema, numOfCols + numOfTags);
bool istbname = isTbnameToken(&pLeft->colInfo);
if (colIdx < 0 && (!istbname)) {
setErrMsg(pCmd, msg1, tListLen(msg1));
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
}
if (colIdx == 0) { // query on time range
*queryTimeRangeIsSet = true;
if (getTimeRange(stime, etime, pRight, pExpr->nSQLOptr, pMeterMeta->precision) != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg2, tListLen(msg2));
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
}
} else if (colIdx >= numOfCols || istbname) { // query on tags
if (UTIL_METER_IS_NOMRAL_METER(pCmd)) {
setErrMsg(pCmd, msg, tListLen(msg));
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
return buildTagQueryCondString(pCmd, pExpr, queryStr);
......@@ -2938,8 +2937,8 @@ int32_t getQueryCondExprImpl(SSqlCmd* pCmd, tSQLExpr* pExpr, int64_t* stime, int
*etime = etime2 < (*etime) ? etime2 : (*etime);
} else {
char msg1[] = "not support multi-segments query time ranges";
setErrMsg(pCmd, msg1, tListLen(msg1));
const char* msg1 = "not support multi-segments query time ranges";
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
}
}
......@@ -3023,7 +3022,7 @@ int tableNameCompar(const void* lhs, const void* rhs) {
static int32_t setMetersIDForMetricQuery(SSqlObj* pSql, char* tmpTagCondBuf) {
SSqlCmd* pCmd = &pSql->cmd;
char msg[] = "meter name too long";
const char* msg = "meter name too long";
pCmd->tagCond.allocSize = 4096;
pCmd->tagCond.pData = realloc(pCmd->tagCond.pData, pCmd->tagCond.allocSize);
......@@ -3066,7 +3065,7 @@ static int32_t setMetersIDForMetricQuery(SSqlObj* pSql, char* tmpTagCondBuf) {
int32_t ret = setObjFullName(pCmd->tagCond.pData + pCmd->tagCond.len, acc, &tDB, &t, &xlen);
if (ret != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg, tListLen(msg));
setErrMsg(pCmd, msg);
tfree(segments);
return ret;
}
......@@ -3108,14 +3107,14 @@ int32_t buildQueryCond(SSqlObj* pSql, tSQLExpr* pExpr) {
return TSDB_CODE_SUCCESS;
}
char msg1[] = "invalid expression";
char msg2[] = "meter is not allowed";
char msg3[] = "invalid filter expression";
const char* msg1 = "invalid expression";
const char* msg2 = "meter is not allowed";
const char* msg3 = "invalid filter expression";
tSQLExpr* pLeft = pExpr->pLeft;
tSQLExpr* pRight = pExpr->pRight;
if (pLeft == NULL || pRight == NULL || (pLeft->nSQLOptr == TK_ID && pRight->nSQLOptr == TK_ID)) {
setErrMsg(pCmd, msg1, tListLen(msg1));
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
}
......@@ -3141,7 +3140,7 @@ int32_t buildQueryCond(SSqlObj* pSql, tSQLExpr* pExpr) {
if (pCmd->tagCond.type == TSQL_STABLE_QTYPE_SET) {
if (!UTIL_METER_IS_METRIC(pCmd)) {
setErrMsg(pCmd, msg2, tListLen(msg2));
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
}
......@@ -3160,7 +3159,7 @@ int32_t buildQueryCond(SSqlObj* pSql, tSQLExpr* pExpr) {
}
if (!validateFilterExpr(pCmd)) {
setErrMsg(pCmd, msg3, tListLen(msg3));
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
}
......@@ -3256,8 +3255,8 @@ int32_t tsRewriteFieldNameIfNecessary(SSqlCmd* pCmd) {
char* fieldName = tscFieldInfoGetField(pCmd, i)->name;
for (int32_t j = i + 1; j < pCmd->fieldsInfo.numOfOutputCols; ++j) {
if (strncasecmp(fieldName, tscFieldInfoGetField(pCmd, j)->name, TSDB_COL_NAME_LEN) == 0) {
char msg[] = "duplicated column name in new table";
setErrMsg(pCmd, msg, tListLen(msg));
const char* msg = "duplicated column name in new table";
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
}
......@@ -3271,12 +3270,12 @@ int32_t setFillPolicy(SSqlCmd* pCmd, SQuerySQL* pQuerySQL) {
tVariantListItem* pItem = &pFillToken->a[0];
const int32_t START_INTERPO_COL_IDX = 1;
char msg[] = "illegal value or data overflow";
char msg1[] = "value is expected";
char msg2[] = "invalid fill option";
const char* msg = "illegal value or data overflow";
const char* msg1 = "value is expected";
const char* msg2 = "invalid fill option";
if (pItem->pVar.nType != TSDB_DATA_TYPE_BINARY) {
setErrMsg(pCmd, msg2, tListLen(msg2));
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
}
......@@ -3297,7 +3296,7 @@ int32_t setFillPolicy(SSqlCmd* pCmd, SQuerySQL* pQuerySQL) {
pCmd->interpoType = TSDB_INTERPO_SET_VALUE;
if (pFillToken->nExpr == 1) {
setErrMsg(pCmd, msg1, tListLen(msg1));
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
}
......@@ -3323,7 +3322,7 @@ int32_t setFillPolicy(SSqlCmd* pCmd, SQuerySQL* pQuerySQL) {
int32_t ret = tVariantDump(&pFillToken->a[j].pVar, (char*)&pCmd->defaultVal[i], pFields->type);
if (ret != TSDB_CODE_SUCCESS) {
setErrMsg(pCmd, msg, tListLen(msg));
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
......@@ -3346,7 +3345,7 @@ int32_t setFillPolicy(SSqlCmd* pCmd, SQuerySQL* pQuerySQL) {
}
}
} else {
setErrMsg(pCmd, msg2, tListLen(msg2));
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
}
......@@ -3371,10 +3370,10 @@ static void setDefaultOrderInfo(SSqlCmd* pCmd) {
}
int32_t setOrderByClause(SSqlCmd* pCmd, SQuerySQL* pQuerySql, SSchema* pSchema, int32_t numOfCols) {
char msg[] = "only support order by primary timestamp";
char msg3[] = "invalid column name";
char msg5[] = "only support order by primary timestamp and queried column";
char msg6[] = "only support order by primary timestamp and first tag in groupby clause";
const char* msg = "only support order by primary timestamp";
const char* msg3 = "invalid column name";
const char* msg5 = "only support order by primary timestamp and queried column";
const char* msg6 = "only support order by primary timestamp and first tag in groupby clause";
setDefaultOrderInfo(pCmd);
......@@ -3385,12 +3384,12 @@ int32_t setOrderByClause(SSqlCmd* pCmd, SQuerySQL* pQuerySql, SSchema* pSchema,
tVariantList* pSortorder = pQuerySql->pSortOrder;
if (UTIL_METER_IS_NOMRAL_METER(pCmd)) {
if (pSortorder->nExpr > 1) {
setErrMsg(pCmd, msg, tListLen(msg));
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
} else {
if (pSortorder->nExpr > 2) {
setErrMsg(pCmd, msg6, tListLen(msg6));
setErrMsg(pCmd, msg6);
return TSDB_CODE_INVALID_SQL;
}
}
......@@ -3422,7 +3421,7 @@ int32_t setOrderByClause(SSqlCmd* pCmd, SQuerySQL* pQuerySql, SSchema* pSchema,
}
if (!(orderByTags || orderByTS)) {
setErrMsg(pCmd, msg6, tListLen(msg6));
setErrMsg(pCmd, msg6);
return TSDB_CODE_INVALID_SQL;
} else {
assert(!(orderByTags && orderByTS));
......@@ -3443,7 +3442,7 @@ int32_t setOrderByClause(SSqlCmd* pCmd, SQuerySQL* pQuerySql, SSchema* pSchema,
SSQLToken cname = {pVar2->nLen, pVar2->nType, pVar2->pz};
columnIndex = getColumnIndexByName(&cname, pSchema, numOfCols);
if (columnIndex != PRIMARYKEY_TIMESTAMP_COL_INDEX) {
setErrMsg(pCmd, msg5, tListLen(msg5));
setErrMsg(pCmd, msg5);
return TSDB_CODE_INVALID_SQL;
} else {
pCmd->order.order = pSortorder->a[1].sortOrder;
......@@ -3454,12 +3453,12 @@ int32_t setOrderByClause(SSqlCmd* pCmd, SQuerySQL* pQuerySql, SSchema* pSchema,
} else { // meter query
int32_t columnIndex = getColumnIndexByName(&columnName, pSchema, numOfCols);
if (columnIndex <= -1) {
setErrMsg(pCmd, msg3, tListLen(msg3));
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
}
if (columnIndex != PRIMARYKEY_TIMESTAMP_COL_INDEX && !isTopBottomQuery(pCmd)) {
setErrMsg(pCmd, msg5, tListLen(msg5));
setErrMsg(pCmd, msg5);
return TSDB_CODE_INVALID_SQL;
}
......@@ -3470,7 +3469,7 @@ int32_t setOrderByClause(SSqlCmd* pCmd, SQuerySQL* pQuerySql, SSchema* pSchema,
pExpr = tscSqlExprGet(pCmd, 1);
if (pExpr->colInfo.colIdx != columnIndex && columnIndex != PRIMARYKEY_TIMESTAMP_COL_INDEX) {
setErrMsg(pCmd, msg, tListLen(msg));
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
......@@ -3492,14 +3491,14 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
pCmd->command = TSDB_SQL_ALTER_TABLE;
if (tscValidateName(&(pAlterSQL->name)) != TSDB_CODE_SUCCESS) {
char msg[] = "invalid table name";
setErrMsg(pCmd, msg, tListLen(msg));
const char* msg = "invalid table name";
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
if (setMeterID(pSql, &(pAlterSQL->name)) != TSDB_CODE_SUCCESS) {
char msg[] = "table name too long";
setErrMsg(pCmd, msg, tListLen(msg));
const char* msg = "table name too long";
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
......@@ -3514,18 +3513,18 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
if (pInfo->sqlType == ALTER_TABLE_TAGS_ADD || pInfo->sqlType == ALTER_TABLE_TAGS_DROP ||
pInfo->sqlType == ALTER_TABLE_TAGS_CHG) {
if (UTIL_METER_IS_NOMRAL_METER(pCmd)) {
char msg[] = "manipulation of tag available for metric";
setErrMsg(pCmd, msg, tListLen(msg));
const char* msg = "manipulation of tag available for metric";
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
} else if ((pInfo->sqlType == ALTER_TABLE_TAGS_SET) && (UTIL_METER_IS_METRIC(pCmd))) {
char msg[] = "set tag value only available for table";
setErrMsg(pCmd, msg, tListLen(msg));
const char* msg = "set tag value only available for table";
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
} else if ((pInfo->sqlType == ALTER_TABLE_ADD_COLUMN || pInfo->sqlType == ALTER_TABLE_DROP_COLUMN) &&
UTIL_METER_IS_CREATE_FROM_METRIC(pCmd)) {
char msg[] = "column can only be modified by metric";
setErrMsg(pCmd, msg, tListLen(msg));
const char* msg = "column can only be modified by metric";
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
......@@ -3534,8 +3533,8 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
tFieldList* pFieldList = pAlterSQL->pAddColumns;
if (pFieldList->nField > 1) {
char msg[] = "only support add one tag";
setErrMsg(pCmd, msg, tListLen(msg));
const char* msg = "only support add one tag";
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
......@@ -3549,26 +3548,26 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
} else if (pInfo->sqlType == ALTER_TABLE_TAGS_DROP) {
pCmd->count = TSDB_ALTER_TABLE_DROP_TAG_COLUMN;
char msg1[] = "no tags can be dropped";
char msg2[] = "only support one tag";
char msg3[] = "tag name too long";
char msg4[] = "illegal tag name";
char msg5[] = "primary tag cannot be dropped";
const char* msg1 = "no tags can be dropped";
const char* msg2 = "only support one tag";
const char* msg3 = "tag name too long";
const char* msg4 = "illegal tag name";
const char* msg5 = "primary tag cannot be dropped";
if (pMeterMeta->numOfTags == 1) {
setErrMsg(pCmd, msg1, tListLen(msg1));
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
}
// numOfTags == 1
if (pAlterSQL->varList->nExpr > 1) {
setErrMsg(pCmd, msg2, tListLen(msg2));
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
}
tVariantListItem* pItem = &pAlterSQL->varList->a[0];
if (pItem->pVar.nLen > TSDB_COL_NAME_LEN) {
setErrMsg(pCmd, msg3, tListLen(msg3));
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
}
......@@ -3585,10 +3584,10 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
if (idx == -1) {
setErrMsg(pCmd, msg4, tListLen(msg4));
setErrMsg(pCmd, msg4);
return TSDB_CODE_INVALID_SQL;
} else if (idx == 0) {
setErrMsg(pCmd, msg5, tListLen(msg5));
setErrMsg(pCmd, msg5);
return TSDB_CODE_INVALID_SQL;
}
......@@ -3599,8 +3598,8 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
pCmd->numOfCols = 1; // only one column
} else if (pInfo->sqlType == ALTER_TABLE_TAGS_CHG) {
char msg1[] = "tag name too long";
char msg2[] = "invalid tag name";
const char* msg1 = "tag name too long";
const char* msg2 = "invalid tag name";
pCmd->count = TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN;
tVariantList* pVarList = pAlterSQL->varList;
......@@ -3612,12 +3611,12 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
tVariantListItem* pDstItem = &pAlterSQL->varList->a[1];
if (pSrcItem->pVar.nLen >= TSDB_COL_NAME_LEN || pDstItem->pVar.nLen >= TSDB_COL_NAME_LEN) {
setErrMsg(pCmd, msg1, tListLen(msg1));
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
}
if (pSrcItem->pVar.nType != TSDB_DATA_TYPE_BINARY || pDstItem->pVar.nType != TSDB_DATA_TYPE_BINARY) {
setErrMsg(pCmd, msg2, tListLen(msg2));
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
}
......@@ -3639,8 +3638,8 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
if ((!srcFound) || dstFound) {
char msg[] = "invalid tag name";
setErrMsg(pCmd, msg, tListLen(msg));
const char* msg = "invalid tag name";
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
......@@ -3664,8 +3663,8 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
tVariant* pTagName = &pVarList->a[0].pVar;
if (pTagName->nLen > TSDB_COL_NAME_LEN) {
char msg[] = "tag name too long";
setErrMsg(pCmd, msg, tListLen(msg));
const char* msg = "tag name too long";
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
......@@ -3682,16 +3681,16 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
if (tagsIndex == -1) {
char msg[] = "invalid tag name";
setErrMsg(pCmd, msg, tListLen(msg));
const char* msg = "invalid tag name";
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
// validate the length of binary
if (pTagsSchema[tagsIndex].type == TSDB_DATA_TYPE_BINARY &&
pVarList->a[1].pVar.nLen > pTagsSchema[tagsIndex].bytes) {
char msg[] = "tag value too long";
setErrMsg(pCmd, msg, tListLen(msg));
const char* msg = "tag value too long";
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
......@@ -3705,8 +3704,8 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
tFieldList* pFieldList = pAlterSQL->pAddColumns;
if (pFieldList->nField > 1) {
char msg[] = "only support add one column";
setErrMsg(pCmd, msg, tListLen(msg));
const char* msg = "only support add one column";
setErrMsg(pCmd, msg);
return TSDB_CODE_INVALID_SQL;
}
......@@ -3720,25 +3719,25 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
} else if (pInfo->sqlType == ALTER_TABLE_DROP_COLUMN) {
pCmd->count = TSDB_ALTER_TABLE_DROP_COLUMN;
char msg1[] = "no columns can be dropped";
char msg2[] = "only support one column";
char msg3[] = "column name too long";
char msg4[] = "illegal column name";
char msg5[] = "primary timestamp column cannot be dropped";
const char* msg1 = "no columns can be dropped";
const char* msg2 = "only support one column";
const char* msg3 = "column name too long";
const char* msg4 = "illegal column name";
const char* msg5 = "primary timestamp column cannot be dropped";
if (pMeterMeta->numOfColumns == TSDB_MIN_COLUMNS) { //
setErrMsg(pCmd, msg1, tListLen(msg1));
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
}
if (pAlterSQL->varList->nExpr > 1) {
setErrMsg(pCmd, msg2, tListLen(msg2));
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
}
tVariantListItem* pItem = &pAlterSQL->varList->a[0];
if (pItem->pVar.nLen > TSDB_COL_NAME_LEN) {
setErrMsg(pCmd, msg3, tListLen(msg3));
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
}
......@@ -3754,10 +3753,10 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
if (idx == -1) {
setErrMsg(pCmd, msg4, tListLen(msg4));
setErrMsg(pCmd, msg4);
return TSDB_CODE_INVALID_SQL;
} else if (idx == 0) {
setErrMsg(pCmd, msg5, tListLen(msg5));
setErrMsg(pCmd, msg5);
return TSDB_CODE_INVALID_SQL;
}
......@@ -3772,18 +3771,18 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
int32_t validateSqlFunctionInStreamSql(SSqlCmd* pCmd) {
char msg0[] = "sample interval can not be less than 10ms.";
char msg1[] = "functions not allowed in select clause";
const char* msg0 = "sample interval can not be less than 10ms.";
const char* msg1 = "functions not allowed in select clause";
if (pCmd->nAggTimeInterval != 0 && pCmd->nAggTimeInterval < 10) {
setErrMsg(pCmd, msg0, tListLen(msg0));
setErrMsg(pCmd, msg0);
return TSDB_CODE_INVALID_SQL;
}
for (int32_t i = 0; i < pCmd->fieldsInfo.numOfOutputCols; ++i) {
int32_t functId = tscSqlExprGet(pCmd, i)->sqlFuncId;
if (!IS_STREAM_QUERY_VALID(aAggs[functId].nStatus)) {
setErrMsg(pCmd, msg1, tListLen(msg1));
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
}
}
......@@ -3793,7 +3792,7 @@ int32_t validateSqlFunctionInStreamSql(SSqlCmd* pCmd) {
int32_t validateFunctionsInIntervalOrGroupbyQuery(SSqlCmd* pCmd) {
bool isProjectionFunction = false;
char msg[] = "column projection is not compatible with interval";
const char* msg = "column projection is not compatible with interval";
// multi-output set/ todo refactor
for (int32_t k = 0; k < pCmd->fieldsInfo.numOfOutputCols; ++k) {
......@@ -3804,7 +3803,7 @@ int32_t validateFunctionsInIntervalOrGroupbyQuery(SSqlCmd* pCmd) {
}
}
if (pCmd->metricQuery == 0 || isProjectionFunction == true) {
setErrMsg(pCmd, msg, tListLen(msg));
setErrMsg(pCmd, msg);
}
return isProjectionFunction == true ? TSDB_CODE_INVALID_SQL : TSDB_CODE_SUCCESS;
......@@ -3905,10 +3904,10 @@ int32_t setLimitOffsetValueInfo(SSqlObj* pSql, SQuerySQL* pQuerySql) {
SSqlCmd* pCmd = &pSql->cmd;
bool isMetric = UTIL_METER_IS_METRIC(pCmd);
char msg0[] = "soffset can not be less than 0";
char msg1[] = "offset can not be less than 0";
char msg2[] = "slimit/soffset only available for STable query";
char msg3[] = "function not supported on table";
const char* msg0 = "soffset can not be less than 0";
const char* msg1 = "offset can not be less than 0";
const char* msg2 = "slimit/soffset only available for STable query";
const char* msg3 = "function not supported on table";
// handle the limit offset value, validate the limit
pCmd->limit = pQuerySql->limit;
......@@ -3932,7 +3931,7 @@ int32_t setLimitOffsetValueInfo(SSqlObj* pSql, SQuerySQL* pQuerySql) {
}
if (pCmd->glimit.offset < 0) {
setErrMsg(pCmd, msg0, tListLen(msg0));
setErrMsg(pCmd, msg0);
return TSDB_CODE_INVALID_SQL;
}
......@@ -3961,14 +3960,14 @@ int32_t setLimitOffsetValueInfo(SSqlObj* pSql, SQuerySQL* pQuerySql) {
pCmd->globalLimit = pCmd->limit.limit;
} else {
if (pCmd->glimit.limit != -1 || pCmd->glimit.offset != 0) {
setErrMsg(pCmd, msg2, tListLen(msg2));
setErrMsg(pCmd, msg2);
return TSDB_CODE_INVALID_SQL;
}
for (int32_t i = 0; i < pCmd->fieldsInfo.numOfOutputCols; ++i) {
SSqlExpr* pExpr = tscSqlExprGet(pCmd, i);
if (pExpr->colInfo.colIdx == -1) {
setErrMsg(pCmd, msg3, tListLen(msg3));
setErrMsg(pCmd, msg3);
return TSDB_CODE_INVALID_SQL;
}
}
......@@ -3979,7 +3978,7 @@ int32_t setLimitOffsetValueInfo(SSqlObj* pSql, SQuerySQL* pQuerySql) {
}
if (pCmd->limit.offset < 0) {
setErrMsg(pCmd, msg1, tListLen(msg1));
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
}
}
......@@ -4008,8 +4007,8 @@ static void setCreateDBOption(SCreateDbMsg* pMsg, SCreateDBInfo* pCreateDb) {
}
int32_t parseCreateDBOptions(SCreateDBInfo* pCreateDbSql, SSqlCmd* pCmd) {
char msg0[] = "invalid number of options";
char msg1[] = "invalid time precision";
const char* msg0 = "invalid number of options";
const char* msg1 = "invalid time precision";
SCreateDbMsg *pMsg = (SCreateDbMsg *) (pCmd->payload + tsRpcHeadSize + sizeof(SMgmtHead));
setCreateDBOption(pMsg, pCreateDbSql);
......@@ -4031,7 +4030,7 @@ int32_t parseCreateDBOptions(SCreateDBInfo* pCreateDbSql, SSqlCmd* pCmd) {
break;
}
default: {
setErrMsg(pCmd, msg0, tListLen(msg0));
setErrMsg(pCmd, msg0);
return TSDB_CODE_INVALID_SQL;
}
}
......@@ -4049,7 +4048,7 @@ int32_t parseCreateDBOptions(SCreateDBInfo* pCreateDbSql, SSqlCmd* pCmd) {
strlen(TSDB_TIME_PRECISION_MICRO_STR) == pToken->n) {
pMsg->precision = TSDB_TIME_PRECISION_MICRO;
} else {
setErrMsg(pCmd, msg1, tListLen(msg1));
setErrMsg(pCmd, msg1);
return TSDB_CODE_INVALID_SQL;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册