fix: some problems of parser
This commit is contained in:
parent
eec7056d1a
commit
21f1321ea8
|
@ -46,6 +46,7 @@ psim/
|
||||||
pysim/
|
pysim/
|
||||||
*.out
|
*.out
|
||||||
*DS_Store
|
*DS_Store
|
||||||
|
tests/script/api/batchprepare
|
||||||
|
|
||||||
# Doxygen Generated files
|
# Doxygen Generated files
|
||||||
html/
|
html/
|
||||||
|
@ -108,4 +109,4 @@ TAGS
|
||||||
contrib/*
|
contrib/*
|
||||||
!contrib/CMakeLists.txt
|
!contrib/CMakeLists.txt
|
||||||
!contrib/test
|
!contrib/test
|
||||||
sql
|
sql
|
||||||
|
|
|
@ -143,12 +143,12 @@ SNode* createDropTableClause(SAstCreateContext* pCxt, bool ignoreNotExists, SNod
|
||||||
SNode* createDropTableStmt(SAstCreateContext* pCxt, SNodeList* pTables);
|
SNode* createDropTableStmt(SAstCreateContext* pCxt, SNodeList* pTables);
|
||||||
SNode* createDropSuperTableStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SNode* pRealTable);
|
SNode* createDropSuperTableStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SNode* pRealTable);
|
||||||
SNode* createAlterTableModifyOptions(SAstCreateContext* pCxt, SNode* pRealTable, SNode* pOptions);
|
SNode* createAlterTableModifyOptions(SAstCreateContext* pCxt, SNode* pRealTable, SNode* pOptions);
|
||||||
SNode* createAlterTableAddModifyCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType,
|
SNode* createAlterTableAddModifyCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, SToken* pColName,
|
||||||
const SToken* pColName, SDataType dataType);
|
SDataType dataType);
|
||||||
SNode* createAlterTableDropCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, const SToken* pColName);
|
SNode* createAlterTableDropCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, SToken* pColName);
|
||||||
SNode* createAlterTableRenameCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType,
|
SNode* createAlterTableRenameCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, SToken* pOldColName,
|
||||||
const SToken* pOldColName, const SToken* pNewColName);
|
SToken* pNewColName);
|
||||||
SNode* createAlterTableSetTag(SAstCreateContext* pCxt, SNode* pRealTable, const SToken* pTagName, SNode* pVal);
|
SNode* createAlterTableSetTag(SAstCreateContext* pCxt, SNode* pRealTable, SToken* pTagName, SNode* pVal);
|
||||||
SNode* createUseDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName);
|
SNode* createUseDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName);
|
||||||
SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pDbName, SNode* pTbNamePattern);
|
SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pDbName, SNode* pTbNamePattern);
|
||||||
SNode* createShowCreateDatabaseStmt(SAstCreateContext* pCxt, const SToken* pDbName);
|
SNode* createShowCreateDatabaseStmt(SAstCreateContext* pCxt, const SToken* pDbName);
|
||||||
|
|
|
@ -94,7 +94,7 @@ static FORCE_INLINE void getSTSRowAppendInfo(uint8_t rowType, SParsedDataColInfo
|
||||||
col_id_t *colIdx) {
|
col_id_t *colIdx) {
|
||||||
col_id_t schemaIdx = 0;
|
col_id_t schemaIdx = 0;
|
||||||
if (IS_DATA_COL_ORDERED(spd)) {
|
if (IS_DATA_COL_ORDERED(spd)) {
|
||||||
schemaIdx = spd->boundColumns[idx] - PRIMARYKEY_TIMESTAMP_COL_ID;
|
schemaIdx = spd->boundColumns[idx];
|
||||||
if (TD_IS_TP_ROW_T(rowType)) {
|
if (TD_IS_TP_ROW_T(rowType)) {
|
||||||
*toffset = (spd->cols + schemaIdx)->toffset; // the offset of firstPart
|
*toffset = (spd->cols + schemaIdx)->toffset; // the offset of firstPart
|
||||||
*colIdx = schemaIdx;
|
*colIdx = schemaIdx;
|
||||||
|
@ -104,7 +104,7 @@ static FORCE_INLINE void getSTSRowAppendInfo(uint8_t rowType, SParsedDataColInfo
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ASSERT(idx == (spd->colIdxInfo + idx)->boundIdx);
|
ASSERT(idx == (spd->colIdxInfo + idx)->boundIdx);
|
||||||
schemaIdx = (spd->colIdxInfo + idx)->schemaColIdx - PRIMARYKEY_TIMESTAMP_COL_ID;
|
schemaIdx = (spd->colIdxInfo + idx)->schemaColIdx;
|
||||||
if (TD_IS_TP_ROW_T(rowType)) {
|
if (TD_IS_TP_ROW_T(rowType)) {
|
||||||
*toffset = (spd->cols + schemaIdx)->toffset;
|
*toffset = (spd->cols + schemaIdx)->toffset;
|
||||||
*colIdx = schemaIdx;
|
*colIdx = schemaIdx;
|
||||||
|
@ -133,14 +133,15 @@ static FORCE_INLINE int32_t setBlockInfo(SSubmitBlk *pBlocks, STableDataBlocks *
|
||||||
int32_t schemaIdxCompar(const void *lhs, const void *rhs);
|
int32_t schemaIdxCompar(const void *lhs, const void *rhs);
|
||||||
int32_t boundIdxCompar(const void *lhs, const void *rhs);
|
int32_t boundIdxCompar(const void *lhs, const void *rhs);
|
||||||
void setBoundColumnInfo(SParsedDataColInfo *pColList, SSchema *pSchema, col_id_t numOfCols);
|
void setBoundColumnInfo(SParsedDataColInfo *pColList, SSchema *pSchema, col_id_t numOfCols);
|
||||||
void destroyBlockArrayList(SArray* pDataBlockList);
|
void destroyBlockArrayList(SArray *pDataBlockList);
|
||||||
void destroyBlockHashmap(SHashObj* pDataBlockHash);
|
void destroyBlockHashmap(SHashObj *pDataBlockHash);
|
||||||
int initRowBuilder(SRowBuilder *pBuilder, int16_t schemaVer, SParsedDataColInfo *pColInfo);
|
int initRowBuilder(SRowBuilder *pBuilder, int16_t schemaVer, SParsedDataColInfo *pColInfo);
|
||||||
int32_t allocateMemIfNeed(STableDataBlocks *pDataBlock, int32_t rowSize, int32_t * numOfRows);
|
int32_t allocateMemIfNeed(STableDataBlocks *pDataBlock, int32_t rowSize, int32_t *numOfRows);
|
||||||
int32_t getDataBlockFromList(SHashObj* pHashList, void* id, int32_t idLen, int32_t size, int32_t startOffset, int32_t rowSize,
|
int32_t getDataBlockFromList(SHashObj *pHashList, void *id, int32_t idLen, int32_t size, int32_t startOffset,
|
||||||
STableMeta* pTableMeta, STableDataBlocks** dataBlocks, SArray* pBlockList, SVCreateTbReq* pCreateTbReq);
|
int32_t rowSize, STableMeta *pTableMeta, STableDataBlocks **dataBlocks, SArray *pBlockList,
|
||||||
int32_t mergeTableDataBlocks(SHashObj* pHashObj, uint8_t payloadType, SArray** pVgDataBlocks);
|
SVCreateTbReq *pCreateTbReq);
|
||||||
int32_t buildCreateTbMsg(STableDataBlocks* pBlocks, SVCreateTbReq* pCreateTbReq);
|
int32_t mergeTableDataBlocks(SHashObj *pHashObj, uint8_t payloadType, SArray **pVgDataBlocks);
|
||||||
|
int32_t buildCreateTbMsg(STableDataBlocks *pBlocks, SVCreateTbReq *pCreateTbReq);
|
||||||
|
|
||||||
int32_t allocateMemForSize(STableDataBlocks *pDataBlock, int32_t allSize);
|
int32_t allocateMemForSize(STableDataBlocks *pDataBlock, int32_t allSize);
|
||||||
|
|
||||||
|
|
|
@ -968,9 +968,9 @@ SNode* createAlterTableModifyOptions(SAstCreateContext* pCxt, SNode* pRealTable,
|
||||||
return createAlterTableStmtFinalize(pRealTable, pStmt);
|
return createAlterTableStmtFinalize(pRealTable, pStmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createAlterTableAddModifyCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType,
|
SNode* createAlterTableAddModifyCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, SToken* pColName,
|
||||||
const SToken* pColName, SDataType dataType) {
|
SDataType dataType) {
|
||||||
if (NULL == pRealTable) {
|
if (NULL == pRealTable || !checkColumnName(pCxt, pColName)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT);
|
SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT);
|
||||||
|
@ -981,8 +981,8 @@ SNode* createAlterTableAddModifyCol(SAstCreateContext* pCxt, SNode* pRealTable,
|
||||||
return createAlterTableStmtFinalize(pRealTable, pStmt);
|
return createAlterTableStmtFinalize(pRealTable, pStmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createAlterTableDropCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, const SToken* pColName) {
|
SNode* createAlterTableDropCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, SToken* pColName) {
|
||||||
if (NULL == pRealTable) {
|
if (NULL == pRealTable || !checkColumnName(pCxt, pColName)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT);
|
SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT);
|
||||||
|
@ -992,9 +992,9 @@ SNode* createAlterTableDropCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_
|
||||||
return createAlterTableStmtFinalize(pRealTable, pStmt);
|
return createAlterTableStmtFinalize(pRealTable, pStmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createAlterTableRenameCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType,
|
SNode* createAlterTableRenameCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, SToken* pOldColName,
|
||||||
const SToken* pOldColName, const SToken* pNewColName) {
|
SToken* pNewColName) {
|
||||||
if (NULL == pRealTable) {
|
if (NULL == pRealTable || !checkColumnName(pCxt, pOldColName) || !checkColumnName(pCxt, pNewColName)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT);
|
SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT);
|
||||||
|
@ -1005,8 +1005,8 @@ SNode* createAlterTableRenameCol(SAstCreateContext* pCxt, SNode* pRealTable, int
|
||||||
return createAlterTableStmtFinalize(pRealTable, pStmt);
|
return createAlterTableStmtFinalize(pRealTable, pStmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* createAlterTableSetTag(SAstCreateContext* pCxt, SNode* pRealTable, const SToken* pTagName, SNode* pVal) {
|
SNode* createAlterTableSetTag(SAstCreateContext* pCxt, SNode* pRealTable, SToken* pTagName, SNode* pVal) {
|
||||||
if (NULL == pRealTable) {
|
if (NULL == pRealTable || !checkColumnName(pCxt, pTagName)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT);
|
SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT);
|
||||||
|
|
|
@ -701,7 +701,7 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, SParsedDataColInfo*
|
||||||
}
|
}
|
||||||
lastColIdx = index;
|
lastColIdx = index;
|
||||||
pColList->cols[index].valStat = VAL_STAT_HAS;
|
pColList->cols[index].valStat = VAL_STAT_HAS;
|
||||||
pColList->boundColumns[pColList->numOfBound] = index + PRIMARYKEY_TIMESTAMP_COL_ID;
|
pColList->boundColumns[pColList->numOfBound] = index;
|
||||||
++pColList->numOfBound;
|
++pColList->numOfBound;
|
||||||
switch (pSchema[t].type) {
|
switch (pSchema[t].type) {
|
||||||
case TSDB_DATA_TYPE_BINARY:
|
case TSDB_DATA_TYPE_BINARY:
|
||||||
|
@ -815,7 +815,7 @@ static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pSchema, uint
|
||||||
return buildInvalidOperationMsg(&pCxt->msg, "no mix usage for ? and tag values");
|
return buildInvalidOperationMsg(&pCxt->msg, "no mix usage for ? and tag values");
|
||||||
}
|
}
|
||||||
|
|
||||||
SSchema* pTagSchema = &pSchema[pCxt->tags.boundColumns[i] - 1]; // colId starts with 1
|
SSchema* pTagSchema = &pSchema[pCxt->tags.boundColumns[i]];
|
||||||
param.schema = pTagSchema;
|
param.schema = pTagSchema;
|
||||||
CHECK_CODE(
|
CHECK_CODE(
|
||||||
parseValueToken(&pCxt->pSql, &sToken, pTagSchema, precision, tmpTokenBuf, KvRowAppend, ¶m, &pCxt->msg));
|
parseValueToken(&pCxt->pSql, &sToken, pTagSchema, precision, tmpTokenBuf, KvRowAppend, ¶m, &pCxt->msg));
|
||||||
|
@ -903,7 +903,7 @@ static int32_t parseUsingClause(SInsertParseContext* pCxt, SName* name, char* tb
|
||||||
if (TK_NK_LP != sToken.type) {
|
if (TK_NK_LP != sToken.type) {
|
||||||
return buildSyntaxErrMsg(&pCxt->msg, "( is expected", sToken.z);
|
return buildSyntaxErrMsg(&pCxt->msg, "( is expected", sToken.z);
|
||||||
}
|
}
|
||||||
CHECK_CODE(parseTagsClause(pCxt, pCxt->pTableMeta->schema, getTableInfo(pCxt->pTableMeta).precision, name->tname));
|
CHECK_CODE(parseTagsClause(pCxt, pTagsSchema, getTableInfo(pCxt->pTableMeta).precision, name->tname));
|
||||||
NEXT_VALID_TOKEN(pCxt->pSql, sToken);
|
NEXT_VALID_TOKEN(pCxt->pSql, sToken);
|
||||||
if (TK_NK_COMMA == sToken.type) {
|
if (TK_NK_COMMA == sToken.type) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msg, TSDB_CODE_PAR_TAGS_NOT_MATCHED);
|
return generateSyntaxErrMsg(&pCxt->msg, TSDB_CODE_PAR_TAGS_NOT_MATCHED);
|
||||||
|
@ -929,7 +929,7 @@ static int parseOneRow(SInsertParseContext* pCxt, STableDataBlocks* pDataBlocks,
|
||||||
// 1. set the parsed value from sql string
|
// 1. set the parsed value from sql string
|
||||||
for (int i = 0; i < spd->numOfBound; ++i) {
|
for (int i = 0; i < spd->numOfBound; ++i) {
|
||||||
NEXT_TOKEN_WITH_PREV(pCxt->pSql, sToken);
|
NEXT_TOKEN_WITH_PREV(pCxt->pSql, sToken);
|
||||||
SSchema* pSchema = &schema[spd->boundColumns[i] - 1];
|
SSchema* pSchema = &schema[spd->boundColumns[i]];
|
||||||
|
|
||||||
if (sToken.type == TK_NK_QUESTION) {
|
if (sToken.type == TK_NK_QUESTION) {
|
||||||
isParseBindParam = true;
|
isParseBindParam = true;
|
||||||
|
@ -1088,7 +1088,7 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
|
||||||
if (sToken.type && pCxt->pSql[0]) {
|
if (sToken.type && pCxt->pSql[0]) {
|
||||||
return buildSyntaxErrMsg(&pCxt->msg, "invalid charactor in SQL", sToken.z);
|
return buildSyntaxErrMsg(&pCxt->msg, "invalid charactor in SQL", sToken.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 == pCxt->totalNum && (!TSDB_QUERY_HAS_TYPE(pCxt->pOutput->insertType, TSDB_QUERY_TYPE_STMT_INSERT))) {
|
if (0 == pCxt->totalNum && (!TSDB_QUERY_HAS_TYPE(pCxt->pOutput->insertType, TSDB_QUERY_TYPE_STMT_INSERT))) {
|
||||||
return buildInvalidOperationMsg(&pCxt->msg, "no data in sql");
|
return buildInvalidOperationMsg(&pCxt->msg, "no data in sql");
|
||||||
}
|
}
|
||||||
|
@ -1337,7 +1337,7 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, char* tN
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSchema* pTagSchema = &pSchema[tags->boundColumns[c] - 1]; // colId starts with 1
|
SSchema* pTagSchema = &pSchema[tags->boundColumns[c]];
|
||||||
param.schema = pTagSchema;
|
param.schema = pTagSchema;
|
||||||
|
|
||||||
int32_t colLen = pTagSchema->bytes;
|
int32_t colLen = pTagSchema->bytes;
|
||||||
|
@ -1384,7 +1384,7 @@ int32_t qBindStmtColsValue(void* pBlock, TAOS_MULTI_BIND* bind, char* msgBuf, in
|
||||||
tdSRowResetBuf(pBuilder, row);
|
tdSRowResetBuf(pBuilder, row);
|
||||||
|
|
||||||
for (int c = 0; c < spd->numOfBound; ++c) {
|
for (int c = 0; c < spd->numOfBound; ++c) {
|
||||||
SSchema* pColSchema = &pSchema[spd->boundColumns[c] - 1];
|
SSchema* pColSchema = &pSchema[spd->boundColumns[c]];
|
||||||
|
|
||||||
if (bind[c].num != rowNum) {
|
if (bind[c].num != rowNum) {
|
||||||
return buildInvalidOperationMsg(&pBuf, "row number in each bind param should be the same");
|
return buildInvalidOperationMsg(&pBuf, "row number in each bind param should be the same");
|
||||||
|
@ -1467,7 +1467,7 @@ int32_t qBindStmtSingleColValue(void* pBlock, TAOS_MULTI_BIND* bind, char* msgBu
|
||||||
tdSRowGetBuf(pBuilder, row);
|
tdSRowGetBuf(pBuilder, row);
|
||||||
}
|
}
|
||||||
|
|
||||||
SSchema* pColSchema = &pSchema[spd->boundColumns[colIdx] - 1];
|
SSchema* pColSchema = &pSchema[spd->boundColumns[colIdx]];
|
||||||
|
|
||||||
if (bind->num != rowNum) {
|
if (bind->num != rowNum) {
|
||||||
return buildInvalidOperationMsg(&pBuf, "row number in each bind param should be the same");
|
return buildInvalidOperationMsg(&pBuf, "row number in each bind param should be the same");
|
||||||
|
@ -1539,7 +1539,7 @@ int32_t buildBoundFields(SParsedDataColInfo* boundInfo, SSchema* pSchema, int32_
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < boundInfo->numOfBound; ++i) {
|
for (int32_t i = 0; i < boundInfo->numOfBound; ++i) {
|
||||||
SSchema* pTagSchema = &pSchema[boundInfo->boundColumns[i] - 1];
|
SSchema* pTagSchema = &pSchema[boundInfo->boundColumns[i]];
|
||||||
strcpy((*fields)[i].name, pTagSchema->name);
|
strcpy((*fields)[i].name, pTagSchema->name);
|
||||||
(*fields)[i].type = pTagSchema->type;
|
(*fields)[i].type = pTagSchema->type;
|
||||||
(*fields)[i].bytes = pTagSchema->bytes;
|
(*fields)[i].bytes = pTagSchema->bytes;
|
||||||
|
@ -1638,7 +1638,7 @@ static int32_t smlBoundColumnData(SArray* cols, SParsedDataColInfo* pColList, SS
|
||||||
}
|
}
|
||||||
lastColIdx = index;
|
lastColIdx = index;
|
||||||
pColList->cols[index].valStat = VAL_STAT_HAS;
|
pColList->cols[index].valStat = VAL_STAT_HAS;
|
||||||
pColList->boundColumns[pColList->numOfBound] = index + PRIMARYKEY_TIMESTAMP_COL_ID;
|
pColList->boundColumns[pColList->numOfBound] = index;
|
||||||
++pColList->numOfBound;
|
++pColList->numOfBound;
|
||||||
switch (pSchema[t].type) {
|
switch (pSchema[t].type) {
|
||||||
case TSDB_DATA_TYPE_BINARY:
|
case TSDB_DATA_TYPE_BINARY:
|
||||||
|
@ -1688,7 +1688,7 @@ static int32_t smlBuildTagRow(SArray* cols, SKVRowBuilder* tagsBuilder, SParsedD
|
||||||
|
|
||||||
SKvParam param = {.builder = tagsBuilder};
|
SKvParam param = {.builder = tagsBuilder};
|
||||||
for (int i = 0; i < tags->numOfBound; ++i) {
|
for (int i = 0; i < tags->numOfBound; ++i) {
|
||||||
SSchema* pTagSchema = &pSchema[tags->boundColumns[i] - 1]; // colId starts with 1
|
SSchema* pTagSchema = &pSchema[tags->boundColumns[i]];
|
||||||
param.schema = pTagSchema;
|
param.schema = pTagSchema;
|
||||||
SSmlKv* kv = taosArrayGetP(cols, i);
|
SSmlKv* kv = taosArrayGetP(cols, i);
|
||||||
if (IS_VAR_DATA_TYPE(kv->type)) {
|
if (IS_VAR_DATA_TYPE(kv->type)) {
|
||||||
|
|
|
@ -74,7 +74,7 @@ void setBoundColumnInfo(SParsedDataColInfo* pColList, SSchema* pSchema, col_id_t
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pColList->boundColumns[i] = pSchema[i].colId;
|
pColList->boundColumns[i] = i;
|
||||||
}
|
}
|
||||||
pColList->allNullLen += pColList->flen;
|
pColList->allNullLen += pColList->flen;
|
||||||
pColList->boundNullLen = pColList->allNullLen; // default set allNullLen
|
pColList->boundNullLen = pColList->allNullLen; // default set allNullLen
|
||||||
|
|
|
@ -1009,6 +1009,7 @@ static EDealRes rewriteColToSelectValFunc(STranslateContext* pCxt, SNode** pNode
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
|
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
|
||||||
*pNode = (SNode*)pFunc;
|
*pNode = (SNode*)pFunc;
|
||||||
|
pCxt->pCurrStmt->hasSelectValFunc = true;
|
||||||
} else {
|
} else {
|
||||||
nodesDestroyNode(pFunc);
|
nodesDestroyNode(pFunc);
|
||||||
}
|
}
|
||||||
|
@ -1042,7 +1043,6 @@ static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) {
|
||||||
return generateDealNodeErrMsg(pCxt->pTranslateCxt, getGroupByErrorCode(pCxt->pTranslateCxt));
|
return generateDealNodeErrMsg(pCxt->pTranslateCxt, getGroupByErrorCode(pCxt->pTranslateCxt));
|
||||||
} else {
|
} else {
|
||||||
pCxt->hasSelectValFunc = true;
|
pCxt->hasSelectValFunc = true;
|
||||||
pCxt->pTranslateCxt->pCurrStmt->hasSelectValFunc = true;
|
|
||||||
return rewriteColToSelectValFunc(pCxt->pTranslateCxt, pNode);
|
return rewriteColToSelectValFunc(pCxt->pTranslateCxt, pNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4096,16 +4096,17 @@ static int32_t createValueFromFunction(STranslateContext* pCxt, SFunctionNode* p
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDataType schemaToDataType(SSchema* pSchema) {
|
static SDataType schemaToDataType(uint8_t precision, SSchema* pSchema) {
|
||||||
SDataType dt = {.type = pSchema->type, .bytes = pSchema->bytes, .precision = 0, .scale = 0};
|
SDataType dt = {.type = pSchema->type, .bytes = pSchema->bytes, .precision = precision, .scale = 0};
|
||||||
return dt;
|
return dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t translateTagVal(STranslateContext* pCxt, SSchema* pSchema, SNode* pNode, SValueNode** pVal) {
|
static int32_t translateTagVal(STranslateContext* pCxt, uint8_t precision, SSchema* pSchema, SNode* pNode,
|
||||||
|
SValueNode** pVal) {
|
||||||
if (QUERY_NODE_FUNCTION == nodeType(pNode)) {
|
if (QUERY_NODE_FUNCTION == nodeType(pNode)) {
|
||||||
return createValueFromFunction(pCxt, (SFunctionNode*)pNode, pVal);
|
return createValueFromFunction(pCxt, (SFunctionNode*)pNode, pVal);
|
||||||
} else if (QUERY_NODE_VALUE == nodeType(pNode)) {
|
} else if (QUERY_NODE_VALUE == nodeType(pNode)) {
|
||||||
return (DEAL_RES_ERROR == translateValueImpl(pCxt, (SValueNode*)pNode, schemaToDataType(pSchema))
|
return (DEAL_RES_ERROR == translateValueImpl(pCxt, (SValueNode*)pNode, schemaToDataType(precision, pSchema))
|
||||||
? pCxt->errCode
|
? pCxt->errCode
|
||||||
: TSDB_CODE_SUCCESS);
|
: TSDB_CODE_SUCCESS);
|
||||||
} else {
|
} else {
|
||||||
|
@ -4136,7 +4137,7 @@ static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableCla
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TAG_NAME, pCol->colName);
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TAG_NAME, pCol->colName);
|
||||||
}
|
}
|
||||||
SValueNode* pVal = NULL;
|
SValueNode* pVal = NULL;
|
||||||
int32_t code = translateTagVal(pCxt, pSchema, pNode, &pVal);
|
int32_t code = translateTagVal(pCxt, pSuperTableMeta->tableInfo.precision, pSchema, pNode, &pVal);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
if (NULL == pVal) {
|
if (NULL == pVal) {
|
||||||
pVal = (SValueNode*)pNode;
|
pVal = (SValueNode*)pNode;
|
||||||
|
@ -4166,7 +4167,7 @@ static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClau
|
||||||
int32_t index = 0;
|
int32_t index = 0;
|
||||||
FOREACH(pNode, pStmt->pValsOfTags) {
|
FOREACH(pNode, pStmt->pValsOfTags) {
|
||||||
SValueNode* pVal = NULL;
|
SValueNode* pVal = NULL;
|
||||||
int32_t code = translateTagVal(pCxt, pTagSchema + index, pNode, &pVal);
|
int32_t code = translateTagVal(pCxt, pSuperTableMeta->tableInfo.precision, pTagSchema + index, pNode, &pVal);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
if (NULL == pVal) {
|
if (NULL == pVal) {
|
||||||
pVal = (SValueNode*)pNode;
|
pVal = (SValueNode*)pNode;
|
||||||
|
@ -4446,7 +4447,8 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DEAL_RES_ERROR == translateValueImpl(pCxt, pStmt->pVal, schemaToDataType(pSchema))) {
|
if (DEAL_RES_ERROR ==
|
||||||
|
translateValueImpl(pCxt, pStmt->pVal, schemaToDataType(pTableMeta->tableInfo.precision, pSchema))) {
|
||||||
return pCxt->errCode;
|
return pCxt->errCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -154,6 +154,7 @@ void generateTestST1(MockCatalogService* mcs) {
|
||||||
builder.done();
|
builder.done();
|
||||||
mcs->createSubTable("test", "st1", "st1s1", 1);
|
mcs->createSubTable("test", "st1", "st1s1", 1);
|
||||||
mcs->createSubTable("test", "st1", "st1s2", 2);
|
mcs->createSubTable("test", "st1", "st1s2", 2);
|
||||||
|
mcs->createSubTable("test", "st1", "st1s3", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -44,3 +44,9 @@ TEST_F(PlanJoinTest, withWhere) {
|
||||||
run("SELECT t1.c1, t2.c1 FROM st1s1 t1 JOIN st1s2 t2 ON t1.ts = t2.ts "
|
run("SELECT t1.c1, t2.c1 FROM st1s1 t1 JOIN st1s2 t2 ON t1.ts = t2.ts "
|
||||||
"WHERE t1.c1 > t2.c1 AND t1.c2 = 'abc' AND t2.c2 = 'qwe'");
|
"WHERE t1.c1 > t2.c1 AND t1.c2 = 'abc' AND t2.c2 = 'qwe'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(PlanJoinTest, multiJoin) {
|
||||||
|
useDb("root", "test");
|
||||||
|
|
||||||
|
run("SELECT t1.c1, t2.c1 FROM st1s1 t1 JOIN st1s2 t2 ON t1.ts = t2.ts JOIN st1s3 t3 ON t1.ts = t3.ts");
|
||||||
|
}
|
||||||
|
|
|
@ -120,7 +120,7 @@ endi
|
||||||
if $data[1][1] != 1 then
|
if $data[1][1] != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data[2][2] != 2 then
|
if $data[1][2] != 2 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data[1][3] != 3 then
|
if $data[1][3] != 3 then
|
||||||
|
|
Loading…
Reference in New Issue