Merge pull request #3668 from taosdata/bugfix/td-1488
[td-1488]<fix>: 'Table does not exist' error when updating metadata between two clients
This commit is contained in:
commit
e9973578fd
|
@ -261,7 +261,7 @@ typedef struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
int32_t insertType;
|
int32_t insertType;
|
||||||
int32_t clauseIndex; // index of multiple subclause query
|
int32_t clauseIndex; // index of multiple subclause query
|
||||||
|
|
||||||
char * curSql; // current sql, resume position of sql after parsing paused
|
char * curSql; // current sql, resume position of sql after parsing paused
|
||||||
int8_t parseFinished;
|
int8_t parseFinished;
|
||||||
|
@ -276,7 +276,8 @@ typedef struct {
|
||||||
int32_t numOfParams;
|
int32_t numOfParams;
|
||||||
|
|
||||||
int8_t dataSourceType; // load data from file or not
|
int8_t dataSourceType; // load data from file or not
|
||||||
int8_t submitSchema; // submit block is built with table schema
|
int8_t submitSchema; // submit block is built with table schema
|
||||||
|
STagData tagData;
|
||||||
SHashObj *pTableList; // referred table involved in sql
|
SHashObj *pTableList; // referred table involved in sql
|
||||||
SArray *pDataBlocks; // SArray<STableDataBlocks*> submit data blocks after parsing sql
|
SArray *pDataBlocks; // SArray<STableDataBlocks*> submit data blocks after parsing sql
|
||||||
} SSqlCmd;
|
} SSqlCmd;
|
||||||
|
|
|
@ -791,7 +791,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
|
||||||
sql += index;
|
sql += index;
|
||||||
|
|
||||||
tscAllocPayload(pCmd, sizeof(STagData));
|
tscAllocPayload(pCmd, sizeof(STagData));
|
||||||
STagData *pTag = (STagData *) pCmd->payload;
|
STagData *pTag = &pCmd->tagData;
|
||||||
|
|
||||||
memset(pTag, 0, sizeof(STagData));
|
memset(pTag, 0, sizeof(STagData));
|
||||||
|
|
||||||
|
@ -946,7 +946,6 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
|
||||||
return tscSQLSyntaxErrMsg(pCmd->payload, ") expected", sToken.z);
|
return tscSQLSyntaxErrMsg(pCmd->payload, ") expected", sToken.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
pCmd->payloadLen = sizeof(pTag->name) + sizeof(pTag->dataLen) + pTag->dataLen;
|
|
||||||
pTag->dataLen = htonl(pTag->dataLen);
|
pTag->dataLen = htonl(pTag->dataLen);
|
||||||
|
|
||||||
if (tscValidateName(&tableToken) != TSDB_CODE_SUCCESS) {
|
if (tscValidateName(&tableToken) != TSDB_CODE_SUCCESS) {
|
||||||
|
|
|
@ -1495,43 +1495,29 @@ int tscBuildConnectMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int tscBuildTableMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
int tscBuildTableMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
SCMTableInfoMsg *pInfoMsg;
|
|
||||||
char * pMsg;
|
|
||||||
int msgLen = 0;
|
|
||||||
|
|
||||||
char *tmpData = NULL;
|
|
||||||
uint32_t len = pSql->cmd.payloadLen;
|
|
||||||
if (len > 0) {
|
|
||||||
if ((tmpData = calloc(1, len)) == NULL) {
|
|
||||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
// STagData is in binary format, strncpy is not available
|
|
||||||
memcpy(tmpData, pSql->cmd.payload, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
pInfoMsg = (SCMTableInfoMsg *)pCmd->payload;
|
SCMTableInfoMsg* pInfoMsg = (SCMTableInfoMsg *)pCmd->payload;
|
||||||
strcpy(pInfoMsg->tableId, pTableMetaInfo->name);
|
strcpy(pInfoMsg->tableId, pTableMetaInfo->name);
|
||||||
pInfoMsg->createFlag = htons(pSql->cmd.autoCreated ? 1 : 0);
|
pInfoMsg->createFlag = htons(pSql->cmd.autoCreated ? 1 : 0);
|
||||||
|
|
||||||
pMsg = (char*)pInfoMsg + sizeof(SCMTableInfoMsg);
|
char* pMsg = (char*)pInfoMsg + sizeof(SCMTableInfoMsg);
|
||||||
|
|
||||||
if (pSql->cmd.autoCreated && len > 0) {
|
size_t len = htonl(pCmd->tagData.dataLen);
|
||||||
memcpy(pInfoMsg->tags, tmpData, len);
|
if (pSql->cmd.autoCreated) {
|
||||||
pMsg += len;
|
if (len > 0) {
|
||||||
|
len += sizeof(pCmd->tagData.name) + sizeof(pCmd->tagData.dataLen);
|
||||||
|
memcpy(pInfoMsg->tags, &pCmd->tagData, len);
|
||||||
|
pMsg += len;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pCmd->payloadLen = (int32_t)(pMsg - (char*)pInfoMsg);
|
pCmd->payloadLen = (int32_t)(pMsg - (char*)pInfoMsg);
|
||||||
pCmd->msgType = TSDB_MSG_TYPE_CM_TABLE_META;
|
pCmd->msgType = TSDB_MSG_TYPE_CM_TABLE_META;
|
||||||
|
|
||||||
taosTFree(tmpData);
|
|
||||||
|
|
||||||
assert(msgLen + minMsgSize() <= (int32_t)pCmd->allocSize);
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2184,8 +2170,7 @@ static int32_t getTableMetaFromMgmt(SSqlObj *pSql, STableMetaInfo *pTableMetaInf
|
||||||
assert(pNew->cmd.numOfClause == 1 && pNewQueryInfo->numOfTables == 1);
|
assert(pNew->cmd.numOfClause == 1 && pNewQueryInfo->numOfTables == 1);
|
||||||
|
|
||||||
tstrncpy(pNewMeterMetaInfo->name, pTableMetaInfo->name, sizeof(pNewMeterMetaInfo->name));
|
tstrncpy(pNewMeterMetaInfo->name, pTableMetaInfo->name, sizeof(pNewMeterMetaInfo->name));
|
||||||
memcpy(pNew->cmd.payload, pSql->cmd.payload, pSql->cmd.payloadLen); // tag information if table does not exists.
|
memcpy(&pNew->cmd.tagData, &pSql->cmd.tagData, sizeof(pSql->cmd.tagData));
|
||||||
pNew->cmd.payloadLen = pSql->cmd.payloadLen;
|
|
||||||
tscDebug("%p new pSqlObj:%p to get tableMeta, auto create:%d", pSql, pNew, pNew->cmd.autoCreated);
|
tscDebug("%p new pSqlObj:%p to get tableMeta, auto create:%d", pSql, pNew, pNew->cmd.autoCreated);
|
||||||
|
|
||||||
pNew->fp = tscTableMetaCallBack;
|
pNew->fp = tscTableMetaCallBack;
|
||||||
|
|
|
@ -1806,6 +1806,7 @@ SSqlObj* createSimpleSubObj(SSqlObj* pSql, void (*fp)(), void* param, int32_t cm
|
||||||
pCmd->command = cmd;
|
pCmd->command = cmd;
|
||||||
pCmd->parseFinished = 1;
|
pCmd->parseFinished = 1;
|
||||||
pCmd->autoCreated = pSql->cmd.autoCreated;
|
pCmd->autoCreated = pSql->cmd.autoCreated;
|
||||||
|
memcpy(&pCmd->tagData, &pSql->cmd.tagData, sizeof(pCmd->tagData));
|
||||||
|
|
||||||
if (tscAddSubqueryInfo(pCmd) != TSDB_CODE_SUCCESS) {
|
if (tscAddSubqueryInfo(pCmd) != TSDB_CODE_SUCCESS) {
|
||||||
tscFreeSqlObj(pNew);
|
tscFreeSqlObj(pNew);
|
||||||
|
|
Loading…
Reference in New Issue