[td-225]fix error.
This commit is contained in:
parent
497a0e3b31
commit
01962da413
|
@ -6508,6 +6508,7 @@ int32_t doValidateSqlNode(SSqlObj* pSql, SQuerySqlNode* pQuerySqlNode, int32_t i
|
||||||
const char* msg5 = "too many columns in selection clause";
|
const char* msg5 = "too many columns in selection clause";
|
||||||
const char* msg6 = "too many tables in from clause";
|
const char* msg6 = "too many tables in from clause";
|
||||||
const char* msg7 = "invalid table alias name";
|
const char* msg7 = "invalid table alias name";
|
||||||
|
const char* msg8 = "alias name too long";
|
||||||
|
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
@ -6545,13 +6546,12 @@ int32_t doValidateSqlNode(SSqlObj* pSql, SQuerySqlNode* pQuerySqlNode, int32_t i
|
||||||
}
|
}
|
||||||
|
|
||||||
pQueryInfo->command = TSDB_SQL_SELECT;
|
pQueryInfo->command = TSDB_SQL_SELECT;
|
||||||
|
|
||||||
if (fromSize > 2) {
|
if (fromSize > 2) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg6);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg6);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set all query tables, which are maybe more than one.
|
// set all query tables, which are maybe more than one.
|
||||||
for (int32_t i = 0; i < fromSize; ) {
|
for (int32_t i = 0; i < fromSize; ++i) {
|
||||||
STableNamePair* item = taosArrayGet(pQuerySqlNode->from->tableList, i);
|
STableNamePair* item = taosArrayGet(pQuerySqlNode->from->tableList, i);
|
||||||
SStrToken* pTableItem = &item->name;
|
SStrToken* pTableItem = &item->name;
|
||||||
|
|
||||||
|
@ -6559,7 +6559,7 @@ int32_t doValidateSqlNode(SSqlObj* pSql, SQuerySqlNode* pQuerySqlNode, int32_t i
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg0);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg0);
|
||||||
}
|
}
|
||||||
|
|
||||||
pTableItem->n = strdequote(pTableItem->z);
|
tscDequoteAndTrimToken(pTableItem);
|
||||||
|
|
||||||
SStrToken tableName = {.z = pTableItem->z, .n = pTableItem->n, .type = TK_STRING};
|
SStrToken tableName = {.z = pTableItem->z, .n = pTableItem->n, .type = TK_STRING};
|
||||||
if (tscValidateName(&tableName) != TSDB_CODE_SUCCESS) {
|
if (tscValidateName(&tableName) != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -6570,39 +6570,41 @@ int32_t doValidateSqlNode(SSqlObj* pSql, SQuerySqlNode* pQuerySqlNode, int32_t i
|
||||||
tscAddEmptyMetaInfo(pQueryInfo);
|
tscAddEmptyMetaInfo(pQueryInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
STableMetaInfo* pTableMetaInfo1 = tscGetMetaInfo(pQueryInfo, i/2);
|
STableMetaInfo* pTableMetaInfo1 = tscGetMetaInfo(pQueryInfo, i);
|
||||||
|
code = tscSetTableFullName(pTableMetaInfo1, pTableItem, pSql);
|
||||||
SStrToken t = {.type = TSDB_DATA_TYPE_BINARY, .n = pTableItem->n, .z = pTableItem->z};
|
|
||||||
code = tscSetTableFullName(pTableMetaInfo1, &t, pSql);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
SStrToken* aliasName = &item->aliasName;
|
SStrToken* aliasName = &item->aliasName;
|
||||||
if (aliasName->type != TSDB_DATA_TYPE_BINARY) {
|
if (TPARSER_HAS_TOKEN(*aliasName)) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg7);
|
if (aliasName->type != TSDB_DATA_TYPE_BINARY) {
|
||||||
}
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg7);
|
||||||
|
}
|
||||||
|
|
||||||
if (TPARSER_HAS_TOKEN(*aliasName) && tscValidateName(aliasName) != TSDB_CODE_SUCCESS) {
|
tscDequoteAndTrimToken(aliasName);
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg7);
|
|
||||||
}
|
|
||||||
|
|
||||||
// has no table alias name
|
SStrToken aliasName1 = {.z = aliasName->z, .n = aliasName->n, .type = TK_STRING};
|
||||||
if (!TPARSER_HAS_TOKEN(*aliasName)) {
|
if (tscValidateName(&aliasName1) != TSDB_CODE_SUCCESS) {
|
||||||
strncpy(pTableMetaInfo1->aliasName, tNameGetTableName(&pTableMetaInfo1->name), tListLen(pTableMetaInfo1->aliasName));
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg7);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aliasName1.n >= TSDB_TABLE_NAME_LEN) {
|
||||||
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg8);
|
||||||
|
}
|
||||||
|
|
||||||
|
strncpy(pTableMetaInfo1->aliasName, aliasName1.z, aliasName1.n);
|
||||||
} else {
|
} else {
|
||||||
tstrncpy(pTableMetaInfo1->aliasName, aliasName->z, sizeof(pTableMetaInfo1->aliasName));
|
strncpy(pTableMetaInfo1->aliasName, tNameGetTableName(&pTableMetaInfo1->name), tListLen(pTableMetaInfo1->aliasName));
|
||||||
}
|
}
|
||||||
|
|
||||||
code = tscGetTableMeta(pSql, pTableMetaInfo1);
|
code = tscGetTableMeta(pSql, pTableMetaInfo1);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
i += 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(pQueryInfo->numOfTables == taosArrayGetSize(pQuerySqlNode->from->tableList) / 2);
|
assert(pQueryInfo->numOfTables == taosArrayGetSize(pQuerySqlNode->from->tableList));
|
||||||
bool isSTable = false;
|
bool isSTable = false;
|
||||||
|
|
||||||
if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
|
if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) {
|
||||||
|
|
|
@ -520,7 +520,7 @@ tablelist(A) ::= ids(X) cpxName(Y) ids(Z). {
|
||||||
toTSDBType(X.type);
|
toTSDBType(X.type);
|
||||||
toTSDBType(Z.type);
|
toTSDBType(Z.type);
|
||||||
X.n += Y.n;
|
X.n += Y.n;
|
||||||
A = setTableNameList(NULL, &X, &Y);
|
A = setTableNameList(NULL, &X, &Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
tablelist(A) ::= tablelist(Y) COMMA ids(X) cpxName(Z). {
|
tablelist(A) ::= tablelist(Y) COMMA ids(X) cpxName(Z). {
|
||||||
|
|
|
@ -2671,7 +2671,7 @@ static void yy_reduce(
|
||||||
toTSDBType(yymsp[-2].minor.yy0.type);
|
toTSDBType(yymsp[-2].minor.yy0.type);
|
||||||
toTSDBType(yymsp[0].minor.yy0.type);
|
toTSDBType(yymsp[0].minor.yy0.type);
|
||||||
yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n;
|
yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n;
|
||||||
yylhsminor.yy285 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[-1].minor.yy0);
|
yylhsminor.yy285 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
|
||||||
}
|
}
|
||||||
yymsp[-2].minor.yy285 = yylhsminor.yy285;
|
yymsp[-2].minor.yy285 = yylhsminor.yy285;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue