Merge remote-tracking branch 'origin/develop' into feature/sim
This commit is contained in:
commit
63a6d230b7
|
@ -16,13 +16,25 @@ ENDIF ()
|
||||||
IF (DEFINED GITINFO)
|
IF (DEFINED GITINFO)
|
||||||
SET(TD_VER_GIT ${GITINFO})
|
SET(TD_VER_GIT ${GITINFO})
|
||||||
ELSE ()
|
ELSE ()
|
||||||
SET(TD_VER_GIT "community")
|
execute_process(
|
||||||
|
COMMAND git log -1 --format=%H
|
||||||
|
WORKING_DIRECTORY ${TD_COMMUNITY_DIR}
|
||||||
|
OUTPUT_VARIABLE GIT_COMMITID
|
||||||
|
)
|
||||||
|
string (REGEX REPLACE "[\n\t\r]" "" GIT_COMMITID ${GIT_COMMITID})
|
||||||
|
SET(TD_VER_GIT ${GIT_COMMITID})
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF (DEFINED GITINFOI)
|
IF (DEFINED GITINFOI)
|
||||||
SET(TD_VER_GIT_INTERNAL ${GITINFOI})
|
SET(TD_VER_GIT_INTERNAL ${GITINFOI})
|
||||||
ELSE ()
|
ELSE ()
|
||||||
SET(TD_VER_GIT_INTERNAL "internal")
|
execute_process(
|
||||||
|
COMMAND git log -1 --format=%H
|
||||||
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||||
|
OUTPUT_VARIABLE GIT_COMMITID
|
||||||
|
)
|
||||||
|
string (REGEX REPLACE "[\n\t\r]" "" GIT_COMMITID ${GIT_COMMITID})
|
||||||
|
SET(TD_VER_GIT_INTERNAL ${GIT_COMMITID})
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF (DEFINED VERDATE)
|
IF (DEFINED VERDATE)
|
||||||
|
|
|
@ -38,7 +38,7 @@ typedef struct SLocalDataSource {
|
||||||
tFilePage filePage;
|
tFilePage filePage;
|
||||||
} SLocalDataSource;
|
} SLocalDataSource;
|
||||||
|
|
||||||
typedef struct SLocalReducer {
|
typedef struct SLocalMerger {
|
||||||
SLocalDataSource ** pLocalDataSrc;
|
SLocalDataSource ** pLocalDataSrc;
|
||||||
int32_t numOfBuffer;
|
int32_t numOfBuffer;
|
||||||
int32_t numOfCompleted;
|
int32_t numOfCompleted;
|
||||||
|
@ -62,7 +62,7 @@ typedef struct SLocalReducer {
|
||||||
bool discard;
|
bool discard;
|
||||||
int32_t offset; // limit offset value
|
int32_t offset; // limit offset value
|
||||||
bool orderPrjOnSTable; // projection query on stable
|
bool orderPrjOnSTable; // projection query on stable
|
||||||
} SLocalReducer;
|
} SLocalMerger;
|
||||||
|
|
||||||
typedef struct SRetrieveSupport {
|
typedef struct SRetrieveSupport {
|
||||||
tExtMemBuffer ** pExtMemBuffer; // for build loser tree
|
tExtMemBuffer ** pExtMemBuffer; // for build loser tree
|
||||||
|
@ -89,10 +89,10 @@ int32_t tscFlushTmpBuffer(tExtMemBuffer *pMemoryBuf, tOrderDescriptor *pDesc, tF
|
||||||
/*
|
/*
|
||||||
* create local reducer to launch the second-stage reduce process at client site
|
* create local reducer to launch the second-stage reduce process at client site
|
||||||
*/
|
*/
|
||||||
void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrderDescriptor *pDesc,
|
void tscCreateLocalMerger(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrderDescriptor *pDesc,
|
||||||
SColumnModel *finalModel, SColumnModel *pFFModel, SSqlObj* pSql);
|
SColumnModel *finalModel, SColumnModel *pFFModel, SSqlObj* pSql);
|
||||||
|
|
||||||
void tscDestroyLocalReducer(SSqlObj *pSql);
|
void tscDestroyLocalMerger(SSqlObj *pSql);
|
||||||
|
|
||||||
int32_t tscDoLocalMerge(SSqlObj *pSql);
|
int32_t tscDoLocalMerge(SSqlObj *pSql);
|
||||||
|
|
||||||
|
|
|
@ -98,8 +98,7 @@ static FORCE_INLINE SQueryInfo* tscGetQueryInfoDetail(SSqlCmd* pCmd, int32_t sub
|
||||||
return pCmd->pQueryInfo[subClauseIndex];
|
return pCmd->pQueryInfo[subClauseIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tscCreateDataBlock(size_t initialSize, int32_t rowSize, int32_t startOffset, const char* name,
|
int32_t tscCreateDataBlock(size_t initialSize, int32_t rowSize, int32_t startOffset, SName* name, STableMeta* pTableMeta, STableDataBlocks** dataBlocks);
|
||||||
STableMeta* pTableMeta, STableDataBlocks** dataBlocks);
|
|
||||||
void tscDestroyDataBlock(STableDataBlocks* pDataBlock);
|
void tscDestroyDataBlock(STableDataBlocks* pDataBlock);
|
||||||
void tscSortRemoveDataBlockDupRows(STableDataBlocks* dataBuf);
|
void tscSortRemoveDataBlockDupRows(STableDataBlocks* dataBuf);
|
||||||
|
|
||||||
|
@ -111,7 +110,7 @@ void* tscDestroyBlockHashTable(SHashObj* pBlockHashTable);
|
||||||
|
|
||||||
int32_t tscCopyDataBlockToPayload(SSqlObj* pSql, STableDataBlocks* pDataBlock);
|
int32_t tscCopyDataBlockToPayload(SSqlObj* pSql, STableDataBlocks* pDataBlock);
|
||||||
int32_t tscMergeTableDataBlocks(SSqlObj* pSql, bool freeBlockMap);
|
int32_t tscMergeTableDataBlocks(SSqlObj* pSql, bool freeBlockMap);
|
||||||
int32_t tscGetDataBlockFromList(SHashObj* pHashList, int64_t id, int32_t size, int32_t startOffset, int32_t rowSize, const char* tableId, STableMeta* pTableMeta,
|
int32_t tscGetDataBlockFromList(SHashObj* pHashList, int64_t id, int32_t size, int32_t startOffset, int32_t rowSize, SName* pName, STableMeta* pTableMeta,
|
||||||
STableDataBlocks** dataBlocks, SArray* pBlockList);
|
STableDataBlocks** dataBlocks, SArray* pBlockList);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -142,10 +141,6 @@ void tscClearInterpInfo(SQueryInfo* pQueryInfo);
|
||||||
|
|
||||||
bool tscIsInsertData(char* sqlstr);
|
bool tscIsInsertData(char* sqlstr);
|
||||||
|
|
||||||
/* use for keep current db info temporarily, for handle table with db prefix */
|
|
||||||
// todo remove it
|
|
||||||
void tscGetDBInfoFromTableFullName(char* tableId, char* db);
|
|
||||||
|
|
||||||
int tscAllocPayload(SSqlCmd* pCmd, int size);
|
int tscAllocPayload(SSqlCmd* pCmd, int size);
|
||||||
|
|
||||||
TAOS_FIELD tscCreateField(int8_t type, const char* name, int16_t bytes);
|
TAOS_FIELD tscCreateField(int8_t type, const char* name, int16_t bytes);
|
||||||
|
@ -215,8 +210,8 @@ SQueryInfo *tscGetQueryInfoDetailSafely(SSqlCmd *pCmd, int32_t subClauseIndex);
|
||||||
|
|
||||||
void tscClearTableMetaInfo(STableMetaInfo* pTableMetaInfo);
|
void tscClearTableMetaInfo(STableMetaInfo* pTableMetaInfo);
|
||||||
|
|
||||||
STableMetaInfo* tscAddTableMetaInfo(SQueryInfo* pQueryInfo, const char* name, STableMeta* pTableMeta,
|
STableMetaInfo* tscAddTableMetaInfo(SQueryInfo* pQueryInfo, SName* name, STableMeta* pTableMeta,
|
||||||
SVgroupsInfo* vgroupList, SArray* pTagCols, SArray* pVgroupTables);
|
SVgroupsInfo* vgroupList, SArray* pTagCols, SArray* pVgroupTables);
|
||||||
|
|
||||||
STableMetaInfo* tscAddEmptyMetaInfo(SQueryInfo *pQueryInfo);
|
STableMetaInfo* tscAddEmptyMetaInfo(SQueryInfo *pQueryInfo);
|
||||||
int32_t tscAddSubqueryInfo(SSqlCmd *pCmd);
|
int32_t tscAddSubqueryInfo(SSqlCmd *pCmd);
|
||||||
|
@ -225,7 +220,7 @@ void tscInitQueryInfo(SQueryInfo* pQueryInfo);
|
||||||
|
|
||||||
void tscClearSubqueryInfo(SSqlCmd* pCmd);
|
void tscClearSubqueryInfo(SSqlCmd* pCmd);
|
||||||
void tscFreeVgroupTableInfo(SArray* pVgroupTables);
|
void tscFreeVgroupTableInfo(SArray* pVgroupTables);
|
||||||
SArray* tscVgroupTableInfoClone(SArray* pVgroupTables);
|
SArray* tscVgroupTableInfoDup(SArray* pVgroupTables);
|
||||||
void tscRemoveVgroupTableGroup(SArray* pVgroupTable, int32_t index);
|
void tscRemoveVgroupTableGroup(SArray* pVgroupTable, int32_t index);
|
||||||
void tscVgroupTableCopy(SVgroupTableInfo* info, SVgroupTableInfo* pInfo);
|
void tscVgroupTableCopy(SVgroupTableInfo* info, SVgroupTableInfo* pInfo);
|
||||||
|
|
||||||
|
@ -292,7 +287,7 @@ uint32_t tscGetTableMetaSize(STableMeta* pTableMeta);
|
||||||
CChildTableMeta* tscCreateChildMeta(STableMeta* pTableMeta);
|
CChildTableMeta* tscCreateChildMeta(STableMeta* pTableMeta);
|
||||||
uint32_t tscGetTableMetaMaxSize();
|
uint32_t tscGetTableMetaMaxSize();
|
||||||
int32_t tscCreateTableMetaFromCChildMeta(STableMeta* pChild, const char* name);
|
int32_t tscCreateTableMetaFromCChildMeta(STableMeta* pChild, const char* name);
|
||||||
STableMeta* tscTableMetaClone(STableMeta* pTableMeta);
|
STableMeta* tscTableMetaDup(STableMeta* pTableMeta);
|
||||||
|
|
||||||
|
|
||||||
void* malloc_throw(size_t size);
|
void* malloc_throw(size_t size);
|
||||||
|
|
|
@ -39,7 +39,7 @@ extern "C" {
|
||||||
|
|
||||||
// forward declaration
|
// forward declaration
|
||||||
struct SSqlInfo;
|
struct SSqlInfo;
|
||||||
struct SLocalReducer;
|
struct SLocalMerger;
|
||||||
|
|
||||||
// data source from sql string or from file
|
// data source from sql string or from file
|
||||||
enum {
|
enum {
|
||||||
|
@ -67,7 +67,7 @@ typedef struct CChildTableMeta {
|
||||||
int32_t vgId;
|
int32_t vgId;
|
||||||
STableId id;
|
STableId id;
|
||||||
uint8_t tableType;
|
uint8_t tableType;
|
||||||
char sTableName[TSDB_TABLE_FNAME_LEN];
|
char sTableName[TSDB_TABLE_FNAME_LEN]; //super table name, not full name
|
||||||
} CChildTableMeta;
|
} CChildTableMeta;
|
||||||
|
|
||||||
typedef struct STableMeta {
|
typedef struct STableMeta {
|
||||||
|
@ -91,7 +91,7 @@ typedef struct STableMetaInfo {
|
||||||
* 2. keep the vgroup index for multi-vnode insertion
|
* 2. keep the vgroup index for multi-vnode insertion
|
||||||
*/
|
*/
|
||||||
int32_t vgroupIndex;
|
int32_t vgroupIndex;
|
||||||
char name[TSDB_TABLE_FNAME_LEN]; // (super) table name
|
SName name;
|
||||||
char aliasName[TSDB_TABLE_NAME_LEN]; // alias name of table specified in query sql
|
char aliasName[TSDB_TABLE_NAME_LEN]; // alias name of table specified in query sql
|
||||||
SArray *tagColList; // SArray<SColumn*>, involved tag columns
|
SArray *tagColList; // SArray<SColumn*>, involved tag columns
|
||||||
} STableMetaInfo;
|
} STableMetaInfo;
|
||||||
|
@ -142,7 +142,7 @@ typedef struct SCond {
|
||||||
} SCond;
|
} SCond;
|
||||||
|
|
||||||
typedef struct SJoinNode {
|
typedef struct SJoinNode {
|
||||||
char tableId[TSDB_TABLE_FNAME_LEN];
|
char tableName[TSDB_TABLE_FNAME_LEN];
|
||||||
uint64_t uid;
|
uint64_t uid;
|
||||||
int16_t tagColId;
|
int16_t tagColId;
|
||||||
} SJoinNode;
|
} SJoinNode;
|
||||||
|
@ -176,7 +176,7 @@ typedef struct SParamInfo {
|
||||||
} SParamInfo;
|
} SParamInfo;
|
||||||
|
|
||||||
typedef struct STableDataBlocks {
|
typedef struct STableDataBlocks {
|
||||||
char tableName[TSDB_TABLE_FNAME_LEN];
|
SName tableName;
|
||||||
int8_t tsSource; // where does the UNIX timestamp come from, server or client
|
int8_t tsSource; // where does the UNIX timestamp come from, server or client
|
||||||
bool ordered; // if current rows are ordered or not
|
bool ordered; // if current rows are ordered or not
|
||||||
int64_t vgId; // virtual group id
|
int64_t vgId; // virtual group id
|
||||||
|
@ -254,7 +254,7 @@ typedef struct {
|
||||||
int8_t submitSchema; // submit block is built with table schema
|
int8_t submitSchema; // submit block is built with table schema
|
||||||
STagData tagData; // NOTE: pTagData->data is used as a variant length array
|
STagData tagData; // NOTE: pTagData->data is used as a variant length array
|
||||||
|
|
||||||
char **pTableNameList; // all involved tableMeta list of current insert sql statement.
|
SName **pTableNameList; // all involved tableMeta list of current insert sql statement.
|
||||||
int32_t numOfTables;
|
int32_t numOfTables;
|
||||||
|
|
||||||
SHashObj *pTableBlockHashList; // data block for each table
|
SHashObj *pTableBlockHashList; // data block for each table
|
||||||
|
@ -292,7 +292,7 @@ typedef struct {
|
||||||
SColumnIndex* pColumnIndex;
|
SColumnIndex* pColumnIndex;
|
||||||
|
|
||||||
SArithmeticSupport *pArithSup; // support the arithmetic expression calculation on agg functions
|
SArithmeticSupport *pArithSup; // support the arithmetic expression calculation on agg functions
|
||||||
struct SLocalReducer *pLocalReducer;
|
struct SLocalMerger *pLocalMerger;
|
||||||
} SSqlRes;
|
} SSqlRes;
|
||||||
|
|
||||||
typedef struct STscObj {
|
typedef struct STscObj {
|
||||||
|
@ -436,7 +436,7 @@ void waitForQueryRsp(void *param, TAOS_RES *tres, int code);
|
||||||
|
|
||||||
void doAsyncQuery(STscObj *pObj, SSqlObj *pSql, __async_cb_func_t fp, void *param, const char *sqlstr, size_t sqlLen);
|
void doAsyncQuery(STscObj *pObj, SSqlObj *pSql, __async_cb_func_t fp, void *param, const char *sqlstr, size_t sqlLen);
|
||||||
|
|
||||||
void tscProcessMultiVnodesImportFromFile(SSqlObj *pSql);
|
void tscImportDataFromFile(SSqlObj *pSql);
|
||||||
void tscInitResObjForLocalQuery(SSqlObj *pObj, int32_t numOfRes, int32_t rowLen);
|
void tscInitResObjForLocalQuery(SSqlObj *pObj, int32_t numOfRes, int32_t rowLen);
|
||||||
bool tscIsUpdateQuery(SSqlObj* pSql);
|
bool tscIsUpdateQuery(SSqlObj* pSql);
|
||||||
bool tscHasReachLimitation(SQueryInfo *pQueryInfo, SSqlRes *pRes);
|
bool tscHasReachLimitation(SQueryInfo *pQueryInfo, SSqlRes *pRes);
|
||||||
|
|
|
@ -569,10 +569,12 @@ static int32_t tscRebuildDDLForSubTable(SSqlObj *pSql, const char *tableName, ch
|
||||||
}
|
}
|
||||||
|
|
||||||
char fullName[TSDB_TABLE_FNAME_LEN * 2] = {0};
|
char fullName[TSDB_TABLE_FNAME_LEN * 2] = {0};
|
||||||
extractDBName(pTableMetaInfo->name, fullName);
|
tNameGetDbName(&pTableMetaInfo->name, fullName);
|
||||||
|
|
||||||
extractTableName(pMeta->sTableName, param->sTableName);
|
extractTableName(pMeta->sTableName, param->sTableName);
|
||||||
snprintf(fullName + strlen(fullName), TSDB_TABLE_FNAME_LEN - strlen(fullName), ".%s", param->sTableName);
|
snprintf(fullName + strlen(fullName), TSDB_TABLE_FNAME_LEN - strlen(fullName), ".%s", param->sTableName);
|
||||||
extractTableName(pTableMetaInfo->name, param->buf);
|
|
||||||
|
strncpy(param->buf, tNameGetTableName(&pTableMetaInfo->name), TSDB_TABLE_NAME_LEN);
|
||||||
|
|
||||||
param->pParentSql = pSql;
|
param->pParentSql = pSql;
|
||||||
param->pInterSql = pInterSql;
|
param->pInterSql = pInterSql;
|
||||||
|
@ -602,6 +604,7 @@ static int32_t tscRebuildDDLForSubTable(SSqlObj *pSql, const char *tableName, ch
|
||||||
|
|
||||||
return TSDB_CODE_TSC_ACTION_IN_PROGRESS;
|
return TSDB_CODE_TSC_ACTION_IN_PROGRESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tscRebuildDDLForNormalTable(SSqlObj *pSql, const char *tableName, char *ddl) {
|
static int32_t tscRebuildDDLForNormalTable(SSqlObj *pSql, const char *tableName, char *ddl) {
|
||||||
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0);
|
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0);
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||||
|
@ -675,8 +678,7 @@ static int32_t tscProcessShowCreateTable(SSqlObj *pSql) {
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||||
assert(pTableMetaInfo->pTableMeta != NULL);
|
assert(pTableMetaInfo->pTableMeta != NULL);
|
||||||
|
|
||||||
char tableName[TSDB_TABLE_NAME_LEN] = {0};
|
const char* tableName = tNameGetTableName(&pTableMetaInfo->name);
|
||||||
extractTableName(pTableMetaInfo->name, tableName);
|
|
||||||
|
|
||||||
char *result = (char *)calloc(1, TSDB_MAX_BINARY_LEN);
|
char *result = (char *)calloc(1, TSDB_MAX_BINARY_LEN);
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
@ -712,7 +714,9 @@ static int32_t tscProcessShowCreateDatabase(SSqlObj *pSql) {
|
||||||
free(pInterSql);
|
free(pInterSql);
|
||||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
extractTableName(pTableMetaInfo->name, param->buf);
|
|
||||||
|
strncpy(param->buf, tNameGetTableName(&pTableMetaInfo->name), TSDB_TABLE_NAME_LEN);
|
||||||
|
|
||||||
param->pParentSql = pSql;
|
param->pParentSql = pSql;
|
||||||
param->pInterSql = pInterSql;
|
param->pInterSql = pInterSql;
|
||||||
param->fp = tscRebuildCreateDBStatement;
|
param->fp = tscRebuildCreateDBStatement;
|
||||||
|
|
|
@ -56,7 +56,7 @@ int32_t treeComparator(const void *pLeft, const void *pRight, void *param) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tscInitSqlContext(SSqlCmd *pCmd, SLocalReducer *pReducer, tOrderDescriptor *pDesc) {
|
static void tscInitSqlContext(SSqlCmd *pCmd, SLocalMerger *pReducer, tOrderDescriptor *pDesc) {
|
||||||
/*
|
/*
|
||||||
* the fields and offset attributes in pCmd and pModel may be different due to
|
* the fields and offset attributes in pCmd and pModel may be different due to
|
||||||
* merge requirement. So, the final result in pRes structure is formatted in accordance with the pCmd object.
|
* merge requirement. So, the final result in pRes structure is formatted in accordance with the pCmd object.
|
||||||
|
@ -166,7 +166,7 @@ static SFillColInfo* createFillColInfo(SQueryInfo* pQueryInfo) {
|
||||||
return pFillCol;
|
return pFillCol;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrderDescriptor *pDesc,
|
void tscCreateLocalMerger(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrderDescriptor *pDesc,
|
||||||
SColumnModel *finalmodel, SColumnModel *pFFModel, SSqlObj* pSql) {
|
SColumnModel *finalmodel, SColumnModel *pFFModel, SSqlObj* pSql) {
|
||||||
SSqlCmd* pCmd = &pSql->cmd;
|
SSqlCmd* pCmd = &pSql->cmd;
|
||||||
SSqlRes* pRes = &pSql->res;
|
SSqlRes* pRes = &pSql->res;
|
||||||
|
@ -212,9 +212,9 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t size = sizeof(SLocalReducer) + POINTER_BYTES * numOfFlush;
|
size_t size = sizeof(SLocalMerger) + POINTER_BYTES * numOfFlush;
|
||||||
|
|
||||||
SLocalReducer *pReducer = (SLocalReducer *) calloc(1, size);
|
SLocalMerger *pReducer = (SLocalMerger *) calloc(1, size);
|
||||||
if (pReducer == NULL) {
|
if (pReducer == NULL) {
|
||||||
tscError("%p failed to create local merge structure, out of memory", pSql);
|
tscError("%p failed to create local merge structure, out of memory", pSql);
|
||||||
|
|
||||||
|
@ -372,7 +372,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
|
||||||
|
|
||||||
pReducer->offset = (int32_t)pQueryInfo->limit.offset;
|
pReducer->offset = (int32_t)pQueryInfo->limit.offset;
|
||||||
|
|
||||||
pRes->pLocalReducer = pReducer;
|
pRes->pLocalMerger = pReducer;
|
||||||
pRes->numOfGroups = 0;
|
pRes->numOfGroups = 0;
|
||||||
|
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
||||||
|
@ -477,13 +477,13 @@ int32_t saveToBuffer(tExtMemBuffer *pMemoryBuf, tOrderDescriptor *pDesc, tFilePa
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscDestroyLocalReducer(SSqlObj *pSql) {
|
void tscDestroyLocalMerger(SSqlObj *pSql) {
|
||||||
if (pSql == NULL) {
|
if (pSql == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSqlRes *pRes = &(pSql->res);
|
SSqlRes *pRes = &(pSql->res);
|
||||||
if (pRes->pLocalReducer == NULL) {
|
if (pRes->pLocalMerger == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -491,14 +491,14 @@ void tscDestroyLocalReducer(SSqlObj *pSql) {
|
||||||
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
||||||
|
|
||||||
// there is no more result, so we release all allocated resource
|
// there is no more result, so we release all allocated resource
|
||||||
SLocalReducer *pLocalReducer = (SLocalReducer *)atomic_exchange_ptr(&pRes->pLocalReducer, NULL);
|
SLocalMerger *pLocalMerge = (SLocalMerger *)atomic_exchange_ptr(&pRes->pLocalMerger, NULL);
|
||||||
if (pLocalReducer != NULL) {
|
if (pLocalMerge != NULL) {
|
||||||
pLocalReducer->pFillInfo = taosDestroyFillInfo(pLocalReducer->pFillInfo);
|
pLocalMerge->pFillInfo = taosDestroyFillInfo(pLocalMerge->pFillInfo);
|
||||||
|
|
||||||
if (pLocalReducer->pCtx != NULL) {
|
if (pLocalMerge->pCtx != NULL) {
|
||||||
int32_t numOfExprs = (int32_t) tscSqlExprNumOfExprs(pQueryInfo);
|
int32_t numOfExprs = (int32_t) tscSqlExprNumOfExprs(pQueryInfo);
|
||||||
for (int32_t i = 0; i < numOfExprs; ++i) {
|
for (int32_t i = 0; i < numOfExprs; ++i) {
|
||||||
SQLFunctionCtx *pCtx = &pLocalReducer->pCtx[i];
|
SQLFunctionCtx *pCtx = &pLocalMerge->pCtx[i];
|
||||||
|
|
||||||
tVariantDestroy(&pCtx->tag);
|
tVariantDestroy(&pCtx->tag);
|
||||||
tfree(pCtx->resultInfo);
|
tfree(pCtx->resultInfo);
|
||||||
|
@ -508,31 +508,31 @@ void tscDestroyLocalReducer(SSqlObj *pSql) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tfree(pLocalReducer->pCtx);
|
tfree(pLocalMerge->pCtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
tfree(pLocalReducer->prevRowOfInput);
|
tfree(pLocalMerge->prevRowOfInput);
|
||||||
|
|
||||||
tfree(pLocalReducer->pTempBuffer);
|
tfree(pLocalMerge->pTempBuffer);
|
||||||
tfree(pLocalReducer->pResultBuf);
|
tfree(pLocalMerge->pResultBuf);
|
||||||
|
|
||||||
if (pLocalReducer->pLoserTree) {
|
if (pLocalMerge->pLoserTree) {
|
||||||
tfree(pLocalReducer->pLoserTree->param);
|
tfree(pLocalMerge->pLoserTree->param);
|
||||||
tfree(pLocalReducer->pLoserTree);
|
tfree(pLocalMerge->pLoserTree);
|
||||||
}
|
}
|
||||||
|
|
||||||
tfree(pLocalReducer->pFinalRes);
|
tfree(pLocalMerge->pFinalRes);
|
||||||
tfree(pLocalReducer->discardData);
|
tfree(pLocalMerge->discardData);
|
||||||
|
|
||||||
tscLocalReducerEnvDestroy(pLocalReducer->pExtMemBuffer, pLocalReducer->pDesc, pLocalReducer->resColModel, pLocalReducer->finalModel,
|
tscLocalReducerEnvDestroy(pLocalMerge->pExtMemBuffer, pLocalMerge->pDesc, pLocalMerge->resColModel, pLocalMerge->finalModel,
|
||||||
pLocalReducer->numOfVnode);
|
pLocalMerge->numOfVnode);
|
||||||
for (int32_t i = 0; i < pLocalReducer->numOfBuffer; ++i) {
|
for (int32_t i = 0; i < pLocalMerge->numOfBuffer; ++i) {
|
||||||
tfree(pLocalReducer->pLocalDataSrc[i]);
|
tfree(pLocalMerge->pLocalDataSrc[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
pLocalReducer->numOfBuffer = 0;
|
pLocalMerge->numOfBuffer = 0;
|
||||||
pLocalReducer->numOfCompleted = 0;
|
pLocalMerge->numOfCompleted = 0;
|
||||||
free(pLocalReducer);
|
free(pLocalMerge);
|
||||||
} else {
|
} else {
|
||||||
tscDebug("%p already freed or another free function is invoked", pSql);
|
tscDebug("%p already freed or another free function is invoked", pSql);
|
||||||
}
|
}
|
||||||
|
@ -604,7 +604,7 @@ static int32_t createOrderDescriptor(tOrderDescriptor **pOrderDesc, SSqlCmd *pCm
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isSameGroup(SSqlCmd *pCmd, SLocalReducer *pReducer, char *pPrev, tFilePage *tmpBuffer) {
|
bool isSameGroup(SSqlCmd *pCmd, SLocalMerger *pReducer, char *pPrev, tFilePage *tmpBuffer) {
|
||||||
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
||||||
|
|
||||||
// disable merge procedure for column projection query
|
// disable merge procedure for column projection query
|
||||||
|
@ -795,12 +795,12 @@ void tscLocalReducerEnvDestroy(tExtMemBuffer **pMemBuffer, tOrderDescriptor *pDe
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param pLocalReducer
|
* @param pLocalMerge
|
||||||
* @param pOneInterDataSrc
|
* @param pOneInterDataSrc
|
||||||
* @param treeList
|
* @param treeList
|
||||||
* @return the number of remain input source. if ret == 0, all data has been handled
|
* @return the number of remain input source. if ret == 0, all data has been handled
|
||||||
*/
|
*/
|
||||||
int32_t loadNewDataFromDiskFor(SLocalReducer *pLocalReducer, SLocalDataSource *pOneInterDataSrc,
|
int32_t loadNewDataFromDiskFor(SLocalMerger *pLocalMerge, SLocalDataSource *pOneInterDataSrc,
|
||||||
bool *needAdjustLoserTree) {
|
bool *needAdjustLoserTree) {
|
||||||
pOneInterDataSrc->rowIdx = 0;
|
pOneInterDataSrc->rowIdx = 0;
|
||||||
pOneInterDataSrc->pageId += 1;
|
pOneInterDataSrc->pageId += 1;
|
||||||
|
@ -817,17 +817,17 @@ int32_t loadNewDataFromDiskFor(SLocalReducer *pLocalReducer, SLocalDataSource *p
|
||||||
#endif
|
#endif
|
||||||
*needAdjustLoserTree = true;
|
*needAdjustLoserTree = true;
|
||||||
} else {
|
} else {
|
||||||
pLocalReducer->numOfCompleted += 1;
|
pLocalMerge->numOfCompleted += 1;
|
||||||
|
|
||||||
pOneInterDataSrc->rowIdx = -1;
|
pOneInterDataSrc->rowIdx = -1;
|
||||||
pOneInterDataSrc->pageId = -1;
|
pOneInterDataSrc->pageId = -1;
|
||||||
*needAdjustLoserTree = true;
|
*needAdjustLoserTree = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return pLocalReducer->numOfBuffer;
|
return pLocalMerge->numOfBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void adjustLoserTreeFromNewData(SLocalReducer *pLocalReducer, SLocalDataSource *pOneInterDataSrc,
|
void adjustLoserTreeFromNewData(SLocalMerger *pLocalMerge, SLocalDataSource *pOneInterDataSrc,
|
||||||
SLoserTreeInfo *pTree) {
|
SLoserTreeInfo *pTree) {
|
||||||
/*
|
/*
|
||||||
* load a new data page into memory for intermediate dataset source,
|
* load a new data page into memory for intermediate dataset source,
|
||||||
|
@ -835,7 +835,7 @@ void adjustLoserTreeFromNewData(SLocalReducer *pLocalReducer, SLocalDataSource *
|
||||||
*/
|
*/
|
||||||
bool needToAdjust = true;
|
bool needToAdjust = true;
|
||||||
if (pOneInterDataSrc->filePage.num <= pOneInterDataSrc->rowIdx) {
|
if (pOneInterDataSrc->filePage.num <= pOneInterDataSrc->rowIdx) {
|
||||||
loadNewDataFromDiskFor(pLocalReducer, pOneInterDataSrc, &needToAdjust);
|
loadNewDataFromDiskFor(pLocalMerge, pOneInterDataSrc, &needToAdjust);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -843,7 +843,7 @@ void adjustLoserTreeFromNewData(SLocalReducer *pLocalReducer, SLocalDataSource *
|
||||||
* if the loser tree is rebuild completed, we do not need to adjust
|
* if the loser tree is rebuild completed, we do not need to adjust
|
||||||
*/
|
*/
|
||||||
if (needToAdjust) {
|
if (needToAdjust) {
|
||||||
int32_t leafNodeIdx = pTree->pNode[0].index + pLocalReducer->numOfBuffer;
|
int32_t leafNodeIdx = pTree->pNode[0].index + pLocalMerge->numOfBuffer;
|
||||||
|
|
||||||
#ifdef _DEBUG_VIEW
|
#ifdef _DEBUG_VIEW
|
||||||
printf("before adjust:\t");
|
printf("before adjust:\t");
|
||||||
|
@ -860,7 +860,7 @@ void adjustLoserTreeFromNewData(SLocalReducer *pLocalReducer, SLocalDataSource *
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void savePrevRecordAndSetupFillInfo(SLocalReducer *pLocalReducer, SQueryInfo *pQueryInfo, SFillInfo *pFillInfo) {
|
void savePrevRecordAndSetupFillInfo(SLocalMerger *pLocalMerge, SQueryInfo *pQueryInfo, SFillInfo *pFillInfo) {
|
||||||
// discard following dataset in the same group and reset the interpolation information
|
// discard following dataset in the same group and reset the interpolation information
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||||
|
|
||||||
|
@ -873,28 +873,28 @@ void savePrevRecordAndSetupFillInfo(SLocalReducer *pLocalReducer, SQueryInfo *pQ
|
||||||
taosResetFillInfo(pFillInfo, revisedSTime);
|
taosResetFillInfo(pFillInfo, revisedSTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
pLocalReducer->discard = true;
|
pLocalMerge->discard = true;
|
||||||
pLocalReducer->discardData->num = 0;
|
pLocalMerge->discardData->num = 0;
|
||||||
|
|
||||||
SColumnModel *pModel = pLocalReducer->pDesc->pColumnModel;
|
SColumnModel *pModel = pLocalMerge->pDesc->pColumnModel;
|
||||||
tColModelAppend(pModel, pLocalReducer->discardData, pLocalReducer->prevRowOfInput, 0, 1, 1);
|
tColModelAppend(pModel, pLocalMerge->discardData, pLocalMerge->prevRowOfInput, 0, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void genFinalResWithoutFill(SSqlRes* pRes, SLocalReducer *pLocalReducer, SQueryInfo* pQueryInfo) {
|
static void genFinalResWithoutFill(SSqlRes* pRes, SLocalMerger *pLocalMerge, SQueryInfo* pQueryInfo) {
|
||||||
assert(pQueryInfo->interval.interval == 0 || pQueryInfo->fillType == TSDB_FILL_NONE);
|
assert(pQueryInfo->interval.interval == 0 || pQueryInfo->fillType == TSDB_FILL_NONE);
|
||||||
|
|
||||||
tFilePage * pBeforeFillData = pLocalReducer->pResultBuf;
|
tFilePage * pBeforeFillData = pLocalMerge->pResultBuf;
|
||||||
|
|
||||||
pRes->data = pLocalReducer->pFinalRes;
|
pRes->data = pLocalMerge->pFinalRes;
|
||||||
pRes->numOfRows = (int32_t) pBeforeFillData->num;
|
pRes->numOfRows = (int32_t) pBeforeFillData->num;
|
||||||
|
|
||||||
if (pQueryInfo->limit.offset > 0) {
|
if (pQueryInfo->limit.offset > 0) {
|
||||||
if (pQueryInfo->limit.offset < pRes->numOfRows) {
|
if (pQueryInfo->limit.offset < pRes->numOfRows) {
|
||||||
int32_t prevSize = (int32_t) pBeforeFillData->num;
|
int32_t prevSize = (int32_t) pBeforeFillData->num;
|
||||||
tColModelErase(pLocalReducer->finalModel, pBeforeFillData, prevSize, 0, (int32_t)pQueryInfo->limit.offset - 1);
|
tColModelErase(pLocalMerge->finalModel, pBeforeFillData, prevSize, 0, (int32_t)pQueryInfo->limit.offset - 1);
|
||||||
|
|
||||||
/* remove the hole in column model */
|
/* remove the hole in column model */
|
||||||
tColModelCompact(pLocalReducer->finalModel, pBeforeFillData, prevSize);
|
tColModelCompact(pLocalMerge->finalModel, pBeforeFillData, prevSize);
|
||||||
|
|
||||||
pRes->numOfRows -= (int32_t) pQueryInfo->limit.offset;
|
pRes->numOfRows -= (int32_t) pQueryInfo->limit.offset;
|
||||||
pQueryInfo->limit.offset = 0;
|
pQueryInfo->limit.offset = 0;
|
||||||
|
@ -907,7 +907,7 @@ static void genFinalResWithoutFill(SSqlRes* pRes, SLocalReducer *pLocalReducer,
|
||||||
if (pRes->numOfRowsGroup >= pQueryInfo->limit.limit && pQueryInfo->limit.limit > 0) {
|
if (pRes->numOfRowsGroup >= pQueryInfo->limit.limit && pQueryInfo->limit.limit > 0) {
|
||||||
pRes->numOfRows = 0;
|
pRes->numOfRows = 0;
|
||||||
pBeforeFillData->num = 0;
|
pBeforeFillData->num = 0;
|
||||||
pLocalReducer->discard = true;
|
pLocalMerge->discard = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -923,29 +923,29 @@ static void genFinalResWithoutFill(SSqlRes* pRes, SLocalReducer *pLocalReducer,
|
||||||
pRes->numOfRows -= overflow;
|
pRes->numOfRows -= overflow;
|
||||||
pBeforeFillData->num -= overflow;
|
pBeforeFillData->num -= overflow;
|
||||||
|
|
||||||
tColModelCompact(pLocalReducer->finalModel, pBeforeFillData, prevSize);
|
tColModelCompact(pLocalMerge->finalModel, pBeforeFillData, prevSize);
|
||||||
|
|
||||||
// set remain data to be discarded, and reset the interpolation information
|
// set remain data to be discarded, and reset the interpolation information
|
||||||
savePrevRecordAndSetupFillInfo(pLocalReducer, pQueryInfo, pLocalReducer->pFillInfo);
|
savePrevRecordAndSetupFillInfo(pLocalMerge, pQueryInfo, pLocalMerge->pFillInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(pRes->data, pBeforeFillData->data, (size_t)(pRes->numOfRows * pLocalReducer->finalModel->rowSize));
|
memcpy(pRes->data, pBeforeFillData->data, (size_t)(pRes->numOfRows * pLocalMerge->finalModel->rowSize));
|
||||||
|
|
||||||
pRes->numOfClauseTotal += pRes->numOfRows;
|
pRes->numOfClauseTotal += pRes->numOfRows;
|
||||||
pBeforeFillData->num = 0;
|
pBeforeFillData->num = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note: pRes->pLocalReducer may be null, due to the fact that "tscDestroyLocalReducer" is called
|
* Note: pRes->pLocalMerge may be null, due to the fact that "tscDestroyLocalMerger" is called
|
||||||
* by "interuptHandler" function in shell
|
* by "interuptHandler" function in shell
|
||||||
*/
|
*/
|
||||||
static void doFillResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool doneOutput) {
|
static void doFillResult(SSqlObj *pSql, SLocalMerger *pLocalMerge, bool doneOutput) {
|
||||||
SSqlCmd *pCmd = &pSql->cmd;
|
SSqlCmd *pCmd = &pSql->cmd;
|
||||||
SSqlRes *pRes = &pSql->res;
|
SSqlRes *pRes = &pSql->res;
|
||||||
|
|
||||||
tFilePage *pBeforeFillData = pLocalReducer->pResultBuf;
|
tFilePage *pBeforeFillData = pLocalMerge->pResultBuf;
|
||||||
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
||||||
SFillInfo *pFillInfo = pLocalReducer->pFillInfo;
|
SFillInfo *pFillInfo = pLocalMerge->pFillInfo;
|
||||||
|
|
||||||
// todo extract function
|
// todo extract function
|
||||||
int64_t actualETime = (pQueryInfo->order.order == TSDB_ORDER_ASC)? pQueryInfo->window.ekey: pQueryInfo->window.skey;
|
int64_t actualETime = (pQueryInfo->order.order == TSDB_ORDER_ASC)? pQueryInfo->window.ekey: pQueryInfo->window.skey;
|
||||||
|
@ -953,11 +953,11 @@ static void doFillResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool doneO
|
||||||
tFilePage **pResPages = malloc(POINTER_BYTES * pQueryInfo->fieldsInfo.numOfOutput);
|
tFilePage **pResPages = malloc(POINTER_BYTES * pQueryInfo->fieldsInfo.numOfOutput);
|
||||||
for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) {
|
for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) {
|
||||||
TAOS_FIELD *pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, i);
|
TAOS_FIELD *pField = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, i);
|
||||||
pResPages[i] = calloc(1, sizeof(tFilePage) + pField->bytes * pLocalReducer->resColModel->capacity);
|
pResPages[i] = calloc(1, sizeof(tFilePage) + pField->bytes * pLocalMerge->resColModel->capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int64_t newRows = taosFillResultDataBlock(pFillInfo, pResPages, pLocalReducer->resColModel->capacity);
|
int64_t newRows = taosFillResultDataBlock(pFillInfo, pResPages, pLocalMerge->resColModel->capacity);
|
||||||
|
|
||||||
if (pQueryInfo->limit.offset < newRows) {
|
if (pQueryInfo->limit.offset < newRows) {
|
||||||
newRows -= pQueryInfo->limit.offset;
|
newRows -= pQueryInfo->limit.offset;
|
||||||
|
@ -970,7 +970,7 @@ static void doFillResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool doneO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pRes->data = pLocalReducer->pFinalRes;
|
pRes->data = pLocalMerge->pFinalRes;
|
||||||
pRes->numOfRows = (int32_t) newRows;
|
pRes->numOfRows = (int32_t) newRows;
|
||||||
|
|
||||||
pQueryInfo->limit.offset = 0;
|
pQueryInfo->limit.offset = 0;
|
||||||
|
@ -985,7 +985,7 @@ static void doFillResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool doneO
|
||||||
}
|
}
|
||||||
|
|
||||||
// all output in current group are completed
|
// all output in current group are completed
|
||||||
int32_t totalRemainRows = (int32_t)getNumOfResultsAfterFillGap(pFillInfo, actualETime, pLocalReducer->resColModel->capacity);
|
int32_t totalRemainRows = (int32_t)getNumOfResultsAfterFillGap(pFillInfo, actualETime, pLocalMerge->resColModel->capacity);
|
||||||
if (totalRemainRows <= 0) {
|
if (totalRemainRows <= 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1003,7 +1003,7 @@ static void doFillResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool doneO
|
||||||
assert(pRes->numOfRows >= 0);
|
assert(pRes->numOfRows >= 0);
|
||||||
|
|
||||||
/* set remain data to be discarded, and reset the interpolation information */
|
/* set remain data to be discarded, and reset the interpolation information */
|
||||||
savePrevRecordAndSetupFillInfo(pLocalReducer, pQueryInfo, pFillInfo);
|
savePrevRecordAndSetupFillInfo(pLocalMerge, pQueryInfo, pFillInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t offset = 0;
|
int32_t offset = 0;
|
||||||
|
@ -1025,8 +1025,8 @@ static void doFillResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool doneO
|
||||||
tfree(pResPages);
|
tfree(pResPages);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void savePreviousRow(SLocalReducer *pLocalReducer, tFilePage *tmpBuffer) {
|
static void savePreviousRow(SLocalMerger *pLocalMerge, tFilePage *tmpBuffer) {
|
||||||
SColumnModel *pColumnModel = pLocalReducer->pDesc->pColumnModel;
|
SColumnModel *pColumnModel = pLocalMerge->pDesc->pColumnModel;
|
||||||
assert(pColumnModel->capacity == 1 && tmpBuffer->num == 1);
|
assert(pColumnModel->capacity == 1 && tmpBuffer->num == 1);
|
||||||
|
|
||||||
// copy to previous temp buffer
|
// copy to previous temp buffer
|
||||||
|
@ -1034,20 +1034,20 @@ static void savePreviousRow(SLocalReducer *pLocalReducer, tFilePage *tmpBuffer)
|
||||||
SSchema *pSchema = getColumnModelSchema(pColumnModel, i);
|
SSchema *pSchema = getColumnModelSchema(pColumnModel, i);
|
||||||
int16_t offset = getColumnModelOffset(pColumnModel, i);
|
int16_t offset = getColumnModelOffset(pColumnModel, i);
|
||||||
|
|
||||||
memcpy(pLocalReducer->prevRowOfInput + offset, tmpBuffer->data + offset, pSchema->bytes);
|
memcpy(pLocalMerge->prevRowOfInput + offset, tmpBuffer->data + offset, pSchema->bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpBuffer->num = 0;
|
tmpBuffer->num = 0;
|
||||||
pLocalReducer->hasPrevRow = true;
|
pLocalMerge->hasPrevRow = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doExecuteSecondaryMerge(SSqlCmd *pCmd, SLocalReducer *pLocalReducer, bool needInit) {
|
static void doExecuteSecondaryMerge(SSqlCmd *pCmd, SLocalMerger *pLocalMerge, bool needInit) {
|
||||||
// the tag columns need to be set before all functions execution
|
// the tag columns need to be set before all functions execution
|
||||||
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
||||||
|
|
||||||
size_t size = tscSqlExprNumOfExprs(pQueryInfo);
|
size_t size = tscSqlExprNumOfExprs(pQueryInfo);
|
||||||
for (int32_t j = 0; j < size; ++j) {
|
for (int32_t j = 0; j < size; ++j) {
|
||||||
SQLFunctionCtx *pCtx = &pLocalReducer->pCtx[j];
|
SQLFunctionCtx *pCtx = &pLocalMerge->pCtx[j];
|
||||||
|
|
||||||
// tags/tags_dummy function, the tag field of SQLFunctionCtx is from the input buffer
|
// tags/tags_dummy function, the tag field of SQLFunctionCtx is from the input buffer
|
||||||
int32_t functionId = pCtx->functionId;
|
int32_t functionId = pCtx->functionId;
|
||||||
|
@ -1074,20 +1074,20 @@ static void doExecuteSecondaryMerge(SSqlCmd *pCmd, SLocalReducer *pLocalReducer,
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t j = 0; j < size; ++j) {
|
for (int32_t j = 0; j < size; ++j) {
|
||||||
int32_t functionId = pLocalReducer->pCtx[j].functionId;
|
int32_t functionId = pLocalMerge->pCtx[j].functionId;
|
||||||
if (functionId == TSDB_FUNC_TAG_DUMMY || functionId == TSDB_FUNC_TS_DUMMY) {
|
if (functionId == TSDB_FUNC_TAG_DUMMY || functionId == TSDB_FUNC_TS_DUMMY) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
aAggs[functionId].mergeFunc(&pLocalReducer->pCtx[j]);
|
aAggs[functionId].mergeFunc(&pLocalMerge->pCtx[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handleUnprocessedRow(SSqlCmd *pCmd, SLocalReducer *pLocalReducer, tFilePage *tmpBuffer) {
|
static void handleUnprocessedRow(SSqlCmd *pCmd, SLocalMerger *pLocalMerge, tFilePage *tmpBuffer) {
|
||||||
if (pLocalReducer->hasUnprocessedRow) {
|
if (pLocalMerge->hasUnprocessedRow) {
|
||||||
pLocalReducer->hasUnprocessedRow = false;
|
pLocalMerge->hasUnprocessedRow = false;
|
||||||
doExecuteSecondaryMerge(pCmd, pLocalReducer, true);
|
doExecuteSecondaryMerge(pCmd, pLocalMerge, true);
|
||||||
savePreviousRow(pLocalReducer, tmpBuffer);
|
savePreviousRow(pLocalMerge, tmpBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1120,7 +1120,7 @@ static int64_t getNumOfResultLocal(SQueryInfo *pQueryInfo, SQLFunctionCtx *pCtx)
|
||||||
* filled with the same result, which is the tags, specified in group by clause
|
* filled with the same result, which is the tags, specified in group by clause
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static void fillMultiRowsOfTagsVal(SQueryInfo *pQueryInfo, int32_t numOfRes, SLocalReducer *pLocalReducer) {
|
static void fillMultiRowsOfTagsVal(SQueryInfo *pQueryInfo, int32_t numOfRes, SLocalMerger *pLocalMerge) {
|
||||||
int32_t maxBufSize = 0; // find the max tags column length to prepare the buffer
|
int32_t maxBufSize = 0; // find the max tags column length to prepare the buffer
|
||||||
size_t size = tscSqlExprNumOfExprs(pQueryInfo);
|
size_t size = tscSqlExprNumOfExprs(pQueryInfo);
|
||||||
|
|
||||||
|
@ -1135,7 +1135,7 @@ static void fillMultiRowsOfTagsVal(SQueryInfo *pQueryInfo, int32_t numOfRes, SLo
|
||||||
|
|
||||||
char *buf = malloc((size_t)maxBufSize);
|
char *buf = malloc((size_t)maxBufSize);
|
||||||
for (int32_t k = 0; k < size; ++k) {
|
for (int32_t k = 0; k < size; ++k) {
|
||||||
SQLFunctionCtx *pCtx = &pLocalReducer->pCtx[k];
|
SQLFunctionCtx *pCtx = &pLocalMerge->pCtx[k];
|
||||||
if (pCtx->functionId != TSDB_FUNC_TAG) {
|
if (pCtx->functionId != TSDB_FUNC_TAG) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1153,20 +1153,20 @@ static void fillMultiRowsOfTagsVal(SQueryInfo *pQueryInfo, int32_t numOfRes, SLo
|
||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t finalizeRes(SQueryInfo *pQueryInfo, SLocalReducer *pLocalReducer) {
|
int32_t finalizeRes(SQueryInfo *pQueryInfo, SLocalMerger *pLocalMerge) {
|
||||||
size_t size = tscSqlExprNumOfExprs(pQueryInfo);
|
size_t size = tscSqlExprNumOfExprs(pQueryInfo);
|
||||||
|
|
||||||
for (int32_t k = 0; k < size; ++k) {
|
for (int32_t k = 0; k < size; ++k) {
|
||||||
SQLFunctionCtx* pCtx = &pLocalReducer->pCtx[k];
|
SQLFunctionCtx* pCtx = &pLocalMerge->pCtx[k];
|
||||||
aAggs[pCtx->functionId].xFinalize(pCtx);
|
aAggs[pCtx->functionId].xFinalize(pCtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
pLocalReducer->hasPrevRow = false;
|
pLocalMerge->hasPrevRow = false;
|
||||||
|
|
||||||
int32_t numOfRes = (int32_t)getNumOfResultLocal(pQueryInfo, pLocalReducer->pCtx);
|
int32_t numOfRes = (int32_t)getNumOfResultLocal(pQueryInfo, pLocalMerge->pCtx);
|
||||||
pLocalReducer->pResultBuf->num += numOfRes;
|
pLocalMerge->pResultBuf->num += numOfRes;
|
||||||
|
|
||||||
fillMultiRowsOfTagsVal(pQueryInfo, numOfRes, pLocalReducer);
|
fillMultiRowsOfTagsVal(pQueryInfo, numOfRes, pLocalMerge);
|
||||||
return numOfRes;
|
return numOfRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1177,22 +1177,22 @@ int32_t finalizeRes(SQueryInfo *pQueryInfo, SLocalReducer *pLocalReducer) {
|
||||||
* results generated by simple aggregation function, we merge them all into one points
|
* results generated by simple aggregation function, we merge them all into one points
|
||||||
* *Exception*: column projection query, required no merge procedure
|
* *Exception*: column projection query, required no merge procedure
|
||||||
*/
|
*/
|
||||||
bool needToMerge(SQueryInfo *pQueryInfo, SLocalReducer *pLocalReducer, tFilePage *tmpBuffer) {
|
bool needToMerge(SQueryInfo *pQueryInfo, SLocalMerger *pLocalMerge, tFilePage *tmpBuffer) {
|
||||||
int32_t ret = 0; // merge all result by default
|
int32_t ret = 0; // merge all result by default
|
||||||
|
|
||||||
int16_t functionId = pLocalReducer->pCtx[0].functionId;
|
int16_t functionId = pLocalMerge->pCtx[0].functionId;
|
||||||
|
|
||||||
// todo opt performance
|
// todo opt performance
|
||||||
if ((/*functionId == TSDB_FUNC_PRJ || */functionId == TSDB_FUNC_ARITHM) || (tscIsProjectionQueryOnSTable(pQueryInfo, 0))) { // column projection query
|
if ((/*functionId == TSDB_FUNC_PRJ || */functionId == TSDB_FUNC_ARITHM) || (tscIsProjectionQueryOnSTable(pQueryInfo, 0))) { // column projection query
|
||||||
ret = 1; // disable merge procedure
|
ret = 1; // disable merge procedure
|
||||||
} else {
|
} else {
|
||||||
tOrderDescriptor *pDesc = pLocalReducer->pDesc;
|
tOrderDescriptor *pDesc = pLocalMerge->pDesc;
|
||||||
if (pDesc->orderInfo.numOfCols > 0) {
|
if (pDesc->orderInfo.numOfCols > 0) {
|
||||||
if (pDesc->tsOrder == TSDB_ORDER_ASC) { // asc
|
if (pDesc->tsOrder == TSDB_ORDER_ASC) { // asc
|
||||||
// todo refactor comparator
|
// todo refactor comparator
|
||||||
ret = compare_a(pLocalReducer->pDesc, 1, 0, pLocalReducer->prevRowOfInput, 1, 0, tmpBuffer->data);
|
ret = compare_a(pLocalMerge->pDesc, 1, 0, pLocalMerge->prevRowOfInput, 1, 0, tmpBuffer->data);
|
||||||
} else { // desc
|
} else { // desc
|
||||||
ret = compare_d(pLocalReducer->pDesc, 1, 0, pLocalReducer->prevRowOfInput, 1, 0, tmpBuffer->data);
|
ret = compare_d(pLocalMerge->pDesc, 1, 0, pLocalMerge->prevRowOfInput, 1, 0, tmpBuffer->data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1230,17 +1230,17 @@ static bool saveGroupResultInfo(SSqlObj *pSql) {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param pSql
|
* @param pSql
|
||||||
* @param pLocalReducer
|
* @param pLocalMerge
|
||||||
* @param noMoreCurrentGroupRes
|
* @param noMoreCurrentGroupRes
|
||||||
* @return if current group is skipped, return false, and do NOT record it into pRes->numOfGroups
|
* @return if current group is skipped, return false, and do NOT record it into pRes->numOfGroups
|
||||||
*/
|
*/
|
||||||
bool genFinalResults(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool noMoreCurrentGroupRes) {
|
bool genFinalResults(SSqlObj *pSql, SLocalMerger *pLocalMerge, bool noMoreCurrentGroupRes) {
|
||||||
SSqlCmd *pCmd = &pSql->cmd;
|
SSqlCmd *pCmd = &pSql->cmd;
|
||||||
SSqlRes *pRes = &pSql->res;
|
SSqlRes *pRes = &pSql->res;
|
||||||
|
|
||||||
SQueryInfo * pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
SQueryInfo * pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
||||||
tFilePage * pResBuf = pLocalReducer->pResultBuf;
|
tFilePage * pResBuf = pLocalMerge->pResultBuf;
|
||||||
SColumnModel *pModel = pLocalReducer->resColModel;
|
SColumnModel *pModel = pLocalMerge->resColModel;
|
||||||
|
|
||||||
pRes->code = TSDB_CODE_SUCCESS;
|
pRes->code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
@ -1251,11 +1251,11 @@ bool genFinalResults(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool noMoreCur
|
||||||
if (pQueryInfo->slimit.offset > 0) {
|
if (pQueryInfo->slimit.offset > 0) {
|
||||||
pRes->numOfRows = 0;
|
pRes->numOfRows = 0;
|
||||||
pQueryInfo->slimit.offset -= 1;
|
pQueryInfo->slimit.offset -= 1;
|
||||||
pLocalReducer->discard = !noMoreCurrentGroupRes;
|
pLocalMerge->discard = !noMoreCurrentGroupRes;
|
||||||
|
|
||||||
if (pLocalReducer->discard) {
|
if (pLocalMerge->discard) {
|
||||||
SColumnModel *pInternModel = pLocalReducer->pDesc->pColumnModel;
|
SColumnModel *pInternModel = pLocalMerge->pDesc->pColumnModel;
|
||||||
tColModelAppend(pInternModel, pLocalReducer->discardData, pLocalReducer->pTempBuffer->data, 0, 1, 1);
|
tColModelAppend(pInternModel, pLocalMerge->discardData, pLocalMerge->pTempBuffer->data, 0, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -1264,19 +1264,14 @@ bool genFinalResults(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool noMoreCur
|
||||||
tColModelCompact(pModel, pResBuf, pModel->capacity);
|
tColModelCompact(pModel, pResBuf, pModel->capacity);
|
||||||
|
|
||||||
if (tscIsSecondStageQuery(pQueryInfo)) {
|
if (tscIsSecondStageQuery(pQueryInfo)) {
|
||||||
doArithmeticCalculate(pQueryInfo, pResBuf, pModel->rowSize, pLocalReducer->finalModel->rowSize);
|
doArithmeticCalculate(pQueryInfo, pResBuf, pModel->rowSize, pLocalMerge->finalModel->rowSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _DEBUG_VIEW
|
|
||||||
printf("final result before interpo:\n");
|
|
||||||
// tColModelDisplay(pLocalReducer->resColModel, pLocalReducer->pBufForInterpo, pResBuf->num, pResBuf->num);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// no interval query, no fill operation
|
// no interval query, no fill operation
|
||||||
if (pQueryInfo->interval.interval == 0 || pQueryInfo->fillType == TSDB_FILL_NONE) {
|
if (pQueryInfo->interval.interval == 0 || pQueryInfo->fillType == TSDB_FILL_NONE) {
|
||||||
genFinalResWithoutFill(pRes, pLocalReducer, pQueryInfo);
|
genFinalResWithoutFill(pRes, pLocalMerge, pQueryInfo);
|
||||||
} else {
|
} else {
|
||||||
SFillInfo* pFillInfo = pLocalReducer->pFillInfo;
|
SFillInfo* pFillInfo = pLocalMerge->pFillInfo;
|
||||||
if (pFillInfo != NULL) {
|
if (pFillInfo != NULL) {
|
||||||
TSKEY ekey = (pQueryInfo->order.order == TSDB_ORDER_ASC)? pQueryInfo->window.ekey: pQueryInfo->window.skey;
|
TSKEY ekey = (pQueryInfo->order.order == TSDB_ORDER_ASC)? pQueryInfo->window.ekey: pQueryInfo->window.skey;
|
||||||
|
|
||||||
|
@ -1284,34 +1279,34 @@ bool genFinalResults(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool noMoreCur
|
||||||
taosFillCopyInputDataFromOneFilePage(pFillInfo, pResBuf);
|
taosFillCopyInputDataFromOneFilePage(pFillInfo, pResBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
doFillResult(pSql, pLocalReducer, noMoreCurrentGroupRes);
|
doFillResult(pSql, pLocalMerge, noMoreCurrentGroupRes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void resetOutputBuf(SQueryInfo *pQueryInfo, SLocalReducer *pLocalReducer) {// reset output buffer to the beginning
|
void resetOutputBuf(SQueryInfo *pQueryInfo, SLocalMerger *pLocalMerge) {// reset output buffer to the beginning
|
||||||
size_t t = tscSqlExprNumOfExprs(pQueryInfo);
|
size_t t = tscSqlExprNumOfExprs(pQueryInfo);
|
||||||
for (int32_t i = 0; i < t; ++i) {
|
for (int32_t i = 0; i < t; ++i) {
|
||||||
SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i);
|
SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, i);
|
||||||
pLocalReducer->pCtx[i].aOutputBuf = pLocalReducer->pResultBuf->data + pExpr->offset * pLocalReducer->resColModel->capacity;
|
pLocalMerge->pCtx[i].aOutputBuf = pLocalMerge->pResultBuf->data + pExpr->offset * pLocalMerge->resColModel->capacity;
|
||||||
|
|
||||||
if (pExpr->functionId == TSDB_FUNC_TOP || pExpr->functionId == TSDB_FUNC_BOTTOM || pExpr->functionId == TSDB_FUNC_DIFF) {
|
if (pExpr->functionId == TSDB_FUNC_TOP || pExpr->functionId == TSDB_FUNC_BOTTOM || pExpr->functionId == TSDB_FUNC_DIFF) {
|
||||||
pLocalReducer->pCtx[i].ptsOutputBuf = pLocalReducer->pCtx[0].aOutputBuf;
|
pLocalMerge->pCtx[i].ptsOutputBuf = pLocalMerge->pCtx[0].aOutputBuf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(pLocalReducer->pResultBuf, 0, pLocalReducer->nResultBufSize + sizeof(tFilePage));
|
memset(pLocalMerge->pResultBuf, 0, pLocalMerge->nResultBufSize + sizeof(tFilePage));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void resetEnvForNewResultset(SSqlRes *pRes, SSqlCmd *pCmd, SLocalReducer *pLocalReducer) {
|
static void resetEnvForNewResultset(SSqlRes *pRes, SSqlCmd *pCmd, SLocalMerger *pLocalMerge) {
|
||||||
// In handling data in other groups, we need to reset the interpolation information for a new group data
|
// In handling data in other groups, we need to reset the interpolation information for a new group data
|
||||||
pRes->numOfRows = 0;
|
pRes->numOfRows = 0;
|
||||||
pRes->numOfRowsGroup = 0;
|
pRes->numOfRowsGroup = 0;
|
||||||
|
|
||||||
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
||||||
|
|
||||||
pQueryInfo->limit.offset = pLocalReducer->offset;
|
pQueryInfo->limit.offset = pLocalMerge->offset;
|
||||||
|
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
||||||
STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta);
|
STableComInfo tinfo = tscGetTableInfo(pTableMetaInfo->pTableMeta);
|
||||||
|
@ -1320,12 +1315,12 @@ static void resetEnvForNewResultset(SSqlRes *pRes, SSqlCmd *pCmd, SLocalReducer
|
||||||
if (pQueryInfo->fillType != TSDB_FILL_NONE) {
|
if (pQueryInfo->fillType != TSDB_FILL_NONE) {
|
||||||
TSKEY skey = (pQueryInfo->order.order == TSDB_ORDER_ASC)? pQueryInfo->window.skey:pQueryInfo->window.ekey;//MIN(pQueryInfo->window.skey, pQueryInfo->window.ekey);
|
TSKEY skey = (pQueryInfo->order.order == TSDB_ORDER_ASC)? pQueryInfo->window.skey:pQueryInfo->window.ekey;//MIN(pQueryInfo->window.skey, pQueryInfo->window.ekey);
|
||||||
int64_t newTime = taosTimeTruncate(skey, &pQueryInfo->interval, tinfo.precision);
|
int64_t newTime = taosTimeTruncate(skey, &pQueryInfo->interval, tinfo.precision);
|
||||||
taosResetFillInfo(pLocalReducer->pFillInfo, newTime);
|
taosResetFillInfo(pLocalMerge->pFillInfo, newTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isAllSourcesCompleted(SLocalReducer *pLocalReducer) {
|
static bool isAllSourcesCompleted(SLocalMerger *pLocalMerge) {
|
||||||
return (pLocalReducer->numOfBuffer == pLocalReducer->numOfCompleted);
|
return (pLocalMerge->numOfBuffer == pLocalMerge->numOfCompleted);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool doBuildFilledResultForGroup(SSqlObj *pSql) {
|
static bool doBuildFilledResultForGroup(SSqlObj *pSql) {
|
||||||
|
@ -1333,19 +1328,19 @@ static bool doBuildFilledResultForGroup(SSqlObj *pSql) {
|
||||||
SSqlRes *pRes = &pSql->res;
|
SSqlRes *pRes = &pSql->res;
|
||||||
|
|
||||||
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
||||||
SLocalReducer *pLocalReducer = pRes->pLocalReducer;
|
SLocalMerger *pLocalMerge = pRes->pLocalMerger;
|
||||||
SFillInfo *pFillInfo = pLocalReducer->pFillInfo;
|
SFillInfo *pFillInfo = pLocalMerge->pFillInfo;
|
||||||
|
|
||||||
if (pFillInfo != NULL && taosFillHasMoreResults(pFillInfo)) {
|
if (pFillInfo != NULL && taosFillHasMoreResults(pFillInfo)) {
|
||||||
assert(pQueryInfo->fillType != TSDB_FILL_NONE);
|
assert(pQueryInfo->fillType != TSDB_FILL_NONE);
|
||||||
|
|
||||||
tFilePage *pFinalDataBuf = pLocalReducer->pResultBuf;
|
tFilePage *pFinalDataBuf = pLocalMerge->pResultBuf;
|
||||||
int64_t etime = *(int64_t *)(pFinalDataBuf->data + TSDB_KEYSIZE * (pFillInfo->numOfRows - 1));
|
int64_t etime = *(int64_t *)(pFinalDataBuf->data + TSDB_KEYSIZE * (pFillInfo->numOfRows - 1));
|
||||||
|
|
||||||
// the first column must be the timestamp column
|
// the first column must be the timestamp column
|
||||||
int32_t rows = (int32_t) getNumOfResultsAfterFillGap(pFillInfo, etime, pLocalReducer->resColModel->capacity);
|
int32_t rows = (int32_t) getNumOfResultsAfterFillGap(pFillInfo, etime, pLocalMerge->resColModel->capacity);
|
||||||
if (rows > 0) { // do fill gap
|
if (rows > 0) { // do fill gap
|
||||||
doFillResult(pSql, pLocalReducer, false);
|
doFillResult(pSql, pLocalMerge, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1358,23 +1353,23 @@ static bool doHandleLastRemainData(SSqlObj *pSql) {
|
||||||
SSqlCmd *pCmd = &pSql->cmd;
|
SSqlCmd *pCmd = &pSql->cmd;
|
||||||
SSqlRes *pRes = &pSql->res;
|
SSqlRes *pRes = &pSql->res;
|
||||||
|
|
||||||
SLocalReducer *pLocalReducer = pRes->pLocalReducer;
|
SLocalMerger *pLocalMerge = pRes->pLocalMerger;
|
||||||
SFillInfo *pFillInfo = pLocalReducer->pFillInfo;
|
SFillInfo *pFillInfo = pLocalMerge->pFillInfo;
|
||||||
|
|
||||||
bool prevGroupCompleted = (!pLocalReducer->discard) && pLocalReducer->hasUnprocessedRow;
|
bool prevGroupCompleted = (!pLocalMerge->discard) && pLocalMerge->hasUnprocessedRow;
|
||||||
|
|
||||||
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
||||||
|
|
||||||
if ((isAllSourcesCompleted(pLocalReducer) && !pLocalReducer->hasPrevRow) || pLocalReducer->pLocalDataSrc[0] == NULL ||
|
if ((isAllSourcesCompleted(pLocalMerge) && !pLocalMerge->hasPrevRow) || pLocalMerge->pLocalDataSrc[0] == NULL ||
|
||||||
prevGroupCompleted) {
|
prevGroupCompleted) {
|
||||||
// if fillType == TSDB_FILL_NONE, return directly
|
// if fillType == TSDB_FILL_NONE, return directly
|
||||||
if (pQueryInfo->fillType != TSDB_FILL_NONE &&
|
if (pQueryInfo->fillType != TSDB_FILL_NONE &&
|
||||||
((pRes->numOfRowsGroup < pQueryInfo->limit.limit && pQueryInfo->limit.limit > 0) || (pQueryInfo->limit.limit < 0))) {
|
((pRes->numOfRowsGroup < pQueryInfo->limit.limit && pQueryInfo->limit.limit > 0) || (pQueryInfo->limit.limit < 0))) {
|
||||||
int64_t etime = (pQueryInfo->order.order == TSDB_ORDER_ASC)? pQueryInfo->window.ekey : pQueryInfo->window.skey;
|
int64_t etime = (pQueryInfo->order.order == TSDB_ORDER_ASC)? pQueryInfo->window.ekey : pQueryInfo->window.skey;
|
||||||
|
|
||||||
int32_t rows = (int32_t)getNumOfResultsAfterFillGap(pFillInfo, etime, pLocalReducer->resColModel->capacity);
|
int32_t rows = (int32_t)getNumOfResultsAfterFillGap(pFillInfo, etime, pLocalMerge->resColModel->capacity);
|
||||||
if (rows > 0) {
|
if (rows > 0) {
|
||||||
doFillResult(pSql, pLocalReducer, true);
|
doFillResult(pSql, pLocalMerge, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1384,7 +1379,7 @@ static bool doHandleLastRemainData(SSqlObj *pSql) {
|
||||||
*
|
*
|
||||||
* No results will be generated and query completed.
|
* No results will be generated and query completed.
|
||||||
*/
|
*/
|
||||||
if (pRes->numOfRows > 0 || (isAllSourcesCompleted(pLocalReducer) && (!pLocalReducer->hasUnprocessedRow))) {
|
if (pRes->numOfRows > 0 || (isAllSourcesCompleted(pLocalMerge) && (!pLocalMerge->hasUnprocessedRow))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1393,7 +1388,7 @@ static bool doHandleLastRemainData(SSqlObj *pSql) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
resetEnvForNewResultset(pRes, pCmd, pLocalReducer);
|
resetEnvForNewResultset(pRes, pCmd, pLocalMerge);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -1403,12 +1398,12 @@ static void doProcessResultInNextWindow(SSqlObj *pSql, int32_t numOfRes) {
|
||||||
SSqlCmd *pCmd = &pSql->cmd;
|
SSqlCmd *pCmd = &pSql->cmd;
|
||||||
SSqlRes *pRes = &pSql->res;
|
SSqlRes *pRes = &pSql->res;
|
||||||
|
|
||||||
SLocalReducer *pLocalReducer = pRes->pLocalReducer;
|
SLocalMerger *pLocalMerge = pRes->pLocalMerger;
|
||||||
SQueryInfo * pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
SQueryInfo * pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
||||||
size_t size = tscSqlExprNumOfExprs(pQueryInfo);
|
size_t size = tscSqlExprNumOfExprs(pQueryInfo);
|
||||||
|
|
||||||
for (int32_t k = 0; k < size; ++k) {
|
for (int32_t k = 0; k < size; ++k) {
|
||||||
SQLFunctionCtx *pCtx = &pLocalReducer->pCtx[k];
|
SQLFunctionCtx *pCtx = &pLocalMerge->pCtx[k];
|
||||||
pCtx->aOutputBuf += pCtx->outputBytes * numOfRes;
|
pCtx->aOutputBuf += pCtx->outputBytes * numOfRes;
|
||||||
|
|
||||||
// set the correct output timestamp column position
|
// set the correct output timestamp column position
|
||||||
|
@ -1417,7 +1412,7 @@ static void doProcessResultInNextWindow(SSqlObj *pSql, int32_t numOfRes) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
doExecuteSecondaryMerge(pCmd, pLocalReducer, true);
|
doExecuteSecondaryMerge(pCmd, pLocalMerge, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tscDoLocalMerge(SSqlObj *pSql) {
|
int32_t tscDoLocalMerge(SSqlObj *pSql) {
|
||||||
|
@ -1426,18 +1421,18 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) {
|
||||||
|
|
||||||
tscResetForNextRetrieve(pRes);
|
tscResetForNextRetrieve(pRes);
|
||||||
|
|
||||||
if (pSql->signature != pSql || pRes == NULL || pRes->pLocalReducer == NULL) { // all data has been processed
|
if (pSql->signature != pSql || pRes == NULL || pRes->pLocalMerger == NULL) { // all data has been processed
|
||||||
if (pRes->code == TSDB_CODE_SUCCESS) {
|
if (pRes->code == TSDB_CODE_SUCCESS) {
|
||||||
return pRes->code;
|
return pRes->code;
|
||||||
}
|
}
|
||||||
|
|
||||||
tscError("%p local merge abort due to error occurs, code:%s", pSql, tstrerror(pRes->code));
|
tscError("%p local merge abort due to error occurs, code:%s", pSql, tstrerror(pRes->code));
|
||||||
return pRes->code;
|
return pRes->code;
|
||||||
}
|
}
|
||||||
|
|
||||||
SLocalReducer *pLocalReducer = pRes->pLocalReducer;
|
SLocalMerger *pLocalMerge = pRes->pLocalMerger;
|
||||||
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
||||||
tFilePage *tmpBuffer = pLocalReducer->pTempBuffer;
|
tFilePage *tmpBuffer = pLocalMerge->pTempBuffer;
|
||||||
|
|
||||||
if (doHandleLastRemainData(pSql)) {
|
if (doHandleLastRemainData(pSql)) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -1447,24 +1442,24 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SLoserTreeInfo *pTree = pLocalReducer->pLoserTree;
|
SLoserTreeInfo *pTree = pLocalMerge->pLoserTree;
|
||||||
|
|
||||||
// clear buffer
|
// clear buffer
|
||||||
handleUnprocessedRow(pCmd, pLocalReducer, tmpBuffer);
|
handleUnprocessedRow(pCmd, pLocalMerge, tmpBuffer);
|
||||||
SColumnModel *pModel = pLocalReducer->pDesc->pColumnModel;
|
SColumnModel *pModel = pLocalMerge->pDesc->pColumnModel;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (isAllSourcesCompleted(pLocalReducer)) {
|
if (isAllSourcesCompleted(pLocalMerge)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _DEBUG_VIEW
|
#ifdef _DEBUG_VIEW
|
||||||
printf("chosen data in pTree[0] = %d\n", pTree->pNode[0].index);
|
printf("chosen data in pTree[0] = %d\n", pTree->pNode[0].index);
|
||||||
#endif
|
#endif
|
||||||
assert((pTree->pNode[0].index < pLocalReducer->numOfBuffer) && (pTree->pNode[0].index >= 0) && tmpBuffer->num == 0);
|
assert((pTree->pNode[0].index < pLocalMerge->numOfBuffer) && (pTree->pNode[0].index >= 0) && tmpBuffer->num == 0);
|
||||||
|
|
||||||
// chosen from loser tree
|
// chosen from loser tree
|
||||||
SLocalDataSource *pOneDataSrc = pLocalReducer->pLocalDataSrc[pTree->pNode[0].index];
|
SLocalDataSource *pOneDataSrc = pLocalMerge->pLocalDataSrc[pTree->pNode[0].index];
|
||||||
|
|
||||||
tColModelAppend(pModel, tmpBuffer, pOneDataSrc->filePage.data, pOneDataSrc->rowIdx, 1,
|
tColModelAppend(pModel, tmpBuffer, pOneDataSrc->filePage.data, pOneDataSrc->rowIdx, 1,
|
||||||
pOneDataSrc->pMemBuffer->pColumnModel->capacity);
|
pOneDataSrc->pMemBuffer->pColumnModel->capacity);
|
||||||
|
@ -1477,76 +1472,76 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) {
|
||||||
tColModelDisplayEx(pModel, tmpBuffer->data, tmpBuffer->num, pModel->capacity, colInfo);
|
tColModelDisplayEx(pModel, tmpBuffer->data, tmpBuffer->num, pModel->capacity, colInfo);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (pLocalReducer->discard) {
|
if (pLocalMerge->discard) {
|
||||||
assert(pLocalReducer->hasUnprocessedRow == false);
|
assert(pLocalMerge->hasUnprocessedRow == false);
|
||||||
|
|
||||||
/* current record belongs to the same group of previous record, need to discard it */
|
/* current record belongs to the same group of previous record, need to discard it */
|
||||||
if (isSameGroup(pCmd, pLocalReducer, pLocalReducer->discardData->data, tmpBuffer)) {
|
if (isSameGroup(pCmd, pLocalMerge, pLocalMerge->discardData->data, tmpBuffer)) {
|
||||||
tmpBuffer->num = 0;
|
tmpBuffer->num = 0;
|
||||||
pOneDataSrc->rowIdx += 1;
|
pOneDataSrc->rowIdx += 1;
|
||||||
|
|
||||||
adjustLoserTreeFromNewData(pLocalReducer, pOneDataSrc, pTree);
|
adjustLoserTreeFromNewData(pLocalMerge, pOneDataSrc, pTree);
|
||||||
|
|
||||||
// all inputs are exhausted, abort current process
|
// all inputs are exhausted, abort current process
|
||||||
if (isAllSourcesCompleted(pLocalReducer)) {
|
if (isAllSourcesCompleted(pLocalMerge)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// data belongs to the same group needs to be discarded
|
// data belongs to the same group needs to be discarded
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
pLocalReducer->discard = false;
|
pLocalMerge->discard = false;
|
||||||
pLocalReducer->discardData->num = 0;
|
pLocalMerge->discardData->num = 0;
|
||||||
|
|
||||||
if (saveGroupResultInfo(pSql)) {
|
if (saveGroupResultInfo(pSql)) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
resetEnvForNewResultset(pRes, pCmd, pLocalReducer);
|
resetEnvForNewResultset(pRes, pCmd, pLocalMerge);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pLocalReducer->hasPrevRow) {
|
if (pLocalMerge->hasPrevRow) {
|
||||||
if (needToMerge(pQueryInfo, pLocalReducer, tmpBuffer)) {
|
if (needToMerge(pQueryInfo, pLocalMerge, tmpBuffer)) {
|
||||||
// belong to the group of the previous row, continue process it
|
// belong to the group of the previous row, continue process it
|
||||||
doExecuteSecondaryMerge(pCmd, pLocalReducer, false);
|
doExecuteSecondaryMerge(pCmd, pLocalMerge, false);
|
||||||
|
|
||||||
// copy to buffer
|
// copy to buffer
|
||||||
savePreviousRow(pLocalReducer, tmpBuffer);
|
savePreviousRow(pLocalMerge, tmpBuffer);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* current row does not belong to the group of previous row.
|
* current row does not belong to the group of previous row.
|
||||||
* so the processing of previous group is completed.
|
* so the processing of previous group is completed.
|
||||||
*/
|
*/
|
||||||
int32_t numOfRes = finalizeRes(pQueryInfo, pLocalReducer);
|
int32_t numOfRes = finalizeRes(pQueryInfo, pLocalMerge);
|
||||||
bool sameGroup = isSameGroup(pCmd, pLocalReducer, pLocalReducer->prevRowOfInput, tmpBuffer);
|
bool sameGroup = isSameGroup(pCmd, pLocalMerge, pLocalMerge->prevRowOfInput, tmpBuffer);
|
||||||
|
|
||||||
tFilePage *pResBuf = pLocalReducer->pResultBuf;
|
tFilePage *pResBuf = pLocalMerge->pResultBuf;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* if the previous group does NOT generate any result (pResBuf->num == 0),
|
* if the previous group does NOT generate any result (pResBuf->num == 0),
|
||||||
* continue to process results instead of return results.
|
* continue to process results instead of return results.
|
||||||
*/
|
*/
|
||||||
if ((!sameGroup && pResBuf->num > 0) || (pResBuf->num == pLocalReducer->resColModel->capacity)) {
|
if ((!sameGroup && pResBuf->num > 0) || (pResBuf->num == pLocalMerge->resColModel->capacity)) {
|
||||||
// does not belong to the same group
|
// does not belong to the same group
|
||||||
bool notSkipped = genFinalResults(pSql, pLocalReducer, !sameGroup);
|
bool notSkipped = genFinalResults(pSql, pLocalMerge, !sameGroup);
|
||||||
|
|
||||||
// this row needs to discard, since it belongs to the group of previous
|
// this row needs to discard, since it belongs to the group of previous
|
||||||
if (pLocalReducer->discard && sameGroup) {
|
if (pLocalMerge->discard && sameGroup) {
|
||||||
pLocalReducer->hasUnprocessedRow = false;
|
pLocalMerge->hasUnprocessedRow = false;
|
||||||
tmpBuffer->num = 0;
|
tmpBuffer->num = 0;
|
||||||
} else { // current row does not belongs to the previous group, so it is not be handled yet.
|
} else { // current row does not belongs to the previous group, so it is not be handled yet.
|
||||||
pLocalReducer->hasUnprocessedRow = true;
|
pLocalMerge->hasUnprocessedRow = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
resetOutputBuf(pQueryInfo, pLocalReducer);
|
resetOutputBuf(pQueryInfo, pLocalMerge);
|
||||||
pOneDataSrc->rowIdx += 1;
|
pOneDataSrc->rowIdx += 1;
|
||||||
|
|
||||||
// here we do not check the return value
|
// here we do not check the return value
|
||||||
adjustLoserTreeFromNewData(pLocalReducer, pOneDataSrc, pTree);
|
adjustLoserTreeFromNewData(pLocalMerge, pOneDataSrc, pTree);
|
||||||
|
|
||||||
if (pRes->numOfRows == 0) {
|
if (pRes->numOfRows == 0) {
|
||||||
handleUnprocessedRow(pCmd, pLocalReducer, tmpBuffer);
|
handleUnprocessedRow(pCmd, pLocalMerge, tmpBuffer);
|
||||||
|
|
||||||
if (!sameGroup) {
|
if (!sameGroup) {
|
||||||
/*
|
/*
|
||||||
|
@ -1557,7 +1552,7 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
resetEnvForNewResultset(pRes, pCmd, pLocalReducer);
|
resetEnvForNewResultset(pRes, pCmd, pLocalMerge);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
|
@ -1565,7 +1560,7 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) {
|
||||||
* We start the process in a new round.
|
* We start the process in a new round.
|
||||||
*/
|
*/
|
||||||
if (sameGroup) {
|
if (sameGroup) {
|
||||||
handleUnprocessedRow(pCmd, pLocalReducer, tmpBuffer);
|
handleUnprocessedRow(pCmd, pLocalMerge, tmpBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1577,24 +1572,24 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) {
|
||||||
}
|
}
|
||||||
} else { // result buffer is not full
|
} else { // result buffer is not full
|
||||||
doProcessResultInNextWindow(pSql, numOfRes);
|
doProcessResultInNextWindow(pSql, numOfRes);
|
||||||
savePreviousRow(pLocalReducer, tmpBuffer);
|
savePreviousRow(pLocalMerge, tmpBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
doExecuteSecondaryMerge(pCmd, pLocalReducer, true);
|
doExecuteSecondaryMerge(pCmd, pLocalMerge, true);
|
||||||
savePreviousRow(pLocalReducer, tmpBuffer); // copy the processed row to buffer
|
savePreviousRow(pLocalMerge, tmpBuffer); // copy the processed row to buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
pOneDataSrc->rowIdx += 1;
|
pOneDataSrc->rowIdx += 1;
|
||||||
adjustLoserTreeFromNewData(pLocalReducer, pOneDataSrc, pTree);
|
adjustLoserTreeFromNewData(pLocalMerge, pOneDataSrc, pTree);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pLocalReducer->hasPrevRow) {
|
if (pLocalMerge->hasPrevRow) {
|
||||||
finalizeRes(pQueryInfo, pLocalReducer);
|
finalizeRes(pQueryInfo, pLocalMerge);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pLocalReducer->pResultBuf->num) {
|
if (pLocalMerge->pResultBuf->num) {
|
||||||
genFinalResults(pSql, pLocalReducer, true);
|
genFinalResults(pSql, pLocalMerge, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -1602,8 +1597,8 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) {
|
||||||
|
|
||||||
void tscInitResObjForLocalQuery(SSqlObj *pObj, int32_t numOfRes, int32_t rowLen) {
|
void tscInitResObjForLocalQuery(SSqlObj *pObj, int32_t numOfRes, int32_t rowLen) {
|
||||||
SSqlRes *pRes = &pObj->res;
|
SSqlRes *pRes = &pObj->res;
|
||||||
if (pRes->pLocalReducer != NULL) {
|
if (pRes->pLocalMerger != NULL) {
|
||||||
tscDestroyLocalReducer(pObj);
|
tscDestroyLocalMerger(pObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
pRes->qhandle = 1; // hack to pass the safety check in fetch_row function
|
pRes->qhandle = 1; // hack to pass the safety check in fetch_row function
|
||||||
|
@ -1611,17 +1606,17 @@ void tscInitResObjForLocalQuery(SSqlObj *pObj, int32_t numOfRes, int32_t rowLen)
|
||||||
pRes->row = 0;
|
pRes->row = 0;
|
||||||
|
|
||||||
pRes->rspType = 0; // used as a flag to denote if taos_retrieved() has been called yet
|
pRes->rspType = 0; // used as a flag to denote if taos_retrieved() has been called yet
|
||||||
pRes->pLocalReducer = (SLocalReducer *)calloc(1, sizeof(SLocalReducer));
|
pRes->pLocalMerger = (SLocalMerger *)calloc(1, sizeof(SLocalMerger));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* we need one additional byte space
|
* we need one additional byte space
|
||||||
* the sprintf function needs one additional space to put '\0' at the end of string
|
* the sprintf function needs one additional space to put '\0' at the end of string
|
||||||
*/
|
*/
|
||||||
size_t allocSize = numOfRes * rowLen + sizeof(tFilePage) + 1;
|
size_t allocSize = numOfRes * rowLen + sizeof(tFilePage) + 1;
|
||||||
pRes->pLocalReducer->pResultBuf = (tFilePage *)calloc(1, allocSize);
|
pRes->pLocalMerger->pResultBuf = (tFilePage *)calloc(1, allocSize);
|
||||||
|
|
||||||
pRes->pLocalReducer->pResultBuf->num = numOfRes;
|
pRes->pLocalMerger->pResultBuf->num = numOfRes;
|
||||||
pRes->data = pRes->pLocalReducer->pResultBuf->data;
|
pRes->data = pRes->pLocalMerger->pResultBuf->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t doArithmeticCalculate(SQueryInfo* pQueryInfo, tFilePage* pOutput, int32_t rowSize, int32_t finalRowSize) {
|
int32_t doArithmeticCalculate(SQueryInfo* pQueryInfo, tFilePage* pOutput, int32_t rowSize, int32_t finalRowSize) {
|
||||||
|
|
|
@ -703,7 +703,7 @@ static int32_t doParseInsertStatement(SSqlCmd* pCmd, char **str, SParsedDataColI
|
||||||
|
|
||||||
STableDataBlocks *dataBuf = NULL;
|
STableDataBlocks *dataBuf = NULL;
|
||||||
int32_t ret = tscGetDataBlockFromList(pCmd->pTableBlockHashList, pTableMeta->id.uid, TSDB_DEFAULT_PAYLOAD_SIZE,
|
int32_t ret = tscGetDataBlockFromList(pCmd->pTableBlockHashList, pTableMeta->id.uid, TSDB_DEFAULT_PAYLOAD_SIZE,
|
||||||
sizeof(SSubmitBlk), tinfo.rowSize, pTableMetaInfo->name, pTableMeta, &dataBuf, NULL);
|
sizeof(SSubmitBlk), tinfo.rowSize, &pTableMetaInfo->name, pTableMeta, &dataBuf, NULL);
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -813,26 +813,26 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
|
||||||
tscAddEmptyMetaInfo(pQueryInfo);
|
tscAddEmptyMetaInfo(pQueryInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
STableMetaInfo *pSTableMeterMetaInfo = tscGetMetaInfo(pQueryInfo, STABLE_INDEX);
|
STableMetaInfo *pSTableMetaInfo = tscGetMetaInfo(pQueryInfo, STABLE_INDEX);
|
||||||
code = tscSetTableFullName(pSTableMeterMetaInfo, &sToken, pSql);
|
code = tscSetTableFullName(pSTableMetaInfo, &sToken, pSql);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
tstrncpy(pCmd->tagData.name, pSTableMeterMetaInfo->name, sizeof(pCmd->tagData.name));
|
tNameExtractFullName(&pSTableMetaInfo->name, pCmd->tagData.name);
|
||||||
pCmd->tagData.dataLen = 0;
|
pCmd->tagData.dataLen = 0;
|
||||||
|
|
||||||
code = tscGetTableMeta(pSql, pSTableMeterMetaInfo);
|
code = tscGetTableMeta(pSql, pSTableMetaInfo);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!UTIL_TABLE_IS_SUPER_TABLE(pSTableMeterMetaInfo)) {
|
if (!UTIL_TABLE_IS_SUPER_TABLE(pSTableMetaInfo)) {
|
||||||
return tscInvalidSQLErrMsg(pCmd->payload, "create table only from super table is allowed", sToken.z);
|
return tscInvalidSQLErrMsg(pCmd->payload, "create table only from super table is allowed", sToken.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
SSchema *pTagSchema = tscGetTableTagSchema(pSTableMeterMetaInfo->pTableMeta);
|
SSchema *pTagSchema = tscGetTableTagSchema(pSTableMetaInfo->pTableMeta);
|
||||||
STableComInfo tinfo = tscGetTableInfo(pSTableMeterMetaInfo->pTableMeta);
|
STableComInfo tinfo = tscGetTableInfo(pSTableMetaInfo->pTableMeta);
|
||||||
|
|
||||||
index = 0;
|
index = 0;
|
||||||
sToken = tStrGetToken(sql, &index, false, 0, NULL);
|
sToken = tStrGetToken(sql, &index, false, 0, NULL);
|
||||||
|
@ -840,7 +840,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
|
||||||
|
|
||||||
SParsedDataColInfo spd = {0};
|
SParsedDataColInfo spd = {0};
|
||||||
|
|
||||||
uint8_t numOfTags = tscGetNumOfTags(pSTableMeterMetaInfo->pTableMeta);
|
uint8_t numOfTags = tscGetNumOfTags(pSTableMetaInfo->pTableMeta);
|
||||||
spd.numOfCols = numOfTags;
|
spd.numOfCols = numOfTags;
|
||||||
|
|
||||||
// if specify some tags column
|
// if specify some tags column
|
||||||
|
@ -1406,39 +1406,38 @@ typedef struct SImportFileSupport {
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
} SImportFileSupport;
|
} SImportFileSupport;
|
||||||
|
|
||||||
static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int code) {
|
static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int32_t numOfRows) {
|
||||||
assert(param != NULL && tres != NULL);
|
assert(param != NULL && tres != NULL);
|
||||||
|
|
||||||
|
char * tokenBuf = NULL;
|
||||||
|
size_t n = 0;
|
||||||
|
ssize_t readLen = 0;
|
||||||
|
char * line = NULL;
|
||||||
|
int32_t count = 0;
|
||||||
|
int32_t maxRows = 0;
|
||||||
|
FILE * fp = NULL;
|
||||||
|
|
||||||
SSqlObj *pSql = tres;
|
SSqlObj *pSql = tres;
|
||||||
SSqlCmd *pCmd = &pSql->cmd;
|
SSqlCmd *pCmd = &pSql->cmd;
|
||||||
|
|
||||||
SImportFileSupport *pSupporter = (SImportFileSupport *) param;
|
SImportFileSupport *pSupporter = (SImportFileSupport *)param;
|
||||||
|
|
||||||
SSqlObj *pParentSql = pSupporter->pSql;
|
SSqlObj *pParentSql = pSupporter->pSql;
|
||||||
FILE *fp = pSupporter->fp;
|
fp = pSupporter->fp;
|
||||||
|
|
||||||
if (taos_errno(pSql) != TSDB_CODE_SUCCESS) { // handle error
|
int32_t code = pSql->res.code;
|
||||||
assert(taos_errno(pSql) == code);
|
|
||||||
|
|
||||||
do {
|
// retry parse data from file and import data from the begining again
|
||||||
if (code == TSDB_CODE_TDB_TABLE_RECONFIGURE) {
|
if (code == TSDB_CODE_TDB_TABLE_RECONFIGURE) {
|
||||||
assert(pSql->res.numOfRows == 0);
|
assert(pSql->res.numOfRows == 0);
|
||||||
int32_t errc = fseek(fp, 0, SEEK_SET);
|
int32_t ret = fseek(fp, 0, SEEK_SET);
|
||||||
if (errc < 0) {
|
if (ret < 0) {
|
||||||
tscError("%p failed to seek SEEK_SET since:%s", pSql, tstrerror(errno));
|
tscError("%p failed to seek SEEK_SET since:%s", pSql, tstrerror(errno));
|
||||||
} else {
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
break;
|
goto _error;
|
||||||
}
|
}
|
||||||
}
|
} else if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
goto _error;
|
||||||
taos_free_result(pSql);
|
|
||||||
tfree(pSupporter);
|
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
pParentSql->res.code = code;
|
|
||||||
tscAsyncResultOnError(pParentSql);
|
|
||||||
return;
|
|
||||||
} while (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// accumulate the total submit records
|
// accumulate the total submit records
|
||||||
|
@ -1452,28 +1451,32 @@ static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int code) {
|
||||||
SParsedDataColInfo spd = {.numOfCols = tinfo.numOfColumns};
|
SParsedDataColInfo spd = {.numOfCols = tinfo.numOfColumns};
|
||||||
tscSetAssignedColumnInfo(&spd, pSchema, tinfo.numOfColumns);
|
tscSetAssignedColumnInfo(&spd, pSchema, tinfo.numOfColumns);
|
||||||
|
|
||||||
size_t n = 0;
|
|
||||||
ssize_t readLen = 0;
|
|
||||||
char * line = NULL;
|
|
||||||
int32_t count = 0;
|
|
||||||
int32_t maxRows = 0;
|
|
||||||
|
|
||||||
tfree(pCmd->pTableNameList);
|
tfree(pCmd->pTableNameList);
|
||||||
pCmd->pDataBlocks = tscDestroyBlockArrayList(pCmd->pDataBlocks);
|
pCmd->pDataBlocks = tscDestroyBlockArrayList(pCmd->pDataBlocks);
|
||||||
|
|
||||||
if (pCmd->pTableBlockHashList == NULL) {
|
if (pCmd->pTableBlockHashList == NULL) {
|
||||||
pCmd->pTableBlockHashList = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, false);
|
pCmd->pTableBlockHashList = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, false);
|
||||||
|
if (pCmd->pTableBlockHashList == NULL) {
|
||||||
|
code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
STableDataBlocks *pTableDataBlock = NULL;
|
STableDataBlocks *pTableDataBlock = NULL;
|
||||||
int32_t ret = tscGetDataBlockFromList(pCmd->pTableBlockHashList, pTableMeta->id.uid, TSDB_PAYLOAD_SIZE,
|
int32_t ret =
|
||||||
sizeof(SSubmitBlk), tinfo.rowSize, pTableMetaInfo->name, pTableMeta, &pTableDataBlock, NULL);
|
tscGetDataBlockFromList(pCmd->pTableBlockHashList, pTableMeta->id.uid, TSDB_PAYLOAD_SIZE, sizeof(SSubmitBlk),
|
||||||
|
tinfo.rowSize, &pTableMetaInfo->name, pTableMeta, &pTableDataBlock, NULL);
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
// return ret;
|
pParentSql->res.code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
tscAllocateMemIfNeed(pTableDataBlock, tinfo.rowSize, &maxRows);
|
tscAllocateMemIfNeed(pTableDataBlock, tinfo.rowSize, &maxRows);
|
||||||
char *tokenBuf = calloc(1, 4096);
|
tokenBuf = calloc(1, TSDB_MAX_BYTES_PER_ROW);
|
||||||
|
if (tokenBuf == NULL) {
|
||||||
|
code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
|
||||||
while ((readLen = tgetline(&line, &n, fp)) != -1) {
|
while ((readLen = tgetline(&line, &n, fp)) != -1) {
|
||||||
if (('\r' == line[readLen - 1]) || ('\n' == line[readLen - 1])) {
|
if (('\r' == line[readLen - 1]) || ('\n' == line[readLen - 1])) {
|
||||||
|
@ -1501,30 +1504,42 @@ static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int code) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tfree(tokenBuf);
|
tfree(tokenBuf);
|
||||||
free(line);
|
tfree(line);
|
||||||
|
|
||||||
if (count > 0) {
|
pParentSql->res.code = code;
|
||||||
code = doPackSendDataBlock(pSql, count, pTableDataBlock);
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (count > 0) {
|
||||||
pParentSql->res.code = code;
|
code = doPackSendDataBlock(pSql, count, pTableDataBlock);
|
||||||
tscAsyncResultOnError(pParentSql);
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
taos_free_result(pSql);
|
||||||
|
tfree(pSupporter);
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
pParentSql->fp = pParentSql->fetchFp;
|
||||||
|
|
||||||
|
// all data has been sent to vnode, call user function
|
||||||
|
int32_t v = (code != TSDB_CODE_SUCCESS) ? code : (int32_t)pParentSql->res.numOfRows;
|
||||||
|
(*pParentSql->fp)(pParentSql->param, pParentSql, v);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
|
||||||
taos_free_result(pSql);
|
|
||||||
tfree(pSupporter);
|
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
pParentSql->fp = pParentSql->fetchFp;
|
|
||||||
|
|
||||||
// all data has been sent to vnode, call user function
|
|
||||||
int32_t v = (pParentSql->res.code != TSDB_CODE_SUCCESS) ? pParentSql->res.code : (int32_t)pParentSql->res.numOfRows;
|
|
||||||
(*pParentSql->fp)(pParentSql->param, pParentSql, v);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_error:
|
||||||
|
tfree(tokenBuf);
|
||||||
|
tfree(line);
|
||||||
|
taos_free_result(pSql);
|
||||||
|
tfree(pSupporter);
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
tscAsyncResultOnError(pParentSql);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscProcessMultiVnodesImportFromFile(SSqlObj *pSql) {
|
void tscImportDataFromFile(SSqlObj *pSql) {
|
||||||
SSqlCmd *pCmd = &pSql->cmd;
|
SSqlCmd *pCmd = &pSql->cmd;
|
||||||
if (pCmd->command != TSDB_SQL_INSERT) {
|
if (pCmd->command != TSDB_SQL_INSERT) {
|
||||||
return;
|
return;
|
||||||
|
@ -1543,12 +1558,11 @@ void tscProcessMultiVnodesImportFromFile(SSqlObj *pSql) {
|
||||||
|
|
||||||
tfree(pSupporter);
|
tfree(pSupporter);
|
||||||
tscAsyncResultOnError(pSql);
|
tscAsyncResultOnError(pSql);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pSupporter->pSql = pSql;
|
pSupporter->pSql = pSql;
|
||||||
pSupporter->fp = fp;
|
pSupporter->fp = fp;
|
||||||
|
|
||||||
parseFileSendDataBlock(pSupporter, pNew, 0);
|
parseFileSendDataBlock(pSupporter, pNew, TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
|
@ -707,7 +707,7 @@ static int insertStmtBindParam(STscStmt* stmt, TAOS_BIND* bind) {
|
||||||
|
|
||||||
int32_t ret =
|
int32_t ret =
|
||||||
tscGetDataBlockFromList(pCmd->pTableBlockHashList, pTableMeta->id.uid, TSDB_PAYLOAD_SIZE, sizeof(SSubmitBlk),
|
tscGetDataBlockFromList(pCmd->pTableBlockHashList, pTableMeta->id.uid, TSDB_PAYLOAD_SIZE, sizeof(SSubmitBlk),
|
||||||
pTableMeta->tableInfo.rowSize, pTableMetaInfo->name, pTableMeta, &pBlock, NULL);
|
pTableMeta->tableInfo.rowSize, &pTableMetaInfo->name, pTableMeta, &pBlock, NULL);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
// todo handle error
|
// todo handle error
|
||||||
}
|
}
|
||||||
|
@ -790,7 +790,7 @@ static int insertStmtExecute(STscStmt* stmt) {
|
||||||
|
|
||||||
int32_t ret =
|
int32_t ret =
|
||||||
tscGetDataBlockFromList(pCmd->pTableBlockHashList, pTableMeta->id.uid, TSDB_PAYLOAD_SIZE, sizeof(SSubmitBlk),
|
tscGetDataBlockFromList(pCmd->pTableBlockHashList, pTableMeta->id.uid, TSDB_PAYLOAD_SIZE, sizeof(SSubmitBlk),
|
||||||
pTableMeta->tableInfo.rowSize, pTableMetaInfo->name, pTableMeta, &pBlock, NULL);
|
pTableMeta->tableInfo.rowSize, &pTableMetaInfo->name, pTableMeta, &pBlock, NULL);
|
||||||
assert(ret == 0);
|
assert(ret == 0);
|
||||||
pBlock->size = sizeof(SSubmitBlk) + pCmd->batchSize * pBlock->rowSize;
|
pBlock->size = sizeof(SSubmitBlk) + pCmd->batchSize * pBlock->rowSize;
|
||||||
SSubmitBlk* pBlk = (SSubmitBlk*) pBlock->pData;
|
SSubmitBlk* pBlk = (SSubmitBlk*) pBlock->pData;
|
||||||
|
|
|
@ -60,7 +60,7 @@ static int32_t setShowInfo(SSqlObj* pSql, SSqlInfo* pInfo);
|
||||||
static char* getAccountId(SSqlObj* pSql);
|
static char* getAccountId(SSqlObj* pSql);
|
||||||
|
|
||||||
static bool has(SArray* pFieldList, int32_t startIdx, const char* name);
|
static bool has(SArray* pFieldList, int32_t startIdx, const char* name);
|
||||||
static void getCurrentDBName(SSqlObj* pSql, SStrToken* pDBToken);
|
static char* getCurrentDBName(SSqlObj* pSql);
|
||||||
static bool hasSpecifyDB(SStrToken* pTableName);
|
static bool hasSpecifyDB(SStrToken* pTableName);
|
||||||
static bool validateTableColumnInfo(SArray* pFieldList, SSqlCmd* pCmd);
|
static bool validateTableColumnInfo(SArray* pFieldList, SSqlCmd* pCmd);
|
||||||
static bool validateTagParams(SArray* pTagsList, SArray* pFieldList, SSqlCmd* pCmd);
|
static bool validateTagParams(SArray* pTagsList, SArray* pFieldList, SSqlCmd* pCmd);
|
||||||
|
@ -100,8 +100,8 @@ static int32_t validateSqlFunctionInStreamSql(SSqlCmd* pCmd, SQueryInfo* pQueryI
|
||||||
static int32_t validateFunctionsInIntervalOrGroupbyQuery(SSqlCmd* pCmd, SQueryInfo* pQueryInfo);
|
static int32_t validateFunctionsInIntervalOrGroupbyQuery(SSqlCmd* pCmd, SQueryInfo* pQueryInfo);
|
||||||
static int32_t validateArithmeticSQLExpr(SSqlCmd* pCmd, tSQLExpr* pExpr, SQueryInfo* pQueryInfo, SColumnList* pList, int32_t* type);
|
static int32_t validateArithmeticSQLExpr(SSqlCmd* pCmd, tSQLExpr* pExpr, SQueryInfo* pQueryInfo, SColumnList* pList, int32_t* type);
|
||||||
static int32_t validateEp(char* ep);
|
static int32_t validateEp(char* ep);
|
||||||
static int32_t validateDNodeConfig(tDCLSQL* pOptions);
|
static int32_t validateDNodeConfig(SMiscInfo* pOptions);
|
||||||
static int32_t validateLocalConfig(tDCLSQL* pOptions);
|
static int32_t validateLocalConfig(SMiscInfo* pOptions);
|
||||||
static int32_t validateColumnName(char* name);
|
static int32_t validateColumnName(char* name);
|
||||||
static int32_t setKillInfo(SSqlObj* pSql, struct SSqlInfo* pInfo, int32_t killType);
|
static int32_t setKillInfo(SSqlObj* pSql, struct SSqlInfo* pInfo, int32_t killType);
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ static bool hasTimestampForPointInterpQuery(SQueryInfo* pQueryInfo);
|
||||||
static bool hasNormalColumnFilter(SQueryInfo* pQueryInfo);
|
static bool hasNormalColumnFilter(SQueryInfo* pQueryInfo);
|
||||||
|
|
||||||
static int32_t parseLimitClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t index, SQuerySQL* pQuerySql, SSqlObj* pSql);
|
static int32_t parseLimitClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t index, SQuerySQL* pQuerySql, SSqlObj* pSql);
|
||||||
static int32_t parseCreateDBOptions(SSqlCmd* pCmd, SCreateDBInfo* pCreateDbSql);
|
static int32_t parseCreateDBOptions(SSqlCmd* pCmd, SCreateDbInfo* pCreateDbSql);
|
||||||
static int32_t getColumnIndexByName(SSqlCmd* pCmd, const SStrToken* pToken, SQueryInfo* pQueryInfo, SColumnIndex* pIndex);
|
static int32_t getColumnIndexByName(SSqlCmd* pCmd, const SStrToken* pToken, SQueryInfo* pQueryInfo, SColumnIndex* pIndex);
|
||||||
static int32_t getTableIndexByName(SStrToken* pToken, SQueryInfo* pQueryInfo, SColumnIndex* pIndex);
|
static int32_t getTableIndexByName(SStrToken* pToken, SQueryInfo* pQueryInfo, SColumnIndex* pIndex);
|
||||||
static int32_t optrToString(tSQLExpr* pExpr, char** exprString);
|
static int32_t optrToString(tSQLExpr* pExpr, char** exprString);
|
||||||
|
@ -239,7 +239,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
if (!pInfo->valid || terrno == TSDB_CODE_TSC_SQL_SYNTAX_ERROR) {
|
if (!pInfo->valid || terrno == TSDB_CODE_TSC_SQL_SYNTAX_ERROR) {
|
||||||
terrno = TSDB_CODE_SUCCESS; // clear the error number
|
terrno = TSDB_CODE_SUCCESS; // clear the error number
|
||||||
return tscSQLSyntaxErrMsg(tscGetErrorMsgPayload(pCmd), NULL, pInfo->pzErrMsg);
|
return tscSQLSyntaxErrMsg(tscGetErrorMsgPayload(pCmd), NULL, pInfo->msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
SQueryInfo* pQueryInfo = tscGetQueryInfoDetailSafely(pCmd, pCmd->clauseIndex);
|
SQueryInfo* pQueryInfo = tscGetQueryInfoDetailSafely(pCmd, pCmd->clauseIndex);
|
||||||
|
@ -266,28 +266,27 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
const char* msg3 = "param name too long";
|
const char* msg3 = "param name too long";
|
||||||
const char* msg4 = "table is not super table";
|
const char* msg4 = "table is not super table";
|
||||||
|
|
||||||
SStrToken* pzName = &pInfo->pDCLInfo->a[0];
|
SStrToken* pzName = taosArrayGet(pInfo->pMiscInfo->a, 0);
|
||||||
if ((pInfo->type != TSDB_SQL_DROP_DNODE) && (tscValidateName(pzName) != TSDB_CODE_SUCCESS)) {
|
if ((pInfo->type != TSDB_SQL_DROP_DNODE) && (tscValidateName(pzName) != TSDB_CODE_SUCCESS)) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pInfo->type == TSDB_SQL_DROP_DB) {
|
if (pInfo->type == TSDB_SQL_DROP_DB) {
|
||||||
assert(pInfo->pDCLInfo->nTokens == 1);
|
assert(taosArrayGetSize(pInfo->pMiscInfo->a) == 1);
|
||||||
|
code = tNameSetDbName(&pTableMetaInfo->name, getAccountId(pSql), pzName);
|
||||||
code = setObjFullName(pTableMetaInfo->name, getAccountId(pSql), pzName, NULL, NULL);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (pInfo->type == TSDB_SQL_DROP_TABLE) {
|
} else if (pInfo->type == TSDB_SQL_DROP_TABLE) {
|
||||||
assert(pInfo->pDCLInfo->nTokens == 1);
|
assert(taosArrayGetSize(pInfo->pMiscInfo->a) == 1);
|
||||||
|
|
||||||
code = tscSetTableFullName(pTableMetaInfo, pzName, pSql);
|
code = tscSetTableFullName(pTableMetaInfo, pzName, pSql);
|
||||||
if(code != TSDB_CODE_SUCCESS) {
|
if(code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pInfo->pDCLInfo->tableType == TSDB_SUPER_TABLE) {
|
if (pInfo->pMiscInfo->tableType == TSDB_SUPER_TABLE) {
|
||||||
code = tscGetTableMeta(pSql, pTableMetaInfo);
|
code = tscGetTableMeta(pSql, pTableMetaInfo);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
|
@ -300,13 +299,13 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
|
|
||||||
} else if (pInfo->type == TSDB_SQL_DROP_DNODE) {
|
} else if (pInfo->type == TSDB_SQL_DROP_DNODE) {
|
||||||
pzName->n = strdequote(pzName->z);
|
pzName->n = strdequote(pzName->z);
|
||||||
strncpy(pTableMetaInfo->name, pzName->z, pzName->n);
|
strncpy(pCmd->payload, pzName->z, pzName->n);
|
||||||
} else { // drop user
|
} else { // drop user/account
|
||||||
if (pzName->n >= TSDB_USER_LEN) {
|
if (pzName->n >= TSDB_USER_LEN) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3);
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(pTableMetaInfo->name, pzName->z, pzName->n);
|
strncpy(pCmd->payload, pzName->z, pzName->n);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -314,13 +313,13 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
|
|
||||||
case TSDB_SQL_USE_DB: {
|
case TSDB_SQL_USE_DB: {
|
||||||
const char* msg = "invalid db name";
|
const char* msg = "invalid db name";
|
||||||
SStrToken* pToken = &pInfo->pDCLInfo->a[0];
|
SStrToken* pToken = taosArrayGet(pInfo->pMiscInfo->a, 0);
|
||||||
|
|
||||||
if (tscValidateName(pToken) != TSDB_CODE_SUCCESS) {
|
if (tscValidateName(pToken) != TSDB_CODE_SUCCESS) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ret = setObjFullName(pTableMetaInfo->name, getAccountId(pSql), pToken, NULL, NULL);
|
int32_t ret = tNameSetDbName(&pTableMetaInfo->name, getAccountId(pSql), pToken);
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg);
|
||||||
}
|
}
|
||||||
|
@ -345,12 +344,12 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
const char* msg1 = "invalid db name";
|
const char* msg1 = "invalid db name";
|
||||||
const char* msg2 = "name too long";
|
const char* msg2 = "name too long";
|
||||||
|
|
||||||
SCreateDBInfo* pCreateDB = &(pInfo->pDCLInfo->dbOpt);
|
SCreateDbInfo* pCreateDB = &(pInfo->pMiscInfo->dbOpt);
|
||||||
if (tscValidateName(&pCreateDB->dbname) != TSDB_CODE_SUCCESS) {
|
if (tscValidateName(&pCreateDB->dbname) != TSDB_CODE_SUCCESS) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ret = setObjFullName(pTableMetaInfo->name, getAccountId(pSql), &(pCreateDB->dbname), NULL, NULL);
|
int32_t ret = tNameSetDbName(&pTableMetaInfo->name, getAccountId(pSql), &(pCreateDB->dbname));
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
||||||
}
|
}
|
||||||
|
@ -362,15 +361,15 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case TSDB_SQL_CREATE_DNODE: { // todo hostname
|
case TSDB_SQL_CREATE_DNODE: {
|
||||||
const char* msg = "invalid host name (ip address)";
|
const char* msg = "invalid host name (ip address)";
|
||||||
|
|
||||||
if (pInfo->pDCLInfo->nTokens > 1) {
|
if (taosArrayGetSize(pInfo->pMiscInfo->a) > 1) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
SStrToken* pIpAddr = &pInfo->pDCLInfo->a[0];
|
SStrToken* id = taosArrayGet(pInfo->pMiscInfo->a, 0);
|
||||||
pIpAddr->n = strdequote(pIpAddr->z);
|
id->n = strdequote(id->z);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,8 +379,8 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
const char* msg2 = "invalid user/account name";
|
const char* msg2 = "invalid user/account name";
|
||||||
const char* msg3 = "name too long";
|
const char* msg3 = "name too long";
|
||||||
|
|
||||||
SStrToken* pName = &pInfo->pDCLInfo->user.user;
|
SStrToken* pName = &pInfo->pMiscInfo->user.user;
|
||||||
SStrToken* pPwd = &pInfo->pDCLInfo->user.passwd;
|
SStrToken* pPwd = &pInfo->pMiscInfo->user.passwd;
|
||||||
|
|
||||||
if (handlePassword(pCmd, pPwd) != TSDB_CODE_SUCCESS) {
|
if (handlePassword(pCmd, pPwd) != TSDB_CODE_SUCCESS) {
|
||||||
return TSDB_CODE_TSC_INVALID_SQL;
|
return TSDB_CODE_TSC_INVALID_SQL;
|
||||||
|
@ -395,7 +394,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCreateAcctSQL* pAcctOpt = &pInfo->pDCLInfo->acctOpt;
|
SCreateAcctInfo* pAcctOpt = &pInfo->pMiscInfo->acctOpt;
|
||||||
if (pAcctOpt->stat.n > 0) {
|
if (pAcctOpt->stat.n > 0) {
|
||||||
if (pAcctOpt->stat.z[0] == 'r' && pAcctOpt->stat.n == 1) {
|
if (pAcctOpt->stat.z[0] == 'r' && pAcctOpt->stat.n == 1) {
|
||||||
} else if (pAcctOpt->stat.z[0] == 'w' && pAcctOpt->stat.n == 1) {
|
} else if (pAcctOpt->stat.z[0] == 'w' && pAcctOpt->stat.n == 1) {
|
||||||
|
@ -410,10 +409,10 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
case TSDB_SQL_DESCRIBE_TABLE: {
|
case TSDB_SQL_DESCRIBE_TABLE: {
|
||||||
SStrToken* pToken = &pInfo->pDCLInfo->a[0];
|
|
||||||
const char* msg1 = "invalid table name";
|
const char* msg1 = "invalid table name";
|
||||||
const char* msg2 = "table name too long";
|
const char* msg2 = "table name too long";
|
||||||
|
|
||||||
|
SStrToken* pToken = taosArrayGet(pInfo->pMiscInfo->a, 0);
|
||||||
if (tscValidateName(pToken) != TSDB_CODE_SUCCESS) {
|
if (tscValidateName(pToken) != TSDB_CODE_SUCCESS) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
||||||
}
|
}
|
||||||
|
@ -431,10 +430,10 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
return tscGetTableMeta(pSql, pTableMetaInfo);
|
return tscGetTableMeta(pSql, pTableMetaInfo);
|
||||||
}
|
}
|
||||||
case TSDB_SQL_SHOW_CREATE_TABLE: {
|
case TSDB_SQL_SHOW_CREATE_TABLE: {
|
||||||
SStrToken* pToken = &pInfo->pDCLInfo->a[0];
|
|
||||||
const char* msg1 = "invalid table name";
|
const char* msg1 = "invalid table name";
|
||||||
const char* msg2 = "table name is too long";
|
const char* msg2 = "table name is too long";
|
||||||
|
|
||||||
|
SStrToken* pToken = taosArrayGet(pInfo->pMiscInfo->a, 0);
|
||||||
if (tscValidateName(pToken) != TSDB_CODE_SUCCESS) {
|
if (tscValidateName(pToken) != TSDB_CODE_SUCCESS) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
||||||
}
|
}
|
||||||
|
@ -452,11 +451,12 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
}
|
}
|
||||||
case TSDB_SQL_SHOW_CREATE_DATABASE: {
|
case TSDB_SQL_SHOW_CREATE_DATABASE: {
|
||||||
const char* msg1 = "invalid database name";
|
const char* msg1 = "invalid database name";
|
||||||
SStrToken* pToken = &pInfo->pDCLInfo->a[0];
|
|
||||||
|
|
||||||
|
SStrToken* pToken = taosArrayGet(pInfo->pMiscInfo->a, 0);
|
||||||
if (tscValidateName(pToken) != TSDB_CODE_SUCCESS) {
|
if (tscValidateName(pToken) != TSDB_CODE_SUCCESS) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pToken->n > TSDB_DB_NAME_LEN) {
|
if (pToken->n > TSDB_DB_NAME_LEN) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
||||||
}
|
}
|
||||||
|
@ -468,29 +468,34 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
const char* msg3 = "invalid dnode ep";
|
const char* msg3 = "invalid dnode ep";
|
||||||
|
|
||||||
/* validate the ip address */
|
/* validate the ip address */
|
||||||
tDCLSQL* pDCL = pInfo->pDCLInfo;
|
SMiscInfo* pMiscInfo = pInfo->pMiscInfo;
|
||||||
|
|
||||||
/* validate the parameter names and options */
|
/* validate the parameter names and options */
|
||||||
if (validateDNodeConfig(pDCL) != TSDB_CODE_SUCCESS) {
|
if (validateDNodeConfig(pMiscInfo) != TSDB_CODE_SUCCESS) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* pMsg = pCmd->payload;
|
char* pMsg = pCmd->payload;
|
||||||
|
|
||||||
SCfgDnodeMsg* pCfg = (SCfgDnodeMsg*)pMsg;
|
SCfgDnodeMsg* pCfg = (SCfgDnodeMsg*)pMsg;
|
||||||
pDCL->a[0].n = strdequote(pDCL->a[0].z);
|
|
||||||
|
SStrToken* t0 = taosArrayGet(pMiscInfo->a, 0);
|
||||||
strncpy(pCfg->ep, pDCL->a[0].z, pDCL->a[0].n);
|
SStrToken* t1 = taosArrayGet(pMiscInfo->a, 1);
|
||||||
|
|
||||||
|
t0->n = strdequote(t0->z);
|
||||||
|
strncpy(pCfg->ep, t0->z, t0->n);
|
||||||
|
|
||||||
if (validateEp(pCfg->ep) != TSDB_CODE_SUCCESS) {
|
if (validateEp(pCfg->ep) != TSDB_CODE_SUCCESS) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3);
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(pCfg->config, pDCL->a[1].z, pDCL->a[1].n);
|
strncpy(pCfg->config, t1->z, t1->n);
|
||||||
|
|
||||||
if (pDCL->nTokens == 3) {
|
if (taosArrayGetSize(pMiscInfo->a) == 3) {
|
||||||
pCfg->config[pDCL->a[1].n] = ' '; // add sep
|
SStrToken* t2 = taosArrayGet(pMiscInfo->a, 2);
|
||||||
strncpy(&pCfg->config[pDCL->a[1].n + 1], pDCL->a[2].z, pDCL->a[2].n);
|
|
||||||
|
pCfg->config[t1->n] = ' '; // add sep
|
||||||
|
strncpy(&pCfg->config[t1->n + 1], t2->z, t2->n);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -505,7 +510,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
|
|
||||||
pCmd->command = pInfo->type;
|
pCmd->command = pInfo->type;
|
||||||
|
|
||||||
SUserInfo* pUser = &pInfo->pDCLInfo->user;
|
SUserInfo* pUser = &pInfo->pMiscInfo->user;
|
||||||
SStrToken* pName = &pUser->user;
|
SStrToken* pName = &pUser->user;
|
||||||
SStrToken* pPwd = &pUser->passwd;
|
SStrToken* pPwd = &pUser->passwd;
|
||||||
|
|
||||||
|
@ -549,18 +554,22 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
case TSDB_SQL_CFG_LOCAL: {
|
case TSDB_SQL_CFG_LOCAL: {
|
||||||
tDCLSQL* pDCL = pInfo->pDCLInfo;
|
SMiscInfo *pMiscInfo = pInfo->pMiscInfo;
|
||||||
const char* msg = "invalid configure options or values";
|
const char *msg = "invalid configure options or values";
|
||||||
|
|
||||||
// validate the parameter names and options
|
// validate the parameter names and options
|
||||||
if (validateLocalConfig(pDCL) != TSDB_CODE_SUCCESS) {
|
if (validateLocalConfig(pMiscInfo) != TSDB_CODE_SUCCESS) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(pCmd->payload, pDCL->a[0].z, pDCL->a[0].n);
|
int32_t numOfToken = (int32_t) taosArrayGetSize(pMiscInfo->a);
|
||||||
if (pDCL->nTokens == 2) {
|
SStrToken* t = taosArrayGet(pMiscInfo->a, 0);
|
||||||
pCmd->payload[pDCL->a[0].n] = ' '; // add sep
|
SStrToken* t1 = taosArrayGet(pMiscInfo->a, 1);
|
||||||
strncpy(&pCmd->payload[pDCL->a[0].n + 1], pDCL->a[1].z, pDCL->a[1].n);
|
|
||||||
|
strncpy(pCmd->payload, t->z, t->n);
|
||||||
|
if (numOfToken == 2) {
|
||||||
|
pCmd->payload[t->n] = ' '; // add sep
|
||||||
|
strncpy(&pCmd->payload[t->n + 1], t1->z, t1->n);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -891,47 +900,47 @@ int32_t parseSlidingClause(SSqlObj* pSql, SQueryInfo* pQueryInfo, SQuerySQL* pQu
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tscSetTableFullName(STableMetaInfo* pTableMetaInfo, SStrToken* pzTableName, SSqlObj* pSql) {
|
int32_t tscSetTableFullName(STableMetaInfo* pTableMetaInfo, SStrToken* pTableName, SSqlObj* pSql) {
|
||||||
const char* msg1 = "name too long";
|
const char* msg1 = "name too long";
|
||||||
|
|
||||||
SSqlCmd* pCmd = &pSql->cmd;
|
SSqlCmd* pCmd = &pSql->cmd;
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
// backup the old name in pTableMetaInfo
|
if (hasSpecifyDB(pTableName)) { // db has been specified in sql string so we ignore current db path
|
||||||
char oldName[TSDB_TABLE_FNAME_LEN] = {0};
|
tNameSetAcctId(&pTableMetaInfo->name, getAccountId(pSql));
|
||||||
tstrncpy(oldName, pTableMetaInfo->name, tListLen(oldName));
|
|
||||||
|
|
||||||
if (hasSpecifyDB(pzTableName)) { // db has been specified in sql string so we ignore current db path
|
char name[TSDB_TABLE_FNAME_LEN] = {0};
|
||||||
code = setObjFullName(pTableMetaInfo->name, getAccountId(pSql), NULL, pzTableName, NULL);
|
strncpy(name, pTableName->z, pTableName->n);
|
||||||
|
|
||||||
|
code = tNameFromString(&pTableMetaInfo->name, name, T_NAME_DB|T_NAME_TABLE);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
||||||
}
|
}
|
||||||
} else { // get current DB name first, and then set it into path
|
} else { // get current DB name first, and then set it into path
|
||||||
SStrToken t = {0};
|
char* t = getCurrentDBName(pSql);
|
||||||
getCurrentDBName(pSql, &t);
|
if (strlen(t) == 0) {
|
||||||
if (t.n == 0) { // current database not available or not specified
|
return TSDB_CODE_TSC_DB_NOT_SELECTED;
|
||||||
code = TSDB_CODE_TSC_DB_NOT_SELECTED;
|
}
|
||||||
} else {
|
|
||||||
code = setObjFullName(pTableMetaInfo->name, NULL, &t, pzTableName, NULL);
|
code = tNameFromString(&pTableMetaInfo->name, t, T_NAME_ACCT | T_NAME_DB);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
return TSDB_CODE_TSC_DB_NOT_SELECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pTableName->n >= TSDB_TABLE_NAME_LEN) {
|
||||||
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
||||||
|
}
|
||||||
|
|
||||||
|
char name[TSDB_TABLE_FNAME_LEN] = {0};
|
||||||
|
strncpy(name, pTableName->z, pTableName->n);
|
||||||
|
|
||||||
|
code = tNameFromString(&pTableMetaInfo->name, name, T_NAME_TABLE);
|
||||||
|
if (code != 0) {
|
||||||
|
code = invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
return code;
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* the old name exists and is not equalled to the new name. Release the table meta
|
|
||||||
* that are corresponding to the old name for the new table name.
|
|
||||||
*/
|
|
||||||
if (strlen(oldName) > 0 && strncasecmp(oldName, pTableMetaInfo->name, tListLen(pTableMetaInfo->name)) != 0) {
|
|
||||||
tscClearTableMetaInfo(pTableMetaInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool validateTableColumnInfo(SArray* pFieldList, SSqlCmd* pCmd) {
|
static bool validateTableColumnInfo(SArray* pFieldList, SSqlCmd* pCmd) {
|
||||||
|
@ -1231,9 +1240,8 @@ static bool has(SArray* pFieldList, int32_t startIdx, const char* name) {
|
||||||
|
|
||||||
static char* getAccountId(SSqlObj* pSql) { return pSql->pTscObj->acctId; }
|
static char* getAccountId(SSqlObj* pSql) { return pSql->pTscObj->acctId; }
|
||||||
|
|
||||||
static void getCurrentDBName(SSqlObj* pSql, SStrToken* pDBToken) {
|
static char* getCurrentDBName(SSqlObj* pSql) {
|
||||||
pDBToken->z = pSql->pTscObj->db;
|
return pSql->pTscObj->db;
|
||||||
pDBToken->n = (uint32_t)strlen(pSql->pTscObj->db);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* length limitation, strstr cannot be applied */
|
/* length limitation, strstr cannot be applied */
|
||||||
|
@ -2608,10 +2616,10 @@ int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
const char* msg6 = "pattern string is empty";
|
const char* msg6 = "pattern string is empty";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* database prefix in pInfo->pDCLInfo->a[0]
|
* database prefix in pInfo->pMiscInfo->a[0]
|
||||||
* wildcard in like clause in pInfo->pDCLInfo->a[1]
|
* wildcard in like clause in pInfo->pMiscInfo->a[1]
|
||||||
*/
|
*/
|
||||||
SShowInfo* pShowInfo = &pInfo->pDCLInfo->showOpt;
|
SShowInfo* pShowInfo = &pInfo->pMiscInfo->showOpt;
|
||||||
int16_t showType = pShowInfo->showType;
|
int16_t showType = pShowInfo->showType;
|
||||||
if (showType == TSDB_MGMT_TABLE_TABLE || showType == TSDB_MGMT_TABLE_METRIC || showType == TSDB_MGMT_TABLE_VGROUP) {
|
if (showType == TSDB_MGMT_TABLE_TABLE || showType == TSDB_MGMT_TABLE_METRIC || showType == TSDB_MGMT_TABLE_VGROUP) {
|
||||||
// db prefix in tagCond, show table conds in payload
|
// db prefix in tagCond, show table conds in payload
|
||||||
|
@ -2630,7 +2638,7 @@ int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ret = setObjFullName(pTableMetaInfo->name, getAccountId(pSql), pDbPrefixToken, NULL, NULL);
|
int32_t ret = tNameSetDbName(&pTableMetaInfo->name, getAccountId(pSql), pDbPrefixToken);
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
||||||
}
|
}
|
||||||
|
@ -2676,7 +2684,7 @@ int32_t setKillInfo(SSqlObj* pSql, struct SSqlInfo* pInfo, int32_t killType) {
|
||||||
SSqlCmd* pCmd = &pSql->cmd;
|
SSqlCmd* pCmd = &pSql->cmd;
|
||||||
pCmd->command = pInfo->type;
|
pCmd->command = pInfo->type;
|
||||||
|
|
||||||
SStrToken* idStr = &(pInfo->pDCLInfo->ip);
|
SStrToken* idStr = &(pInfo->pMiscInfo->id);
|
||||||
if (idStr->n > TSDB_KILL_MSG_LEN) {
|
if (idStr->n > TSDB_KILL_MSG_LEN) {
|
||||||
return TSDB_CODE_TSC_INVALID_SQL;
|
return TSDB_CODE_TSC_INVALID_SQL;
|
||||||
}
|
}
|
||||||
|
@ -2911,7 +2919,7 @@ int32_t parseGroupbyClause(SQueryInfo* pQueryInfo, SArray* pList, SSqlCmd* pCmd)
|
||||||
|
|
||||||
STableMeta* pTableMeta = NULL;
|
STableMeta* pTableMeta = NULL;
|
||||||
SSchema* pSchema = NULL;
|
SSchema* pSchema = NULL;
|
||||||
SSchema s = tscGetTbnameColumnSchema();
|
SSchema s = tGetTbnameColumnSchema();
|
||||||
|
|
||||||
int32_t tableIndex = COLUMN_INDEX_INITIAL_VAL;
|
int32_t tableIndex = COLUMN_INDEX_INITIAL_VAL;
|
||||||
|
|
||||||
|
@ -3434,6 +3442,7 @@ static int32_t getColumnQueryCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSQ
|
||||||
|
|
||||||
static int32_t getJoinCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSQLExpr* pExpr) {
|
static int32_t getJoinCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSQLExpr* pExpr) {
|
||||||
const char* msg1 = "invalid join query condition";
|
const char* msg1 = "invalid join query condition";
|
||||||
|
const char* msg2 = "invalid table name in join query";
|
||||||
const char* msg3 = "type of join columns must be identical";
|
const char* msg3 = "type of join columns must be identical";
|
||||||
const char* msg4 = "invalid column name in join condition";
|
const char* msg4 = "invalid column name in join condition";
|
||||||
|
|
||||||
|
@ -3459,7 +3468,11 @@ static int32_t getJoinCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSQLExpr*
|
||||||
|
|
||||||
pLeft->uid = pTableMetaInfo->pTableMeta->id.uid;
|
pLeft->uid = pTableMetaInfo->pTableMeta->id.uid;
|
||||||
pLeft->tagColId = pTagSchema1->colId;
|
pLeft->tagColId = pTagSchema1->colId;
|
||||||
strcpy(pLeft->tableId, pTableMetaInfo->name);
|
|
||||||
|
int32_t code = tNameExtractFullName(&pTableMetaInfo->name, pLeft->tableName);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
||||||
|
}
|
||||||
|
|
||||||
index = (SColumnIndex)COLUMN_INDEX_INITIALIZER;
|
index = (SColumnIndex)COLUMN_INDEX_INITIALIZER;
|
||||||
if (getColumnIndexByName(pCmd, &pExpr->pRight->colInfo, pQueryInfo, &index) != TSDB_CODE_SUCCESS) {
|
if (getColumnIndexByName(pCmd, &pExpr->pRight->colInfo, pQueryInfo, &index) != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -3471,7 +3484,11 @@ static int32_t getJoinCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSQLExpr*
|
||||||
|
|
||||||
pRight->uid = pTableMetaInfo->pTableMeta->id.uid;
|
pRight->uid = pTableMetaInfo->pTableMeta->id.uid;
|
||||||
pRight->tagColId = pTagSchema2->colId;
|
pRight->tagColId = pTagSchema2->colId;
|
||||||
strcpy(pRight->tableId, pTableMetaInfo->name);
|
|
||||||
|
code = tNameExtractFullName(&pTableMetaInfo->name, pRight->tableName);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2);
|
||||||
|
}
|
||||||
|
|
||||||
if (pTagSchema1->type != pTagSchema2->type) {
|
if (pTagSchema1->type != pTagSchema2->type) {
|
||||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3);
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3);
|
||||||
|
@ -4048,8 +4065,6 @@ static int32_t setTableCondForSTableQuery(SSqlCmd* pCmd, SQueryInfo* pQueryInfo,
|
||||||
SStringBuilder sb1; memset(&sb1, 0, sizeof(sb1));
|
SStringBuilder sb1; memset(&sb1, 0, sizeof(sb1));
|
||||||
taosStringBuilderAppendStringLen(&sb1, QUERY_COND_REL_PREFIX_IN, QUERY_COND_REL_PREFIX_IN_LEN);
|
taosStringBuilderAppendStringLen(&sb1, QUERY_COND_REL_PREFIX_IN, QUERY_COND_REL_PREFIX_IN_LEN);
|
||||||
|
|
||||||
char db[TSDB_TABLE_FNAME_LEN] = {0};
|
|
||||||
|
|
||||||
// remove the duplicated input table names
|
// remove the duplicated input table names
|
||||||
int32_t num = 0;
|
int32_t num = 0;
|
||||||
char* tableNameString = taosStringBuilderGetResult(sb, NULL);
|
char* tableNameString = taosStringBuilderGetResult(sb, NULL);
|
||||||
|
@ -4065,7 +4080,8 @@ static int32_t setTableCondForSTableQuery(SSqlCmd* pCmd, SQueryInfo* pQueryInfo,
|
||||||
}
|
}
|
||||||
num = j;
|
num = j;
|
||||||
|
|
||||||
char* name = extractDBName(pTableMetaInfo->name, db);
|
char name[TSDB_DB_NAME_LEN] = {0};
|
||||||
|
tNameGetDbName(&pTableMetaInfo->name, name);
|
||||||
SStrToken dbToken = { .type = TK_STRING, .z = name, .n = (uint32_t)strlen(name) };
|
SStrToken dbToken = { .type = TK_STRING, .z = name, .n = (uint32_t)strlen(name) };
|
||||||
|
|
||||||
for (int32_t i = 0; i < num; ++i) {
|
for (int32_t i = 0; i < num; ++i) {
|
||||||
|
@ -4812,7 +4828,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
SSqlCmd* pCmd = &pSql->cmd;
|
SSqlCmd* pCmd = &pSql->cmd;
|
||||||
SAlterTableSQL* pAlterSQL = pInfo->pAlterInfo;
|
SAlterTableInfo* pAlterSQL = pInfo->pAlterInfo;
|
||||||
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, 0);
|
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, 0);
|
||||||
|
|
||||||
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, DEFAULT_TABLE_INDEX);
|
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, DEFAULT_TABLE_INDEX);
|
||||||
|
@ -5151,8 +5167,10 @@ int32_t validateEp(char* ep) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t validateDNodeConfig(tDCLSQL* pOptions) {
|
int32_t validateDNodeConfig(SMiscInfo* pOptions) {
|
||||||
if (pOptions->nTokens < 2 || pOptions->nTokens > 3) {
|
int32_t numOfToken = (int32_t) taosArrayGetSize(pOptions->a);
|
||||||
|
|
||||||
|
if (numOfToken < 2 || numOfToken > 3) {
|
||||||
return TSDB_CODE_TSC_INVALID_SQL;
|
return TSDB_CODE_TSC_INVALID_SQL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5170,9 +5188,9 @@ int32_t validateDNodeConfig(tDCLSQL* pOptions) {
|
||||||
{"cqDebugFlag", 11},
|
{"cqDebugFlag", 11},
|
||||||
};
|
};
|
||||||
|
|
||||||
SStrToken* pOptionToken = &pOptions->a[1];
|
SStrToken* pOptionToken = taosArrayGet(pOptions->a, 1);
|
||||||
|
|
||||||
if (pOptions->nTokens == 2) {
|
if (numOfToken == 2) {
|
||||||
// reset log and reset query cache does not need value
|
// reset log and reset query cache does not need value
|
||||||
for (int32_t i = 0; i < tokenLogEnd; ++i) {
|
for (int32_t i = 0; i < tokenLogEnd; ++i) {
|
||||||
const SDNodeDynConfOption* pOption = &cfgOptions[i];
|
const SDNodeDynConfOption* pOption = &cfgOptions[i];
|
||||||
|
@ -5182,7 +5200,7 @@ int32_t validateDNodeConfig(tDCLSQL* pOptions) {
|
||||||
}
|
}
|
||||||
} else if ((strncasecmp(cfgOptions[tokenBalance].name, pOptionToken->z, pOptionToken->n) == 0) &&
|
} else if ((strncasecmp(cfgOptions[tokenBalance].name, pOptionToken->z, pOptionToken->n) == 0) &&
|
||||||
(cfgOptions[tokenBalance].len == pOptionToken->n)) {
|
(cfgOptions[tokenBalance].len == pOptionToken->n)) {
|
||||||
SStrToken* pValToken = &pOptions->a[2];
|
SStrToken* pValToken = taosArrayGet(pOptions->a, 2);
|
||||||
int32_t vnodeId = 0;
|
int32_t vnodeId = 0;
|
||||||
int32_t dnodeId = 0;
|
int32_t dnodeId = 0;
|
||||||
strdequote(pValToken->z);
|
strdequote(pValToken->z);
|
||||||
|
@ -5193,14 +5211,14 @@ int32_t validateDNodeConfig(tDCLSQL* pOptions) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
} else if ((strncasecmp(cfgOptions[tokenMonitor].name, pOptionToken->z, pOptionToken->n) == 0) &&
|
} else if ((strncasecmp(cfgOptions[tokenMonitor].name, pOptionToken->z, pOptionToken->n) == 0) &&
|
||||||
(cfgOptions[tokenMonitor].len == pOptionToken->n)) {
|
(cfgOptions[tokenMonitor].len == pOptionToken->n)) {
|
||||||
SStrToken* pValToken = &pOptions->a[2];
|
SStrToken* pValToken = taosArrayGet(pOptions->a, 2);
|
||||||
int32_t val = strtol(pValToken->z, NULL, 10);
|
int32_t val = strtol(pValToken->z, NULL, 10);
|
||||||
if (val != 0 && val != 1) {
|
if (val != 0 && val != 1) {
|
||||||
return TSDB_CODE_TSC_INVALID_SQL; // options value is invalid
|
return TSDB_CODE_TSC_INVALID_SQL; // options value is invalid
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
SStrToken* pValToken = &pOptions->a[2];
|
SStrToken* pValToken = taosArrayGet(pOptions->a, 2);
|
||||||
|
|
||||||
int32_t val = strtol(pValToken->z, NULL, 10);
|
int32_t val = strtol(pValToken->z, NULL, 10);
|
||||||
if (val < 0 || val > 256) {
|
if (val < 0 || val > 256) {
|
||||||
|
@ -5211,8 +5229,8 @@ int32_t validateDNodeConfig(tDCLSQL* pOptions) {
|
||||||
for (int32_t i = tokenDebugFlag; i < tokenDebugFlagEnd; ++i) {
|
for (int32_t i = tokenDebugFlag; i < tokenDebugFlagEnd; ++i) {
|
||||||
const SDNodeDynConfOption* pOption = &cfgOptions[i];
|
const SDNodeDynConfOption* pOption = &cfgOptions[i];
|
||||||
|
|
||||||
|
// options is valid
|
||||||
if ((strncasecmp(pOption->name, pOptionToken->z, pOptionToken->n) == 0) && (pOption->len == pOptionToken->n)) {
|
if ((strncasecmp(pOption->name, pOptionToken->z, pOptionToken->n) == 0) && (pOption->len == pOptionToken->n)) {
|
||||||
/* options is valid */
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5221,17 +5239,18 @@ int32_t validateDNodeConfig(tDCLSQL* pOptions) {
|
||||||
return TSDB_CODE_TSC_INVALID_SQL;
|
return TSDB_CODE_TSC_INVALID_SQL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t validateLocalConfig(tDCLSQL* pOptions) {
|
int32_t validateLocalConfig(SMiscInfo* pOptions) {
|
||||||
if (pOptions->nTokens < 1 || pOptions->nTokens > 2) {
|
int32_t numOfToken = (int32_t) taosArrayGetSize(pOptions->a);
|
||||||
|
if (numOfToken < 1 || numOfToken > 2) {
|
||||||
return TSDB_CODE_TSC_INVALID_SQL;
|
return TSDB_CODE_TSC_INVALID_SQL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDNodeDynConfOption LOCAL_DYNAMIC_CFG_OPTIONS[6] = {{"resetLog", 8}, {"rpcDebugFlag", 12}, {"tmrDebugFlag", 12},
|
SDNodeDynConfOption LOCAL_DYNAMIC_CFG_OPTIONS[6] = {{"resetLog", 8}, {"rpcDebugFlag", 12}, {"tmrDebugFlag", 12},
|
||||||
{"cDebugFlag", 10}, {"uDebugFlag", 10}, {"debugFlag", 9}};
|
{"cDebugFlag", 10}, {"uDebugFlag", 10}, {"debugFlag", 9}};
|
||||||
|
|
||||||
SStrToken* pOptionToken = &pOptions->a[0];
|
SStrToken* pOptionToken = taosArrayGet(pOptions->a, 0);
|
||||||
|
|
||||||
if (pOptions->nTokens == 1) {
|
if (numOfToken == 1) {
|
||||||
// reset log does not need value
|
// reset log does not need value
|
||||||
for (int32_t i = 0; i < 1; ++i) {
|
for (int32_t i = 0; i < 1; ++i) {
|
||||||
SDNodeDynConfOption* pOption = &LOCAL_DYNAMIC_CFG_OPTIONS[i];
|
SDNodeDynConfOption* pOption = &LOCAL_DYNAMIC_CFG_OPTIONS[i];
|
||||||
|
@ -5240,7 +5259,7 @@ int32_t validateLocalConfig(tDCLSQL* pOptions) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SStrToken* pValToken = &pOptions->a[1];
|
SStrToken* pValToken = taosArrayGet(pOptions->a, 1);
|
||||||
|
|
||||||
int32_t val = strtol(pValToken->z, NULL, 10);
|
int32_t val = strtol(pValToken->z, NULL, 10);
|
||||||
if (val < 131 || val > 199) {
|
if (val < 131 || val > 199) {
|
||||||
|
@ -5392,7 +5411,7 @@ int32_t parseLimitClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t clauseIn
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t setKeepOption(SSqlCmd* pCmd, SCreateDbMsg* pMsg, SCreateDBInfo* pCreateDb) {
|
static int32_t setKeepOption(SSqlCmd* pCmd, SCreateDbMsg* pMsg, SCreateDbInfo* pCreateDb) {
|
||||||
const char* msg = "invalid number of options";
|
const char* msg = "invalid number of options";
|
||||||
|
|
||||||
pMsg->daysToKeep = htonl(-1);
|
pMsg->daysToKeep = htonl(-1);
|
||||||
|
@ -5430,7 +5449,7 @@ static int32_t setKeepOption(SSqlCmd* pCmd, SCreateDbMsg* pMsg, SCreateDBInfo* p
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t setTimePrecision(SSqlCmd* pCmd, SCreateDbMsg* pMsg, SCreateDBInfo* pCreateDbInfo) {
|
static int32_t setTimePrecision(SSqlCmd* pCmd, SCreateDbMsg* pMsg, SCreateDbInfo* pCreateDbInfo) {
|
||||||
const char* msg = "invalid time precision";
|
const char* msg = "invalid time precision";
|
||||||
|
|
||||||
pMsg->precision = TSDB_TIME_PRECISION_MILLI; // millisecond by default
|
pMsg->precision = TSDB_TIME_PRECISION_MILLI; // millisecond by default
|
||||||
|
@ -5454,7 +5473,7 @@ static int32_t setTimePrecision(SSqlCmd* pCmd, SCreateDbMsg* pMsg, SCreateDBInfo
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setCreateDBOption(SCreateDbMsg* pMsg, SCreateDBInfo* pCreateDb) {
|
static void setCreateDBOption(SCreateDbMsg* pMsg, SCreateDbInfo* pCreateDb) {
|
||||||
pMsg->maxTables = htonl(-1); // max tables can not be set anymore
|
pMsg->maxTables = htonl(-1); // max tables can not be set anymore
|
||||||
pMsg->cacheBlockSize = htonl(pCreateDb->cacheBlockSize);
|
pMsg->cacheBlockSize = htonl(pCreateDb->cacheBlockSize);
|
||||||
pMsg->totalBlocks = htonl(pCreateDb->numOfBlocks);
|
pMsg->totalBlocks = htonl(pCreateDb->numOfBlocks);
|
||||||
|
@ -5472,7 +5491,7 @@ static void setCreateDBOption(SCreateDbMsg* pMsg, SCreateDBInfo* pCreateDb) {
|
||||||
pMsg->cacheLastRow = pCreateDb->cachelast;
|
pMsg->cacheLastRow = pCreateDb->cachelast;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t parseCreateDBOptions(SSqlCmd* pCmd, SCreateDBInfo* pCreateDbSql) {
|
int32_t parseCreateDBOptions(SSqlCmd* pCmd, SCreateDbInfo* pCreateDbSql) {
|
||||||
SCreateDbMsg* pMsg = (SCreateDbMsg *)(pCmd->payload);
|
SCreateDbMsg* pMsg = (SCreateDbMsg *)(pCmd->payload);
|
||||||
setCreateDBOption(pMsg, pCreateDbSql);
|
setCreateDBOption(pMsg, pCreateDbSql);
|
||||||
|
|
||||||
|
@ -6233,9 +6252,9 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// get table meta from mnode
|
// get table meta from mnode
|
||||||
tstrncpy(pCreateTableInfo->tagdata.name, pStableMetaInfo->name, tListLen(pCreateTableInfo->tagdata.name));
|
code = tNameExtractFullName(&pStableMetaInfo->name, pCreateTableInfo->tagdata.name);
|
||||||
SArray* pList = pCreateTableInfo->pTagVals;
|
|
||||||
|
|
||||||
|
SArray* pList = pCreateTableInfo->pTagVals;
|
||||||
code = tscGetTableMeta(pSql, pStableMetaInfo);
|
code = tscGetTableMeta(pSql, pStableMetaInfo);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
|
@ -6313,7 +6332,11 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
pCreateTableInfo->fullname = strndup(pTableMetaInfo->name, TSDB_TABLE_FNAME_LEN);
|
pCreateTableInfo->fullname = calloc(1, tNameLen(&pTableMetaInfo->name) + 1);
|
||||||
|
ret = tNameExtractFullName(&pTableMetaInfo->name, pCreateTableInfo->fullname);
|
||||||
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
|
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -6560,7 +6583,7 @@ int32_t doCheckForQuery(SSqlObj* pSql, SQuerySQL* pQuerySql, int32_t index) {
|
||||||
|
|
||||||
// has no table alias name
|
// has no table alias name
|
||||||
if (memcmp(pTableItem->pz, p1->pVar.pz, p1->pVar.nLen) == 0) {
|
if (memcmp(pTableItem->pz, p1->pVar.pz, p1->pVar.nLen) == 0) {
|
||||||
extractTableName(pTableMetaInfo1->name, pTableMetaInfo1->aliasName);
|
strncpy(pTableMetaInfo1->aliasName, tNameGetTableName(&pTableMetaInfo1->name), tListLen(pTableMetaInfo->aliasName));
|
||||||
} else {
|
} else {
|
||||||
tstrncpy(pTableMetaInfo1->aliasName, p1->pVar.pz, sizeof(pTableMetaInfo1->aliasName));
|
tstrncpy(pTableMetaInfo1->aliasName, p1->pVar.pz, sizeof(pTableMetaInfo1->aliasName));
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,6 +106,7 @@ STableMeta* tscCreateTableMetaFromMsg(STableMetaMsg* pTableMetaMsg) {
|
||||||
|
|
||||||
pTableMeta->sversion = pTableMetaMsg->sversion;
|
pTableMeta->sversion = pTableMetaMsg->sversion;
|
||||||
pTableMeta->tversion = pTableMetaMsg->tversion;
|
pTableMeta->tversion = pTableMetaMsg->tversion;
|
||||||
|
|
||||||
tstrncpy(pTableMeta->sTableName, pTableMetaMsg->sTableName, TSDB_TABLE_FNAME_LEN);
|
tstrncpy(pTableMeta->sTableName, pTableMetaMsg->sTableName, TSDB_TABLE_FNAME_LEN);
|
||||||
|
|
||||||
memcpy(pTableMeta->schema, pTableMetaMsg->schema, schemaSize);
|
memcpy(pTableMeta->schema, pTableMetaMsg->schema, schemaSize);
|
||||||
|
|
|
@ -309,7 +309,7 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pEpSet) { // todo update this
|
if (pEpSet) {
|
||||||
if (!tscEpSetIsEqual(&pSql->epSet, pEpSet)) {
|
if (!tscEpSetIsEqual(&pSql->epSet, pEpSet)) {
|
||||||
if (pCmd->command < TSDB_SQL_MGMT) {
|
if (pCmd->command < TSDB_SQL_MGMT) {
|
||||||
tscUpdateVgroupInfo(pSql, pEpSet);
|
tscUpdateVgroupInfo(pSql, pEpSet);
|
||||||
|
@ -461,16 +461,20 @@ int doProcessSql(SSqlObj *pSql) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int tscProcessSql(SSqlObj *pSql) {
|
int tscProcessSql(SSqlObj *pSql) {
|
||||||
char *name = NULL;
|
char name[TSDB_TABLE_FNAME_LEN] = {0};
|
||||||
|
|
||||||
SSqlCmd *pCmd = &pSql->cmd;
|
SSqlCmd *pCmd = &pSql->cmd;
|
||||||
|
uint32_t type = 0;
|
||||||
|
|
||||||
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
||||||
STableMetaInfo *pTableMetaInfo = NULL;
|
STableMetaInfo *pTableMetaInfo = NULL;
|
||||||
uint32_t type = 0;
|
|
||||||
|
|
||||||
if (pQueryInfo != NULL) {
|
if (pQueryInfo != NULL) {
|
||||||
pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||||
name = (pTableMetaInfo != NULL)? pTableMetaInfo->name:NULL;
|
if (pTableMetaInfo != NULL) {
|
||||||
|
tNameExtractFullName(&pTableMetaInfo->name, name);
|
||||||
|
}
|
||||||
|
|
||||||
type = pQueryInfo->type;
|
type = pQueryInfo->type;
|
||||||
|
|
||||||
// while numOfTables equals to 0, it must be Heartbeat
|
// while numOfTables equals to 0, it must be Heartbeat
|
||||||
|
@ -669,10 +673,11 @@ static char *doSerializeTableInfo(SQueryTableMsg* pQueryMsg, SSqlObj *pSql, char
|
||||||
pMsg += sizeof(STableIdInfo);
|
pMsg += sizeof(STableIdInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tscDebug("%p vgId:%d, query on table:%s, tid:%d, uid:%" PRIu64, pSql, htonl(pQueryMsg->head.vgId), pTableMetaInfo->name,
|
char n[TSDB_TABLE_FNAME_LEN] = {0};
|
||||||
pTableMeta->id.tid, pTableMeta->id.uid);
|
tNameExtractFullName(&pTableMetaInfo->name, n);
|
||||||
|
|
||||||
|
tscDebug("%p vgId:%d, query on table:%s, tid:%d, uid:%" PRIu64, pSql, htonl(pQueryMsg->head.vgId), n, pTableMeta->id.tid, pTableMeta->id.uid);
|
||||||
return pMsg;
|
return pMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -755,8 +760,11 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
SSchema *pColSchema = &pSchema[pCol->colIndex.columnIndex];
|
SSchema *pColSchema = &pSchema[pCol->colIndex.columnIndex];
|
||||||
|
|
||||||
if (pCol->colIndex.columnIndex >= tscGetNumOfColumns(pTableMeta) || !isValidDataType(pColSchema->type)) {
|
if (pCol->colIndex.columnIndex >= tscGetNumOfColumns(pTableMeta) || !isValidDataType(pColSchema->type)) {
|
||||||
|
char n[TSDB_TABLE_FNAME_LEN] = {0};
|
||||||
|
tNameExtractFullName(&pTableMetaInfo->name, n);
|
||||||
|
|
||||||
tscError("%p tid:%d uid:%" PRIu64" id:%s, column index out of range, numOfColumns:%d, index:%d, column name:%s",
|
tscError("%p tid:%d uid:%" PRIu64" id:%s, column index out of range, numOfColumns:%d, index:%d, column name:%s",
|
||||||
pSql, pTableMeta->id.tid, pTableMeta->id.uid, pTableMetaInfo->name, tscGetNumOfColumns(pTableMeta), pCol->colIndex.columnIndex,
|
pSql, pTableMeta->id.tid, pTableMeta->id.uid, n, tscGetNumOfColumns(pTableMeta), pCol->colIndex.columnIndex,
|
||||||
pColSchema->name);
|
pColSchema->name);
|
||||||
return TSDB_CODE_TSC_INVALID_SQL;
|
return TSDB_CODE_TSC_INVALID_SQL;
|
||||||
}
|
}
|
||||||
|
@ -942,9 +950,11 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
|
|
||||||
if ((pCol->colIndex.columnIndex >= numOfTagColumns || pCol->colIndex.columnIndex < -1) ||
|
if ((pCol->colIndex.columnIndex >= numOfTagColumns || pCol->colIndex.columnIndex < -1) ||
|
||||||
(!isValidDataType(pColSchema->type))) {
|
(!isValidDataType(pColSchema->type))) {
|
||||||
|
char n[TSDB_TABLE_FNAME_LEN] = {0};
|
||||||
|
tNameExtractFullName(&pTableMetaInfo->name, n);
|
||||||
|
|
||||||
tscError("%p tid:%d uid:%" PRIu64 " id:%s, tag index out of range, totalCols:%d, numOfTags:%d, index:%d, column name:%s",
|
tscError("%p tid:%d uid:%" PRIu64 " id:%s, tag index out of range, totalCols:%d, numOfTags:%d, index:%d, column name:%s",
|
||||||
pSql, pTableMeta->id.tid, pTableMeta->id.uid, pTableMetaInfo->name, total, numOfTagColumns,
|
pSql, pTableMeta->id.tid, pTableMeta->id.uid, n, total, numOfTagColumns, pCol->colIndex.columnIndex, pColSchema->name);
|
||||||
pCol->colIndex.columnIndex, pColSchema->name);
|
|
||||||
|
|
||||||
return TSDB_CODE_TSC_INVALID_SQL;
|
return TSDB_CODE_TSC_INVALID_SQL;
|
||||||
}
|
}
|
||||||
|
@ -1021,7 +1031,8 @@ int32_t tscBuildCreateDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
|
|
||||||
assert(pCmd->numOfClause == 1);
|
assert(pCmd->numOfClause == 1);
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
||||||
tstrncpy(pCreateDbMsg->db, pTableMetaInfo->name, sizeof(pCreateDbMsg->db));
|
int32_t code = tNameExtractFullName(&pTableMetaInfo->name, pCreateDbMsg->db);
|
||||||
|
assert(code == TSDB_CODE_SUCCESS);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1035,7 +1046,9 @@ int32_t tscBuildCreateDnodeMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SCreateDnodeMsg *pCreate = (SCreateDnodeMsg *)pCmd->payload;
|
SCreateDnodeMsg *pCreate = (SCreateDnodeMsg *)pCmd->payload;
|
||||||
strncpy(pCreate->ep, pInfo->pDCLInfo->a[0].z, pInfo->pDCLInfo->a[0].n);
|
|
||||||
|
SStrToken* t0 = taosArrayGet(pInfo->pMiscInfo->a, 0);
|
||||||
|
strncpy(pCreate->ep, t0->z, t0->n);
|
||||||
|
|
||||||
pCmd->msgType = TSDB_MSG_TYPE_CM_CREATE_DNODE;
|
pCmd->msgType = TSDB_MSG_TYPE_CM_CREATE_DNODE;
|
||||||
|
|
||||||
|
@ -1052,13 +1065,13 @@ int32_t tscBuildAcctMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
|
|
||||||
SCreateAcctMsg *pAlterMsg = (SCreateAcctMsg *)pCmd->payload;
|
SCreateAcctMsg *pAlterMsg = (SCreateAcctMsg *)pCmd->payload;
|
||||||
|
|
||||||
SStrToken *pName = &pInfo->pDCLInfo->user.user;
|
SStrToken *pName = &pInfo->pMiscInfo->user.user;
|
||||||
SStrToken *pPwd = &pInfo->pDCLInfo->user.passwd;
|
SStrToken *pPwd = &pInfo->pMiscInfo->user.passwd;
|
||||||
|
|
||||||
strncpy(pAlterMsg->user, pName->z, pName->n);
|
strncpy(pAlterMsg->user, pName->z, pName->n);
|
||||||
strncpy(pAlterMsg->pass, pPwd->z, pPwd->n);
|
strncpy(pAlterMsg->pass, pPwd->z, pPwd->n);
|
||||||
|
|
||||||
SCreateAcctSQL *pAcctOpt = &pInfo->pDCLInfo->acctOpt;
|
SCreateAcctInfo *pAcctOpt = &pInfo->pMiscInfo->acctOpt;
|
||||||
|
|
||||||
pAlterMsg->cfg.maxUsers = htonl(pAcctOpt->maxUsers);
|
pAlterMsg->cfg.maxUsers = htonl(pAcctOpt->maxUsers);
|
||||||
pAlterMsg->cfg.maxDbs = htonl(pAcctOpt->maxDbs);
|
pAlterMsg->cfg.maxDbs = htonl(pAcctOpt->maxDbs);
|
||||||
|
@ -1098,7 +1111,7 @@ int32_t tscBuildUserMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
|
|
||||||
SCreateUserMsg *pAlterMsg = (SCreateUserMsg *)pCmd->payload;
|
SCreateUserMsg *pAlterMsg = (SCreateUserMsg *)pCmd->payload;
|
||||||
|
|
||||||
SUserInfo *pUser = &pInfo->pDCLInfo->user;
|
SUserInfo *pUser = &pInfo->pMiscInfo->user;
|
||||||
strncpy(pAlterMsg->user, pUser->user.z, pUser->user.n);
|
strncpy(pAlterMsg->user, pUser->user.z, pUser->user.n);
|
||||||
pAlterMsg->flag = (int8_t)pUser->type;
|
pAlterMsg->flag = (int8_t)pUser->type;
|
||||||
|
|
||||||
|
@ -1138,8 +1151,11 @@ int32_t tscBuildDropDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
SDropDbMsg *pDropDbMsg = (SDropDbMsg*)pCmd->payload;
|
SDropDbMsg *pDropDbMsg = (SDropDbMsg*)pCmd->payload;
|
||||||
|
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
||||||
tstrncpy(pDropDbMsg->db, pTableMetaInfo->name, sizeof(pDropDbMsg->db));
|
|
||||||
pDropDbMsg->ignoreNotExists = pInfo->pDCLInfo->existsCheck ? 1 : 0;
|
int32_t code = tNameExtractFullName(&pTableMetaInfo->name, pDropDbMsg->db);
|
||||||
|
assert(code == TSDB_CODE_SUCCESS && pTableMetaInfo->name.type == TSDB_DB_NAME_T);
|
||||||
|
|
||||||
|
pDropDbMsg->ignoreNotExists = pInfo->pMiscInfo->existsCheck ? 1 : 0;
|
||||||
|
|
||||||
pCmd->msgType = TSDB_MSG_TYPE_CM_DROP_DB;
|
pCmd->msgType = TSDB_MSG_TYPE_CM_DROP_DB;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -1156,15 +1172,19 @@ int32_t tscBuildDropTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
|
|
||||||
SCMDropTableMsg *pDropTableMsg = (SCMDropTableMsg*)pCmd->payload;
|
SCMDropTableMsg *pDropTableMsg = (SCMDropTableMsg*)pCmd->payload;
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
||||||
strcpy(pDropTableMsg->tableFname, pTableMetaInfo->name);
|
tNameExtractFullName(&pTableMetaInfo->name, pDropTableMsg->name);
|
||||||
pDropTableMsg->igNotExists = pInfo->pDCLInfo->existsCheck ? 1 : 0;
|
|
||||||
|
|
||||||
|
pDropTableMsg->igNotExists = pInfo->pMiscInfo->existsCheck ? 1 : 0;
|
||||||
pCmd->msgType = TSDB_MSG_TYPE_CM_DROP_TABLE;
|
pCmd->msgType = TSDB_MSG_TYPE_CM_DROP_TABLE;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tscBuildDropDnodeMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
int32_t tscBuildDropDnodeMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
SSqlCmd *pCmd = &pSql->cmd;
|
SSqlCmd *pCmd = &pSql->cmd;
|
||||||
|
|
||||||
|
char dnodeEp[TSDB_EP_LEN] = {0};
|
||||||
|
tstrncpy(dnodeEp, pCmd->payload, TSDB_EP_LEN);
|
||||||
|
|
||||||
pCmd->payloadLen = sizeof(SDropDnodeMsg);
|
pCmd->payloadLen = sizeof(SDropDnodeMsg);
|
||||||
if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, pCmd->payloadLen)) {
|
if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, pCmd->payloadLen)) {
|
||||||
tscError("%p failed to malloc for query msg", pSql);
|
tscError("%p failed to malloc for query msg", pSql);
|
||||||
|
@ -1172,43 +1192,28 @@ int32_t tscBuildDropDnodeMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SDropDnodeMsg * pDrop = (SDropDnodeMsg *)pCmd->payload;
|
SDropDnodeMsg * pDrop = (SDropDnodeMsg *)pCmd->payload;
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
tstrncpy(pDrop->ep, dnodeEp, tListLen(pDrop->ep));
|
||||||
tstrncpy(pDrop->ep, pTableMetaInfo->name, sizeof(pDrop->ep));
|
|
||||||
pCmd->msgType = TSDB_MSG_TYPE_CM_DROP_DNODE;
|
pCmd->msgType = TSDB_MSG_TYPE_CM_DROP_DNODE;
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tscBuildDropUserMsg(SSqlObj *pSql, SSqlInfo * UNUSED_PARAM(pInfo)) {
|
int32_t tscBuildDropUserAcctMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
SSqlCmd *pCmd = &pSql->cmd;
|
SSqlCmd *pCmd = &pSql->cmd;
|
||||||
|
|
||||||
|
char user[TSDB_USER_LEN] = {0};
|
||||||
|
tstrncpy(user, pCmd->payload, TSDB_USER_LEN);
|
||||||
|
|
||||||
pCmd->payloadLen = sizeof(SDropUserMsg);
|
pCmd->payloadLen = sizeof(SDropUserMsg);
|
||||||
pCmd->msgType = TSDB_MSG_TYPE_CM_DROP_USER;
|
pCmd->msgType = (pInfo->type == TSDB_SQL_DROP_USER)? TSDB_MSG_TYPE_CM_DROP_USER:TSDB_MSG_TYPE_CM_DROP_ACCT;
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, pCmd->payloadLen)) {
|
if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, pCmd->payloadLen)) {
|
||||||
tscError("%p failed to malloc for query msg", pSql);
|
tscError("%p failed to malloc for query msg", pSql);
|
||||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDropUserMsg * pDropMsg = (SDropUserMsg *)pCmd->payload;
|
SDropUserMsg *pDropMsg = (SDropUserMsg *)pCmd->payload;
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
tstrncpy(pDropMsg->user, user, tListLen(user));
|
||||||
tstrncpy(pDropMsg->user, pTableMetaInfo->name, sizeof(pDropMsg->user));
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t tscBuildDropAcctMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
|
||||||
SSqlCmd *pCmd = &pSql->cmd;
|
|
||||||
pCmd->payloadLen = sizeof(SDropUserMsg);
|
|
||||||
pCmd->msgType = TSDB_MSG_TYPE_CM_DROP_ACCT;
|
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, pCmd->payloadLen)) {
|
|
||||||
tscError("%p failed to malloc for query msg", pSql);
|
|
||||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
SDropUserMsg * pDropMsg = (SDropUserMsg *)pCmd->payload;
|
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
|
||||||
tstrncpy(pDropMsg->user, pTableMetaInfo->name, sizeof(pDropMsg->user));
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1224,7 +1229,7 @@ int32_t tscBuildUseDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
|
|
||||||
SUseDbMsg *pUseDbMsg = (SUseDbMsg *)pCmd->payload;
|
SUseDbMsg *pUseDbMsg = (SUseDbMsg *)pCmd->payload;
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
||||||
strcpy(pUseDbMsg->db, pTableMetaInfo->name);
|
tNameExtractFullName(&pTableMetaInfo->name, pUseDbMsg->db);
|
||||||
pCmd->msgType = TSDB_MSG_TYPE_CM_USE_DB;
|
pCmd->msgType = TSDB_MSG_TYPE_CM_USE_DB;
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -1244,14 +1249,14 @@ int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
SShowMsg *pShowMsg = (SShowMsg *)pCmd->payload;
|
SShowMsg *pShowMsg = (SShowMsg *)pCmd->payload;
|
||||||
|
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
||||||
size_t nameLen = strlen(pTableMetaInfo->name);
|
|
||||||
if (nameLen > 0) {
|
if (tNameIsEmpty(&pTableMetaInfo->name)) {
|
||||||
tstrncpy(pShowMsg->db, pTableMetaInfo->name, sizeof(pShowMsg->db)); // prefix is set here
|
|
||||||
} else {
|
|
||||||
tstrncpy(pShowMsg->db, pObj->db, sizeof(pShowMsg->db));
|
tstrncpy(pShowMsg->db, pObj->db, sizeof(pShowMsg->db));
|
||||||
|
} else {
|
||||||
|
tNameGetFullDbName(&pTableMetaInfo->name, pShowMsg->db);
|
||||||
}
|
}
|
||||||
|
|
||||||
SShowInfo *pShowInfo = &pInfo->pDCLInfo->showOpt;
|
SShowInfo *pShowInfo = &pInfo->pMiscInfo->showOpt;
|
||||||
pShowMsg->type = pShowInfo->showType;
|
pShowMsg->type = pShowInfo->showType;
|
||||||
|
|
||||||
if (pShowInfo->showType != TSDB_MGMT_TABLE_VNODES) {
|
if (pShowInfo->showType != TSDB_MGMT_TABLE_VNODES) {
|
||||||
|
@ -1310,12 +1315,12 @@ int tscEstimateCreateTableMsgLength(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int tscBuildCreateTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
int tscBuildCreateTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
int msgLen = 0;
|
int msgLen = 0;
|
||||||
SSchema * pSchema;
|
int size = 0;
|
||||||
int size = 0;
|
SSchema *pSchema;
|
||||||
SSqlCmd *pCmd = &pSql->cmd;
|
SSqlCmd *pCmd = &pSql->cmd;
|
||||||
|
|
||||||
SQueryInfo * pQueryInfo = tscGetQueryInfoDetail(pCmd, 0);
|
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, 0);
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||||
|
|
||||||
// Reallocate the payload size
|
// Reallocate the payload size
|
||||||
|
@ -1346,11 +1351,10 @@ int tscBuildCreateTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
pMsg += sizeof(SCreateTableMsg);
|
pMsg += sizeof(SCreateTableMsg);
|
||||||
|
|
||||||
SCreatedTableInfo* p = taosArrayGet(list, i);
|
SCreatedTableInfo* p = taosArrayGet(list, i);
|
||||||
strcpy(pCreate->tableFname, p->fullname);
|
strcpy(pCreate->tableName, p->fullname);
|
||||||
pCreate->igExists = (p->igExist)? 1 : 0;
|
pCreate->igExists = (p->igExist)? 1 : 0;
|
||||||
|
|
||||||
// use dbinfo from table id without modifying current db info
|
// use dbinfo from table id without modifying current db info
|
||||||
tscGetDBInfoFromTableFullName(p->fullname, pCreate->db);
|
|
||||||
pMsg = serializeTagData(&p->tagdata, pMsg);
|
pMsg = serializeTagData(&p->tagdata, pMsg);
|
||||||
|
|
||||||
int32_t len = (int32_t)(pMsg - (char*) pCreate);
|
int32_t len = (int32_t)(pMsg - (char*) pCreate);
|
||||||
|
@ -1359,10 +1363,8 @@ int tscBuildCreateTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
} else { // create (super) table
|
} else { // create (super) table
|
||||||
pCreateTableMsg->numOfTables = htonl(1); // only one table will be created
|
pCreateTableMsg->numOfTables = htonl(1); // only one table will be created
|
||||||
|
|
||||||
strcpy(pCreateMsg->tableFname, pTableMetaInfo->name);
|
int32_t code = tNameExtractFullName(&pTableMetaInfo->name, pCreateMsg->tableName);
|
||||||
|
assert(code == 0);
|
||||||
// use dbinfo from table id without modifying current db info
|
|
||||||
tscGetDBInfoFromTableFullName(pTableMetaInfo->name, pCreateMsg->db);
|
|
||||||
|
|
||||||
SCreateTableSQL *pCreateTable = pInfo->pCreateTableInfo;
|
SCreateTableSQL *pCreateTable = pInfo->pCreateTableInfo;
|
||||||
|
|
||||||
|
@ -1420,7 +1422,7 @@ int tscBuildAlterTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
|
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||||
|
|
||||||
SAlterTableSQL *pAlterInfo = pInfo->pAlterInfo;
|
SAlterTableInfo *pAlterInfo = pInfo->pAlterInfo;
|
||||||
int size = tscEstimateAlterTableMsgLength(pCmd);
|
int size = tscEstimateAlterTableMsgLength(pCmd);
|
||||||
if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, size)) {
|
if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, size)) {
|
||||||
tscError("%p failed to malloc for alter table msg", pSql);
|
tscError("%p failed to malloc for alter table msg", pSql);
|
||||||
|
@ -1428,9 +1430,8 @@ int tscBuildAlterTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SAlterTableMsg *pAlterTableMsg = (SAlterTableMsg *)pCmd->payload;
|
SAlterTableMsg *pAlterTableMsg = (SAlterTableMsg *)pCmd->payload;
|
||||||
tscGetDBInfoFromTableFullName(pTableMetaInfo->name, pAlterTableMsg->db);
|
|
||||||
|
|
||||||
strcpy(pAlterTableMsg->tableFname, pTableMetaInfo->name);
|
tNameExtractFullName(&pTableMetaInfo->name, pAlterTableMsg->tableFname);
|
||||||
pAlterTableMsg->type = htons(pAlterInfo->type);
|
pAlterTableMsg->type = htons(pAlterInfo->type);
|
||||||
|
|
||||||
pAlterTableMsg->numOfCols = htons(tscNumOfFields(pQueryInfo));
|
pAlterTableMsg->numOfCols = htons(tscNumOfFields(pQueryInfo));
|
||||||
|
@ -1485,7 +1486,7 @@ int tscAlterDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
|
|
||||||
SAlterDbMsg *pAlterDbMsg = (SAlterDbMsg* )pCmd->payload;
|
SAlterDbMsg *pAlterDbMsg = (SAlterDbMsg* )pCmd->payload;
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0);
|
||||||
tstrncpy(pAlterDbMsg->db, pTableMetaInfo->name, sizeof(pAlterDbMsg->db));
|
tNameExtractFullName(&pTableMetaInfo->name, pAlterDbMsg->db);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1623,13 +1624,17 @@ int tscBuildConnectMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int tscBuildTableMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
int tscBuildTableMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
SSqlCmd * pCmd = &pSql->cmd;
|
SSqlCmd *pCmd = &pSql->cmd;
|
||||||
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0);
|
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0);
|
||||||
|
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
|
||||||
|
STableInfoMsg *pInfoMsg = (STableInfoMsg *)pCmd->payload;
|
||||||
|
|
||||||
|
int32_t code = tNameExtractFullName(&pTableMetaInfo->name, pInfoMsg->tableFname);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
return TSDB_CODE_TSC_INVALID_SQL;
|
||||||
|
}
|
||||||
|
|
||||||
STableInfoMsg *pInfoMsg = (STableInfoMsg *)pCmd->payload;
|
|
||||||
strcpy(pInfoMsg->tableFname, pTableMetaInfo->name);
|
|
||||||
pInfoMsg->createFlag = htons(pSql->cmd.autoCreated ? 1 : 0);
|
pInfoMsg->createFlag = htons(pSql->cmd.autoCreated ? 1 : 0);
|
||||||
|
|
||||||
char *pMsg = (char *)pInfoMsg + sizeof(STableInfoMsg);
|
char *pMsg = (char *)pInfoMsg + sizeof(STableInfoMsg);
|
||||||
|
@ -1686,33 +1691,6 @@ int tscBuildMultiMeterMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//static UNUSED_FUNC int32_t tscEstimateMetricMetaMsgSize(SSqlCmd *pCmd) {
|
|
||||||
//// const int32_t defaultSize =
|
|
||||||
//// minMsgSize() + sizeof(SSuperTableMetaMsg) + sizeof(SMgmtHead) + sizeof(int16_t) * TSDB_MAX_TAGS;
|
|
||||||
//// SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, 0);
|
|
||||||
////
|
|
||||||
//// int32_t n = 0;
|
|
||||||
//// size_t size = taosArrayGetSize(pQueryInfo->tagCond.pCond);
|
|
||||||
//// for (int32_t i = 0; i < size; ++i) {
|
|
||||||
//// assert(0);
|
|
||||||
////// n += strlen(pQueryInfo->tagCond.cond[i].cond);
|
|
||||||
//// }
|
|
||||||
////
|
|
||||||
//// int32_t tagLen = n * TSDB_NCHAR_SIZE;
|
|
||||||
//// if (pQueryInfo->tagCond.tbnameCond.cond != NULL) {
|
|
||||||
//// tagLen += strlen(pQueryInfo->tagCond.tbnameCond.cond) * TSDB_NCHAR_SIZE;
|
|
||||||
//// }
|
|
||||||
////
|
|
||||||
//// int32_t joinCondLen = (TSDB_TABLE_FNAME_LEN + sizeof(int16_t)) * 2;
|
|
||||||
//// int32_t elemSize = sizeof(SSuperTableMetaElemMsg) * pQueryInfo->numOfTables;
|
|
||||||
////
|
|
||||||
//// int32_t colSize = pQueryInfo->groupbyExpr.numOfGroupCols*sizeof(SColIndex);
|
|
||||||
////
|
|
||||||
//// int32_t len = tagLen + joinCondLen + elemSize + colSize + defaultSize;
|
|
||||||
////
|
|
||||||
//// return MAX(len, TSDB_DEFAULT_PAYLOAD_SIZE);
|
|
||||||
//}
|
|
||||||
|
|
||||||
int tscBuildSTableVgroupMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
int tscBuildSTableVgroupMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
SSqlCmd *pCmd = &pSql->cmd;
|
SSqlCmd *pCmd = &pSql->cmd;
|
||||||
|
|
||||||
|
@ -1725,9 +1703,10 @@ int tscBuildSTableVgroupMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
|
|
||||||
for (int32_t i = 0; i < pQueryInfo->numOfTables; ++i) {
|
for (int32_t i = 0; i < pQueryInfo->numOfTables; ++i) {
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, i);
|
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, i);
|
||||||
size_t size = sizeof(pTableMetaInfo->name);
|
int32_t code = tNameExtractFullName(&pTableMetaInfo->name, pMsg);
|
||||||
tstrncpy(pMsg, pTableMetaInfo->name, size);
|
assert(code == TSDB_CODE_SUCCESS);
|
||||||
pMsg += size;
|
|
||||||
|
pMsg += TSDB_TABLE_FNAME_LEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
pCmd->msgType = TSDB_MSG_TYPE_CM_STABLE_VGROUP;
|
pCmd->msgType = TSDB_MSG_TYPE_CM_STABLE_VGROUP;
|
||||||
|
@ -1827,7 +1806,6 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) {
|
||||||
assert(i == 0);
|
assert(i == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(isValidDataType(pSchema->type));
|
|
||||||
pSchema++;
|
pSchema++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1835,8 +1813,8 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) {
|
||||||
assert(pTableMetaInfo->pTableMeta == NULL);
|
assert(pTableMetaInfo->pTableMeta == NULL);
|
||||||
|
|
||||||
STableMeta* pTableMeta = tscCreateTableMetaFromMsg(pMetaMsg);
|
STableMeta* pTableMeta = tscCreateTableMetaFromMsg(pMetaMsg);
|
||||||
if (!isValidSchema(pTableMeta->schema, pTableMeta->tableInfo.numOfColumns, pTableMeta->tableInfo.numOfTags)) {
|
if (!tIsValidSchema(pTableMeta->schema, pTableMeta->tableInfo.numOfColumns, pTableMeta->tableInfo.numOfTags)) {
|
||||||
tscError("%p invalid table meta from mnode, name:%s", pSql, pTableMetaInfo->name);
|
tscError("%p invalid table meta from mnode, name:%s", pSql, tNameGetTableName(&pTableMetaInfo->name));
|
||||||
return TSDB_CODE_TSC_INVALID_VALUE;
|
return TSDB_CODE_TSC_INVALID_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1854,11 +1832,19 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) {
|
||||||
tfree(pSupTableMeta);
|
tfree(pSupTableMeta);
|
||||||
|
|
||||||
CChildTableMeta* cMeta = tscCreateChildMeta(pTableMeta);
|
CChildTableMeta* cMeta = tscCreateChildMeta(pTableMeta);
|
||||||
taosHashPut(tscTableMetaInfo, pTableMetaInfo->name, strlen(pTableMetaInfo->name), cMeta, sizeof(CChildTableMeta));
|
|
||||||
|
char name[TSDB_TABLE_FNAME_LEN] = {0};
|
||||||
|
tNameExtractFullName(&pTableMetaInfo->name, name);
|
||||||
|
|
||||||
|
taosHashPut(tscTableMetaInfo, name, strlen(name), cMeta, sizeof(CChildTableMeta));
|
||||||
tfree(cMeta);
|
tfree(cMeta);
|
||||||
} else {
|
} else {
|
||||||
uint32_t s = tscGetTableMetaSize(pTableMeta);
|
uint32_t s = tscGetTableMetaSize(pTableMeta);
|
||||||
taosHashPut(tscTableMetaInfo, pTableMetaInfo->name, strlen(pTableMetaInfo->name), pTableMeta, s);
|
|
||||||
|
char name[TSDB_TABLE_FNAME_LEN] = {0};
|
||||||
|
tNameExtractFullName(&pTableMetaInfo->name, name);
|
||||||
|
|
||||||
|
taosHashPut(tscTableMetaInfo, name, strlen(name), pTableMeta, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the vgroupInfo if needed
|
// update the vgroupInfo if needed
|
||||||
|
@ -1877,9 +1863,10 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tscDebug("%p recv table meta, uid:%"PRId64 ", tid:%d, name:%s", pSql, pTableMeta->id.uid, pTableMeta->id.tid, pTableMetaInfo->name);
|
tscDebug("%p recv table meta, uid:%" PRIu64 ", tid:%d, name:%s", pSql, pTableMeta->id.uid, pTableMeta->id.tid,
|
||||||
|
tNameGetTableName(&pTableMetaInfo->name));
|
||||||
|
|
||||||
free(pTableMeta);
|
free(pTableMeta);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2174,9 +2161,7 @@ int tscProcessConnectRsp(SSqlObj *pSql) {
|
||||||
int tscProcessUseDbRsp(SSqlObj *pSql) {
|
int tscProcessUseDbRsp(SSqlObj *pSql) {
|
||||||
STscObj * pObj = pSql->pTscObj;
|
STscObj * pObj = pSql->pTscObj;
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, 0, 0);
|
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, 0, 0);
|
||||||
|
return tNameExtractFullName(&pTableMetaInfo->name, pObj->db);
|
||||||
tstrncpy(pObj->db, pTableMetaInfo->name, sizeof(pObj->db));
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int tscProcessDropDbRsp(SSqlObj *pSql) {
|
int tscProcessDropDbRsp(SSqlObj *pSql) {
|
||||||
|
@ -2189,9 +2174,11 @@ int tscProcessDropTableRsp(SSqlObj *pSql) {
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, 0, 0);
|
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, 0, 0);
|
||||||
|
|
||||||
//The cached tableMeta is expired in this case, so clean it in hash table
|
//The cached tableMeta is expired in this case, so clean it in hash table
|
||||||
taosHashRemove(tscTableMetaInfo, pTableMetaInfo->name, strnlen(pTableMetaInfo->name, TSDB_TABLE_FNAME_LEN));
|
char name[TSDB_TABLE_FNAME_LEN] = {0};
|
||||||
tscDebug("%p remove table meta after drop table:%s, numOfRemain:%d", pSql, pTableMetaInfo->name,
|
tNameExtractFullName(&pTableMetaInfo->name, name);
|
||||||
(int32_t) taosHashGetSize(tscTableMetaInfo));
|
|
||||||
|
taosHashRemove(tscTableMetaInfo, name, strnlen(name, TSDB_TABLE_FNAME_LEN));
|
||||||
|
tscDebug("%p remove table meta after drop table:%s, numOfRemain:%d", pSql, name, (int32_t) taosHashGetSize(tscTableMetaInfo));
|
||||||
|
|
||||||
pTableMetaInfo->pTableMeta = NULL;
|
pTableMetaInfo->pTableMeta = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2200,7 +2187,9 @@ int tscProcessDropTableRsp(SSqlObj *pSql) {
|
||||||
int tscProcessAlterTableMsgRsp(SSqlObj *pSql) {
|
int tscProcessAlterTableMsgRsp(SSqlObj *pSql) {
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, 0, 0);
|
STableMetaInfo *pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, 0, 0);
|
||||||
|
|
||||||
char* name = pTableMetaInfo->name;
|
char name[TSDB_TABLE_FNAME_LEN] = {0};
|
||||||
|
tNameExtractFullName(&pTableMetaInfo->name, name);
|
||||||
|
|
||||||
tscDebug("%p remove tableMeta in hashMap after alter-table: %s", pSql, name);
|
tscDebug("%p remove tableMeta in hashMap after alter-table: %s", pSql, name);
|
||||||
|
|
||||||
bool isSuperTable = UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo);
|
bool isSuperTable = UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo);
|
||||||
|
@ -2319,7 +2308,7 @@ static int32_t getTableMetaFromMnode(SSqlObj *pSql, STableMetaInfo *pTableMetaIn
|
||||||
STableMetaInfo *pNewMeterMetaInfo = tscAddEmptyMetaInfo(pNewQueryInfo);
|
STableMetaInfo *pNewMeterMetaInfo = tscAddEmptyMetaInfo(pNewQueryInfo);
|
||||||
assert(pNew->cmd.numOfClause == 1 && pNewQueryInfo->numOfTables == 1);
|
assert(pNew->cmd.numOfClause == 1 && pNewQueryInfo->numOfTables == 1);
|
||||||
|
|
||||||
tstrncpy(pNewMeterMetaInfo->name, pTableMetaInfo->name, sizeof(pNewMeterMetaInfo->name));
|
tNameAssign(&pNewMeterMetaInfo->name, &pTableMetaInfo->name);
|
||||||
|
|
||||||
if (pSql->cmd.autoCreated) {
|
if (pSql->cmd.autoCreated) {
|
||||||
int32_t code = copyTagData(&pNew->cmd.tagData, &pSql->cmd.tagData);
|
int32_t code = copyTagData(&pNew->cmd.tagData, &pSql->cmd.tagData);
|
||||||
|
@ -2350,7 +2339,8 @@ static int32_t getTableMetaFromMnode(SSqlObj *pSql, STableMetaInfo *pTableMetaIn
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tscGetTableMeta(SSqlObj *pSql, STableMetaInfo *pTableMetaInfo) {
|
int32_t tscGetTableMeta(SSqlObj *pSql, STableMetaInfo *pTableMetaInfo) {
|
||||||
assert(strlen(pTableMetaInfo->name) != 0);
|
assert(tIsValidName(&pTableMetaInfo->name));
|
||||||
|
|
||||||
tfree(pTableMetaInfo->pTableMeta);
|
tfree(pTableMetaInfo->pTableMeta);
|
||||||
|
|
||||||
uint32_t size = tscGetTableMetaMaxSize();
|
uint32_t size = tscGetTableMetaMaxSize();
|
||||||
|
@ -2358,15 +2348,18 @@ int32_t tscGetTableMeta(SSqlObj *pSql, STableMetaInfo *pTableMetaInfo) {
|
||||||
|
|
||||||
pTableMetaInfo->pTableMeta->tableType = -1;
|
pTableMetaInfo->pTableMeta->tableType = -1;
|
||||||
pTableMetaInfo->pTableMeta->tableInfo.numOfColumns = -1;
|
pTableMetaInfo->pTableMeta->tableInfo.numOfColumns = -1;
|
||||||
int32_t len = (int32_t) strlen(pTableMetaInfo->name);
|
|
||||||
|
|
||||||
taosHashGetClone(tscTableMetaInfo, pTableMetaInfo->name, len, NULL, pTableMetaInfo->pTableMeta, -1);
|
char name[TSDB_TABLE_FNAME_LEN] = {0};
|
||||||
|
tNameExtractFullName(&pTableMetaInfo->name, name);
|
||||||
|
|
||||||
|
size_t len = strlen(name);
|
||||||
|
taosHashGetClone(tscTableMetaInfo, name, len, NULL, pTableMetaInfo->pTableMeta, -1);
|
||||||
|
|
||||||
// TODO resize the tableMeta
|
// TODO resize the tableMeta
|
||||||
STableMeta* pMeta = pTableMetaInfo->pTableMeta;
|
STableMeta* pMeta = pTableMetaInfo->pTableMeta;
|
||||||
if (pMeta->id.uid > 0) {
|
if (pMeta->id.uid > 0) {
|
||||||
if (pMeta->tableType == TSDB_CHILD_TABLE) {
|
if (pMeta->tableType == TSDB_CHILD_TABLE) {
|
||||||
int32_t code = tscCreateTableMetaFromCChildMeta(pTableMetaInfo->pTableMeta, pTableMetaInfo->name);
|
int32_t code = tscCreateTableMetaFromCChildMeta(pTableMetaInfo->pTableMeta, name);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return getTableMetaFromMnode(pSql, pTableMetaInfo);
|
return getTableMetaFromMnode(pSql, pTableMetaInfo);
|
||||||
}
|
}
|
||||||
|
@ -2394,16 +2387,24 @@ int tscRenewTableMeta(SSqlObj *pSql, int32_t tableIndex) {
|
||||||
|
|
||||||
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, 0);
|
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, 0);
|
||||||
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, tableIndex);
|
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, tableIndex);
|
||||||
const char* name = pTableMetaInfo->name;
|
|
||||||
|
char name[TSDB_TABLE_FNAME_LEN] = {0};
|
||||||
|
int32_t code = tNameExtractFullName(&pTableMetaInfo->name, name);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
tscError("%p failed to generate the table full name", pSql);
|
||||||
|
return TSDB_CODE_TSC_INVALID_SQL;
|
||||||
|
}
|
||||||
|
|
||||||
STableMeta* pTableMeta = pTableMetaInfo->pTableMeta;
|
STableMeta* pTableMeta = pTableMetaInfo->pTableMeta;
|
||||||
if (pTableMeta) {
|
if (pTableMeta) {
|
||||||
tscDebug("%p update table meta:%s, old meta numOfTags:%d, numOfCols:%d, uid:%" PRId64, pSql, name,
|
tscDebug("%p update table meta:%s, old meta numOfTags:%d, numOfCols:%d, uid:%" PRId64, pSql, name,
|
||||||
tscGetNumOfTags(pTableMeta), tscGetNumOfColumns(pTableMeta), pTableMeta->id.uid);
|
tscGetNumOfTags(pTableMeta), tscGetNumOfColumns(pTableMeta), pTableMeta->id.uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove stored tableMeta info in hash table
|
// remove stored tableMeta info in hash table
|
||||||
taosHashRemove(tscTableMetaInfo, name, strnlen(name, TSDB_TABLE_FNAME_LEN));
|
size_t len = strlen(name);
|
||||||
|
taosHashRemove(tscTableMetaInfo, name, len);
|
||||||
|
|
||||||
return getTableMetaFromMnode(pSql, pTableMetaInfo);
|
return getTableMetaFromMnode(pSql, pTableMetaInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2444,8 +2445,8 @@ int tscGetSTableVgroupInfo(SSqlObj *pSql, int32_t clauseIndex) {
|
||||||
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, clauseIndex);
|
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, clauseIndex);
|
||||||
for (int32_t i = 0; i < pQueryInfo->numOfTables; ++i) {
|
for (int32_t i = 0; i < pQueryInfo->numOfTables; ++i) {
|
||||||
STableMetaInfo *pMInfo = tscGetMetaInfo(pQueryInfo, i);
|
STableMetaInfo *pMInfo = tscGetMetaInfo(pQueryInfo, i);
|
||||||
STableMeta* pTableMeta = tscTableMetaClone(pMInfo->pTableMeta);
|
STableMeta* pTableMeta = tscTableMetaDup(pMInfo->pTableMeta);
|
||||||
tscAddTableMetaInfo(pNewQueryInfo, pMInfo->name, pTableMeta, NULL, pMInfo->tagColList, pMInfo->pVgroupTables);
|
tscAddTableMetaInfo(pNewQueryInfo, &pMInfo->name, pTableMeta, NULL, pMInfo->tagColList, pMInfo->pVgroupTables);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((code = tscAllocPayload(&pNew->cmd, TSDB_DEFAULT_PAYLOAD_SIZE)) != TSDB_CODE_SUCCESS) {
|
if ((code = tscAllocPayload(&pNew->cmd, TSDB_DEFAULT_PAYLOAD_SIZE)) != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -2485,8 +2486,8 @@ void tscInitMsgsFp() {
|
||||||
tscBuildMsg[TSDB_SQL_ALTER_ACCT] = tscBuildAcctMsg;
|
tscBuildMsg[TSDB_SQL_ALTER_ACCT] = tscBuildAcctMsg;
|
||||||
|
|
||||||
tscBuildMsg[TSDB_SQL_CREATE_TABLE] = tscBuildCreateTableMsg;
|
tscBuildMsg[TSDB_SQL_CREATE_TABLE] = tscBuildCreateTableMsg;
|
||||||
tscBuildMsg[TSDB_SQL_DROP_USER] = tscBuildDropUserMsg;
|
tscBuildMsg[TSDB_SQL_DROP_USER] = tscBuildDropUserAcctMsg;
|
||||||
tscBuildMsg[TSDB_SQL_DROP_ACCT] = tscBuildDropAcctMsg;
|
tscBuildMsg[TSDB_SQL_DROP_ACCT] = tscBuildDropUserAcctMsg;
|
||||||
tscBuildMsg[TSDB_SQL_DROP_DB] = tscBuildDropDbMsg;
|
tscBuildMsg[TSDB_SQL_DROP_DB] = tscBuildDropDbMsg;
|
||||||
tscBuildMsg[TSDB_SQL_DROP_TABLE] = tscBuildDropTableMsg;
|
tscBuildMsg[TSDB_SQL_DROP_TABLE] = tscBuildDropTableMsg;
|
||||||
tscBuildMsg[TSDB_SQL_ALTER_USER] = tscBuildUserMsg;
|
tscBuildMsg[TSDB_SQL_ALTER_USER] = tscBuildUserMsg;
|
||||||
|
|
|
@ -995,7 +995,8 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (payloadLen + strlen(pTableMetaInfo->name) + 128 >= pCmd->allocSize) {
|
int32_t xlen = tNameLen(&pTableMetaInfo->name);
|
||||||
|
if (payloadLen + xlen + 128 >= pCmd->allocSize) {
|
||||||
char *pNewMem = realloc(pCmd->payload, pCmd->allocSize + tblListLen);
|
char *pNewMem = realloc(pCmd->payload, pCmd->allocSize + tblListLen);
|
||||||
if (pNewMem == NULL) {
|
if (pNewMem == NULL) {
|
||||||
code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
|
@ -1008,7 +1009,9 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t
|
||||||
pMsg = pCmd->payload;
|
pMsg = pCmd->payload;
|
||||||
}
|
}
|
||||||
|
|
||||||
payloadLen += sprintf(pMsg + payloadLen, "%s,", pTableMetaInfo->name);
|
char n[TSDB_TABLE_FNAME_LEN] = {0};
|
||||||
|
tNameExtractFullName(&pTableMetaInfo->name, n);
|
||||||
|
payloadLen += sprintf(pMsg + payloadLen, "%s,", n);
|
||||||
}
|
}
|
||||||
|
|
||||||
*(pMsg + payloadLen) = '\0';
|
*(pMsg + payloadLen) = '\0';
|
||||||
|
|
|
@ -104,7 +104,7 @@ static void doLaunchQuery(void* param, TAOS_RES* tres, int32_t code) {
|
||||||
// failed to get table Meta or vgroup list, retry in 10sec.
|
// failed to get table Meta or vgroup list, retry in 10sec.
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
tscTansformSQLFuncForSTableQuery(pQueryInfo);
|
tscTansformSQLFuncForSTableQuery(pQueryInfo);
|
||||||
tscDebug("%p stream:%p, start stream query on:%s", pSql, pStream, pTableMetaInfo->name);
|
tscDebug("%p stream:%p, start stream query on:%s", pSql, pStream, tNameGetTableName(&pTableMetaInfo->name));
|
||||||
|
|
||||||
pSql->fp = tscProcessStreamQueryCallback;
|
pSql->fp = tscProcessStreamQueryCallback;
|
||||||
pSql->fetchFp = tscProcessStreamQueryCallback;
|
pSql->fetchFp = tscProcessStreamQueryCallback;
|
||||||
|
@ -191,8 +191,9 @@ static void tscProcessStreamQueryCallback(void *param, TAOS_RES *tres, int numOf
|
||||||
|
|
||||||
STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pStream->pSql->cmd, 0, 0);
|
STableMetaInfo* pTableMetaInfo = tscGetTableMetaInfoFromCmd(&pStream->pSql->cmd, 0, 0);
|
||||||
|
|
||||||
char* name = pTableMetaInfo->name;
|
assert(0);
|
||||||
taosHashRemove(tscTableMetaInfo, name, strnlen(name, TSDB_TABLE_FNAME_LEN));
|
// char* name = pTableMetaInfo->name;
|
||||||
|
// taosHashRemove(tscTableMetaInfo, name, strnlen(name, TSDB_TABLE_FNAME_LEN));
|
||||||
pTableMetaInfo->vgroupList = tscVgroupInfoClear(pTableMetaInfo->vgroupList);
|
pTableMetaInfo->vgroupList = tscVgroupInfoClear(pTableMetaInfo->vgroupList);
|
||||||
|
|
||||||
tscSetRetryTimer(pStream, pStream->pSql, retryDelay);
|
tscSetRetryTimer(pStream, pStream->pSql, retryDelay);
|
||||||
|
@ -291,8 +292,8 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
|
||||||
pStream->stime += 1;
|
pStream->stime += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tscDebug("%p stream:%p, query on:%s, fetch result completed, fetched rows:%" PRId64, pSql, pStream, pTableMetaInfo->name,
|
// tscDebug("%p stream:%p, query on:%s, fetch result completed, fetched rows:%" PRId64, pSql, pStream, pTableMetaInfo->name,
|
||||||
pStream->numOfRes);
|
// pStream->numOfRes);
|
||||||
|
|
||||||
tfree(pTableMetaInfo->pTableMeta);
|
tfree(pTableMetaInfo->pTableMeta);
|
||||||
|
|
||||||
|
@ -555,8 +556,8 @@ static void tscCreateStream(void *param, TAOS_RES *res, int code) {
|
||||||
|
|
||||||
taosTmrReset(tscProcessStreamTimer, (int32_t)starttime, pStream, tscTmr, &pStream->pTimer);
|
taosTmrReset(tscProcessStreamTimer, (int32_t)starttime, pStream, tscTmr, &pStream->pTimer);
|
||||||
|
|
||||||
tscDebug("%p stream:%p is opened, query on:%s, interval:%" PRId64 ", sliding:%" PRId64 ", first launched in:%" PRId64 ", sql:%s", pSql,
|
// tscDebug("%p stream:%p is opened, query on:%s, interval:%" PRId64 ", sliding:%" PRId64 ", first launched in:%" PRId64 ", sql:%s", pSql,
|
||||||
pStream, pTableMetaInfo->name, pStream->interval.interval, pStream->interval.sliding, starttime, pSql->sqlstr);
|
// pStream, pTableMetaInfo->name, pStream->interval.interval, pStream->interval.sliding, starttime, pSql->sqlstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscSetStreamDestTable(SSqlStream* pStream, const char* dstTable) {
|
void tscSetStreamDestTable(SSqlStream* pStream, const char* dstTable) {
|
||||||
|
|
|
@ -534,7 +534,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
|
||||||
size_t numOfCols = taosArrayGetSize(pQueryInfo->colList);
|
size_t numOfCols = taosArrayGetSize(pQueryInfo->colList);
|
||||||
tscDebug("%p subquery:%p tableIndex:%d, vgroupIndex:%d, type:%d, exprInfo:%" PRIzu ", colList:%" PRIzu ", fieldsInfo:%d, name:%s",
|
tscDebug("%p subquery:%p tableIndex:%d, vgroupIndex:%d, type:%d, exprInfo:%" PRIzu ", colList:%" PRIzu ", fieldsInfo:%d, name:%s",
|
||||||
pSql, pNew, 0, pTableMetaInfo->vgroupIndex, pQueryInfo->type, taosArrayGetSize(pQueryInfo->exprList),
|
pSql, pNew, 0, pTableMetaInfo->vgroupIndex, pQueryInfo->type, taosArrayGetSize(pQueryInfo->exprList),
|
||||||
numOfCols, pQueryInfo->fieldsInfo.numOfOutput, pTableMetaInfo->name);
|
numOfCols, pQueryInfo->fieldsInfo.numOfOutput, tNameGetTableName(&pTableMetaInfo->name));
|
||||||
}
|
}
|
||||||
|
|
||||||
//prepare the subqueries object failed, abort
|
//prepare the subqueries object failed, abort
|
||||||
|
@ -730,7 +730,7 @@ static void issueTSCompQuery(SSqlObj* pSql, SJoinSupporter* pSupporter, SSqlObj*
|
||||||
"%p subquery:%p tableIndex:%d, vgroupIndex:%d, numOfVgroups:%d, type:%d, ts_comp query to retrieve timestamps, "
|
"%p subquery:%p tableIndex:%d, vgroupIndex:%d, numOfVgroups:%d, type:%d, ts_comp query to retrieve timestamps, "
|
||||||
"numOfExpr:%" PRIzu ", colList:%" PRIzu ", numOfOutputFields:%d, name:%s",
|
"numOfExpr:%" PRIzu ", colList:%" PRIzu ", numOfOutputFields:%d, name:%s",
|
||||||
pParent, pSql, 0, pTableMetaInfo->vgroupIndex, pTableMetaInfo->vgroupList->numOfVgroups, pQueryInfo->type,
|
pParent, pSql, 0, pTableMetaInfo->vgroupIndex, pTableMetaInfo->vgroupList->numOfVgroups, pQueryInfo->type,
|
||||||
tscSqlExprNumOfExprs(pQueryInfo), numOfCols, pQueryInfo->fieldsInfo.numOfOutput, pTableMetaInfo->name);
|
tscSqlExprNumOfExprs(pQueryInfo), numOfCols, pQueryInfo->fieldsInfo.numOfOutput, tNameGetTableName(&pTableMetaInfo->name));
|
||||||
|
|
||||||
tscProcessSql(pSql);
|
tscProcessSql(pSql);
|
||||||
}
|
}
|
||||||
|
@ -951,10 +951,10 @@ static void tidTagRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
|
||||||
tscBuildVgroupTableInfo(pParentSql, pTableMetaInfo2, s2);
|
tscBuildVgroupTableInfo(pParentSql, pTableMetaInfo2, s2);
|
||||||
|
|
||||||
SSqlObj* psub1 = pParentSql->pSubs[0];
|
SSqlObj* psub1 = pParentSql->pSubs[0];
|
||||||
((SJoinSupporter*)psub1->param)->pVgroupTables = tscVgroupTableInfoClone(pTableMetaInfo1->pVgroupTables);
|
((SJoinSupporter*)psub1->param)->pVgroupTables = tscVgroupTableInfoDup(pTableMetaInfo1->pVgroupTables);
|
||||||
|
|
||||||
SSqlObj* psub2 = pParentSql->pSubs[1];
|
SSqlObj* psub2 = pParentSql->pSubs[1];
|
||||||
((SJoinSupporter*)psub2->param)->pVgroupTables = tscVgroupTableInfoClone(pTableMetaInfo2->pVgroupTables);
|
((SJoinSupporter*)psub2->param)->pVgroupTables = tscVgroupTableInfoDup(pTableMetaInfo2->pVgroupTables);
|
||||||
|
|
||||||
pParentSql->subState.numOfSub = 2;
|
pParentSql->subState.numOfSub = 2;
|
||||||
|
|
||||||
|
@ -1636,7 +1636,7 @@ int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter
|
||||||
"%p subquery:%p tableIndex:%d, vgroupIndex:%d, type:%d, transfer to tid_tag query to retrieve (tableId, tags), "
|
"%p subquery:%p tableIndex:%d, vgroupIndex:%d, type:%d, transfer to tid_tag query to retrieve (tableId, tags), "
|
||||||
"exprInfo:%" PRIzu ", colList:%" PRIzu ", fieldsInfo:%d, tagIndex:%d, name:%s",
|
"exprInfo:%" PRIzu ", colList:%" PRIzu ", fieldsInfo:%d, tagIndex:%d, name:%s",
|
||||||
pSql, pNew, tableIndex, pTableMetaInfo->vgroupIndex, pNewQueryInfo->type, tscSqlExprNumOfExprs(pNewQueryInfo),
|
pSql, pNew, tableIndex, pTableMetaInfo->vgroupIndex, pNewQueryInfo->type, tscSqlExprNumOfExprs(pNewQueryInfo),
|
||||||
numOfCols, pNewQueryInfo->fieldsInfo.numOfOutput, colIndex.columnIndex, pNewQueryInfo->pTableMetaInfo[0]->name);
|
numOfCols, pNewQueryInfo->fieldsInfo.numOfOutput, colIndex.columnIndex, tNameGetTableName(&pNewQueryInfo->pTableMetaInfo[0]->name));
|
||||||
} else {
|
} else {
|
||||||
SSchema colSchema = {.type = TSDB_DATA_TYPE_BINARY, .bytes = 1};
|
SSchema colSchema = {.type = TSDB_DATA_TYPE_BINARY, .bytes = 1};
|
||||||
SColumnIndex colIndex = {0, PRIMARYKEY_TIMESTAMP_COL_INDEX};
|
SColumnIndex colIndex = {0, PRIMARYKEY_TIMESTAMP_COL_INDEX};
|
||||||
|
@ -1671,7 +1671,7 @@ int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter
|
||||||
"%p subquery:%p tableIndex:%d, vgroupIndex:%d, type:%u, transfer to ts_comp query to retrieve timestamps, "
|
"%p subquery:%p tableIndex:%d, vgroupIndex:%d, type:%u, transfer to ts_comp query to retrieve timestamps, "
|
||||||
"exprInfo:%" PRIzu ", colList:%" PRIzu ", fieldsInfo:%d, name:%s",
|
"exprInfo:%" PRIzu ", colList:%" PRIzu ", fieldsInfo:%d, name:%s",
|
||||||
pSql, pNew, tableIndex, pTableMetaInfo->vgroupIndex, pNewQueryInfo->type, tscSqlExprNumOfExprs(pNewQueryInfo),
|
pSql, pNew, tableIndex, pTableMetaInfo->vgroupIndex, pNewQueryInfo->type, tscSqlExprNumOfExprs(pNewQueryInfo),
|
||||||
numOfCols, pNewQueryInfo->fieldsInfo.numOfOutput, pNewQueryInfo->pTableMetaInfo[0]->name);
|
numOfCols, pNewQueryInfo->fieldsInfo.numOfOutput, tNameGetTableName(&pNewQueryInfo->pTableMetaInfo[0]->name));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
assert(0);
|
assert(0);
|
||||||
|
@ -2133,7 +2133,7 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p
|
||||||
SQueryInfo *pPQueryInfo = tscGetQueryInfoDetail(&pParentSql->cmd, 0);
|
SQueryInfo *pPQueryInfo = tscGetQueryInfoDetail(&pParentSql->cmd, 0);
|
||||||
tscClearInterpInfo(pPQueryInfo);
|
tscClearInterpInfo(pPQueryInfo);
|
||||||
|
|
||||||
tscCreateLocalReducer(trsupport->pExtMemBuffer, pState->numOfSub, pDesc, trsupport->pFinalColModel, trsupport->pFFColModel, pParentSql);
|
tscCreateLocalMerger(trsupport->pExtMemBuffer, pState->numOfSub, pDesc, trsupport->pFinalColModel, trsupport->pFFColModel, pParentSql);
|
||||||
tscDebug("%p build loser tree completed", pParentSql);
|
tscDebug("%p build loser tree completed", pParentSql);
|
||||||
|
|
||||||
pParentSql->res.precision = pSql->res.precision;
|
pParentSql->res.precision = pSql->res.precision;
|
||||||
|
@ -2421,7 +2421,7 @@ static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows)
|
||||||
tscFreeQueryInfo(&pSql->cmd);
|
tscFreeQueryInfo(&pSql->cmd);
|
||||||
SQueryInfo* pQueryInfo = tscGetQueryInfoDetailSafely(&pSql->cmd, 0);
|
SQueryInfo* pQueryInfo = tscGetQueryInfoDetailSafely(&pSql->cmd, 0);
|
||||||
STableMetaInfo* pMasterTableMetaInfo = tscGetTableMetaInfoFromCmd(&pParentObj->cmd, pSql->cmd.clauseIndex, 0);
|
STableMetaInfo* pMasterTableMetaInfo = tscGetTableMetaInfoFromCmd(&pParentObj->cmd, pSql->cmd.clauseIndex, 0);
|
||||||
tscAddTableMetaInfo(pQueryInfo, pMasterTableMetaInfo->name, NULL, NULL, NULL, NULL);
|
tscAddTableMetaInfo(pQueryInfo, &pMasterTableMetaInfo->name, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
subquerySetState(pSql, &pParentObj->subState, i, 0);
|
subquerySetState(pSql, &pParentObj->subState, i, 0);
|
||||||
|
|
||||||
|
@ -2434,7 +2434,8 @@ static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows)
|
||||||
|
|
||||||
tscDebug("%p cleanup %d tableMeta in hashTable", pParentObj, pParentObj->cmd.numOfTables);
|
tscDebug("%p cleanup %d tableMeta in hashTable", pParentObj, pParentObj->cmd.numOfTables);
|
||||||
for(int32_t i = 0; i < pParentObj->cmd.numOfTables; ++i) {
|
for(int32_t i = 0; i < pParentObj->cmd.numOfTables; ++i) {
|
||||||
char* name = pParentObj->cmd.pTableNameList[i];
|
char name[TSDB_TABLE_FNAME_LEN] = {0};
|
||||||
|
tNameExtractFullName(pParentObj->cmd.pTableNameList[i], name);
|
||||||
taosHashRemove(tscTableMetaInfo, name, strnlen(name, TSDB_TABLE_FNAME_LEN));
|
taosHashRemove(tscTableMetaInfo, name, strnlen(name, TSDB_TABLE_FNAME_LEN));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,21 +89,6 @@ bool tscQueryTags(SQueryInfo* pQueryInfo) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo refactor, extract methods and move the common module
|
|
||||||
void tscGetDBInfoFromTableFullName(char* tableId, char* db) {
|
|
||||||
char* st = strstr(tableId, TS_PATH_DELIMITER);
|
|
||||||
if (st != NULL) {
|
|
||||||
char* end = strstr(st + 1, TS_PATH_DELIMITER);
|
|
||||||
if (end != NULL) {
|
|
||||||
memcpy(db, tableId, (end - tableId));
|
|
||||||
db[end - tableId] = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
db[0] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool tscIsTwoStageSTableQuery(SQueryInfo* pQueryInfo, int32_t tableIndex) {
|
bool tscIsTwoStageSTableQuery(SQueryInfo* pQueryInfo, int32_t tableIndex) {
|
||||||
if (pQueryInfo == NULL) {
|
if (pQueryInfo == NULL) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -420,7 +405,7 @@ void tscResetSqlCmdObj(SSqlCmd* pCmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscFreeSqlResult(SSqlObj* pSql) {
|
void tscFreeSqlResult(SSqlObj* pSql) {
|
||||||
tscDestroyLocalReducer(pSql);
|
tscDestroyLocalMerger(pSql);
|
||||||
|
|
||||||
SSqlRes* pRes = &pSql->res;
|
SSqlRes* pRes = &pSql->res;
|
||||||
tscDestroyResPointerInfo(pRes);
|
tscDestroyResPointerInfo(pRes);
|
||||||
|
@ -612,15 +597,13 @@ int32_t tscCopyDataBlockToPayload(SSqlObj* pSql, STableDataBlocks* pDataBlock) {
|
||||||
// todo refactor
|
// todo refactor
|
||||||
// set the correct table meta object, the table meta has been locked in pDataBlocks, so it must be in the cache
|
// set the correct table meta object, the table meta has been locked in pDataBlocks, so it must be in the cache
|
||||||
if (pTableMetaInfo->pTableMeta != pDataBlock->pTableMeta) {
|
if (pTableMetaInfo->pTableMeta != pDataBlock->pTableMeta) {
|
||||||
tstrncpy(pTableMetaInfo->name, pDataBlock->tableName, sizeof(pTableMetaInfo->name));
|
tNameAssign(&pTableMetaInfo->name, &pDataBlock->tableName);
|
||||||
|
|
||||||
if (pTableMetaInfo->pTableMeta != NULL) {
|
if (pTableMetaInfo->pTableMeta != NULL) {
|
||||||
tfree(pTableMetaInfo->pTableMeta);
|
tfree(pTableMetaInfo->pTableMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
pTableMetaInfo->pTableMeta = tscTableMetaClone(pDataBlock->pTableMeta);
|
pTableMetaInfo->pTableMeta = tscTableMetaDup(pDataBlock->pTableMeta);
|
||||||
} else {
|
|
||||||
assert(strncmp(pTableMetaInfo->name, pDataBlock->tableName, tListLen(pDataBlock->tableName)) == 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -655,7 +638,7 @@ int32_t tscCopyDataBlockToPayload(SSqlObj* pSql, STableDataBlocks* pDataBlock) {
|
||||||
* @param dataBlocks
|
* @param dataBlocks
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int32_t tscCreateDataBlock(size_t initialSize, int32_t rowSize, int32_t startOffset, const char* name,
|
int32_t tscCreateDataBlock(size_t initialSize, int32_t rowSize, int32_t startOffset, SName* name,
|
||||||
STableMeta* pTableMeta, STableDataBlocks** dataBlocks) {
|
STableMeta* pTableMeta, STableDataBlocks** dataBlocks) {
|
||||||
STableDataBlocks* dataBuf = (STableDataBlocks*)calloc(1, sizeof(STableDataBlocks));
|
STableDataBlocks* dataBuf = (STableDataBlocks*)calloc(1, sizeof(STableDataBlocks));
|
||||||
if (dataBuf == NULL) {
|
if (dataBuf == NULL) {
|
||||||
|
@ -683,18 +666,18 @@ int32_t tscCreateDataBlock(size_t initialSize, int32_t rowSize, int32_t startOff
|
||||||
dataBuf->size = startOffset;
|
dataBuf->size = startOffset;
|
||||||
dataBuf->tsSource = -1;
|
dataBuf->tsSource = -1;
|
||||||
|
|
||||||
tstrncpy(dataBuf->tableName, name, sizeof(dataBuf->tableName));
|
tNameAssign(&dataBuf->tableName, name);
|
||||||
|
|
||||||
//Here we keep the tableMeta to avoid it to be remove by other threads.
|
//Here we keep the tableMeta to avoid it to be remove by other threads.
|
||||||
dataBuf->pTableMeta = tscTableMetaClone(pTableMeta);
|
dataBuf->pTableMeta = tscTableMetaDup(pTableMeta);
|
||||||
assert(initialSize > 0 && pTableMeta != NULL && dataBuf->pTableMeta != NULL);
|
assert(initialSize > 0 && pTableMeta != NULL && dataBuf->pTableMeta != NULL);
|
||||||
|
|
||||||
*dataBlocks = dataBuf;
|
*dataBlocks = dataBuf;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tscGetDataBlockFromList(SHashObj* pHashList, int64_t id, int32_t size, int32_t startOffset, int32_t rowSize, const char* tableId, STableMeta* pTableMeta,
|
int32_t tscGetDataBlockFromList(SHashObj* pHashList, int64_t id, int32_t size, int32_t startOffset, int32_t rowSize,
|
||||||
STableDataBlocks** dataBlocks, SArray* pBlockList) {
|
SName* name, STableMeta* pTableMeta, STableDataBlocks** dataBlocks, SArray* pBlockList) {
|
||||||
*dataBlocks = NULL;
|
*dataBlocks = NULL;
|
||||||
STableDataBlocks** t1 = (STableDataBlocks**)taosHashGet(pHashList, (const char*)&id, sizeof(id));
|
STableDataBlocks** t1 = (STableDataBlocks**)taosHashGet(pHashList, (const char*)&id, sizeof(id));
|
||||||
if (t1 != NULL) {
|
if (t1 != NULL) {
|
||||||
|
@ -702,7 +685,7 @@ int32_t tscGetDataBlockFromList(SHashObj* pHashList, int64_t id, int32_t size, i
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*dataBlocks == NULL) {
|
if (*dataBlocks == NULL) {
|
||||||
int32_t ret = tscCreateDataBlock((size_t)size, rowSize, startOffset, tableId, pTableMeta, dataBlocks);
|
int32_t ret = tscCreateDataBlock((size_t)size, rowSize, startOffset, name, pTableMeta, dataBlocks);
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -803,7 +786,7 @@ static void extractTableNameList(SSqlCmd* pCmd, bool freeBlockMap) {
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
while(p1) {
|
while(p1) {
|
||||||
STableDataBlocks* pBlocks = *p1;
|
STableDataBlocks* pBlocks = *p1;
|
||||||
pCmd->pTableNameList[i++] = strndup(pBlocks->tableName, TSDB_TABLE_FNAME_LEN);
|
pCmd->pTableNameList[i++] = tNameDup(&pBlocks->tableName);
|
||||||
p1 = taosHashIterate(pCmd->pTableBlockHashList, p1);
|
p1 = taosHashIterate(pCmd->pTableBlockHashList, p1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -828,7 +811,7 @@ int32_t tscMergeTableDataBlocks(SSqlObj* pSql, bool freeBlockMap) {
|
||||||
STableDataBlocks* dataBuf = NULL;
|
STableDataBlocks* dataBuf = NULL;
|
||||||
|
|
||||||
int32_t ret = tscGetDataBlockFromList(pVnodeDataBlockHashList, pOneTableBlock->vgId, TSDB_PAYLOAD_SIZE,
|
int32_t ret = tscGetDataBlockFromList(pVnodeDataBlockHashList, pOneTableBlock->vgId, TSDB_PAYLOAD_SIZE,
|
||||||
INSERT_HEAD_SIZE, 0, pOneTableBlock->tableName, pOneTableBlock->pTableMeta, &dataBuf, pVnodeDataBlockList);
|
INSERT_HEAD_SIZE, 0, &pOneTableBlock->tableName, pOneTableBlock->pTableMeta, &dataBuf, pVnodeDataBlockList);
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
tscError("%p failed to prepare the data block buffer for merging table data, code:%d", pSql, ret);
|
tscError("%p failed to prepare the data block buffer for merging table data, code:%d", pSql, ret);
|
||||||
taosHashCleanup(pVnodeDataBlockHashList);
|
taosHashCleanup(pVnodeDataBlockHashList);
|
||||||
|
@ -861,8 +844,8 @@ int32_t tscMergeTableDataBlocks(SSqlObj* pSql, bool freeBlockMap) {
|
||||||
|
|
||||||
tscSortRemoveDataBlockDupRows(pOneTableBlock);
|
tscSortRemoveDataBlockDupRows(pOneTableBlock);
|
||||||
char* ekey = (char*)pBlocks->data + pOneTableBlock->rowSize*(pBlocks->numOfRows-1);
|
char* ekey = (char*)pBlocks->data + pOneTableBlock->rowSize*(pBlocks->numOfRows-1);
|
||||||
|
|
||||||
tscDebug("%p name:%s, sid:%d rows:%d sversion:%d skey:%" PRId64 ", ekey:%" PRId64, pSql, pOneTableBlock->tableName,
|
tscDebug("%p name:%s, name:%d rows:%d sversion:%d skey:%" PRId64 ", ekey:%" PRId64, pSql, tNameGetTableName(&pOneTableBlock->tableName),
|
||||||
pBlocks->tid, pBlocks->numOfRows, pBlocks->sversion, GET_INT64_VAL(pBlocks->data), GET_INT64_VAL(ekey));
|
pBlocks->tid, pBlocks->numOfRows, pBlocks->sversion, GET_INT64_VAL(pBlocks->data), GET_INT64_VAL(ekey));
|
||||||
|
|
||||||
int32_t len = pBlocks->numOfRows * (pOneTableBlock->rowSize + expandSize) + sizeof(STColumn) * tscGetNumOfColumns(pOneTableBlock->pTableMeta);
|
int32_t len = pBlocks->numOfRows * (pOneTableBlock->rowSize + expandSize) + sizeof(STColumn) * tscGetNumOfColumns(pOneTableBlock->pTableMeta);
|
||||||
|
@ -1310,7 +1293,7 @@ SColumn* tscColumnClone(const SColumn* src) {
|
||||||
|
|
||||||
dst->colIndex = src->colIndex;
|
dst->colIndex = src->colIndex;
|
||||||
dst->numOfFilters = src->numOfFilters;
|
dst->numOfFilters = src->numOfFilters;
|
||||||
dst->filterInfo = tscFilterInfoClone(src->filterInfo, src->numOfFilters);
|
dst->filterInfo = tFilterInfoDup(src->filterInfo, src->numOfFilters);
|
||||||
|
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
@ -1816,10 +1799,10 @@ void tscVgroupTableCopy(SVgroupTableInfo* info, SVgroupTableInfo* pInfo) {
|
||||||
info->vgInfo.epAddr[j].fqdn = strdup(pInfo->vgInfo.epAddr[j].fqdn);
|
info->vgInfo.epAddr[j].fqdn = strdup(pInfo->vgInfo.epAddr[j].fqdn);
|
||||||
}
|
}
|
||||||
|
|
||||||
info->itemList = taosArrayClone(pInfo->itemList);
|
info->itemList = taosArrayDup(pInfo->itemList);
|
||||||
}
|
}
|
||||||
|
|
||||||
SArray* tscVgroupTableInfoClone(SArray* pVgroupTables) {
|
SArray* tscVgroupTableInfoDup(SArray* pVgroupTables) {
|
||||||
if (pVgroupTables == NULL) {
|
if (pVgroupTables == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1850,7 +1833,7 @@ void clearAllTableMetaInfo(SQueryInfo* pQueryInfo) {
|
||||||
tfree(pQueryInfo->pTableMetaInfo);
|
tfree(pQueryInfo->pTableMetaInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
STableMetaInfo* tscAddTableMetaInfo(SQueryInfo* pQueryInfo, const char* name, STableMeta* pTableMeta,
|
STableMetaInfo* tscAddTableMetaInfo(SQueryInfo* pQueryInfo, SName* name, STableMeta* pTableMeta,
|
||||||
SVgroupsInfo* vgroupList, SArray* pTagCols, SArray* pVgroupTables) {
|
SVgroupsInfo* vgroupList, SArray* pTagCols, SArray* pVgroupTables) {
|
||||||
void* pAlloc = realloc(pQueryInfo->pTableMetaInfo, (pQueryInfo->numOfTables + 1) * POINTER_BYTES);
|
void* pAlloc = realloc(pQueryInfo->pTableMetaInfo, (pQueryInfo->numOfTables + 1) * POINTER_BYTES);
|
||||||
if (pAlloc == NULL) {
|
if (pAlloc == NULL) {
|
||||||
|
@ -1868,7 +1851,7 @@ STableMetaInfo* tscAddTableMetaInfo(SQueryInfo* pQueryInfo, const char* name, ST
|
||||||
pQueryInfo->pTableMetaInfo[pQueryInfo->numOfTables] = pTableMetaInfo;
|
pQueryInfo->pTableMetaInfo[pQueryInfo->numOfTables] = pTableMetaInfo;
|
||||||
|
|
||||||
if (name != NULL) {
|
if (name != NULL) {
|
||||||
tstrncpy(pTableMetaInfo->name, name, sizeof(pTableMetaInfo->name));
|
tNameAssign(&pTableMetaInfo->name, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
pTableMetaInfo->pTableMeta = pTableMeta;
|
pTableMetaInfo->pTableMeta = pTableMeta;
|
||||||
|
@ -1887,7 +1870,7 @@ STableMetaInfo* tscAddTableMetaInfo(SQueryInfo* pQueryInfo, const char* name, ST
|
||||||
tscColumnListCopy(pTableMetaInfo->tagColList, pTagCols, -1);
|
tscColumnListCopy(pTableMetaInfo->tagColList, pTagCols, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
pTableMetaInfo->pVgroupTables = tscVgroupTableInfoClone(pVgroupTables);
|
pTableMetaInfo->pVgroupTables = tscVgroupTableInfoDup(pVgroupTables);
|
||||||
|
|
||||||
pQueryInfo->numOfTables += 1;
|
pQueryInfo->numOfTables += 1;
|
||||||
return pTableMetaInfo;
|
return pTableMetaInfo;
|
||||||
|
@ -1965,7 +1948,7 @@ SSqlObj* createSimpleSubObj(SSqlObj* pSql, __async_cb_func_t fp, void* param, in
|
||||||
assert(pSql->cmd.clauseIndex == 0);
|
assert(pSql->cmd.clauseIndex == 0);
|
||||||
STableMetaInfo* pMasterTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, pSql->cmd.clauseIndex, 0);
|
STableMetaInfo* pMasterTableMetaInfo = tscGetTableMetaInfoFromCmd(&pSql->cmd, pSql->cmd.clauseIndex, 0);
|
||||||
|
|
||||||
tscAddTableMetaInfo(pQueryInfo, pMasterTableMetaInfo->name, NULL, NULL, NULL, NULL);
|
tscAddTableMetaInfo(pQueryInfo, &pMasterTableMetaInfo->name, NULL, NULL, NULL, NULL);
|
||||||
registerSqlObj(pNew);
|
registerSqlObj(pNew);
|
||||||
|
|
||||||
return pNew;
|
return pNew;
|
||||||
|
@ -2070,7 +2053,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, __async_cb_func_t
|
||||||
|
|
||||||
pNewQueryInfo->groupbyExpr = pQueryInfo->groupbyExpr;
|
pNewQueryInfo->groupbyExpr = pQueryInfo->groupbyExpr;
|
||||||
if (pQueryInfo->groupbyExpr.columnInfo != NULL) {
|
if (pQueryInfo->groupbyExpr.columnInfo != NULL) {
|
||||||
pNewQueryInfo->groupbyExpr.columnInfo = taosArrayClone(pQueryInfo->groupbyExpr.columnInfo);
|
pNewQueryInfo->groupbyExpr.columnInfo = taosArrayDup(pQueryInfo->groupbyExpr.columnInfo);
|
||||||
if (pNewQueryInfo->groupbyExpr.columnInfo == NULL) {
|
if (pNewQueryInfo->groupbyExpr.columnInfo == NULL) {
|
||||||
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
goto _error;
|
goto _error;
|
||||||
|
@ -2121,27 +2104,26 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, __async_cb_func_t
|
||||||
pNew->param = param;
|
pNew->param = param;
|
||||||
pNew->maxRetry = TSDB_MAX_REPLICA;
|
pNew->maxRetry = TSDB_MAX_REPLICA;
|
||||||
|
|
||||||
char* name = pTableMetaInfo->name;
|
|
||||||
STableMetaInfo* pFinalInfo = NULL;
|
STableMetaInfo* pFinalInfo = NULL;
|
||||||
|
|
||||||
if (pPrevSql == NULL) {
|
if (pPrevSql == NULL) {
|
||||||
STableMeta* pTableMeta = tscTableMetaClone(pTableMetaInfo->pTableMeta);
|
STableMeta* pTableMeta = tscTableMetaDup(pTableMetaInfo->pTableMeta);
|
||||||
assert(pTableMeta != NULL);
|
assert(pTableMeta != NULL);
|
||||||
|
|
||||||
pFinalInfo = tscAddTableMetaInfo(pNewQueryInfo, name, pTableMeta, pTableMetaInfo->vgroupList,
|
pFinalInfo = tscAddTableMetaInfo(pNewQueryInfo, &pTableMetaInfo->name, pTableMeta, pTableMetaInfo->vgroupList,
|
||||||
pTableMetaInfo->tagColList, pTableMetaInfo->pVgroupTables);
|
pTableMetaInfo->tagColList, pTableMetaInfo->pVgroupTables);
|
||||||
} else { // transfer the ownership of pTableMeta to the newly create sql object.
|
} else { // transfer the ownership of pTableMeta to the newly create sql object.
|
||||||
STableMetaInfo* pPrevInfo = tscGetTableMetaInfoFromCmd(&pPrevSql->cmd, pPrevSql->cmd.clauseIndex, 0);
|
STableMetaInfo* pPrevInfo = tscGetTableMetaInfoFromCmd(&pPrevSql->cmd, pPrevSql->cmd.clauseIndex, 0);
|
||||||
|
|
||||||
STableMeta* pPrevTableMeta = tscTableMetaClone(pPrevInfo->pTableMeta);
|
STableMeta* pPrevTableMeta = tscTableMetaDup(pPrevInfo->pTableMeta);
|
||||||
SVgroupsInfo* pVgroupsInfo = pPrevInfo->vgroupList;
|
SVgroupsInfo* pVgroupsInfo = pPrevInfo->vgroupList;
|
||||||
pFinalInfo = tscAddTableMetaInfo(pNewQueryInfo, name, pPrevTableMeta, pVgroupsInfo, pTableMetaInfo->tagColList,
|
pFinalInfo = tscAddTableMetaInfo(pNewQueryInfo, &pTableMetaInfo->name, pPrevTableMeta, pVgroupsInfo, pTableMetaInfo->tagColList,
|
||||||
pTableMetaInfo->pVgroupTables);
|
pTableMetaInfo->pVgroupTables);
|
||||||
}
|
}
|
||||||
|
|
||||||
// this case cannot be happened
|
// this case cannot be happened
|
||||||
if (pFinalInfo->pTableMeta == NULL) {
|
if (pFinalInfo->pTableMeta == NULL) {
|
||||||
tscError("%p new subquery failed since no tableMeta, name:%s", pSql, name);
|
tscError("%p new subquery failed since no tableMeta, name:%s", pSql, tNameGetTableName(&pTableMetaInfo->name));
|
||||||
|
|
||||||
if (pPrevSql != NULL) { // pass the previous error to client
|
if (pPrevSql != NULL) { // pass the previous error to client
|
||||||
assert(pPrevSql->res.code != TSDB_CODE_SUCCESS);
|
assert(pPrevSql->res.code != TSDB_CODE_SUCCESS);
|
||||||
|
@ -2166,7 +2148,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, __async_cb_func_t
|
||||||
"%p new subquery:%p, tableIndex:%d, vgroupIndex:%d, type:%d, exprInfo:%" PRIzu ", colList:%" PRIzu ","
|
"%p new subquery:%p, tableIndex:%d, vgroupIndex:%d, type:%d, exprInfo:%" PRIzu ", colList:%" PRIzu ","
|
||||||
"fieldInfo:%d, name:%s, qrang:%" PRId64 " - %" PRId64 " order:%d, limit:%" PRId64,
|
"fieldInfo:%d, name:%s, qrang:%" PRId64 " - %" PRId64 " order:%d, limit:%" PRId64,
|
||||||
pSql, pNew, tableIndex, pTableMetaInfo->vgroupIndex, pNewQueryInfo->type, tscSqlExprNumOfExprs(pNewQueryInfo),
|
pSql, pNew, tableIndex, pTableMetaInfo->vgroupIndex, pNewQueryInfo->type, tscSqlExprNumOfExprs(pNewQueryInfo),
|
||||||
size, pNewQueryInfo->fieldsInfo.numOfOutput, pFinalInfo->name, pNewQueryInfo->window.skey,
|
size, pNewQueryInfo->fieldsInfo.numOfOutput, tNameGetTableName(&pFinalInfo->name), pNewQueryInfo->window.skey,
|
||||||
pNewQueryInfo->window.ekey, pNewQueryInfo->order.order, pNewQueryInfo->limit.limit);
|
pNewQueryInfo->window.ekey, pNewQueryInfo->order.order, pNewQueryInfo->limit.limit);
|
||||||
|
|
||||||
tscPrintSelectClause(pNew, 0);
|
tscPrintSelectClause(pNew, 0);
|
||||||
|
@ -2203,7 +2185,7 @@ void tscDoQuery(SSqlObj* pSql) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pCmd->dataSourceType == DATA_FROM_DATA_FILE) {
|
if (pCmd->dataSourceType == DATA_FROM_DATA_FILE) {
|
||||||
tscProcessMultiVnodesImportFromFile(pSql);
|
tscImportDataFromFile(pSql);
|
||||||
} else {
|
} else {
|
||||||
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
||||||
uint16_t type = pQueryInfo->type;
|
uint16_t type = pQueryInfo->type;
|
||||||
|
@ -2303,7 +2285,6 @@ int32_t tscSQLSyntaxErrMsg(char* msg, const char* additionalInfo, const char* s
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_TSC_SQL_SYNTAX_ERROR;
|
return TSDB_CODE_TSC_SQL_SYNTAX_ERROR;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tscInvalidSQLErrMsg(char* msg, const char* additionalInfo, const char* sql) {
|
int32_t tscInvalidSQLErrMsg(char* msg, const char* additionalInfo, const char* sql) {
|
||||||
|
@ -2701,7 +2682,7 @@ uint32_t tscGetTableMetaMaxSize() {
|
||||||
return sizeof(STableMeta) + TSDB_MAX_COLUMNS * sizeof(SSchema);
|
return sizeof(STableMeta) + TSDB_MAX_COLUMNS * sizeof(SSchema);
|
||||||
}
|
}
|
||||||
|
|
||||||
STableMeta* tscTableMetaClone(STableMeta* pTableMeta) {
|
STableMeta* tscTableMetaDup(STableMeta* pTableMeta) {
|
||||||
assert(pTableMeta != NULL);
|
assert(pTableMeta != NULL);
|
||||||
uint32_t size = tscGetTableMetaSize(pTableMeta);
|
uint32_t size = tscGetTableMetaSize(pTableMeta);
|
||||||
STableMeta* p = calloc(1, size);
|
STableMeta* p = calloc(1, size);
|
||||||
|
|
|
@ -21,6 +21,20 @@ typedef struct SColumnInfoData {
|
||||||
void* pData; // the corresponding block data in memory
|
void* pData; // the corresponding block data in memory
|
||||||
} SColumnInfoData;
|
} SColumnInfoData;
|
||||||
|
|
||||||
|
#define TSDB_DB_NAME_T 1
|
||||||
|
#define TSDB_TABLE_NAME_T 2
|
||||||
|
|
||||||
|
#define T_NAME_ACCT 0x1u
|
||||||
|
#define T_NAME_DB 0x2u
|
||||||
|
#define T_NAME_TABLE 0x4u
|
||||||
|
|
||||||
|
typedef struct SName {
|
||||||
|
uint8_t type; //db_name_t, table_name_t
|
||||||
|
char acctId[TSDB_ACCT_ID_LEN];
|
||||||
|
char dbname[TSDB_DB_NAME_LEN];
|
||||||
|
char tname[TSDB_TABLE_NAME_LEN];
|
||||||
|
} SName;
|
||||||
|
|
||||||
void extractTableName(const char *tableId, char *name);
|
void extractTableName(const char *tableId, char *name);
|
||||||
|
|
||||||
char* extractDBName(const char *tableId, char *name);
|
char* extractDBName(const char *tableId, char *name);
|
||||||
|
@ -35,9 +49,9 @@ SSchema tGetUserSpecifiedColumnSchema(tVariant* pVal, SStrToken* exprStr, const
|
||||||
|
|
||||||
bool tscValidateTableNameLength(size_t len);
|
bool tscValidateTableNameLength(size_t len);
|
||||||
|
|
||||||
SColumnFilterInfo* tscFilterInfoClone(const SColumnFilterInfo* src, int32_t numOfFilters);
|
SColumnFilterInfo* tFilterInfoDup(const SColumnFilterInfo* src, int32_t numOfFilters);
|
||||||
|
|
||||||
SSchema tscGetTbnameColumnSchema();
|
SSchema tGetTbnameColumnSchema();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check if the schema is valid or not, including following aspects:
|
* check if the schema is valid or not, including following aspects:
|
||||||
|
@ -51,6 +65,28 @@ SSchema tscGetTbnameColumnSchema();
|
||||||
* @param numOfCols
|
* @param numOfCols
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
bool isValidSchema(struct SSchema* pSchema, int32_t numOfCols, int32_t numOfTags);
|
bool tIsValidSchema(struct SSchema* pSchema, int32_t numOfCols, int32_t numOfTags);
|
||||||
|
|
||||||
|
int32_t tNameExtractFullName(const SName* name, char* dst);
|
||||||
|
int32_t tNameLen(const SName* name);
|
||||||
|
|
||||||
|
SName* tNameDup(const SName* name);
|
||||||
|
|
||||||
|
bool tIsValidName(const SName* name);
|
||||||
|
|
||||||
|
const char* tNameGetTableName(const SName* name);
|
||||||
|
|
||||||
|
int32_t tNameGetDbName(const SName* name, char* dst);
|
||||||
|
int32_t tNameGetFullDbName(const SName* name, char* dst);
|
||||||
|
|
||||||
|
bool tNameIsEmpty(const SName* name);
|
||||||
|
|
||||||
|
void tNameAssign(SName* dst, const SName* src);
|
||||||
|
|
||||||
|
int32_t tNameFromString(SName* dst, const char* str, uint32_t type);
|
||||||
|
|
||||||
|
int32_t tNameSetAcctId(SName* dst, const char* acct);
|
||||||
|
|
||||||
|
int32_t tNameSetDbName(SName* dst, const char* acct, SStrToken* dbToken);
|
||||||
|
|
||||||
#endif // TDENGINE_NAME_H
|
#endif // TDENGINE_NAME_H
|
||||||
|
|
|
@ -3,31 +3,12 @@
|
||||||
|
|
||||||
#include "tname.h"
|
#include "tname.h"
|
||||||
#include "tstoken.h"
|
#include "tstoken.h"
|
||||||
#include "ttokendef.h"
|
|
||||||
#include "tvariant.h"
|
#include "tvariant.h"
|
||||||
|
|
||||||
#define VALIDNUMOFCOLS(x) ((x) >= TSDB_MIN_COLUMNS && (x) <= TSDB_MAX_COLUMNS)
|
#define VALIDNUMOFCOLS(x) ((x) >= TSDB_MIN_COLUMNS && (x) <= TSDB_MAX_COLUMNS)
|
||||||
|
|
||||||
#define VALIDNUMOFTAGS(x) ((x) >= 0 && (x) <= TSDB_MAX_TAGS)
|
#define VALIDNUMOFTAGS(x) ((x) >= 0 && (x) <= TSDB_MAX_TAGS)
|
||||||
|
|
||||||
// todo refactor
|
#define VALID_NAME_TYPE(x) ((x) == TSDB_DB_NAME_T || (x) == TSDB_TABLE_NAME_T)
|
||||||
UNUSED_FUNC static FORCE_INLINE const char* skipSegments(const char* input, char delim, int32_t num) {
|
|
||||||
for (int32_t i = 0; i < num; ++i) {
|
|
||||||
while (*input != 0 && *input++ != delim) {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return input;
|
|
||||||
}
|
|
||||||
|
|
||||||
UNUSED_FUNC static FORCE_INLINE size_t copy(char* dst, const char* src, char delimiter) {
|
|
||||||
size_t len = 0;
|
|
||||||
while (*src != delimiter && *src != 0) {
|
|
||||||
*dst++ = *src++;
|
|
||||||
len++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
void extractTableName(const char* tableId, char* name) {
|
void extractTableName(const char* tableId, char* name) {
|
||||||
size_t s1 = strcspn(tableId, &TS_PATH_DELIMITER[0]);
|
size_t s1 = strcspn(tableId, &TS_PATH_DELIMITER[0]);
|
||||||
|
@ -85,7 +66,7 @@ bool tscValidateTableNameLength(size_t len) {
|
||||||
return len < TSDB_TABLE_NAME_LEN;
|
return len < TSDB_TABLE_NAME_LEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
SColumnFilterInfo* tscFilterInfoClone(const SColumnFilterInfo* src, int32_t numOfFilters) {
|
SColumnFilterInfo* tFilterInfoDup(const SColumnFilterInfo* src, int32_t numOfFilters) {
|
||||||
if (numOfFilters == 0) {
|
if (numOfFilters == 0) {
|
||||||
assert(src == NULL);
|
assert(src == NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -200,7 +181,7 @@ void extractTableNameFromToken(SStrToken* pToken, SStrToken* pTable) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SSchema tscGetTbnameColumnSchema() {
|
SSchema tGetTbnameColumnSchema() {
|
||||||
struct SSchema s = {
|
struct SSchema s = {
|
||||||
.colId = TSDB_TBNAME_COLUMN_INDEX,
|
.colId = TSDB_TBNAME_COLUMN_INDEX,
|
||||||
.type = TSDB_DATA_TYPE_BINARY,
|
.type = TSDB_DATA_TYPE_BINARY,
|
||||||
|
@ -248,7 +229,7 @@ static bool doValidateSchema(SSchema* pSchema, int32_t numOfCols, int32_t maxLen
|
||||||
return rowLen <= maxLen;
|
return rowLen <= maxLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isValidSchema(struct SSchema* pSchema, int32_t numOfCols, int32_t numOfTags) {
|
bool tIsValidSchema(struct SSchema* pSchema, int32_t numOfCols, int32_t numOfTags) {
|
||||||
if (!VALIDNUMOFCOLS(numOfCols)) {
|
if (!VALIDNUMOFCOLS(numOfCols)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -272,3 +253,179 @@ bool isValidSchema(struct SSchema* pSchema, int32_t numOfCols, int32_t numOfTags
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t tNameExtractFullName(const SName* name, char* dst) {
|
||||||
|
assert(name != NULL && dst != NULL);
|
||||||
|
|
||||||
|
// invalid full name format, abort
|
||||||
|
if (!tIsValidName(name)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t len = snprintf(dst, TSDB_ACCT_ID_LEN + 1 + TSDB_DB_NAME_LEN, "%s.%s", name->acctId, name->dbname);
|
||||||
|
|
||||||
|
size_t tnameLen = strlen(name->tname);
|
||||||
|
if (tnameLen > 0) {
|
||||||
|
assert(name->type == TSDB_TABLE_NAME_T);
|
||||||
|
dst[len] = TS_PATH_DELIMITER[0];
|
||||||
|
|
||||||
|
memcpy(dst + len + 1, name->tname, tnameLen);
|
||||||
|
dst[len + tnameLen + 1] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tNameLen(const SName* name) {
|
||||||
|
assert(name != NULL);
|
||||||
|
int32_t len = (int32_t) strlen(name->acctId);
|
||||||
|
int32_t len1 = (int32_t) strlen(name->dbname);
|
||||||
|
int32_t len2 = (int32_t) strlen(name->tname);
|
||||||
|
|
||||||
|
if (name->type == TSDB_DB_NAME_T) {
|
||||||
|
assert(len2 == 0);
|
||||||
|
return len + len1 + TS_PATH_DELIMITER_LEN;
|
||||||
|
} else {
|
||||||
|
assert(len2 > 0);
|
||||||
|
return len + len1 + len2 + TS_PATH_DELIMITER_LEN * 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool tIsValidName(const SName* name) {
|
||||||
|
assert(name != NULL);
|
||||||
|
|
||||||
|
if (!VALID_NAME_TYPE(name->type)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen(name->acctId) <= 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name->type == TSDB_DB_NAME_T) {
|
||||||
|
return strlen(name->dbname) > 0;
|
||||||
|
} else {
|
||||||
|
return strlen(name->dbname) > 0 && strlen(name->tname) > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SName* tNameDup(const SName* name) {
|
||||||
|
assert(name != NULL);
|
||||||
|
|
||||||
|
SName* p = calloc(1, sizeof(SName));
|
||||||
|
memcpy(p, name, sizeof(SName));
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tNameGetDbName(const SName* name, char* dst) {
|
||||||
|
assert(name != NULL && dst != NULL);
|
||||||
|
strncpy(dst, name->dbname, tListLen(name->dbname));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tNameGetFullDbName(const SName* name, char* dst) {
|
||||||
|
assert(name != NULL && dst != NULL);
|
||||||
|
snprintf(dst, TSDB_ACCT_ID_LEN + TS_PATH_DELIMITER_LEN + TSDB_DB_NAME_LEN,
|
||||||
|
"%s.%s", name->acctId, name->dbname);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool tNameIsEmpty(const SName* name) {
|
||||||
|
assert(name != NULL);
|
||||||
|
return name->type == 0 || strlen(name->acctId) <= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* tNameGetTableName(const SName* name) {
|
||||||
|
assert(name != NULL && name->type == TSDB_TABLE_NAME_T);
|
||||||
|
return &name->tname[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
void tNameAssign(SName* dst, const SName* src) {
|
||||||
|
memcpy(dst, src, sizeof(SName));
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tNameSetDbName(SName* dst, const char* acct, SStrToken* dbToken) {
|
||||||
|
assert(dst != NULL && dbToken != NULL && acct != NULL);
|
||||||
|
|
||||||
|
// too long account id or too long db name
|
||||||
|
if (strlen(acct) >= tListLen(dst->acctId) || dbToken->n >= tListLen(dst->dbname)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
dst->type = TSDB_DB_NAME_T;
|
||||||
|
tstrncpy(dst->acctId, acct, tListLen(dst->acctId));
|
||||||
|
tstrncpy(dst->dbname, dbToken->z, dbToken->n + 1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tNameSetAcctId(SName* dst, const char* acct) {
|
||||||
|
assert(dst != NULL && acct != NULL);
|
||||||
|
|
||||||
|
// too long account id or too long db name
|
||||||
|
if (strlen(acct) >= tListLen(dst->acctId)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
tstrncpy(dst->acctId, acct, tListLen(dst->acctId));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t tNameFromString(SName* dst, const char* str, uint32_t type) {
|
||||||
|
assert(dst != NULL && str != NULL && strlen(str) > 0);
|
||||||
|
|
||||||
|
char* p = NULL;
|
||||||
|
if ((type & T_NAME_ACCT) == T_NAME_ACCT) {
|
||||||
|
p = strstr(str, TS_PATH_DELIMITER);
|
||||||
|
if (p == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t len = (int32_t)(p - str);
|
||||||
|
|
||||||
|
// too long account id or too long db name
|
||||||
|
if (len >= tListLen(dst->acctId) || len == 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy (dst->acctId, str, len);
|
||||||
|
dst->acctId[len] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((type & T_NAME_DB) == T_NAME_DB) {
|
||||||
|
dst->type = TSDB_DB_NAME_T;
|
||||||
|
char* start = (char*)((p == NULL)? str:(p+1));
|
||||||
|
|
||||||
|
int32_t len = 0;
|
||||||
|
p = strstr(start, TS_PATH_DELIMITER);
|
||||||
|
if (p == NULL) {
|
||||||
|
len = (int32_t) strlen(start);
|
||||||
|
} else {
|
||||||
|
len = (int32_t) (p - start);
|
||||||
|
}
|
||||||
|
|
||||||
|
// too long account id or too long db name
|
||||||
|
if (len >= tListLen(dst->dbname) || len == 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy (dst->dbname, start, len);
|
||||||
|
dst->dbname[len] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((type & T_NAME_TABLE) == T_NAME_TABLE) {
|
||||||
|
dst->type = TSDB_TABLE_NAME_T;
|
||||||
|
char* start = (char*) ((p == NULL)? str: (p+1));
|
||||||
|
|
||||||
|
int32_t len = (int32_t) strlen(start);
|
||||||
|
|
||||||
|
// too long account id or too long db name
|
||||||
|
if (len >= tListLen(dst->tname) || len == 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy (dst->tname, start, len);
|
||||||
|
dst->tname[len] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -268,8 +268,7 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t len; // one create table message
|
int32_t len; // one create table message
|
||||||
char tableFname[TSDB_TABLE_FNAME_LEN];
|
char tableName[TSDB_TABLE_FNAME_LEN];
|
||||||
char db[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN];
|
|
||||||
int8_t igExists;
|
int8_t igExists;
|
||||||
int8_t getMeta;
|
int8_t getMeta;
|
||||||
int16_t numOfTags;
|
int16_t numOfTags;
|
||||||
|
@ -285,7 +284,7 @@ typedef struct {
|
||||||
} SCMCreateTableMsg;
|
} SCMCreateTableMsg;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char tableFname[TSDB_TABLE_FNAME_LEN];
|
char name[TSDB_TABLE_FNAME_LEN];
|
||||||
int8_t igNotExists;
|
int8_t igNotExists;
|
||||||
} SCMDropTableMsg;
|
} SCMDropTableMsg;
|
||||||
|
|
||||||
|
|
|
@ -227,9 +227,6 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define TK_SPACE 300
|
#define TK_SPACE 300
|
||||||
#define TK_COMMENT 301
|
#define TK_COMMENT 301
|
||||||
#define TK_ILLEGAL 302
|
#define TK_ILLEGAL 302
|
||||||
|
|
|
@ -32,7 +32,7 @@ int32_t mnodeInitDbs();
|
||||||
void mnodeCleanupDbs();
|
void mnodeCleanupDbs();
|
||||||
int64_t mnodeGetDbNum();
|
int64_t mnodeGetDbNum();
|
||||||
SDbObj *mnodeGetDb(char *db);
|
SDbObj *mnodeGetDb(char *db);
|
||||||
SDbObj *mnodeGetDbByTableId(char *db);
|
SDbObj *mnodeGetDbByTableName(char *db);
|
||||||
void * mnodeGetNextDb(void *pIter, SDbObj **pDb);
|
void * mnodeGetNextDb(void *pIter, SDbObj **pDb);
|
||||||
void mnodeCancelGetNextDb(void *pIter);
|
void mnodeCancelGetNextDb(void *pIter);
|
||||||
void mnodeIncDbRef(SDbObj *pDb);
|
void mnodeIncDbRef(SDbObj *pDb);
|
||||||
|
|
|
@ -199,18 +199,13 @@ void mnodeDecDbRef(SDbObj *pDb) {
|
||||||
return sdbDecRef(tsDbSdb, pDb);
|
return sdbDecRef(tsDbSdb, pDb);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDbObj *mnodeGetDbByTableId(char *tableId) {
|
SDbObj *mnodeGetDbByTableName(char *tableName) {
|
||||||
char db[TSDB_TABLE_FNAME_LEN], *pos;
|
SName name = {0};
|
||||||
|
tNameFromString(&name, tableName, T_NAME_ACCT|T_NAME_DB|T_NAME_TABLE);
|
||||||
// tableId format should be : acct.db.table
|
|
||||||
pos = strstr(tableId, TS_PATH_DELIMITER);
|
|
||||||
assert(NULL != pos);
|
|
||||||
|
|
||||||
pos = strstr(pos + 1, TS_PATH_DELIMITER);
|
// validate the tableName?
|
||||||
assert(NULL != pos);
|
char db[TSDB_TABLE_FNAME_LEN] = {0};
|
||||||
|
tNameGetFullDbName(&name, db);
|
||||||
memset(db, 0, sizeof(db));
|
|
||||||
strncpy(db, tableId, pos - tableId);
|
|
||||||
|
|
||||||
return mnodeGetDb(db);
|
return mnodeGetDb(db);
|
||||||
}
|
}
|
||||||
|
|
|
@ -297,7 +297,7 @@ static int32_t mnodeChildTableActionRestored() {
|
||||||
pIter = mnodeGetNextChildTable(pIter, &pTable);
|
pIter = mnodeGetNextChildTable(pIter, &pTable);
|
||||||
if (pTable == NULL) break;
|
if (pTable == NULL) break;
|
||||||
|
|
||||||
SDbObj *pDb = mnodeGetDbByTableId(pTable->info.tableId);
|
SDbObj *pDb = mnodeGetDbByTableName(pTable->info.tableId);
|
||||||
if (pDb == NULL || pDb->status != TSDB_DB_STATUS_READY) {
|
if (pDb == NULL || pDb->status != TSDB_DB_STATUS_READY) {
|
||||||
mError("ctable:%s, failed to get db or db in dropping, discard it", pTable->info.tableId);
|
mError("ctable:%s, failed to get db or db in dropping, discard it", pTable->info.tableId);
|
||||||
SSdbRow desc = {.type = SDB_OPER_LOCAL, .pObj = pTable, .pTable = tsChildTableSdb};
|
SSdbRow desc = {.type = SDB_OPER_LOCAL, .pObj = pTable, .pTable = tsChildTableSdb};
|
||||||
|
@ -443,7 +443,7 @@ static int32_t mnodeSuperTableActionDestroy(SSdbRow *pRow) {
|
||||||
|
|
||||||
static int32_t mnodeSuperTableActionInsert(SSdbRow *pRow) {
|
static int32_t mnodeSuperTableActionInsert(SSdbRow *pRow) {
|
||||||
SSTableObj *pStable = pRow->pObj;
|
SSTableObj *pStable = pRow->pObj;
|
||||||
SDbObj *pDb = mnodeGetDbByTableId(pStable->info.tableId);
|
SDbObj *pDb = mnodeGetDbByTableName(pStable->info.tableId);
|
||||||
if (pDb != NULL && pDb->status == TSDB_DB_STATUS_READY) {
|
if (pDb != NULL && pDb->status == TSDB_DB_STATUS_READY) {
|
||||||
mnodeAddSuperTableIntoDb(pDb);
|
mnodeAddSuperTableIntoDb(pDb);
|
||||||
}
|
}
|
||||||
|
@ -455,7 +455,7 @@ static int32_t mnodeSuperTableActionInsert(SSdbRow *pRow) {
|
||||||
|
|
||||||
static int32_t mnodeSuperTableActionDelete(SSdbRow *pRow) {
|
static int32_t mnodeSuperTableActionDelete(SSdbRow *pRow) {
|
||||||
SSTableObj *pStable = pRow->pObj;
|
SSTableObj *pStable = pRow->pObj;
|
||||||
SDbObj *pDb = mnodeGetDbByTableId(pStable->info.tableId);
|
SDbObj *pDb = mnodeGetDbByTableName(pStable->info.tableId);
|
||||||
if (pDb != NULL) {
|
if (pDb != NULL) {
|
||||||
mnodeRemoveSuperTableFromDb(pDb);
|
mnodeRemoveSuperTableFromDb(pDb);
|
||||||
mnodeDropAllChildTablesInStable((SSTableObj *)pStable);
|
mnodeDropAllChildTablesInStable((SSTableObj *)pStable);
|
||||||
|
@ -748,9 +748,12 @@ void mnodeDestroySubMsg(SMnodeMsg *pSubMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeValidateCreateTableMsg(SCreateTableMsg *pCreateTable, SMnodeMsg *pMsg) {
|
static int32_t mnodeValidateCreateTableMsg(SCreateTableMsg *pCreateTable, SMnodeMsg *pMsg) {
|
||||||
if (pMsg->pDb == NULL) pMsg->pDb = mnodeGetDb(pCreateTable->db);
|
|
||||||
if (pMsg->pDb == NULL) {
|
if (pMsg->pDb == NULL) {
|
||||||
mError("msg:%p, app:%p table:%s, failed to create, db not selected", pMsg, pMsg->rpcMsg.ahandle, pCreateTable->tableFname);
|
pMsg->pDb = mnodeGetDbByTableName(pCreateTable->tableName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pMsg->pDb == NULL) {
|
||||||
|
mError("msg:%p, app:%p table:%s, failed to create, db not selected", pMsg, pMsg->rpcMsg.ahandle, pCreateTable->tableName);
|
||||||
return TSDB_CODE_MND_DB_NOT_SELECTED;
|
return TSDB_CODE_MND_DB_NOT_SELECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -759,28 +762,28 @@ static int32_t mnodeValidateCreateTableMsg(SCreateTableMsg *pCreateTable, SMnode
|
||||||
return TSDB_CODE_MND_DB_IN_DROPPING;
|
return TSDB_CODE_MND_DB_IN_DROPPING;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pMsg->pTable == NULL) pMsg->pTable = mnodeGetTable(pCreateTable->tableFname);
|
if (pMsg->pTable == NULL) pMsg->pTable = mnodeGetTable(pCreateTable->tableName);
|
||||||
if (pMsg->pTable != NULL && pMsg->retry == 0) {
|
if (pMsg->pTable != NULL && pMsg->retry == 0) {
|
||||||
if (pCreateTable->getMeta) {
|
if (pCreateTable->getMeta) {
|
||||||
mDebug("msg:%p, app:%p table:%s, continue to get meta", pMsg, pMsg->rpcMsg.ahandle, pCreateTable->tableFname);
|
mDebug("msg:%p, app:%p table:%s, continue to get meta", pMsg, pMsg->rpcMsg.ahandle, pCreateTable->tableName);
|
||||||
return mnodeGetChildTableMeta(pMsg);
|
return mnodeGetChildTableMeta(pMsg);
|
||||||
} else if (pCreateTable->igExists) {
|
} else if (pCreateTable->igExists) {
|
||||||
mDebug("msg:%p, app:%p table:%s, is already exist", pMsg, pMsg->rpcMsg.ahandle, pCreateTable->tableFname);
|
mDebug("msg:%p, app:%p table:%s, is already exist", pMsg, pMsg->rpcMsg.ahandle, pCreateTable->tableName);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
mError("msg:%p, app:%p table:%s, failed to create, table already exist", pMsg, pMsg->rpcMsg.ahandle,
|
mError("msg:%p, app:%p table:%s, failed to create, table already exist", pMsg, pMsg->rpcMsg.ahandle,
|
||||||
pCreateTable->tableFname);
|
pCreateTable->tableName);
|
||||||
return TSDB_CODE_MND_TABLE_ALREADY_EXIST;
|
return TSDB_CODE_MND_TABLE_ALREADY_EXIST;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pCreateTable->numOfTags != 0) {
|
if (pCreateTable->numOfTags != 0) {
|
||||||
mDebug("msg:%p, app:%p table:%s, create stable msg is received from thandle:%p", pMsg, pMsg->rpcMsg.ahandle,
|
mDebug("msg:%p, app:%p table:%s, create stable msg is received from thandle:%p", pMsg, pMsg->rpcMsg.ahandle,
|
||||||
pCreateTable->tableFname, pMsg->rpcMsg.handle);
|
pCreateTable->tableName, pMsg->rpcMsg.handle);
|
||||||
return mnodeProcessCreateSuperTableMsg(pMsg);
|
return mnodeProcessCreateSuperTableMsg(pMsg);
|
||||||
} else {
|
} else {
|
||||||
mDebug("msg:%p, app:%p table:%s, create ctable msg is received from thandle:%p", pMsg, pMsg->rpcMsg.ahandle,
|
mDebug("msg:%p, app:%p table:%s, create ctable msg is received from thandle:%p", pMsg, pMsg->rpcMsg.ahandle,
|
||||||
pCreateTable->tableFname, pMsg->rpcMsg.handle);
|
pCreateTable->tableName, pMsg->rpcMsg.handle);
|
||||||
return mnodeProcessCreateChildTableMsg(pMsg);
|
return mnodeProcessCreateChildTableMsg(pMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -860,9 +863,12 @@ static int32_t mnodeProcessCreateTableMsg(SMnodeMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SCreateTableMsg *p = (SCreateTableMsg*)((char*) pCreate + sizeof(SCMCreateTableMsg));
|
SCreateTableMsg *p = (SCreateTableMsg*)((char*) pCreate + sizeof(SCMCreateTableMsg));
|
||||||
if (pMsg->pDb == NULL) pMsg->pDb = mnodeGetDb(p->db);
|
|
||||||
if (pMsg->pDb == NULL) {
|
if (pMsg->pDb == NULL) {
|
||||||
mError("msg:%p, app:%p table:%s, failed to create, db not selected", pMsg, pMsg->rpcMsg.ahandle, p->tableFname);
|
pMsg->pDb = mnodeGetDbByTableName(p->tableName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pMsg->pDb == NULL) {
|
||||||
|
mError("msg:%p, app:%p table:%s, failed to create, db not selected", pMsg, pMsg->rpcMsg.ahandle, p->tableName);
|
||||||
return TSDB_CODE_MND_DB_NOT_SELECTED;
|
return TSDB_CODE_MND_DB_NOT_SELECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -871,37 +877,37 @@ static int32_t mnodeProcessCreateTableMsg(SMnodeMsg *pMsg) {
|
||||||
return TSDB_CODE_MND_DB_IN_DROPPING;
|
return TSDB_CODE_MND_DB_IN_DROPPING;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pMsg->pTable == NULL) pMsg->pTable = mnodeGetTable(p->tableFname);
|
if (pMsg->pTable == NULL) pMsg->pTable = mnodeGetTable(p->tableName);
|
||||||
if (pMsg->pTable != NULL && pMsg->retry == 0) {
|
if (pMsg->pTable != NULL && pMsg->retry == 0) {
|
||||||
if (p->getMeta) {
|
if (p->getMeta) {
|
||||||
mDebug("msg:%p, app:%p table:%s, continue to get meta", pMsg, pMsg->rpcMsg.ahandle, p->tableFname);
|
mDebug("msg:%p, app:%p table:%s, continue to get meta", pMsg, pMsg->rpcMsg.ahandle, p->tableName);
|
||||||
return mnodeGetChildTableMeta(pMsg);
|
return mnodeGetChildTableMeta(pMsg);
|
||||||
} else if (p->igExists) {
|
} else if (p->igExists) {
|
||||||
mDebug("msg:%p, app:%p table:%s, is already exist", pMsg, pMsg->rpcMsg.ahandle, p->tableFname);
|
mDebug("msg:%p, app:%p table:%s, is already exist", pMsg, pMsg->rpcMsg.ahandle, p->tableName);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
mError("msg:%p, app:%p table:%s, failed to create, table already exist", pMsg, pMsg->rpcMsg.ahandle, p->tableFname);
|
mError("msg:%p, app:%p table:%s, failed to create, table already exist", pMsg, pMsg->rpcMsg.ahandle, p->tableName);
|
||||||
return TSDB_CODE_MND_TABLE_ALREADY_EXIST;
|
return TSDB_CODE_MND_TABLE_ALREADY_EXIST;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->numOfTags != 0) {
|
if (p->numOfTags != 0) {
|
||||||
mDebug("msg:%p, app:%p table:%s, create stable msg is received from thandle:%p", pMsg, pMsg->rpcMsg.ahandle,
|
mDebug("msg:%p, app:%p table:%s, create stable msg is received from thandle:%p", pMsg, pMsg->rpcMsg.ahandle,
|
||||||
p->tableFname, pMsg->rpcMsg.handle);
|
p->tableName, pMsg->rpcMsg.handle);
|
||||||
return mnodeProcessCreateSuperTableMsg(pMsg);
|
return mnodeProcessCreateSuperTableMsg(pMsg);
|
||||||
} else {
|
} else {
|
||||||
mDebug("msg:%p, app:%p table:%s, create ctable msg is received from thandle:%p", pMsg, pMsg->rpcMsg.ahandle,
|
mDebug("msg:%p, app:%p table:%s, create ctable msg is received from thandle:%p", pMsg, pMsg->rpcMsg.ahandle,
|
||||||
p->tableFname, pMsg->rpcMsg.handle);
|
p->tableName, pMsg->rpcMsg.handle);
|
||||||
return mnodeProcessCreateChildTableMsg(pMsg);
|
return mnodeProcessCreateChildTableMsg(pMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeProcessDropTableMsg(SMnodeMsg *pMsg) {
|
static int32_t mnodeProcessDropTableMsg(SMnodeMsg *pMsg) {
|
||||||
SCMDropTableMsg *pDrop = pMsg->rpcMsg.pCont;
|
SCMDropTableMsg *pDrop = pMsg->rpcMsg.pCont;
|
||||||
if (pMsg->pDb == NULL) pMsg->pDb = mnodeGetDbByTableId(pDrop->tableFname);
|
if (pMsg->pDb == NULL) pMsg->pDb = mnodeGetDbByTableName(pDrop->name);
|
||||||
if (pMsg->pDb == NULL) {
|
if (pMsg->pDb == NULL) {
|
||||||
mError("msg:%p, app:%p table:%s, failed to drop table, db not selected or db in dropping", pMsg,
|
mError("msg:%p, app:%p table:%s, failed to drop table, db not selected or db in dropping", pMsg,
|
||||||
pMsg->rpcMsg.ahandle, pDrop->tableFname);
|
pMsg->rpcMsg.ahandle, pDrop->name);
|
||||||
return TSDB_CODE_MND_DB_NOT_SELECTED;
|
return TSDB_CODE_MND_DB_NOT_SELECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -912,17 +918,17 @@ static int32_t mnodeProcessDropTableMsg(SMnodeMsg *pMsg) {
|
||||||
|
|
||||||
if (mnodeCheckIsMonitorDB(pMsg->pDb->name, tsMonitorDbName)) {
|
if (mnodeCheckIsMonitorDB(pMsg->pDb->name, tsMonitorDbName)) {
|
||||||
mError("msg:%p, app:%p table:%s, failed to drop table, in monitor database", pMsg, pMsg->rpcMsg.ahandle,
|
mError("msg:%p, app:%p table:%s, failed to drop table, in monitor database", pMsg, pMsg->rpcMsg.ahandle,
|
||||||
pDrop->tableFname);
|
pDrop->name);
|
||||||
return TSDB_CODE_MND_MONITOR_DB_FORBIDDEN;
|
return TSDB_CODE_MND_MONITOR_DB_FORBIDDEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pMsg->pTable == NULL) pMsg->pTable = mnodeGetTable(pDrop->tableFname);
|
if (pMsg->pTable == NULL) pMsg->pTable = mnodeGetTable(pDrop->name);
|
||||||
if (pMsg->pTable == NULL) {
|
if (pMsg->pTable == NULL) {
|
||||||
if (pDrop->igNotExists) {
|
if (pDrop->igNotExists) {
|
||||||
mDebug("msg:%p, app:%p table:%s is not exist, treat as success", pMsg, pMsg->rpcMsg.ahandle, pDrop->tableFname);
|
mDebug("msg:%p, app:%p table:%s is not exist, treat as success", pMsg, pMsg->rpcMsg.ahandle, pDrop->name);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
mError("msg:%p, app:%p table:%s, failed to drop, table not exist", pMsg, pMsg->rpcMsg.ahandle, pDrop->tableFname);
|
mError("msg:%p, app:%p table:%s, failed to drop, table not exist", pMsg, pMsg->rpcMsg.ahandle, pDrop->name);
|
||||||
return TSDB_CODE_MND_INVALID_TABLE_NAME;
|
return TSDB_CODE_MND_INVALID_TABLE_NAME;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -930,12 +936,12 @@ static int32_t mnodeProcessDropTableMsg(SMnodeMsg *pMsg) {
|
||||||
if (pMsg->pTable->type == TSDB_SUPER_TABLE) {
|
if (pMsg->pTable->type == TSDB_SUPER_TABLE) {
|
||||||
SSTableObj *pSTable = (SSTableObj *)pMsg->pTable;
|
SSTableObj *pSTable = (SSTableObj *)pMsg->pTable;
|
||||||
mInfo("msg:%p, app:%p table:%s, start to drop stable, uid:%" PRIu64 ", numOfChildTables:%d, sizeOfVgList:%d", pMsg,
|
mInfo("msg:%p, app:%p table:%s, start to drop stable, uid:%" PRIu64 ", numOfChildTables:%d, sizeOfVgList:%d", pMsg,
|
||||||
pMsg->rpcMsg.ahandle, pDrop->tableFname, pSTable->uid, pSTable->numOfTables, taosHashGetSize(pSTable->vgHash));
|
pMsg->rpcMsg.ahandle, pDrop->name, pSTable->uid, pSTable->numOfTables, taosHashGetSize(pSTable->vgHash));
|
||||||
return mnodeProcessDropSuperTableMsg(pMsg);
|
return mnodeProcessDropSuperTableMsg(pMsg);
|
||||||
} else {
|
} else {
|
||||||
SCTableObj *pCTable = (SCTableObj *)pMsg->pTable;
|
SCTableObj *pCTable = (SCTableObj *)pMsg->pTable;
|
||||||
mInfo("msg:%p, app:%p table:%s, start to drop ctable, vgId:%d tid:%d uid:%" PRIu64, pMsg, pMsg->rpcMsg.ahandle,
|
mInfo("msg:%p, app:%p table:%s, start to drop ctable, vgId:%d tid:%d uid:%" PRIu64, pMsg, pMsg->rpcMsg.ahandle,
|
||||||
pDrop->tableFname, pCTable->vgId, pCTable->tid, pCTable->uid);
|
pDrop->name, pCTable->vgId, pCTable->tid, pCTable->uid);
|
||||||
return mnodeProcessDropChildTableMsg(pMsg);
|
return mnodeProcessDropChildTableMsg(pMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -946,7 +952,7 @@ static int32_t mnodeProcessTableMetaMsg(SMnodeMsg *pMsg) {
|
||||||
mDebug("msg:%p, app:%p table:%s, table meta msg is received from thandle:%p, createFlag:%d", pMsg, pMsg->rpcMsg.ahandle,
|
mDebug("msg:%p, app:%p table:%s, table meta msg is received from thandle:%p, createFlag:%d", pMsg, pMsg->rpcMsg.ahandle,
|
||||||
pInfo->tableFname, pMsg->rpcMsg.handle, pInfo->createFlag);
|
pInfo->tableFname, pMsg->rpcMsg.handle, pInfo->createFlag);
|
||||||
|
|
||||||
if (pMsg->pDb == NULL) pMsg->pDb = mnodeGetDbByTableId(pInfo->tableFname);
|
if (pMsg->pDb == NULL) pMsg->pDb = mnodeGetDbByTableName(pInfo->tableFname);
|
||||||
if (pMsg->pDb == NULL) {
|
if (pMsg->pDb == NULL) {
|
||||||
mError("msg:%p, app:%p table:%s, failed to get table meta, db not selected", pMsg, pMsg->rpcMsg.ahandle,
|
mError("msg:%p, app:%p table:%s, failed to get table meta, db not selected", pMsg, pMsg->rpcMsg.ahandle,
|
||||||
pInfo->tableFname);
|
pInfo->tableFname);
|
||||||
|
@ -1006,12 +1012,12 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) {
|
||||||
|
|
||||||
SSTableObj * pStable = calloc(1, sizeof(SSTableObj));
|
SSTableObj * pStable = calloc(1, sizeof(SSTableObj));
|
||||||
if (pStable == NULL) {
|
if (pStable == NULL) {
|
||||||
mError("msg:%p, app:%p table:%s, failed to create, no enough memory", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableFname);
|
mError("msg:%p, app:%p table:%s, failed to create, no enough memory", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableName);
|
||||||
return TSDB_CODE_MND_OUT_OF_MEMORY;
|
return TSDB_CODE_MND_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t us = taosGetTimestampUs();
|
int64_t us = taosGetTimestampUs();
|
||||||
pStable->info.tableId = strdup(pCreate->tableFname);
|
pStable->info.tableId = strdup(pCreate->tableName);
|
||||||
pStable->info.type = TSDB_SUPER_TABLE;
|
pStable->info.type = TSDB_SUPER_TABLE;
|
||||||
pStable->createdTime = taosGetTimestampMs();
|
pStable->createdTime = taosGetTimestampMs();
|
||||||
pStable->uid = (us << 24) + ((sdbGetVersion() & ((1ul << 16) - 1ul)) << 8) + (taosRand() & ((1ul << 8) - 1ul));
|
pStable->uid = (us << 24) + ((sdbGetVersion() & ((1ul << 16) - 1ul)) << 8) + (taosRand() & ((1ul << 8) - 1ul));
|
||||||
|
@ -1025,14 +1031,14 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) {
|
||||||
pStable->schema = (SSchema *)calloc(1, schemaSize);
|
pStable->schema = (SSchema *)calloc(1, schemaSize);
|
||||||
if (pStable->schema == NULL) {
|
if (pStable->schema == NULL) {
|
||||||
free(pStable);
|
free(pStable);
|
||||||
mError("msg:%p, app:%p table:%s, failed to create, no schema input", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableFname);
|
mError("msg:%p, app:%p table:%s, failed to create, no schema input", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableName);
|
||||||
return TSDB_CODE_MND_INVALID_TABLE_NAME;
|
return TSDB_CODE_MND_INVALID_TABLE_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(pStable->schema, pCreate->schema, numOfCols * sizeof(SSchema));
|
memcpy(pStable->schema, pCreate->schema, numOfCols * sizeof(SSchema));
|
||||||
|
|
||||||
if (pStable->numOfColumns > TSDB_MAX_COLUMNS || pStable->numOfTags > TSDB_MAX_TAGS) {
|
if (pStable->numOfColumns > TSDB_MAX_COLUMNS || pStable->numOfTags > TSDB_MAX_TAGS) {
|
||||||
mError("msg:%p, app:%p table:%s, failed to create, too many columns", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableFname);
|
mError("msg:%p, app:%p table:%s, failed to create, too many columns", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableName);
|
||||||
return TSDB_CODE_MND_INVALID_TABLE_NAME;
|
return TSDB_CODE_MND_INVALID_TABLE_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1044,8 +1050,8 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) {
|
||||||
tschema[col].bytes = htons(tschema[col].bytes);
|
tschema[col].bytes = htons(tschema[col].bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isValidSchema(pStable->schema, pStable->numOfColumns, pStable->numOfTags)) {
|
if (!tIsValidSchema(pStable->schema, pStable->numOfColumns, pStable->numOfTags)) {
|
||||||
mError("msg:%p, app:%p table:%s, failed to create table, invalid schema", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableFname);
|
mError("msg:%p, app:%p table:%s, failed to create table, invalid schema", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableName);
|
||||||
return TSDB_CODE_MND_INVALID_CREATE_TABLE_MSG;
|
return TSDB_CODE_MND_INVALID_CREATE_TABLE_MSG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1065,7 +1071,7 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) {
|
||||||
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
||||||
mnodeDestroySuperTable(pStable);
|
mnodeDestroySuperTable(pStable);
|
||||||
pMsg->pTable = NULL;
|
pMsg->pTable = NULL;
|
||||||
mError("msg:%p, app:%p table:%s, failed to create, sdb error", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableFname);
|
mError("msg:%p, app:%p table:%s, failed to create, sdb error", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -1907,12 +1913,12 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) {
|
||||||
|
|
||||||
SCTableObj *pTable = calloc(1, sizeof(SCTableObj));
|
SCTableObj *pTable = calloc(1, sizeof(SCTableObj));
|
||||||
if (pTable == NULL) {
|
if (pTable == NULL) {
|
||||||
mError("msg:%p, app:%p table:%s, failed to alloc memory", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableFname);
|
mError("msg:%p, app:%p table:%s, failed to alloc memory", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableName);
|
||||||
return TSDB_CODE_MND_OUT_OF_MEMORY;
|
return TSDB_CODE_MND_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
pTable->info.type = (pCreate->numOfColumns == 0)? TSDB_CHILD_TABLE:TSDB_NORMAL_TABLE;
|
pTable->info.type = (pCreate->numOfColumns == 0)? TSDB_CHILD_TABLE:TSDB_NORMAL_TABLE;
|
||||||
pTable->info.tableId = strdup(pCreate->tableFname);
|
pTable->info.tableId = strdup(pCreate->tableName);
|
||||||
pTable->createdTime = taosGetTimestampMs();
|
pTable->createdTime = taosGetTimestampMs();
|
||||||
pTable->tid = tid;
|
pTable->tid = tid;
|
||||||
pTable->vgId = pVgroup->vgId;
|
pTable->vgId = pVgroup->vgId;
|
||||||
|
@ -1928,7 +1934,7 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) {
|
||||||
size_t prefixLen = tableIdPrefix(pMsg->pDb->name, prefix, 64);
|
size_t prefixLen = tableIdPrefix(pMsg->pDb->name, prefix, 64);
|
||||||
if (0 != strncasecmp(prefix, stableName, prefixLen)) {
|
if (0 != strncasecmp(prefix, stableName, prefixLen)) {
|
||||||
mError("msg:%p, app:%p table:%s, corresponding super table:%s not in this db", pMsg, pMsg->rpcMsg.ahandle,
|
mError("msg:%p, app:%p table:%s, corresponding super table:%s not in this db", pMsg, pMsg->rpcMsg.ahandle,
|
||||||
pCreate->tableFname, stableName);
|
pCreate->tableName, stableName);
|
||||||
mnodeDestroyChildTable(pTable);
|
mnodeDestroyChildTable(pTable);
|
||||||
return TSDB_CODE_TDB_INVALID_CREATE_TB_MSG;
|
return TSDB_CODE_TDB_INVALID_CREATE_TB_MSG;
|
||||||
}
|
}
|
||||||
|
@ -1936,7 +1942,7 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) {
|
||||||
if (pMsg->pSTable == NULL) pMsg->pSTable = mnodeGetSuperTable(stableName);
|
if (pMsg->pSTable == NULL) pMsg->pSTable = mnodeGetSuperTable(stableName);
|
||||||
if (pMsg->pSTable == NULL) {
|
if (pMsg->pSTable == NULL) {
|
||||||
mError("msg:%p, app:%p table:%s, corresponding super table:%s does not exist", pMsg, pMsg->rpcMsg.ahandle,
|
mError("msg:%p, app:%p table:%s, corresponding super table:%s does not exist", pMsg, pMsg->rpcMsg.ahandle,
|
||||||
pCreate->tableFname, stableName);
|
pCreate->tableName, stableName);
|
||||||
mnodeDestroyChildTable(pTable);
|
mnodeDestroyChildTable(pTable);
|
||||||
return TSDB_CODE_MND_INVALID_TABLE_NAME;
|
return TSDB_CODE_MND_INVALID_TABLE_NAME;
|
||||||
}
|
}
|
||||||
|
@ -2003,7 +2009,7 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) {
|
||||||
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
||||||
mnodeDestroyChildTable(pTable);
|
mnodeDestroyChildTable(pTable);
|
||||||
pMsg->pTable = NULL;
|
pMsg->pTable = NULL;
|
||||||
mError("msg:%p, app:%p table:%s, failed to create, reason:%s", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableFname,
|
mError("msg:%p, app:%p table:%s, failed to create, reason:%s", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableName,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
} else {
|
} else {
|
||||||
mDebug("msg:%p, app:%p table:%s, allocated in vgroup, vgId:%d sid:%d uid:%" PRIu64, pMsg, pMsg->rpcMsg.ahandle,
|
mDebug("msg:%p, app:%p table:%s, allocated in vgroup, vgId:%d sid:%d uid:%" PRIu64, pMsg, pMsg->rpcMsg.ahandle,
|
||||||
|
@ -2020,7 +2026,7 @@ static int32_t mnodeProcessCreateChildTableMsg(SMnodeMsg *pMsg) {
|
||||||
int32_t code = grantCheck(TSDB_GRANT_TIMESERIES);
|
int32_t code = grantCheck(TSDB_GRANT_TIMESERIES);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
mError("msg:%p, app:%p table:%s, failed to create, grant timeseries failed", pMsg, pMsg->rpcMsg.ahandle,
|
mError("msg:%p, app:%p table:%s, failed to create, grant timeseries failed", pMsg, pMsg->rpcMsg.ahandle,
|
||||||
pCreate->tableFname);
|
pCreate->tableName);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2031,7 +2037,7 @@ static int32_t mnodeProcessCreateChildTableMsg(SMnodeMsg *pMsg) {
|
||||||
code = mnodeGetAvailableVgroup(pMsg, &pVgroup, &tid);
|
code = mnodeGetAvailableVgroup(pMsg, &pVgroup, &tid);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
mDebug("msg:%p, app:%p table:%s, failed to get available vgroup, reason:%s", pMsg, pMsg->rpcMsg.ahandle,
|
mDebug("msg:%p, app:%p table:%s, failed to get available vgroup, reason:%s", pMsg, pMsg->rpcMsg.ahandle,
|
||||||
pCreate->tableFname, tstrerror(code));
|
pCreate->tableName, tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2045,15 +2051,15 @@ static int32_t mnodeProcessCreateChildTableMsg(SMnodeMsg *pMsg) {
|
||||||
return mnodeDoCreateChildTable(pMsg, tid);
|
return mnodeDoCreateChildTable(pMsg, tid);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (pMsg->pTable == NULL) pMsg->pTable = mnodeGetTable(pCreate->tableFname);
|
if (pMsg->pTable == NULL) pMsg->pTable = mnodeGetTable(pCreate->tableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pMsg->pTable == NULL) {
|
if (pMsg->pTable == NULL) {
|
||||||
mError("msg:%p, app:%p table:%s, object not found, retry:%d reason:%s", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableFname, pMsg->retry,
|
mError("msg:%p, app:%p table:%s, object not found, retry:%d reason:%s", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableName, pMsg->retry,
|
||||||
tstrerror(terrno));
|
tstrerror(terrno));
|
||||||
return terrno;
|
return terrno;
|
||||||
} else {
|
} else {
|
||||||
mDebug("msg:%p, app:%p table:%s, send create msg to vnode again", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableFname);
|
mDebug("msg:%p, app:%p table:%s, send create msg to vnode again", pMsg, pMsg->rpcMsg.ahandle, pCreate->tableName);
|
||||||
return mnodeDoCreateChildTableFp(pMsg);
|
return mnodeDoCreateChildTableFp(pMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2398,8 +2404,7 @@ static int32_t mnodeAutoCreateChildTable(SMnodeMsg *pMsg) {
|
||||||
SCreateTableMsg* pCreate = (SCreateTableMsg*) ((char*) pCreateMsg + sizeof(SCMCreateTableMsg));
|
SCreateTableMsg* pCreate = (SCreateTableMsg*) ((char*) pCreateMsg + sizeof(SCMCreateTableMsg));
|
||||||
|
|
||||||
size_t size = tListLen(pInfo->tableFname);
|
size_t size = tListLen(pInfo->tableFname);
|
||||||
tstrncpy(pCreate->tableFname, pInfo->tableFname, size);
|
tstrncpy(pCreate->tableName, pInfo->tableFname, size);
|
||||||
tstrncpy(pCreate->db, pMsg->pDb->name, sizeof(pCreate->db));
|
|
||||||
pCreate->igExists = 1;
|
pCreate->igExists = 1;
|
||||||
pCreate->getMeta = 1;
|
pCreate->getMeta = 1;
|
||||||
|
|
||||||
|
@ -2767,7 +2772,7 @@ static int32_t mnodeProcessMultiTableMetaMsg(SMnodeMsg *pMsg) {
|
||||||
SCTableObj *pTable = mnodeGetChildTable(tableId);
|
SCTableObj *pTable = mnodeGetChildTable(tableId);
|
||||||
if (pTable == NULL) continue;
|
if (pTable == NULL) continue;
|
||||||
|
|
||||||
if (pMsg->pDb == NULL) pMsg->pDb = mnodeGetDbByTableId(tableId);
|
if (pMsg->pDb == NULL) pMsg->pDb = mnodeGetDbByTableName(tableId);
|
||||||
if (pMsg->pDb == NULL || pMsg->pDb->status != TSDB_DB_STATUS_READY) {
|
if (pMsg->pDb == NULL || pMsg->pDb->status != TSDB_DB_STATUS_READY) {
|
||||||
mnodeDecTableRef(pTable);
|
mnodeDecTableRef(pTable);
|
||||||
continue;
|
continue;
|
||||||
|
@ -2988,7 +2993,7 @@ static int32_t mnodeProcessAlterTableMsg(SMnodeMsg *pMsg) {
|
||||||
mDebug("msg:%p, app:%p table:%s, alter table msg is received from thandle:%p", pMsg, pMsg->rpcMsg.ahandle,
|
mDebug("msg:%p, app:%p table:%s, alter table msg is received from thandle:%p", pMsg, pMsg->rpcMsg.ahandle,
|
||||||
pAlter->tableFname, pMsg->rpcMsg.handle);
|
pAlter->tableFname, pMsg->rpcMsg.handle);
|
||||||
|
|
||||||
if (pMsg->pDb == NULL) pMsg->pDb = mnodeGetDbByTableId(pAlter->tableFname);
|
if (pMsg->pDb == NULL) pMsg->pDb = mnodeGetDbByTableName(pAlter->tableFname);
|
||||||
if (pMsg->pDb == NULL) {
|
if (pMsg->pDb == NULL) {
|
||||||
mError("msg:%p, app:%p table:%s, failed to alter table, db not selected", pMsg, pMsg->rpcMsg.ahandle, pAlter->tableFname);
|
mError("msg:%p, app:%p table:%s, failed to alter table, db not selected", pMsg, pMsg->rpcMsg.ahandle, pAlter->tableFname);
|
||||||
return TSDB_CODE_MND_DB_NOT_SELECTED;
|
return TSDB_CODE_MND_DB_NOT_SELECTED;
|
||||||
|
|
|
@ -96,16 +96,16 @@ typedef struct SCreateTableSQL {
|
||||||
SQuerySQL *pSelect;
|
SQuerySQL *pSelect;
|
||||||
} SCreateTableSQL;
|
} SCreateTableSQL;
|
||||||
|
|
||||||
typedef struct SAlterTableSQL {
|
typedef struct SAlterTableInfo {
|
||||||
SStrToken name;
|
SStrToken name;
|
||||||
int16_t tableType;
|
int16_t tableType;
|
||||||
int16_t type;
|
int16_t type;
|
||||||
STagData tagData;
|
STagData tagData;
|
||||||
SArray *pAddColumns; // SArray<TAOS_FIELD>
|
SArray *pAddColumns; // SArray<TAOS_FIELD>
|
||||||
SArray *varList; // set t=val or: change src dst, SArray<tVariantListItem>
|
SArray *varList; // set t=val or: change src dst, SArray<tVariantListItem>
|
||||||
} SAlterTableSQL;
|
} SAlterTableInfo;
|
||||||
|
|
||||||
typedef struct SCreateDBInfo {
|
typedef struct SCreateDbInfo {
|
||||||
SStrToken dbname;
|
SStrToken dbname;
|
||||||
int32_t replica;
|
int32_t replica;
|
||||||
int32_t cacheBlockSize;
|
int32_t cacheBlockSize;
|
||||||
|
@ -123,11 +123,10 @@ typedef struct SCreateDBInfo {
|
||||||
bool ignoreExists;
|
bool ignoreExists;
|
||||||
int8_t update;
|
int8_t update;
|
||||||
int8_t cachelast;
|
int8_t cachelast;
|
||||||
|
SArray *keep;
|
||||||
SArray *keep;
|
} SCreateDbInfo;
|
||||||
} SCreateDBInfo;
|
|
||||||
|
|
||||||
typedef struct SCreateAcctSQL {
|
typedef struct SCreateAcctInfo {
|
||||||
int32_t maxUsers;
|
int32_t maxUsers;
|
||||||
int32_t maxDbs;
|
int32_t maxDbs;
|
||||||
int32_t maxTimeSeries;
|
int32_t maxTimeSeries;
|
||||||
|
@ -137,7 +136,7 @@ typedef struct SCreateAcctSQL {
|
||||||
int64_t maxQueryTime;
|
int64_t maxQueryTime;
|
||||||
int32_t maxConnections;
|
int32_t maxConnections;
|
||||||
SStrToken stat;
|
SStrToken stat;
|
||||||
} SCreateAcctSQL;
|
} SCreateAcctInfo;
|
||||||
|
|
||||||
typedef struct SShowInfo {
|
typedef struct SShowInfo {
|
||||||
uint8_t showType;
|
uint8_t showType;
|
||||||
|
@ -152,23 +151,18 @@ typedef struct SUserInfo {
|
||||||
int16_t type;
|
int16_t type;
|
||||||
} SUserInfo;
|
} SUserInfo;
|
||||||
|
|
||||||
typedef struct tDCLSQL {
|
typedef struct SMiscInfo {
|
||||||
int32_t nTokens; /* Number of expressions on the list */
|
SArray *a; // SArray<SStrToken>
|
||||||
int32_t nAlloc; /* Number of entries allocated below */
|
bool existsCheck;
|
||||||
SStrToken *a; /* one entry for element */
|
|
||||||
bool existsCheck;
|
|
||||||
int16_t tableType;
|
int16_t tableType;
|
||||||
|
SUserInfo user;
|
||||||
union {
|
union {
|
||||||
SCreateDBInfo dbOpt;
|
SCreateDbInfo dbOpt;
|
||||||
SCreateAcctSQL acctOpt;
|
SCreateAcctInfo acctOpt;
|
||||||
SShowInfo showOpt;
|
SShowInfo showOpt;
|
||||||
SStrToken ip;
|
SStrToken id;
|
||||||
};
|
};
|
||||||
|
} SMiscInfo;
|
||||||
SUserInfo user;
|
|
||||||
|
|
||||||
} tDCLSQL;
|
|
||||||
|
|
||||||
typedef struct SSubclauseInfo { // "UNION" multiple select sub-clause
|
typedef struct SSubclauseInfo { // "UNION" multiple select sub-clause
|
||||||
SQuerySQL **pClause;
|
SQuerySQL **pClause;
|
||||||
|
@ -178,15 +172,13 @@ typedef struct SSubclauseInfo { // "UNION" multiple select sub-clause
|
||||||
typedef struct SSqlInfo {
|
typedef struct SSqlInfo {
|
||||||
int32_t type;
|
int32_t type;
|
||||||
bool valid;
|
bool valid;
|
||||||
|
|
||||||
union {
|
|
||||||
SCreateTableSQL *pCreateTableInfo;
|
|
||||||
SAlterTableSQL *pAlterInfo;
|
|
||||||
tDCLSQL *pDCLInfo;
|
|
||||||
};
|
|
||||||
|
|
||||||
SSubclauseInfo subclauseInfo;
|
SSubclauseInfo subclauseInfo;
|
||||||
char pzErrMsg[256];
|
char msg[256];
|
||||||
|
union {
|
||||||
|
SCreateTableSQL *pCreateTableInfo;
|
||||||
|
SAlterTableInfo *pAlterInfo;
|
||||||
|
SMiscInfo *pMiscInfo;
|
||||||
|
};
|
||||||
} SSqlInfo;
|
} SSqlInfo;
|
||||||
|
|
||||||
typedef struct tSQLExpr {
|
typedef struct tSQLExpr {
|
||||||
|
@ -252,7 +244,7 @@ SCreateTableSQL *tSetCreateSqlElems(SArray *pCols, SArray *pTags, SQuerySQL *pSe
|
||||||
|
|
||||||
void tSqlExprNodeDestroy(tSQLExpr *pExpr);
|
void tSqlExprNodeDestroy(tSQLExpr *pExpr);
|
||||||
|
|
||||||
SAlterTableSQL * tAlterTableSqlElems(SStrToken *pTableName, SArray *pCols, SArray *pVals, int32_t type, int16_t tableTable);
|
SAlterTableInfo * tAlterTableSqlElems(SStrToken *pTableName, SArray *pCols, SArray *pVals, int32_t type, int16_t tableTable);
|
||||||
SCreatedTableInfo createNewChildTableInfo(SStrToken *pTableName, SArray *pTagVals, SStrToken *pToken, SStrToken* igExists);
|
SCreatedTableInfo createNewChildTableInfo(SStrToken *pTableName, SArray *pTagVals, SStrToken *pToken, SStrToken* igExists);
|
||||||
|
|
||||||
void destroyAllSelectClause(SSubclauseInfo *pSql);
|
void destroyAllSelectClause(SSubclauseInfo *pSql);
|
||||||
|
@ -272,16 +264,14 @@ void setDCLSQLElems(SSqlInfo *pInfo, int32_t type, int32_t nParams, ...);
|
||||||
void setDropDbTableInfo(SSqlInfo *pInfo, int32_t type, SStrToken* pToken, SStrToken* existsCheck,int16_t tableType);
|
void setDropDbTableInfo(SSqlInfo *pInfo, int32_t type, SStrToken* pToken, SStrToken* existsCheck,int16_t tableType);
|
||||||
void setShowOptions(SSqlInfo *pInfo, int32_t type, SStrToken* prefix, SStrToken* pPatterns);
|
void setShowOptions(SSqlInfo *pInfo, int32_t type, SStrToken* prefix, SStrToken* pPatterns);
|
||||||
|
|
||||||
tDCLSQL *tTokenListAppend(tDCLSQL *pTokenList, SStrToken *pToken);
|
void setCreateDbInfo(SSqlInfo *pInfo, int32_t type, SStrToken *pToken, SCreateDbInfo *pDB, SStrToken *pIgExists);
|
||||||
|
|
||||||
void setCreateDBSQL(SSqlInfo *pInfo, int32_t type, SStrToken *pToken, SCreateDBInfo *pDB, SStrToken *pIgExists);
|
void setCreateAcctSql(SSqlInfo *pInfo, int32_t type, SStrToken *pName, SStrToken *pPwd, SCreateAcctInfo *pAcctInfo);
|
||||||
|
|
||||||
void setCreateAcctSql(SSqlInfo *pInfo, int32_t type, SStrToken *pName, SStrToken *pPwd, SCreateAcctSQL *pAcctInfo);
|
|
||||||
void setCreateUserSql(SSqlInfo *pInfo, SStrToken *pName, SStrToken *pPasswd);
|
void setCreateUserSql(SSqlInfo *pInfo, SStrToken *pName, SStrToken *pPasswd);
|
||||||
void setKillSql(SSqlInfo *pInfo, int32_t type, SStrToken *ip);
|
void setKillSql(SSqlInfo *pInfo, int32_t type, SStrToken *ip);
|
||||||
void setAlterUserSql(SSqlInfo *pInfo, int16_t type, SStrToken *pName, SStrToken* pPwd, SStrToken *pPrivilege);
|
void setAlterUserSql(SSqlInfo *pInfo, int16_t type, SStrToken *pName, SStrToken* pPwd, SStrToken *pPrivilege);
|
||||||
|
|
||||||
void setDefaultCreateDbOption(SCreateDBInfo *pDBInfo);
|
void setDefaultCreateDbOption(SCreateDbInfo *pDBInfo);
|
||||||
|
|
||||||
// prefix show db.tables;
|
// prefix show db.tables;
|
||||||
void setDbName(SStrToken *pCpxName, SStrToken *pDb);
|
void setDbName(SStrToken *pCpxName, SStrToken *pDb);
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
%syntax_error {
|
%syntax_error {
|
||||||
pInfo->valid = false;
|
pInfo->valid = false;
|
||||||
int32_t outputBufLen = tListLen(pInfo->pzErrMsg);
|
int32_t outputBufLen = tListLen(pInfo->msg);
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
|
|
||||||
if(TOKEN.z) {
|
if(TOKEN.z) {
|
||||||
|
@ -46,13 +46,13 @@
|
||||||
if (sqlLen + sizeof(msg)/sizeof(msg[0]) + 1 > outputBufLen) {
|
if (sqlLen + sizeof(msg)/sizeof(msg[0]) + 1 > outputBufLen) {
|
||||||
char tmpstr[128] = {0};
|
char tmpstr[128] = {0};
|
||||||
memcpy(tmpstr, &TOKEN.z[0], sizeof(tmpstr)/sizeof(tmpstr[0]) - 1);
|
memcpy(tmpstr, &TOKEN.z[0], sizeof(tmpstr)/sizeof(tmpstr[0]) - 1);
|
||||||
len = sprintf(pInfo->pzErrMsg, msg, tmpstr);
|
len = sprintf(pInfo->msg, msg, tmpstr);
|
||||||
} else {
|
} else {
|
||||||
len = sprintf(pInfo->pzErrMsg, msg, &TOKEN.z[0]);
|
len = sprintf(pInfo->msg, msg, &TOKEN.z[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
len = sprintf(pInfo->pzErrMsg, "Incomplete SQL statement");
|
len = sprintf(pInfo->msg, "Incomplete SQL statement");
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(len <= outputBufLen);
|
assert(len <= outputBufLen);
|
||||||
|
@ -216,7 +216,7 @@ conns(Y) ::= CONNS INTEGER(X). { Y = X; }
|
||||||
state(Y) ::= . { Y.n = 0; }
|
state(Y) ::= . { Y.n = 0; }
|
||||||
state(Y) ::= STATE ids(X). { Y = X; }
|
state(Y) ::= STATE ids(X). { Y = X; }
|
||||||
|
|
||||||
%type acct_optr {SCreateAcctSQL}
|
%type acct_optr {SCreateAcctInfo}
|
||||||
acct_optr(Y) ::= pps(C) tseries(D) storage(P) streams(F) qtime(Q) dbs(E) users(K) conns(L) state(M). {
|
acct_optr(Y) ::= pps(C) tseries(D) storage(P) streams(F) qtime(Q) dbs(E) users(K) conns(L) state(M). {
|
||||||
Y.maxUsers = (K.n>0)?atoi(K.z):-1;
|
Y.maxUsers = (K.n>0)?atoi(K.z):-1;
|
||||||
Y.maxDbs = (E.n>0)?atoi(E.z):-1;
|
Y.maxDbs = (E.n>0)?atoi(E.z):-1;
|
||||||
|
@ -248,7 +248,7 @@ prec(Y) ::= PRECISION STRING(X). { Y = X; }
|
||||||
update(Y) ::= UPDATE INTEGER(X). { Y = X; }
|
update(Y) ::= UPDATE INTEGER(X). { Y = X; }
|
||||||
cachelast(Y) ::= CACHELAST INTEGER(X). { Y = X; }
|
cachelast(Y) ::= CACHELAST INTEGER(X). { Y = X; }
|
||||||
|
|
||||||
%type db_optr {SCreateDBInfo}
|
%type db_optr {SCreateDbInfo}
|
||||||
db_optr(Y) ::= . {setDefaultCreateDbOption(&Y);}
|
db_optr(Y) ::= . {setDefaultCreateDbOption(&Y);}
|
||||||
|
|
||||||
db_optr(Y) ::= db_optr(Z) cache(X). { Y = Z; Y.cacheBlockSize = strtol(X.z, NULL, 10); }
|
db_optr(Y) ::= db_optr(Z) cache(X). { Y = Z; Y.cacheBlockSize = strtol(X.z, NULL, 10); }
|
||||||
|
@ -267,7 +267,7 @@ db_optr(Y) ::= db_optr(Z) keep(X). { Y = Z; Y.keep = X; }
|
||||||
db_optr(Y) ::= db_optr(Z) update(X). { Y = Z; Y.update = strtol(X.z, NULL, 10); }
|
db_optr(Y) ::= db_optr(Z) update(X). { Y = Z; Y.update = strtol(X.z, NULL, 10); }
|
||||||
db_optr(Y) ::= db_optr(Z) cachelast(X). { Y = Z; Y.cachelast = strtol(X.z, NULL, 10); }
|
db_optr(Y) ::= db_optr(Z) cachelast(X). { Y = Z; Y.cachelast = strtol(X.z, NULL, 10); }
|
||||||
|
|
||||||
%type alter_db_optr {SCreateDBInfo}
|
%type alter_db_optr {SCreateDbInfo}
|
||||||
alter_db_optr(Y) ::= . { setDefaultCreateDbOption(&Y);}
|
alter_db_optr(Y) ::= . { setDefaultCreateDbOption(&Y);}
|
||||||
|
|
||||||
alter_db_optr(Y) ::= alter_db_optr(Z) replica(X). { Y = Z; Y.replica = strtol(X.z, NULL, 10); }
|
alter_db_optr(Y) ::= alter_db_optr(Z) replica(X). { Y = Z; Y.replica = strtol(X.z, NULL, 10); }
|
||||||
|
@ -692,7 +692,7 @@ cmd ::= RESET QUERY CACHE. { setDCLSQLElems(pInfo, TSDB_SQL_RESET_CACHE, 0);}
|
||||||
///////////////////////////////////ALTER TABLE statement//////////////////////////////////
|
///////////////////////////////////ALTER TABLE statement//////////////////////////////////
|
||||||
cmd ::= ALTER TABLE ids(X) cpxName(F) ADD COLUMN columnlist(A). {
|
cmd ::= ALTER TABLE ids(X) cpxName(F) ADD COLUMN columnlist(A). {
|
||||||
X.n += F.n;
|
X.n += F.n;
|
||||||
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, A, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1);
|
SAlterTableInfo* pAlterTable = tAlterTableSqlElems(&X, A, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1);
|
||||||
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -702,14 +702,14 @@ cmd ::= ALTER TABLE ids(X) cpxName(F) DROP COLUMN ids(A). {
|
||||||
toTSDBType(A.type);
|
toTSDBType(A.type);
|
||||||
SArray* K = tVariantListAppendToken(NULL, &A, -1);
|
SArray* K = tVariantListAppendToken(NULL, &A, -1);
|
||||||
|
|
||||||
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, NULL, K, TSDB_ALTER_TABLE_DROP_COLUMN, -1);
|
SAlterTableInfo* pAlterTable = tAlterTableSqlElems(&X, NULL, K, TSDB_ALTER_TABLE_DROP_COLUMN, -1);
|
||||||
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////ALTER TAGS statement/////////////////////////////////////
|
//////////////////////////////////ALTER TAGS statement/////////////////////////////////////
|
||||||
cmd ::= ALTER TABLE ids(X) cpxName(Y) ADD TAG columnlist(A). {
|
cmd ::= ALTER TABLE ids(X) cpxName(Y) ADD TAG columnlist(A). {
|
||||||
X.n += Y.n;
|
X.n += Y.n;
|
||||||
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, A, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1);
|
SAlterTableInfo* pAlterTable = tAlterTableSqlElems(&X, A, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1);
|
||||||
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
||||||
}
|
}
|
||||||
cmd ::= ALTER TABLE ids(X) cpxName(Z) DROP TAG ids(Y). {
|
cmd ::= ALTER TABLE ids(X) cpxName(Z) DROP TAG ids(Y). {
|
||||||
|
@ -718,7 +718,7 @@ cmd ::= ALTER TABLE ids(X) cpxName(Z) DROP TAG ids(Y). {
|
||||||
toTSDBType(Y.type);
|
toTSDBType(Y.type);
|
||||||
SArray* A = tVariantListAppendToken(NULL, &Y, -1);
|
SArray* A = tVariantListAppendToken(NULL, &Y, -1);
|
||||||
|
|
||||||
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, NULL, A, TSDB_ALTER_TABLE_DROP_TAG_COLUMN, -1);
|
SAlterTableInfo* pAlterTable = tAlterTableSqlElems(&X, NULL, A, TSDB_ALTER_TABLE_DROP_TAG_COLUMN, -1);
|
||||||
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -731,7 +731,7 @@ cmd ::= ALTER TABLE ids(X) cpxName(F) CHANGE TAG ids(Y) ids(Z). {
|
||||||
toTSDBType(Z.type);
|
toTSDBType(Z.type);
|
||||||
A = tVariantListAppendToken(A, &Z, -1);
|
A = tVariantListAppendToken(A, &Z, -1);
|
||||||
|
|
||||||
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, NULL, A, TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN, -1);
|
SAlterTableInfo* pAlterTable = tAlterTableSqlElems(&X, NULL, A, TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN, -1);
|
||||||
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -742,7 +742,7 @@ cmd ::= ALTER TABLE ids(X) cpxName(F) SET TAG ids(Y) EQ tagitem(Z). {
|
||||||
SArray* A = tVariantListAppendToken(NULL, &Y, -1);
|
SArray* A = tVariantListAppendToken(NULL, &Y, -1);
|
||||||
A = tVariantListAppend(A, &Z, -1);
|
A = tVariantListAppend(A, &Z, -1);
|
||||||
|
|
||||||
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL, -1);
|
SAlterTableInfo* pAlterTable = tAlterTableSqlElems(&X, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL, -1);
|
||||||
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -750,7 +750,7 @@ cmd ::= ALTER TABLE ids(X) cpxName(F) SET TAG ids(Y) EQ tagitem(Z). {
|
||||||
///////////////////////////////////ALTER STABLE statement//////////////////////////////////
|
///////////////////////////////////ALTER STABLE statement//////////////////////////////////
|
||||||
cmd ::= ALTER STABLE ids(X) cpxName(F) ADD COLUMN columnlist(A). {
|
cmd ::= ALTER STABLE ids(X) cpxName(F) ADD COLUMN columnlist(A). {
|
||||||
X.n += F.n;
|
X.n += F.n;
|
||||||
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, A, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE);
|
SAlterTableInfo* pAlterTable = tAlterTableSqlElems(&X, A, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE);
|
||||||
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -760,14 +760,14 @@ cmd ::= ALTER STABLE ids(X) cpxName(F) DROP COLUMN ids(A). {
|
||||||
toTSDBType(A.type);
|
toTSDBType(A.type);
|
||||||
SArray* K = tVariantListAppendToken(NULL, &A, -1);
|
SArray* K = tVariantListAppendToken(NULL, &A, -1);
|
||||||
|
|
||||||
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, NULL, K, TSDB_ALTER_TABLE_DROP_COLUMN, TSDB_SUPER_TABLE);
|
SAlterTableInfo* pAlterTable = tAlterTableSqlElems(&X, NULL, K, TSDB_ALTER_TABLE_DROP_COLUMN, TSDB_SUPER_TABLE);
|
||||||
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////ALTER TAGS statement/////////////////////////////////////
|
//////////////////////////////////ALTER TAGS statement/////////////////////////////////////
|
||||||
cmd ::= ALTER STABLE ids(X) cpxName(Y) ADD TAG columnlist(A). {
|
cmd ::= ALTER STABLE ids(X) cpxName(Y) ADD TAG columnlist(A). {
|
||||||
X.n += Y.n;
|
X.n += Y.n;
|
||||||
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, A, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE);
|
SAlterTableInfo* pAlterTable = tAlterTableSqlElems(&X, A, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE);
|
||||||
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
||||||
}
|
}
|
||||||
cmd ::= ALTER STABLE ids(X) cpxName(Z) DROP TAG ids(Y). {
|
cmd ::= ALTER STABLE ids(X) cpxName(Z) DROP TAG ids(Y). {
|
||||||
|
@ -776,7 +776,7 @@ cmd ::= ALTER STABLE ids(X) cpxName(Z) DROP TAG ids(Y). {
|
||||||
toTSDBType(Y.type);
|
toTSDBType(Y.type);
|
||||||
SArray* A = tVariantListAppendToken(NULL, &Y, -1);
|
SArray* A = tVariantListAppendToken(NULL, &Y, -1);
|
||||||
|
|
||||||
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, NULL, A, TSDB_ALTER_TABLE_DROP_TAG_COLUMN, TSDB_SUPER_TABLE);
|
SAlterTableInfo* pAlterTable = tAlterTableSqlElems(&X, NULL, A, TSDB_ALTER_TABLE_DROP_TAG_COLUMN, TSDB_SUPER_TABLE);
|
||||||
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -789,7 +789,7 @@ cmd ::= ALTER STABLE ids(X) cpxName(F) CHANGE TAG ids(Y) ids(Z). {
|
||||||
toTSDBType(Z.type);
|
toTSDBType(Z.type);
|
||||||
A = tVariantListAppendToken(A, &Z, -1);
|
A = tVariantListAppendToken(A, &Z, -1);
|
||||||
|
|
||||||
SAlterTableSQL* pAlterTable = tAlterTableSqlElems(&X, NULL, A, TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN, TSDB_SUPER_TABLE);
|
SAlterTableInfo* pAlterTable = tAlterTableSqlElems(&X, NULL, A, TSDB_ALTER_TABLE_CHANGE_TAG_COLUMN, TSDB_SUPER_TABLE);
|
||||||
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -407,7 +407,7 @@ tExprNode* exprTreeFromTableName(const char* tbnameCond) {
|
||||||
SSchema* pSchema = exception_calloc(1, sizeof(SSchema));
|
SSchema* pSchema = exception_calloc(1, sizeof(SSchema));
|
||||||
left->pSchema = pSchema;
|
left->pSchema = pSchema;
|
||||||
|
|
||||||
*pSchema = tscGetTbnameColumnSchema();
|
*pSchema = tGetTbnameColumnSchema();
|
||||||
|
|
||||||
tExprNode* right = exception_calloc(1, sizeof(tExprNode));
|
tExprNode* right = exception_calloc(1, sizeof(tExprNode));
|
||||||
expr->_node.pRight = right;
|
expr->_node.pRight = right;
|
||||||
|
|
|
@ -1875,6 +1875,7 @@ static int32_t setCtxTagColumnInfo(SQueryRuntimeEnv *pRuntimeEnv, SQLFunctionCtx
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo refactor
|
||||||
static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int16_t order) {
|
static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int16_t order) {
|
||||||
qDebug("QInfo:%p setup runtime env", GET_QINFO_ADDR(pRuntimeEnv));
|
qDebug("QInfo:%p setup runtime env", GET_QINFO_ADDR(pRuntimeEnv));
|
||||||
SQuery *pQuery = pRuntimeEnv->pQuery;
|
SQuery *pQuery = pRuntimeEnv->pQuery;
|
||||||
|
@ -3849,11 +3850,6 @@ void setExecutionContext(SQInfo *pQInfo, int32_t groupIndex, TSKEY nextKey) {
|
||||||
|
|
||||||
// lastKey needs to be updated
|
// lastKey needs to be updated
|
||||||
pTableQueryInfo->lastKey = nextKey;
|
pTableQueryInfo->lastKey = nextKey;
|
||||||
|
|
||||||
if (pRuntimeEnv->hasTagResults || pRuntimeEnv->pTsBuf != NULL) {
|
|
||||||
setAdditionalInfo(pQInfo, pTableQueryInfo->pTable, pTableQueryInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pRuntimeEnv->prevGroupId != INT32_MIN && pRuntimeEnv->prevGroupId == groupIndex) {
|
if (pRuntimeEnv->prevGroupId != INT32_MIN && pRuntimeEnv->prevGroupId == groupIndex) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4779,19 +4775,17 @@ static void enableExecutionForNextTable(SQueryRuntimeEnv *pRuntimeEnv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO refactor: setAdditionalInfo
|
|
||||||
static FORCE_INLINE void setEnvForEachBlock(SQInfo* pQInfo, STableQueryInfo* pTableQueryInfo, SDataBlockInfo* pBlockInfo) {
|
static FORCE_INLINE void setEnvForEachBlock(SQInfo* pQInfo, STableQueryInfo* pTableQueryInfo, SDataBlockInfo* pBlockInfo) {
|
||||||
SQueryRuntimeEnv* pRuntimeEnv = &pQInfo->runtimeEnv;
|
SQueryRuntimeEnv* pRuntimeEnv = &pQInfo->runtimeEnv;
|
||||||
SQuery* pQuery = pQInfo->runtimeEnv.pQuery;
|
SQuery* pQuery = pQInfo->runtimeEnv.pQuery;
|
||||||
int32_t step = GET_FORWARD_DIRECTION_FACTOR(pQuery->order.order);
|
int32_t step = GET_FORWARD_DIRECTION_FACTOR(pQuery->order.order);
|
||||||
|
|
||||||
if (QUERY_IS_INTERVAL_QUERY(pQuery)) {
|
if (pRuntimeEnv->hasTagResults || pRuntimeEnv->pTsBuf != NULL) {
|
||||||
TSKEY nextKey = pBlockInfo->window.skey;
|
setAdditionalInfo(pQInfo, pTableQueryInfo->pTable, pTableQueryInfo);
|
||||||
setIntervalQueryRange(pQInfo, nextKey);
|
}
|
||||||
|
|
||||||
if (pRuntimeEnv->hasTagResults || pRuntimeEnv->pTsBuf != NULL) {
|
if (QUERY_IS_INTERVAL_QUERY(pQuery)) {
|
||||||
setAdditionalInfo(pQInfo, pTableQueryInfo->pTable, pTableQueryInfo);
|
setIntervalQueryRange(pQInfo, pBlockInfo->window.skey);
|
||||||
}
|
|
||||||
} else { // non-interval query
|
} else { // non-interval query
|
||||||
setExecutionContext(pQInfo, pTableQueryInfo->groupIndex, pBlockInfo->window.ekey + step);
|
setExecutionContext(pQInfo, pTableQueryInfo->groupIndex, pBlockInfo->window.ekey + step);
|
||||||
}
|
}
|
||||||
|
@ -4814,7 +4808,7 @@ static void doTableQueryInfoTimeWindowCheck(SQuery* pQuery, STableQueryInfo* pTa
|
||||||
static int64_t scanMultiTableDataBlocks(SQInfo *pQInfo) {
|
static int64_t scanMultiTableDataBlocks(SQInfo *pQInfo) {
|
||||||
SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv;
|
SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv;
|
||||||
SQuery* pQuery = pRuntimeEnv->pQuery;
|
SQuery* pQuery = pRuntimeEnv->pQuery;
|
||||||
SQueryCostInfo* summary = &pRuntimeEnv->summary;
|
SQueryCostInfo* summary = &pRuntimeEnv->summary;
|
||||||
|
|
||||||
int64_t st = taosGetTimestampMs();
|
int64_t st = taosGetTimestampMs();
|
||||||
|
|
||||||
|
@ -5047,7 +5041,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
|
||||||
STsdbQueryCond cond = createTsdbQueryCond(pQuery, &pQuery->window);
|
STsdbQueryCond cond = createTsdbQueryCond(pQuery, &pQuery->window);
|
||||||
|
|
||||||
SArray *g1 = taosArrayInit(1, POINTER_BYTES);
|
SArray *g1 = taosArrayInit(1, POINTER_BYTES);
|
||||||
SArray *tx = taosArrayClone(group);
|
SArray *tx = taosArrayDup(group);
|
||||||
taosArrayPush(g1, &tx);
|
taosArrayPush(g1, &tx);
|
||||||
|
|
||||||
STableGroupInfo gp = {.numOfTables = taosArrayGetSize(tx), .pGroupList = g1};
|
STableGroupInfo gp = {.numOfTables = taosArrayGetSize(tx), .pGroupList = g1};
|
||||||
|
@ -5107,7 +5101,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
|
||||||
STsdbQueryCond cond = createTsdbQueryCond(pQuery, &pQuery->window);
|
STsdbQueryCond cond = createTsdbQueryCond(pQuery, &pQuery->window);
|
||||||
|
|
||||||
SArray *g1 = taosArrayInit(1, POINTER_BYTES);
|
SArray *g1 = taosArrayInit(1, POINTER_BYTES);
|
||||||
SArray *tx = taosArrayClone(group);
|
SArray *tx = taosArrayDup(group);
|
||||||
taosArrayPush(g1, &tx);
|
taosArrayPush(g1, &tx);
|
||||||
|
|
||||||
STableGroupInfo gp = {.numOfTables = taosArrayGetSize(tx), .pGroupList = g1};
|
STableGroupInfo gp = {.numOfTables = taosArrayGetSize(tx), .pGroupList = g1};
|
||||||
|
@ -5471,7 +5465,7 @@ static void doRestoreContext(SQInfo *pQInfo) {
|
||||||
SET_MASTER_SCAN_FLAG(pRuntimeEnv);
|
SET_MASTER_SCAN_FLAG(pRuntimeEnv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doCloseAllTimeWindowAfterScan(SQInfo *pQInfo) {
|
static void doCloseAllTimeWindow(SQInfo *pQInfo) {
|
||||||
SQuery *pQuery = pQInfo->runtimeEnv.pQuery;
|
SQuery *pQuery = pQInfo->runtimeEnv.pQuery;
|
||||||
|
|
||||||
if (QUERY_IS_INTERVAL_QUERY(pQuery)) {
|
if (QUERY_IS_INTERVAL_QUERY(pQuery)) {
|
||||||
|
@ -5523,7 +5517,7 @@ static void multiTableQueryProcess(SQInfo *pQInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// close all time window results
|
// close all time window results
|
||||||
doCloseAllTimeWindowAfterScan(pQInfo);
|
doCloseAllTimeWindow(pQInfo);
|
||||||
|
|
||||||
if (needReverseScan(pQuery)) {
|
if (needReverseScan(pQuery)) {
|
||||||
int32_t code = doSaveContext(pQInfo);
|
int32_t code = doSaveContext(pQInfo);
|
||||||
|
@ -5848,8 +5842,7 @@ static void stableQueryImpl(SQInfo *pQInfo) {
|
||||||
(isFixedOutputQuery(pRuntimeEnv) && (!isPointInterpoQuery(pQuery)) && (!pRuntimeEnv->groupbyColumn))) {
|
(isFixedOutputQuery(pRuntimeEnv) && (!isPointInterpoQuery(pQuery)) && (!pRuntimeEnv->groupbyColumn))) {
|
||||||
multiTableQueryProcess(pQInfo);
|
multiTableQueryProcess(pQInfo);
|
||||||
} else {
|
} else {
|
||||||
assert((pQuery->checkResultBuf == 1 && pQuery->interval.interval == 0) || isPointInterpoQuery(pQuery) ||
|
assert(pQuery->checkResultBuf == 1 || isPointInterpoQuery(pQuery) || pRuntimeEnv->groupbyColumn);
|
||||||
pRuntimeEnv->groupbyColumn);
|
|
||||||
|
|
||||||
sequentialTableProcess(pQInfo);
|
sequentialTableProcess(pQInfo);
|
||||||
}
|
}
|
||||||
|
@ -6377,7 +6370,7 @@ static int32_t createQueryFuncExprFromMsg(SQueryTableMsg *pQueryMsg, int32_t num
|
||||||
if (functId == TSDB_FUNC_TOP || functId == TSDB_FUNC_BOTTOM) {
|
if (functId == TSDB_FUNC_TOP || functId == TSDB_FUNC_BOTTOM) {
|
||||||
int32_t j = getColumnIndexInSource(pQueryMsg, &pExprs[i].base, pTagCols);
|
int32_t j = getColumnIndexInSource(pQueryMsg, &pExprs[i].base, pTagCols);
|
||||||
if (j < 0 || j >= pQueryMsg->numOfCols) {
|
if (j < 0 || j >= pQueryMsg->numOfCols) {
|
||||||
assert(0);
|
return TSDB_CODE_QRY_INVALID_MSG;
|
||||||
} else {
|
} else {
|
||||||
SColumnInfo *pCol = &pQueryMsg->colList[j];
|
SColumnInfo *pCol = &pQueryMsg->colList[j];
|
||||||
int32_t ret =
|
int32_t ret =
|
||||||
|
@ -6576,7 +6569,7 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SSqlGroupbyExpr *pGrou
|
||||||
int32_t srcSize = 0;
|
int32_t srcSize = 0;
|
||||||
for (int16_t i = 0; i < numOfCols; ++i) {
|
for (int16_t i = 0; i < numOfCols; ++i) {
|
||||||
pQuery->colList[i] = pQueryMsg->colList[i];
|
pQuery->colList[i] = pQueryMsg->colList[i];
|
||||||
pQuery->colList[i].filters = tscFilterInfoClone(pQueryMsg->colList[i].filters, pQuery->colList[i].numOfFilters);
|
pQuery->colList[i].filters = tFilterInfoDup(pQueryMsg->colList[i].filters, pQuery->colList[i].numOfFilters);
|
||||||
srcSize += pQuery->colList[i].bytes;
|
srcSize += pQuery->colList[i].bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6642,7 +6635,7 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SSqlGroupbyExpr *pGrou
|
||||||
pQInfo->runtimeEnv.summary.tableInfoSize += (pTableGroupInfo->numOfTables * sizeof(STableQueryInfo));
|
pQInfo->runtimeEnv.summary.tableInfoSize += (pTableGroupInfo->numOfTables * sizeof(STableQueryInfo));
|
||||||
|
|
||||||
pQInfo->runtimeEnv.pResultRowHashTable = taosHashInit(pTableGroupInfo->numOfTables, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
pQInfo->runtimeEnv.pResultRowHashTable = taosHashInit(pTableGroupInfo->numOfTables, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||||
pQInfo->runtimeEnv.keyBuf = malloc(TSDB_MAX_BYTES_PER_ROW);
|
pQInfo->runtimeEnv.keyBuf = malloc(TSDB_MAX_BYTES_PER_ROW); // todo opt size
|
||||||
pQInfo->runtimeEnv.pool = initResultRowPool(getResultRowSize(&pQInfo->runtimeEnv));
|
pQInfo->runtimeEnv.pool = initResultRowPool(getResultRowSize(&pQInfo->runtimeEnv));
|
||||||
pQInfo->runtimeEnv.prevRow = malloc(POINTER_BYTES * pQuery->numOfCols + srcSize);
|
pQInfo->runtimeEnv.prevRow = malloc(POINTER_BYTES * pQuery->numOfCols + srcSize);
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ SSqlInfo qSQLParse(const char *pStr) {
|
||||||
|
|
||||||
case TK_QUESTION:
|
case TK_QUESTION:
|
||||||
case TK_ILLEGAL: {
|
case TK_ILLEGAL: {
|
||||||
snprintf(sqlInfo.pzErrMsg, tListLen(sqlInfo.pzErrMsg), "unrecognized token: \"%s\"", t0.z);
|
snprintf(sqlInfo.msg, tListLen(sqlInfo.msg), "unrecognized token: \"%s\"", t0.z);
|
||||||
sqlInfo.valid = false;
|
sqlInfo.valid = false;
|
||||||
goto abort_parse;
|
goto abort_parse;
|
||||||
}
|
}
|
||||||
|
@ -585,8 +585,8 @@ SCreatedTableInfo createNewChildTableInfo(SStrToken *pTableName, SArray *pTagVal
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
SAlterTableSQL *tAlterTableSqlElems(SStrToken *pTableName, SArray *pCols, SArray *pVals, int32_t type, int16_t tableType) {
|
SAlterTableInfo *tAlterTableSqlElems(SStrToken *pTableName, SArray *pCols, SArray *pVals, int32_t type, int16_t tableType) {
|
||||||
SAlterTableSQL *pAlterTable = calloc(1, sizeof(SAlterTableSQL));
|
SAlterTableInfo *pAlterTable = calloc(1, sizeof(SAlterTableInfo));
|
||||||
|
|
||||||
pAlterTable->name = *pTableName;
|
pAlterTable->name = *pTableName;
|
||||||
pAlterTable->type = type;
|
pAlterTable->type = type;
|
||||||
|
@ -632,15 +632,15 @@ void SqlInfoDestroy(SSqlInfo *pInfo) {
|
||||||
tfree(pInfo->pAlterInfo->tagData.data);
|
tfree(pInfo->pAlterInfo->tagData.data);
|
||||||
tfree(pInfo->pAlterInfo);
|
tfree(pInfo->pAlterInfo);
|
||||||
} else {
|
} else {
|
||||||
if (pInfo->pDCLInfo != NULL && pInfo->pDCLInfo->nAlloc > 0) {
|
if (pInfo->pMiscInfo != NULL) {
|
||||||
free(pInfo->pDCLInfo->a);
|
taosArrayDestroy(pInfo->pMiscInfo->a);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pInfo->pDCLInfo != NULL && pInfo->type == TSDB_SQL_CREATE_DB) {
|
if (pInfo->pMiscInfo != NULL && pInfo->type == TSDB_SQL_CREATE_DB) {
|
||||||
taosArrayDestroyEx(pInfo->pDCLInfo->dbOpt.keep, freeVariant);
|
taosArrayDestroyEx(pInfo->pMiscInfo->dbOpt.keep, freeVariant);
|
||||||
}
|
}
|
||||||
|
|
||||||
tfree(pInfo->pDCLInfo);
|
tfree(pInfo->pMiscInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -697,58 +697,49 @@ void setCreatedTableName(SSqlInfo *pInfo, SStrToken *pTableNameToken, SStrToken
|
||||||
pInfo->pCreateTableInfo->existCheck = (pIfNotExists->n != 0);
|
pInfo->pCreateTableInfo->existCheck = (pIfNotExists->n != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tTokenListBuyMoreSpace(tDCLSQL *pTokenList) {
|
|
||||||
if (pTokenList->nAlloc <= pTokenList->nTokens) { //
|
|
||||||
pTokenList->nAlloc = (pTokenList->nAlloc << 1u) + 4;
|
|
||||||
pTokenList->a = realloc(pTokenList->a, pTokenList->nAlloc * sizeof(pTokenList->a[0]));
|
|
||||||
if (pTokenList->a == 0) {
|
|
||||||
pTokenList->nTokens = pTokenList->nAlloc = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tDCLSQL *tTokenListAppend(tDCLSQL *pTokenList, SStrToken *pToken) {
|
|
||||||
if (pToken == NULL) return NULL;
|
|
||||||
|
|
||||||
if (pTokenList == NULL) pTokenList = calloc(1, sizeof(tDCLSQL));
|
|
||||||
|
|
||||||
tTokenListBuyMoreSpace(pTokenList);
|
|
||||||
pTokenList->a[pTokenList->nTokens++] = *pToken;
|
|
||||||
|
|
||||||
return pTokenList;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setDCLSQLElems(SSqlInfo *pInfo, int32_t type, int32_t nParam, ...) {
|
void setDCLSQLElems(SSqlInfo *pInfo, int32_t type, int32_t nParam, ...) {
|
||||||
pInfo->type = type;
|
pInfo->type = type;
|
||||||
|
if (nParam == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (nParam == 0) return;
|
if (pInfo->pMiscInfo == NULL) {
|
||||||
if (pInfo->pDCLInfo == NULL) pInfo->pDCLInfo = (tDCLSQL *)calloc(1, sizeof(tDCLSQL));
|
pInfo->pMiscInfo = (SMiscInfo *)calloc(1, sizeof(SMiscInfo));
|
||||||
|
pInfo->pMiscInfo->a = taosArrayInit(4, sizeof(SStrToken));
|
||||||
|
}
|
||||||
|
|
||||||
va_list va;
|
va_list va;
|
||||||
va_start(va, nParam);
|
va_start(va, nParam);
|
||||||
|
|
||||||
while (nParam-- > 0) {
|
while ((nParam--) > 0) {
|
||||||
SStrToken *pToken = va_arg(va, SStrToken *);
|
SStrToken *pToken = va_arg(va, SStrToken *);
|
||||||
pInfo->pDCLInfo = tTokenListAppend(pInfo->pDCLInfo, pToken);
|
taosArrayPush(pInfo->pMiscInfo->a, pToken);
|
||||||
}
|
}
|
||||||
va_end(va);
|
va_end(va);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDropDbTableInfo(SSqlInfo *pInfo, int32_t type, SStrToken* pToken, SStrToken* existsCheck, int16_t tableType) {
|
void setDropDbTableInfo(SSqlInfo *pInfo, int32_t type, SStrToken* pToken, SStrToken* existsCheck, int16_t tableType) {
|
||||||
pInfo->type = type;
|
pInfo->type = type;
|
||||||
pInfo->pDCLInfo = tTokenListAppend(pInfo->pDCLInfo, pToken);
|
|
||||||
pInfo->pDCLInfo->tableType = tableType;
|
if (pInfo->pMiscInfo == NULL) {
|
||||||
pInfo->pDCLInfo->existsCheck = (existsCheck->n == 1);
|
pInfo->pMiscInfo = (SMiscInfo *)calloc(1, sizeof(SMiscInfo));
|
||||||
|
pInfo->pMiscInfo->a = taosArrayInit(4, sizeof(SStrToken));
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayPush(pInfo->pMiscInfo->a, pToken);
|
||||||
|
|
||||||
|
pInfo->pMiscInfo->existsCheck = (existsCheck->n == 1);
|
||||||
|
pInfo->pMiscInfo->tableType = tableType;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setShowOptions(SSqlInfo *pInfo, int32_t type, SStrToken* prefix, SStrToken* pPatterns) {
|
void setShowOptions(SSqlInfo *pInfo, int32_t type, SStrToken* prefix, SStrToken* pPatterns) {
|
||||||
if (pInfo->pDCLInfo == NULL) {
|
if (pInfo->pMiscInfo == NULL) {
|
||||||
pInfo->pDCLInfo = calloc(1, sizeof(tDCLSQL));
|
pInfo->pMiscInfo = calloc(1, sizeof(SMiscInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->type = TSDB_SQL_SHOW;
|
pInfo->type = TSDB_SQL_SHOW;
|
||||||
|
|
||||||
SShowInfo* pShowInfo = &pInfo->pDCLInfo->showOpt;
|
SShowInfo* pShowInfo = &pInfo->pMiscInfo->showOpt;
|
||||||
pShowInfo->showType = type;
|
pShowInfo->showType = type;
|
||||||
|
|
||||||
if (prefix != NULL && prefix->type != 0) {
|
if (prefix != NULL && prefix->type != 0) {
|
||||||
|
@ -764,54 +755,54 @@ void setShowOptions(SSqlInfo *pInfo, int32_t type, SStrToken* prefix, SStrToken*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCreateDBSQL(SSqlInfo *pInfo, int32_t type, SStrToken *pToken, SCreateDBInfo *pDB, SStrToken *pIgExists) {
|
void setCreateDbInfo(SSqlInfo *pInfo, int32_t type, SStrToken *pToken, SCreateDbInfo *pDB, SStrToken *pIgExists) {
|
||||||
pInfo->type = type;
|
pInfo->type = type;
|
||||||
if (pInfo->pDCLInfo == NULL) {
|
if (pInfo->pMiscInfo == NULL) {
|
||||||
pInfo->pDCLInfo = calloc(1, sizeof(tDCLSQL));
|
pInfo->pMiscInfo = calloc(1, sizeof(SMiscInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->pDCLInfo->dbOpt = *pDB;
|
pInfo->pMiscInfo->dbOpt = *pDB;
|
||||||
pInfo->pDCLInfo->dbOpt.dbname = *pToken;
|
pInfo->pMiscInfo->dbOpt.dbname = *pToken;
|
||||||
pInfo->pDCLInfo->dbOpt.ignoreExists = pIgExists->n; // sql.y has: ifnotexists(X) ::= IF NOT EXISTS. {X.n = 1;}
|
pInfo->pMiscInfo->dbOpt.ignoreExists = pIgExists->n; // sql.y has: ifnotexists(X) ::= IF NOT EXISTS. {X.n = 1;}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCreateAcctSql(SSqlInfo *pInfo, int32_t type, SStrToken *pName, SStrToken *pPwd, SCreateAcctSQL *pAcctInfo) {
|
void setCreateAcctSql(SSqlInfo *pInfo, int32_t type, SStrToken *pName, SStrToken *pPwd, SCreateAcctInfo *pAcctInfo) {
|
||||||
pInfo->type = type;
|
pInfo->type = type;
|
||||||
if (pInfo->pDCLInfo == NULL) {
|
if (pInfo->pMiscInfo == NULL) {
|
||||||
pInfo->pDCLInfo = calloc(1, sizeof(tDCLSQL));
|
pInfo->pMiscInfo = calloc(1, sizeof(SMiscInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->pDCLInfo->acctOpt = *pAcctInfo;
|
pInfo->pMiscInfo->acctOpt = *pAcctInfo;
|
||||||
|
|
||||||
assert(pName != NULL);
|
assert(pName != NULL);
|
||||||
pInfo->pDCLInfo->user.user = *pName;
|
pInfo->pMiscInfo->user.user = *pName;
|
||||||
|
|
||||||
if (pPwd != NULL) {
|
if (pPwd != NULL) {
|
||||||
pInfo->pDCLInfo->user.passwd = *pPwd;
|
pInfo->pMiscInfo->user.passwd = *pPwd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCreateUserSql(SSqlInfo *pInfo, SStrToken *pName, SStrToken *pPasswd) {
|
void setCreateUserSql(SSqlInfo *pInfo, SStrToken *pName, SStrToken *pPasswd) {
|
||||||
pInfo->type = TSDB_SQL_CREATE_USER;
|
pInfo->type = TSDB_SQL_CREATE_USER;
|
||||||
if (pInfo->pDCLInfo == NULL) {
|
if (pInfo->pMiscInfo == NULL) {
|
||||||
pInfo->pDCLInfo = calloc(1, sizeof(tDCLSQL));
|
pInfo->pMiscInfo = calloc(1, sizeof(SMiscInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(pName != NULL && pPasswd != NULL);
|
assert(pName != NULL && pPasswd != NULL);
|
||||||
|
|
||||||
pInfo->pDCLInfo->user.user = *pName;
|
pInfo->pMiscInfo->user.user = *pName;
|
||||||
pInfo->pDCLInfo->user.passwd = *pPasswd;
|
pInfo->pMiscInfo->user.passwd = *pPasswd;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAlterUserSql(SSqlInfo *pInfo, int16_t type, SStrToken *pName, SStrToken* pPwd, SStrToken *pPrivilege) {
|
void setAlterUserSql(SSqlInfo *pInfo, int16_t type, SStrToken *pName, SStrToken* pPwd, SStrToken *pPrivilege) {
|
||||||
pInfo->type = TSDB_SQL_ALTER_USER;
|
pInfo->type = TSDB_SQL_ALTER_USER;
|
||||||
if (pInfo->pDCLInfo == NULL) {
|
if (pInfo->pMiscInfo == NULL) {
|
||||||
pInfo->pDCLInfo = calloc(1, sizeof(tDCLSQL));
|
pInfo->pMiscInfo = calloc(1, sizeof(SMiscInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(pName != NULL);
|
assert(pName != NULL);
|
||||||
|
|
||||||
SUserInfo* pUser = &pInfo->pDCLInfo->user;
|
SUserInfo* pUser = &pInfo->pMiscInfo->user;
|
||||||
pUser->type = type;
|
pUser->type = type;
|
||||||
pUser->user = *pName;
|
pUser->user = *pName;
|
||||||
|
|
||||||
|
@ -828,18 +819,17 @@ void setAlterUserSql(SSqlInfo *pInfo, int16_t type, SStrToken *pName, SStrToken*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setKillSql(SSqlInfo *pInfo, int32_t type, SStrToken *ip) {
|
void setKillSql(SSqlInfo *pInfo, int32_t type, SStrToken *id) {
|
||||||
pInfo->type = type;
|
pInfo->type = type;
|
||||||
if (pInfo->pDCLInfo == NULL) {
|
if (pInfo->pMiscInfo == NULL) {
|
||||||
pInfo->pDCLInfo = calloc(1, sizeof(tDCLSQL));
|
pInfo->pMiscInfo = calloc(1, sizeof(SMiscInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(ip != NULL);
|
assert(id != NULL);
|
||||||
|
pInfo->pMiscInfo->id = *id;
|
||||||
pInfo->pDCLInfo->ip = *ip;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDefaultCreateDbOption(SCreateDBInfo *pDBInfo) {
|
void setDefaultCreateDbOption(SCreateDbInfo *pDBInfo) {
|
||||||
pDBInfo->compressionLevel = -1;
|
pDBInfo->compressionLevel = -1;
|
||||||
|
|
||||||
pDBInfo->walLevel = -1;
|
pDBInfo->walLevel = -1;
|
||||||
|
|
1989
src/query/src/sql.c
1989
src/query/src/sql.c
File diff suppressed because it is too large
Load Diff
|
@ -1388,8 +1388,8 @@ static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo*
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((tsArray[pos] > pQueryHandle->window.ekey || pos > endPos) && ASCENDING_TRAVERSE(pQueryHandle->order)) ||
|
if (((pos > endPos || tsArray[pos] > pQueryHandle->window.ekey) && ASCENDING_TRAVERSE(pQueryHandle->order)) ||
|
||||||
((tsArray[pos] < pQueryHandle->window.ekey || pos < endPos) && !ASCENDING_TRAVERSE(pQueryHandle->order))) {
|
((pos < endPos || tsArray[pos] < pQueryHandle->window.ekey) && !ASCENDING_TRAVERSE(pQueryHandle->order))) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@ void taosArrayCopy(SArray* pDst, const SArray* pSrc);
|
||||||
* clone a new array
|
* clone a new array
|
||||||
* @param pSrc
|
* @param pSrc
|
||||||
*/
|
*/
|
||||||
SArray* taosArrayClone(const SArray* pSrc);
|
SArray* taosArrayDup(const SArray* pSrc);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* clear the array (remove all element)
|
* clear the array (remove all element)
|
||||||
|
|
|
@ -165,7 +165,7 @@ void taosArrayCopy(SArray* pDst, const SArray* pSrc) {
|
||||||
pDst->size = pSrc->size;
|
pDst->size = pSrc->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
SArray* taosArrayClone(const SArray* pSrc) {
|
SArray* taosArrayDup(const SArray* pSrc) {
|
||||||
assert(pSrc != NULL);
|
assert(pSrc != NULL);
|
||||||
|
|
||||||
if (pSrc->size == 0) { // empty array list
|
if (pSrc->size == 0) { // empty array list
|
||||||
|
|
|
@ -3,6 +3,6 @@ PROJECT(TDengine)
|
||||||
IF (TD_LINUX)
|
IF (TD_LINUX)
|
||||||
INCLUDE_DIRECTORIES(. ${TD_COMMUNITY_DIR}/src/inc ${TD_COMMUNITY_DIR}/src/client/inc ${TD_COMMUNITY_DIR}/inc)
|
INCLUDE_DIRECTORIES(. ${TD_COMMUNITY_DIR}/src/inc ${TD_COMMUNITY_DIR}/src/client/inc ${TD_COMMUNITY_DIR}/inc)
|
||||||
AUX_SOURCE_DIRECTORY(. SRC)
|
AUX_SOURCE_DIRECTORY(. SRC)
|
||||||
ADD_EXECUTABLE(demo demo.c)
|
ADD_EXECUTABLE(demo apitest.c)
|
||||||
TARGET_LINK_LIBRARIES(demo taos_static trpc tutil pthread )
|
TARGET_LINK_LIBRARIES(demo taos_static trpc tutil pthread )
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
|
@ -3,7 +3,7 @@ system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c wallevel -v 2
|
system sh/cfg.sh -n dnode1 -c wallevel -v 2
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
$db = csaa_db
|
$db = csaa_db
|
||||||
|
@ -53,10 +53,10 @@ endi
|
||||||
|
|
||||||
print ================== restart server to commit data into disk
|
print ================== restart server to commit data into disk
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
sleep 5000
|
sleep 3000
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
print ================== server restart completed
|
print ================== server restart completed
|
||||||
sleep 5000
|
sleep 3000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
sql use $db
|
sql use $db
|
||||||
|
|
|
@ -7,7 +7,7 @@ system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4
|
||||||
|
|
||||||
print ========= start dnode1 as master
|
print ========= start dnode1 as master
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
print ======== step1
|
print ======== step1
|
||||||
|
@ -141,9 +141,9 @@ endi
|
||||||
|
|
||||||
print ============= step10
|
print ============= step10
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
sleep 5000
|
sleep 3000
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 5000
|
sleep 3000
|
||||||
|
|
||||||
sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb
|
sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb
|
||||||
if $data00 != 24 then
|
if $data00 != 24 then
|
||||||
|
@ -250,9 +250,9 @@ endi
|
||||||
|
|
||||||
print ============== step18
|
print ============== step18
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
sleep 5000
|
sleep 3000
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 5000
|
sleep 3000
|
||||||
|
|
||||||
#sql select count(g) from tb
|
#sql select count(g) from tb
|
||||||
#if $data00 != 12 then
|
#if $data00 != 12 then
|
||||||
|
|
|
@ -4,14 +4,14 @@ system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 2
|
system sh/cfg.sh -n dnode1 -c walLevel -v 2
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
print ======== step1
|
print ======== step1
|
||||||
sql alter dnode 1 resetlog
|
sql alter dnode 1 resetlog
|
||||||
sql alter dnode 1 monitor 1
|
sql alter dnode 1 monitor 1
|
||||||
|
|
||||||
sleep 5000
|
sleep 3000
|
||||||
sql select * from log.dn
|
sql select * from log.dn
|
||||||
if $rows <= 0 then
|
if $rows <= 0 then
|
||||||
return -1
|
return -1
|
||||||
|
|
|
@ -7,7 +7,7 @@ system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4
|
||||||
|
|
||||||
print ========= start dnode1 as master
|
print ========= start dnode1 as master
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
print ======== step1
|
print ======== step1
|
||||||
|
|
|
@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c wallevel -v 2
|
system sh/cfg.sh -n dnode1 -c wallevel -v 2
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
print ======== step1
|
print ======== step1
|
||||||
|
@ -940,9 +940,9 @@ endi
|
||||||
print ======== step9
|
print ======== step9
|
||||||
|
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
sleep 5000
|
sleep 3000
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 5000
|
sleep 3000
|
||||||
|
|
||||||
sql select * from tb order by ts asc
|
sql select * from tb order by ts asc
|
||||||
if $rows != 8 then
|
if $rows != 8 then
|
||||||
|
|
|
@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c wallevel -v 2
|
system sh/cfg.sh -n dnode1 -c wallevel -v 2
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
print ======== step1
|
print ======== step1
|
||||||
|
@ -608,9 +608,9 @@ sql_error alter table tb drop column a
|
||||||
|
|
||||||
print ======== step9
|
print ======== step9
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
sleep 5000
|
sleep 3000
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 5000
|
sleep 3000
|
||||||
|
|
||||||
sql select * from tb order by ts desc
|
sql select * from tb order by ts desc
|
||||||
if $rows != 7 then
|
if $rows != 7 then
|
||||||
|
|
|
@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 2
|
system sh/cfg.sh -n dnode1 -c walLevel -v 2
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
print ======== step1
|
print ======== step1
|
||||||
|
@ -367,9 +367,9 @@ endi
|
||||||
print ======== step9
|
print ======== step9
|
||||||
print ======== step10
|
print ======== step10
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
sleep 5000
|
sleep 3000
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 5000
|
sleep 3000
|
||||||
|
|
||||||
sql use d2
|
sql use d2
|
||||||
sql describe tb
|
sql describe tb
|
||||||
|
|
|
@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 2
|
system sh/cfg.sh -n dnode1 -c walLevel -v 2
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
print ======== step1
|
print ======== step1
|
||||||
|
@ -318,9 +318,9 @@ endi
|
||||||
print ======== step9
|
print ======== step9
|
||||||
print ======== step10
|
print ======== step10
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
sleep 5000
|
sleep 3000
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 5000
|
sleep 3000
|
||||||
|
|
||||||
sql use d1
|
sql use d1
|
||||||
sql describe tb
|
sql describe tb
|
||||||
|
|
|
@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
$i = 0
|
$i = 0
|
||||||
|
|
|
@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
print ======================== dnode1 start
|
print ======================== dnode1 start
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ endi
|
||||||
|
|
||||||
print =============== step2
|
print =============== step2
|
||||||
system sh/exec.sh -n dnode1 -s stop
|
system sh/exec.sh -n dnode1 -s stop
|
||||||
sleep 5000
|
sleep 3000
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
|
@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
print ======================== dnode1 start
|
print ======================== dnode1 start
|
||||||
|
|
||||||
|
@ -33,14 +33,14 @@ endi
|
||||||
|
|
||||||
print =============== step2
|
print =============== step2
|
||||||
system sh/exec.sh -n dnode1 -s stop
|
system sh/exec.sh -n dnode1 -s stop
|
||||||
sleep 5000
|
sleep 3000
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
print =============== step3
|
print =============== step3
|
||||||
print ==> sleep 8 seconds to renew cache
|
print ==> sleep 8 seconds to renew cache
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql reset query cache
|
sql reset query cache
|
||||||
sleep 18000
|
sleep 18000
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
print =============== step1
|
print =============== step1
|
||||||
|
@ -89,9 +89,9 @@ endi
|
||||||
|
|
||||||
print =============== step4
|
print =============== step4
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
sleep 5000
|
sleep 3000
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 5000
|
sleep 3000
|
||||||
|
|
||||||
print =============== step5
|
print =============== step5
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
print =============== step1
|
print =============== step1
|
||||||
|
@ -157,9 +157,9 @@ endi
|
||||||
|
|
||||||
print =============== step4
|
print =============== step4
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
sleep 5000
|
sleep 3000
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 5000
|
sleep 3000
|
||||||
|
|
||||||
print =============== step5
|
print =============== step5
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
print =============== step1
|
print =============== step1
|
||||||
|
@ -129,9 +129,9 @@ endi
|
||||||
|
|
||||||
print =============== step4
|
print =============== step4
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
sleep 5000
|
sleep 3000
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 5000
|
sleep 3000
|
||||||
|
|
||||||
print ============== step5
|
print ============== step5
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ system sh/cfg.sh -n dnode1 -c walLevel -v 1
|
||||||
system sh/cfg.sh -n dnode1 -c comp -v 1
|
system sh/cfg.sh -n dnode1 -c comp -v 1
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
print ============================ dnode1 start
|
print ============================ dnode1 start
|
||||||
|
|
||||||
|
@ -87,9 +87,9 @@ endi
|
||||||
|
|
||||||
print =============== step4
|
print =============== step4
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
sleep 5000
|
sleep 3000
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 5000
|
sleep 3000
|
||||||
|
|
||||||
print =============== step5
|
print =============== step5
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
system sh/cfg.sh -n dnode1 -c comp -v 1
|
system sh/cfg.sh -n dnode1 -c comp -v 1
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
print ============================ dnode1 start
|
print ============================ dnode1 start
|
||||||
|
@ -82,9 +82,9 @@ endi
|
||||||
|
|
||||||
print =============== step4
|
print =============== step4
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
sleep 5000
|
sleep 3000
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 5000
|
sleep 3000
|
||||||
|
|
||||||
print =============== step5
|
print =============== step5
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
system sh/cfg.sh -n dnode1 -c comp -v 2
|
system sh/cfg.sh -n dnode1 -c comp -v 2
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
print ============================ dnode1 start
|
print ============================ dnode1 start
|
||||||
|
@ -82,9 +82,9 @@ endi
|
||||||
|
|
||||||
print =============== step4
|
print =============== step4
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
sleep 5000
|
sleep 3000
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 5000
|
sleep 3000
|
||||||
|
|
||||||
print =============== step5
|
print =============== step5
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
system sh/cfg.sh -n dnode1 -c comp -v 1
|
system sh/cfg.sh -n dnode1 -c comp -v 1
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
print ============================ dnode1 start
|
print ============================ dnode1 start
|
||||||
|
|
||||||
|
@ -81,9 +81,9 @@ endi
|
||||||
|
|
||||||
print =============== step4
|
print =============== step4
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
sleep 5000
|
|
||||||
system sh/exec.sh -n dnode1 -s start
|
|
||||||
sleep 3000
|
sleep 3000
|
||||||
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
sleep 2000
|
||||||
|
|
||||||
print =============== step5
|
print =============== step5
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
$dbPrefix = m_av_db
|
$dbPrefix = m_av_db
|
||||||
|
|
|
@ -3,7 +3,7 @@ system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
$dbPrefix = m_bo_db
|
$dbPrefix = m_bo_db
|
||||||
|
|
|
@ -3,7 +3,7 @@ system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
$dbPrefix = m_co_db
|
$dbPrefix = m_co_db
|
||||||
|
|
|
@ -3,7 +3,7 @@ system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
$dbPrefix = m_di_db
|
$dbPrefix = m_di_db
|
||||||
|
|
|
@ -3,7 +3,7 @@ system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
$dbPrefix = m_di_db
|
$dbPrefix = m_di_db
|
||||||
|
|
|
@ -3,7 +3,7 @@ system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
$dbPrefix = m_fi_db
|
$dbPrefix = m_fi_db
|
||||||
|
|
|
@ -3,7 +3,7 @@ system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
$dbPrefix = m_in_db
|
$dbPrefix = m_in_db
|
||||||
|
|
|
@ -3,7 +3,7 @@ system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
$dbPrefix = m_la_db
|
$dbPrefix = m_la_db
|
||||||
|
|
|
@ -3,7 +3,7 @@ system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
$dbPrefix = m_la_db
|
$dbPrefix = m_la_db
|
||||||
|
|
|
@ -3,7 +3,7 @@ system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
$dbPrefix = m_le_db
|
$dbPrefix = m_le_db
|
||||||
|
|
|
@ -3,7 +3,7 @@ system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
$dbPrefix = m_ma_db
|
$dbPrefix = m_ma_db
|
||||||
|
|
|
@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
$dbPrefix = m_mi_db
|
$dbPrefix = m_mi_db
|
||||||
|
|
|
@ -3,7 +3,7 @@ system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
$dbPrefix = db
|
$dbPrefix = db
|
||||||
|
|
|
@ -3,7 +3,7 @@ system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
$dbPrefix = m_pe_db
|
$dbPrefix = m_pe_db
|
||||||
|
|
|
@ -3,7 +3,7 @@ system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
$dbPrefix = m_st_db
|
$dbPrefix = m_st_db
|
||||||
|
|
|
@ -3,7 +3,7 @@ system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
$dbPrefix = m_su_db
|
$dbPrefix = m_su_db
|
||||||
|
|
|
@ -3,7 +3,7 @@ system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
$dbPrefix = m_to_db
|
$dbPrefix = m_to_db
|
||||||
|
|
|
@ -2,7 +2,7 @@ system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c wallevel -v 0
|
system sh/cfg.sh -n dnode1 -c wallevel -v 0
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
print ============= step1
|
print ============= step1
|
||||||
|
|
|
@ -10,7 +10,7 @@ system sh/cfg.sh -n dnode1 -c mqtt -v 1
|
||||||
|
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
sql create database mqttdb;
|
sql create database mqttdb;
|
||||||
sql create table mqttdb.devices(ts timestamp, value double) tags(name binary(32), model binary(32), serial binary(16), param binary(16), unit binary(16));
|
sql create table mqttdb.devices(ts timestamp, value double) tags(name binary(32), model binary(32), serial binary(16), param binary(16), unit binary(16));
|
||||||
|
|
|
@ -5,7 +5,7 @@ system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 1000
|
||||||
|
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
print ============= create database
|
print ============= create database
|
||||||
|
|
|
@ -264,10 +264,10 @@ endi
|
||||||
print ============================ step7
|
print ============================ step7
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
system sh/exec.sh -n dnode2 -s stop -x SIGINT
|
system sh/exec.sh -n dnode2 -s stop -x SIGINT
|
||||||
sleep 5000
|
sleep 3000
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
system sh/exec.sh -n dnode2 -s start
|
system sh/exec.sh -n dnode2 -s start
|
||||||
sleep 5000
|
sleep 3000
|
||||||
|
|
||||||
sql reset query cache
|
sql reset query cache
|
||||||
sleep 1000
|
sleep 1000
|
||||||
|
|
|
@ -232,9 +232,9 @@ endi
|
||||||
|
|
||||||
print ============================ step7
|
print ============================ step7
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
sleep 5000
|
sleep 3000
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 5000
|
sleep 3000
|
||||||
|
|
||||||
sql reset query cache
|
sql reset query cache
|
||||||
sleep 1000
|
sleep 1000
|
||||||
|
|
|
@ -6,7 +6,7 @@ system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 20
|
||||||
|
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
print ============================ step1
|
print ============================ step1
|
||||||
|
@ -70,9 +70,9 @@ endi
|
||||||
print ============================ step3
|
print ============================ step3
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 2
|
system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 2
|
||||||
sleep 5000
|
sleep 3000
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 5000
|
sleep 3000
|
||||||
|
|
||||||
sql create table db.t100 using db.st tags(0)
|
sql create table db.t100 using db.st tags(0)
|
||||||
sql create table db.t101 using db.st tags(1)
|
sql create table db.t101 using db.st tags(1)
|
||||||
|
@ -132,9 +132,9 @@ print ============================ step5
|
||||||
|
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 3
|
system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 3
|
||||||
sleep 5000
|
sleep 3000
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 5000
|
sleep 3000
|
||||||
|
|
||||||
sql create table db.t200 using db.st tags(0)
|
sql create table db.t200 using db.st tags(0)
|
||||||
sql create table db.t201 using db.st tags(1)
|
sql create table db.t201 using db.st tags(1)
|
||||||
|
|
|
@ -23,7 +23,7 @@ sql connect
|
||||||
print ========= start other dnodes
|
print ========= start other dnodes
|
||||||
sql create dnode $hostname2
|
sql create dnode $hostname2
|
||||||
system sh/exec.sh -n dnode2 -s start
|
system sh/exec.sh -n dnode2 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
|
|
||||||
print ======== step1 create db
|
print ======== step1 create db
|
||||||
sql create database keepdb replica 1 keep 30 days 7
|
sql create database keepdb replica 1 keep 30 days 7
|
||||||
|
@ -50,9 +50,9 @@ endi
|
||||||
|
|
||||||
print ======== step2 stop dnode
|
print ======== step2 stop dnode
|
||||||
system sh/exec.sh -n dnode2 -s stop -x SIGINT
|
system sh/exec.sh -n dnode2 -s stop -x SIGINT
|
||||||
sleep 5000
|
sleep 3000
|
||||||
system sh/exec.sh -n dnode2 -s start
|
system sh/exec.sh -n dnode2 -s start
|
||||||
sleep 5000
|
sleep 3000
|
||||||
|
|
||||||
sql select * from tb
|
sql select * from tb
|
||||||
print ===> rows $rows
|
print ===> rows $rows
|
||||||
|
@ -112,9 +112,9 @@ endi
|
||||||
|
|
||||||
print ======== step5 stop dnode
|
print ======== step5 stop dnode
|
||||||
system sh/exec.sh -n dnode2 -s stop -x SIGINT
|
system sh/exec.sh -n dnode2 -s stop -x SIGINT
|
||||||
sleep 5000
|
sleep 3000
|
||||||
system sh/exec.sh -n dnode2 -s start
|
system sh/exec.sh -n dnode2 -s start
|
||||||
sleep 5000
|
sleep 3000
|
||||||
|
|
||||||
sql select * from tb
|
sql select * from tb
|
||||||
print ===> rows $rows
|
print ===> rows $rows
|
||||||
|
@ -153,9 +153,9 @@ endi
|
||||||
|
|
||||||
print ======== step7 stop dnode
|
print ======== step7 stop dnode
|
||||||
system sh/exec.sh -n dnode2 -s stop -x SIGINT
|
system sh/exec.sh -n dnode2 -s stop -x SIGINT
|
||||||
sleep 3000
|
sleep 2000
|
||||||
system sh/exec.sh -n dnode2 -s start
|
system sh/exec.sh -n dnode2 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
|
|
||||||
sql select * from tb
|
sql select * from tb
|
||||||
print ===> rows $rows
|
print ===> rows $rows
|
||||||
|
|
|
@ -6,7 +6,7 @@ system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 1000
|
||||||
|
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
print ============================ dnode1 start
|
print ============================ dnode1 start
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
system sh/stop_dnodes.sh
|
system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
print =============== create database
|
print =============== create database
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
system sh/stop_dnodes.sh
|
system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
print =============== create database d1
|
print =============== create database d1
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
system sh/stop_dnodes.sh
|
system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
print =============== create database d1
|
print =============== create database d1
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
system sh/stop_dnodes.sh
|
system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
print =============== create database d1
|
print =============== create database d1
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
system sh/stop_dnodes.sh
|
system sh/stop_dnodes.sh
|
||||||
system sh/deploy.sh -n dnode1 -i 1
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
print =============== create database d1
|
print =============== create database d1
|
||||||
|
|
|
@ -6,7 +6,7 @@ system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 1000
|
||||||
|
|
||||||
print ========= start dnodes
|
print ========= start dnodes
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
print ======== step1
|
print ======== step1
|
||||||
|
@ -44,7 +44,7 @@ endi
|
||||||
|
|
||||||
print ======= step3
|
print ======= step3
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
sleep 5000
|
sleep 3000
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
$x = 0
|
$x = 0
|
||||||
|
|
|
@ -22,7 +22,7 @@ system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4
|
||||||
|
|
||||||
print ========= start dnodes
|
print ========= start dnodes
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
print ======== step1
|
print ======== step1
|
||||||
|
|
|
@ -21,9 +21,9 @@ system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4
|
||||||
system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4
|
system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4
|
||||||
|
|
||||||
print ========= start dnodes
|
print ========= start dnodes
|
||||||
sleep 2000
|
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
|
|
||||||
sql connect
|
sql connect
|
||||||
sql reset query cache
|
sql reset query cache
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ endi
|
||||||
|
|
||||||
print ======== step2
|
print ======== step2
|
||||||
sql drop database d1
|
sql drop database d1
|
||||||
sleep 1000
|
sleep 500
|
||||||
sql insert into d1.t1 values(now, 2) -x step2
|
sql insert into d1.t1 values(now, 2) -x step2
|
||||||
return -1
|
return -1
|
||||||
step2:
|
step2:
|
||||||
|
@ -73,7 +73,7 @@ step2:
|
||||||
print ========= step3
|
print ========= step3
|
||||||
sql create database db1 replica 1
|
sql create database db1 replica 1
|
||||||
sql reset query cache
|
sql reset query cache
|
||||||
sleep 1000
|
sleep 500
|
||||||
sql create table db1.tb1 (ts timestamp, i int)
|
sql create table db1.tb1 (ts timestamp, i int)
|
||||||
sql insert into db1.tb1 values(now, 2)
|
sql insert into db1.tb1 values(now, 2)
|
||||||
sql select * from db1.tb1
|
sql select * from db1.tb1
|
||||||
|
@ -90,7 +90,7 @@ while $x < 20
|
||||||
sql use $db
|
sql use $db
|
||||||
sql drop database $db
|
sql drop database $db
|
||||||
|
|
||||||
sleep 1000
|
sleep 500
|
||||||
sql insert into $tb values(now, -1) -x step4
|
sql insert into $tb values(now, -1) -x step4
|
||||||
return -1
|
return -1
|
||||||
step4:
|
step4:
|
||||||
|
@ -100,7 +100,7 @@ while $x < 20
|
||||||
$tb = tb . $x
|
$tb = tb . $x
|
||||||
|
|
||||||
sql reset query cache
|
sql reset query cache
|
||||||
sleep 1000
|
sleep 500
|
||||||
|
|
||||||
sql create database $db replica 1
|
sql create database $db replica 1
|
||||||
sql use $db
|
sql use $db
|
||||||
|
|
|
@ -4,7 +4,7 @@ system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
|
||||||
|
|
||||||
print ========= start dnodes
|
print ========= start dnodes
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
print ======== step1
|
print ======== step1
|
||||||
|
|
|
@ -43,7 +43,7 @@ while $x < 20
|
||||||
sql create database db
|
sql create database db
|
||||||
sql create table db.tb (ts timestamp, i int)
|
sql create table db.tb (ts timestamp, i int)
|
||||||
|
|
||||||
sleep 3000
|
sleep 2000
|
||||||
|
|
||||||
$x = $x + 1
|
$x = $x + 1
|
||||||
endw
|
endw
|
||||||
|
|
|
@ -5,7 +5,7 @@ system sh/cfg.sh -n dnode1 -c wallevel -v 0
|
||||||
|
|
||||||
print ========= start dnodes
|
print ========= start dnodes
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
sql create database db
|
sql create database db
|
||||||
|
@ -39,7 +39,7 @@ while $x < 10
|
||||||
sql create database db
|
sql create database db
|
||||||
sql create table db.tb (ts timestamp, i int)
|
sql create table db.tb (ts timestamp, i int)
|
||||||
|
|
||||||
sleep 3000
|
sleep 2000
|
||||||
|
|
||||||
$x = $x + 1
|
$x = $x + 1
|
||||||
endw
|
endw
|
||||||
|
|
|
@ -11,7 +11,7 @@ print ========== prepare data
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
system sh/exec.sh -n dnode2 -s start
|
system sh/exec.sh -n dnode2 -s start
|
||||||
|
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
sql create dnode $hostname2
|
sql create dnode $hostname2
|
||||||
|
@ -72,7 +72,7 @@ endi
|
||||||
print ========== step3
|
print ========== step3
|
||||||
|
|
||||||
system sh/exec.sh -n dnode2 -s stop -x SIGINT
|
system sh/exec.sh -n dnode2 -s stop -x SIGINT
|
||||||
sleep 5000
|
sleep 3000
|
||||||
sql drop dnode $hostname2
|
sql drop dnode $hostname2
|
||||||
sleep 2000
|
sleep 2000
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2000
|
system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2000
|
||||||
|
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
print =============== step1
|
print =============== step1
|
||||||
|
|
|
@ -6,7 +6,7 @@ system sh/cfg.sh -n dnode1 -c wallevel -v 2
|
||||||
print ========== step1
|
print ========== step1
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sql connect
|
sql connect
|
||||||
sleep 3000
|
sleep 2000
|
||||||
|
|
||||||
print ========== step3
|
print ========== step3
|
||||||
sql create database d1
|
sql create database d1
|
||||||
|
@ -20,7 +20,7 @@ sql insert into d1.t1 values(now+5s, 31)
|
||||||
print ========== step4
|
print ========== step4
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
|
|
||||||
print ========== step5
|
print ========== step5
|
||||||
sql select * from d1.t1 order by t desc
|
sql select * from d1.t1 order by t desc
|
||||||
|
|
|
@ -5,7 +5,7 @@ system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
|
||||||
|
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
print ============================ dnode1 start
|
print ============================ dnode1 start
|
||||||
|
|
||||||
|
@ -21,13 +21,13 @@ sql create table d3.t1(ts timestamp, i int)
|
||||||
sql create database d4
|
sql create database d4
|
||||||
sql create table d4.t1(ts timestamp, i int)
|
sql create table d4.t1(ts timestamp, i int)
|
||||||
|
|
||||||
sleep 3000
|
sleep 2000
|
||||||
|
|
||||||
sql drop database d1
|
sql drop database d1
|
||||||
sql drop database d2
|
sql drop database d2
|
||||||
sql drop database d3
|
sql drop database d3
|
||||||
sql drop database d4
|
sql drop database d4
|
||||||
sleep 3000
|
sleep 2000
|
||||||
|
|
||||||
sql create database d5
|
sql create database d5
|
||||||
sql create table d5.t1(ts timestamp, i int)
|
sql create table d5.t1(ts timestamp, i int)
|
||||||
|
@ -41,14 +41,14 @@ sql create table d7.t1(ts timestamp, i int)
|
||||||
sql create database d8
|
sql create database d8
|
||||||
sql create table d8.t1(ts timestamp, i int)
|
sql create table d8.t1(ts timestamp, i int)
|
||||||
|
|
||||||
sleep 3000
|
sleep 2000
|
||||||
|
|
||||||
sql drop database d5
|
sql drop database d5
|
||||||
sql drop database d6
|
sql drop database d6
|
||||||
sql drop database d7
|
sql drop database d7
|
||||||
sql drop database d8
|
sql drop database d8
|
||||||
|
|
||||||
sleep 3000
|
sleep 2000
|
||||||
|
|
||||||
sql create database d9;
|
sql create database d9;
|
||||||
sql create table d9.t1(ts timestamp, i int)
|
sql create table d9.t1(ts timestamp, i int)
|
||||||
|
|
|
@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
|
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
print =============== step2
|
print =============== step2
|
||||||
|
|
|
@ -4,7 +4,7 @@ system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
|
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
print ===============create three type table
|
print ===============create three type table
|
||||||
|
|
|
@ -6,7 +6,7 @@ system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 4
|
||||||
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
|
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
|
||||||
|
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
print =============== step2
|
print =============== step2
|
||||||
|
|
|
@ -15,7 +15,7 @@ system sh/cfg.sh -n dnode1 -c maxMgmtConnections -v 100000
|
||||||
|
|
||||||
print ========== prepare data
|
print ========== prepare data
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
sql create database db blocks 3 cache 1
|
sql create database db blocks 3 cache 1
|
||||||
sql use db
|
sql use db
|
||||||
|
|
|
@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
print ======================== dnode1 start
|
print ======================== dnode1 start
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
print ======================== dnode1 start
|
print ======================== dnode1 start
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
print ======================== dnode1 start
|
print ======================== dnode1 start
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
print ======================== dnode1 start
|
print ======================== dnode1 start
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
print ======================== dnode1 start
|
print ======================== dnode1 start
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1
|
||||||
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
system sh/cfg.sh -n dnode1 -c walLevel -v 0
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
sleep 3000
|
sleep 2000
|
||||||
sql connect
|
sql connect
|
||||||
print ======================== dnode1 start
|
print ======================== dnode1 start
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue