fix: add meta debug log
This commit is contained in:
parent
b77754a63e
commit
bd450fe751
|
@ -49,6 +49,35 @@ int32_t fillTableColCmpr(SMetaReader *reader, SSchemaExt *pExt, int32_t numOfCol
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void vnodePrintTableMeta(STableMetaRsp* pMeta) {
|
||||||
|
if (!(qDebugFlag & DEBUG_DEBUG)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug("tbName:%s", pMeta->tbName);
|
||||||
|
qDebug("stbName:%s", pMeta->stbName);
|
||||||
|
qDebug("dbFName:%s", pMeta->dbFName);
|
||||||
|
qDebug("dbId:%" PRId64, pMeta->dbId);
|
||||||
|
qDebug("numOfTags:%d", pMeta->numOfTags);
|
||||||
|
qDebug("numOfColumns:%d", pMeta->numOfColumns);
|
||||||
|
qDebug("precision:%d", pMeta->precision);
|
||||||
|
qDebug("tableType:%d", pMeta->tableType);
|
||||||
|
qDebug("sversion:%d", pMeta->sversion);
|
||||||
|
qDebug("tversion:%d", pMeta->tversion);
|
||||||
|
qDebug("suid:%" PRIu64, pMeta->suid);
|
||||||
|
qDebug("tuid:%" PRIu64, pMeta->tuid);
|
||||||
|
qDebug("vgId:%d", pMeta->vgId);
|
||||||
|
qDebug("sysInfo:%d", pMeta->sysInfo);
|
||||||
|
if (pMeta->pSchemas) {
|
||||||
|
for (int32_t i = 0; i < (pMeta->numOfColumns + pMeta->numOfTags); ++i) {
|
||||||
|
SSchema* pSchema = pMeta->pSchemas + i;
|
||||||
|
qDebug("%d col/tag: type:%d, flags:%d, colId:%d, bytes:%d, name:%s", i, pSchema->type, pSchema->flags, pSchema->colId, pSchema->bytes, pSchema->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
int32_t vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
||||||
STableInfoReq infoReq = {0};
|
STableInfoReq infoReq = {0};
|
||||||
STableMetaRsp metaRsp = {0};
|
STableMetaRsp metaRsp = {0};
|
||||||
|
@ -155,6 +184,8 @@ int32_t vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vnodePrintTableMeta(&metaRsp);
|
||||||
|
|
||||||
// encode and send response
|
// encode and send response
|
||||||
rspLen = tSerializeSTableMetaRsp(NULL, 0, &metaRsp);
|
rspLen = tSerializeSTableMetaRsp(NULL, 0, &metaRsp);
|
||||||
if (rspLen < 0) {
|
if (rspLen < 0) {
|
||||||
|
|
|
@ -67,24 +67,29 @@ static bool doValidateSchema(SSchema* pSchema, int32_t numOfCols, int32_t maxLen
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
// 1. valid types
|
// 1. valid types
|
||||||
if (!isValidDataType(pSchema[i].type)) {
|
if (!isValidDataType(pSchema[i].type)) {
|
||||||
|
qError("The %d col/tag data type error, type:%d", i, pSchema[i].type);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. valid length for each type
|
// 2. valid length for each type
|
||||||
if (pSchema[i].type == TSDB_DATA_TYPE_BINARY || pSchema[i].type == TSDB_DATA_TYPE_VARBINARY) {
|
if (pSchema[i].type == TSDB_DATA_TYPE_BINARY || pSchema[i].type == TSDB_DATA_TYPE_VARBINARY) {
|
||||||
if (pSchema[i].bytes > TSDB_MAX_BINARY_LEN) {
|
if (pSchema[i].bytes > TSDB_MAX_BINARY_LEN) {
|
||||||
|
qError("The %d col/tag var data len error, type:%d, len:%d", i, pSchema[i].type, pSchema[i].bytes);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (pSchema[i].type == TSDB_DATA_TYPE_NCHAR) {
|
} else if (pSchema[i].type == TSDB_DATA_TYPE_NCHAR) {
|
||||||
if (pSchema[i].bytes > TSDB_MAX_NCHAR_LEN) {
|
if (pSchema[i].bytes > TSDB_MAX_NCHAR_LEN) {
|
||||||
|
qError("The %d col/tag nchar data len error, len:%d", i, pSchema[i].bytes);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (pSchema[i].type == TSDB_DATA_TYPE_GEOMETRY) {
|
} else if (pSchema[i].type == TSDB_DATA_TYPE_GEOMETRY) {
|
||||||
if (pSchema[i].bytes > TSDB_MAX_GEOMETRY_LEN) {
|
if (pSchema[i].bytes > TSDB_MAX_GEOMETRY_LEN) {
|
||||||
|
qError("The %d col/tag geometry data len error, len:%d", i, pSchema[i].bytes);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (pSchema[i].bytes != tDataTypes[pSchema[i].type].bytes) {
|
if (pSchema[i].bytes != tDataTypes[pSchema[i].type].bytes) {
|
||||||
|
qError("The %d col/tag data len error, type:%d, len:%d", i, pSchema[i].type, pSchema[i].bytes);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,6 +97,7 @@ static bool doValidateSchema(SSchema* pSchema, int32_t numOfCols, int32_t maxLen
|
||||||
// 3. valid column names
|
// 3. valid column names
|
||||||
for (int32_t j = i + 1; j < numOfCols; ++j) {
|
for (int32_t j = i + 1; j < numOfCols; ++j) {
|
||||||
if (strncmp(pSchema[i].name, pSchema[j].name, sizeof(pSchema[i].name) - 1) == 0) {
|
if (strncmp(pSchema[i].name, pSchema[j].name, sizeof(pSchema[i].name) - 1) == 0) {
|
||||||
|
qError("The %d col/tag name %s is same with %d col/tag name %s", i, pSchema[i].name, j, pSchema[j].name);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,23 +110,28 @@ static bool doValidateSchema(SSchema* pSchema, int32_t numOfCols, int32_t maxLen
|
||||||
|
|
||||||
bool tIsValidSchema(struct SSchema* pSchema, int32_t numOfCols, int32_t numOfTags) {
|
bool tIsValidSchema(struct SSchema* pSchema, int32_t numOfCols, int32_t numOfTags) {
|
||||||
if (!pSchema || !VALIDNUMOFCOLS(numOfCols)) {
|
if (!pSchema || !VALIDNUMOFCOLS(numOfCols)) {
|
||||||
|
qError("invalid numOfCols: %d", numOfCols);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!VALIDNUMOFTAGS(numOfTags)) {
|
if (!VALIDNUMOFTAGS(numOfTags)) {
|
||||||
|
qError("invalid numOfTags: %d", numOfTags);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* first column must be the timestamp, which is a primary key */
|
/* first column must be the timestamp, which is a primary key */
|
||||||
if (pSchema[0].type != TSDB_DATA_TYPE_TIMESTAMP) {
|
if (pSchema[0].type != TSDB_DATA_TYPE_TIMESTAMP) {
|
||||||
|
qError("invalid first column type: %d", pSchema[0].type);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!doValidateSchema(pSchema, numOfCols, TSDB_MAX_BYTES_PER_ROW)) {
|
if (!doValidateSchema(pSchema, numOfCols, TSDB_MAX_BYTES_PER_ROW)) {
|
||||||
|
qError("validate schema columns failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!doValidateSchema(&pSchema[numOfCols], numOfTags, TSDB_MAX_TAGS_LEN)) {
|
if (!doValidateSchema(&pSchema[numOfCols], numOfTags, TSDB_MAX_TAGS_LEN)) {
|
||||||
|
qError("validate schema tags failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue