[TD-10] fix error while parse schema
This commit is contained in:
parent
d7e96770f1
commit
b23c4cd1c2
|
@ -344,10 +344,10 @@ int32_t mgmtCreateNormalTable(SCMCreateTableMsg *pCreate, int32_t contLen, SVgOb
|
|||
pTable->sid = sid;
|
||||
pTable->createdTime = taosGetTimestampMs();
|
||||
pTable->sversion = 0;
|
||||
pTable->numOfColumns = pCreate->numOfColumns;
|
||||
pTable->sqlLen = pTable->sqlLen;
|
||||
pTable->numOfColumns = htons(pCreate->numOfColumns);
|
||||
pTable->sqlLen = htons(pCreate->sqlLen);
|
||||
|
||||
int32_t numOfCols = pCreate->numOfColumns;
|
||||
int32_t numOfCols = pTable->numOfColumns;
|
||||
int32_t schemaSize = numOfCols * sizeof(SSchema);
|
||||
pTable->schema = (SSchema *) calloc(1, schemaSize);
|
||||
if (pTable->schema == NULL) {
|
||||
|
@ -357,13 +357,12 @@ int32_t mgmtCreateNormalTable(SCMCreateTableMsg *pCreate, int32_t contLen, SVgOb
|
|||
memcpy(pTable->schema, pCreate->schema, numOfCols * sizeof(SSchema));
|
||||
|
||||
pTable->nextColId = 0;
|
||||
for (int32_t col = 0; col < pCreate->numOfColumns; col++) {
|
||||
for (int32_t col = 0; col < numOfCols; col++) {
|
||||
SSchema *tschema = pTable->schema;
|
||||
tschema[col].colId = pTable->nextColId++;
|
||||
tschema[col].bytes = pTable->schema[col].bytes;
|
||||
tschema[col].bytes = htons(tschema[col].bytes);
|
||||
}
|
||||
|
||||
pTable->sqlLen = pCreate->sqlLen;
|
||||
if (pTable->sqlLen != 0) {
|
||||
pTable->type = TSDB_STREAM_TABLE;
|
||||
pTable->sql = calloc(1, pTable->sqlLen);
|
||||
|
@ -371,20 +370,20 @@ int32_t mgmtCreateNormalTable(SCMCreateTableMsg *pCreate, int32_t contLen, SVgOb
|
|||
free(pTable);
|
||||
return TSDB_CODE_SERV_OUT_OF_MEMORY;
|
||||
}
|
||||
memcpy(pTable->sql, (char *) (pCreate->schema) + numOfCols * sizeof(SSchema), pCreate->sqlLen);
|
||||
pTable->sql[pCreate->sqlLen - 1] = 0;
|
||||
mTrace("table:%s, stream sql len:%d sql:%s", pCreate->tableId, pCreate->sqlLen, pTable->sql);
|
||||
memcpy(pTable->sql, (char *) (pCreate->schema) + numOfCols * sizeof(SSchema), pTable->sqlLen);
|
||||
pTable->sql[pTable->sqlLen - 1] = 0;
|
||||
mTrace("table:%s, stream sql len:%d sql:%s", pTable->tableId, pTable->sqlLen, pTable->sql);
|
||||
}
|
||||
|
||||
if (sdbInsertRow(tsNormalTableSdb, pTable, 0) < 0) {
|
||||
mError("table:%s, update sdb error", pCreate->tableId);
|
||||
mError("table:%s, update sdb error", pTable->tableId);
|
||||
free(pTable);
|
||||
return TSDB_CODE_SDB_ERROR;
|
||||
}
|
||||
|
||||
*pDCreateOut = mgmtBuildCreateNormalTableMsg(pTable, pVgroup);
|
||||
if (*pDCreateOut == NULL) {
|
||||
mError("table:%s, failed to build create table message", pCreate->tableId);
|
||||
mError("table:%s, failed to build create table message", pTable->tableId);
|
||||
sdbDeleteRow(tsNormalTableSdb, pTable);
|
||||
return TSDB_CODE_SERV_OUT_OF_MEMORY;
|
||||
}
|
||||
|
|
|
@ -242,11 +242,11 @@ int32_t mgmtCreateSuperTable(SDbObj *pDb, SCMCreateTableMsg *pCreate) {
|
|||
}
|
||||
|
||||
if (sdbInsertRow(tsSuperTableSdb, pStable, 0) < 0) {
|
||||
mError("stable:%s, update sdb error", pCreate->tableId);
|
||||
mError("stable:%s, update sdb error", pStable->tableId);
|
||||
return TSDB_CODE_SDB_ERROR;
|
||||
}
|
||||
|
||||
mPrint("stable:%s, is created, tags:%d cols:%d", pCreate->tableId, pStable->numOfTags, pStable->numOfColumns);
|
||||
mPrint("stable:%s, is created, tags:%d cols:%d", pStable->tableId, pStable->numOfTags, pStable->numOfColumns);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -137,17 +137,6 @@ int32_t mgmtGetTableMeta(SDbObj *pDb, STableInfo *pTable, STableMeta *pMeta, boo
|
|||
static void mgmtCreateTable(SVgObj *pVgroup, SQueuedMsg *pMsg) {
|
||||
SCMCreateTableMsg *pCreate = pMsg->pCont;
|
||||
|
||||
pCreate->numOfColumns = htons(pCreate->numOfColumns);
|
||||
pCreate->numOfTags = htons(pCreate->numOfTags);
|
||||
pCreate->sqlLen = htons(pCreate->sqlLen);
|
||||
|
||||
SSchema *pSchema = (SSchema*) pCreate->schema;
|
||||
for (int32_t i = 0; i < pCreate->numOfColumns + pCreate->numOfTags; ++i) {
|
||||
pSchema->bytes = htons(pSchema->bytes);
|
||||
pSchema->colId = i;
|
||||
pSchema++;
|
||||
}
|
||||
|
||||
int32_t sid = taosAllocateId(pVgroup->idPool);
|
||||
if (sid < 0) {
|
||||
mTrace("tables:%s, no enough sid in vgroup:%d", pVgroup->vgId);
|
||||
|
|
Loading…
Reference in New Issue