Revert "feat: show create table, desc table with col comments"
This reverts commit 16754b5ac1
.
This commit is contained in:
parent
05834eaa80
commit
7fad1de841
|
@ -23,11 +23,10 @@ extern "C" {
|
|||
#include "query.h"
|
||||
#include "querynodes.h"
|
||||
|
||||
#define DESCRIBE_RESULT_COLS 5
|
||||
#define DESCRIBE_RESULT_COLS 4
|
||||
#define DESCRIBE_RESULT_FIELD_LEN (TSDB_COL_NAME_LEN - 1 + VARSTR_HEADER_SIZE)
|
||||
#define DESCRIBE_RESULT_TYPE_LEN (20 + VARSTR_HEADER_SIZE)
|
||||
#define DESCRIBE_RESULT_NOTE_LEN (8 + VARSTR_HEADER_SIZE)
|
||||
#define DESCRIBE_RESULT_COL_COMMENT_LEN (TSDB_COL_COMMENT_LEN)
|
||||
|
||||
#define SHOW_CREATE_DB_RESULT_COLS 2
|
||||
#define SHOW_CREATE_DB_RESULT_FIELD1_LEN (TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE)
|
||||
|
|
|
@ -2327,7 +2327,7 @@ int32_t tDeserializeSTableCfgRsp(void *buf, int32_t bufLen, STableCfgRsp *pRsp)
|
|||
}
|
||||
|
||||
int32_t totalCols = pRsp->numOfTags + pRsp->numOfColumns;
|
||||
pRsp->pSchemas = taosMemoryCalloc(totalCols, sizeof(SSchema));
|
||||
pRsp->pSchemas = taosMemoryMalloc(sizeof(SSchema) * totalCols);
|
||||
if (pRsp->pSchemas == NULL) return -1;
|
||||
|
||||
for (int32_t i = 0; i < totalCols; ++i) {
|
||||
|
@ -3740,7 +3740,7 @@ static int32_t tDecodeSTableMetaRsp(SDecoder *pDecoder, STableMetaRsp *pRsp) {
|
|||
|
||||
int32_t totalCols = pRsp->numOfTags + pRsp->numOfColumns;
|
||||
if (totalCols > 0) {
|
||||
pRsp->pSchemas = taosMemoryCalloc(totalCols, sizeof(SSchema));
|
||||
pRsp->pSchemas = taosMemoryMalloc(sizeof(SSchema) * totalCols);
|
||||
if (pRsp->pSchemas == NULL) return -1;
|
||||
|
||||
for (int32_t i = 0; i < totalCols; ++i) {
|
||||
|
|
|
@ -216,7 +216,7 @@ int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
|||
|
||||
cfgRsp.numOfTags = schemaTag.nCols;
|
||||
cfgRsp.numOfColumns = schema.nCols;
|
||||
cfgRsp.pSchemas = (SSchema *)taosMemoryCalloc(cfgRsp.numOfColumns + cfgRsp.numOfTags, sizeof(SSchema));
|
||||
cfgRsp.pSchemas = (SSchema *)taosMemoryMalloc(sizeof(SSchema) * (cfgRsp.numOfColumns + cfgRsp.numOfTags));
|
||||
|
||||
memcpy(cfgRsp.pSchemas, schema.pSchema, sizeof(SSchema) * schema.nCols);
|
||||
if (schemaTag.nCols) {
|
||||
|
|
|
@ -78,10 +78,6 @@ static int32_t buildDescResultDataBlock(SSDataBlock** pOutput) {
|
|||
infoData = createColumnInfoData(TSDB_DATA_TYPE_VARCHAR, DESCRIBE_RESULT_NOTE_LEN, 4);
|
||||
code = blockDataAppendColInfo(pBlock, &infoData);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
infoData = createColumnInfoData(TSDB_DATA_TYPE_VARCHAR, DESCRIBE_RESULT_COL_COMMENT_LEN, 5);
|
||||
code = blockDataAppendColInfo(pBlock, &infoData);
|
||||
}
|
||||
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
*pOutput = pBlock;
|
||||
|
@ -103,9 +99,7 @@ static int32_t setDescResultIntoDataBlock(bool sysInfoUser, SSDataBlock* pBlock,
|
|||
SColumnInfoData* pCol3 = taosArrayGet(pBlock->pDataBlock, 2);
|
||||
// Note
|
||||
SColumnInfoData* pCol4 = taosArrayGet(pBlock->pDataBlock, 3);
|
||||
// Comment
|
||||
SColumnInfoData* pCol5 = taosArrayGet(pBlock->pDataBlock, 4);
|
||||
char buf[DESCRIBE_RESULT_COL_COMMENT_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
char buf[DESCRIBE_RESULT_FIELD_LEN] = {0};
|
||||
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||
if (invisibleColumn(sysInfoUser, pMeta->tableType, pMeta->schema[i].flags)) {
|
||||
continue;
|
||||
|
@ -118,8 +112,6 @@ static int32_t setDescResultIntoDataBlock(bool sysInfoUser, SSDataBlock* pBlock,
|
|||
colDataSetVal(pCol3, pBlock->info.rows, (const char*)&bytes, false);
|
||||
STR_TO_VARSTR(buf, i >= pMeta->tableInfo.numOfColumns ? "TAG" : "");
|
||||
colDataSetVal(pCol4, pBlock->info.rows, buf, false);
|
||||
STR_TO_VARSTR(buf, pMeta->schema[i].comment);
|
||||
colDataSetVal(pCol5, pBlock->info.rows, buf, false);
|
||||
++(pBlock->info.rows);
|
||||
}
|
||||
if (pBlock->info.rows <= 0) {
|
||||
|
@ -464,19 +456,14 @@ void appendColumnFields(char* buf, int32_t* len, STableCfg* pCfg) {
|
|||
for (int32_t i = 0; i < pCfg->numOfColumns; ++i) {
|
||||
SSchema* pSchema = pCfg->pSchemas + i;
|
||||
char type[32];
|
||||
char comments[TSDB_COL_COMMENT_LEN + 16] = {0};
|
||||
sprintf(type, "%s", tDataTypes[pSchema->type].name);
|
||||
if (TSDB_DATA_TYPE_VARCHAR == pSchema->type || TSDB_DATA_TYPE_GEOMETRY == pSchema->type) {
|
||||
sprintf(type + strlen(type), "(%d)", (int32_t)(pSchema->bytes - VARSTR_HEADER_SIZE));
|
||||
} else if (TSDB_DATA_TYPE_NCHAR == pSchema->type) {
|
||||
sprintf(type + strlen(type), "(%d)", (int32_t)((pSchema->bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE));
|
||||
}
|
||||
if (pSchema->comment[0]) {
|
||||
sprintf(comments, " COMMENT '%s'", pSchema->comment);
|
||||
}
|
||||
|
||||
*len +=
|
||||
sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s`%s` %s%s", ((i > 0) ? ", " : ""), pSchema->name, type, comments);
|
||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s`%s` %s", ((i > 0) ? ", " : ""), pSchema->name, type);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -484,18 +471,14 @@ void appendTagFields(char* buf, int32_t* len, STableCfg* pCfg) {
|
|||
for (int32_t i = 0; i < pCfg->numOfTags; ++i) {
|
||||
SSchema* pSchema = pCfg->pSchemas + pCfg->numOfColumns + i;
|
||||
char type[32];
|
||||
char comments[TSDB_COL_COMMENT_LEN + 16] = {0};
|
||||
sprintf(type, "%s", tDataTypes[pSchema->type].name);
|
||||
if (TSDB_DATA_TYPE_VARCHAR == pSchema->type || TSDB_DATA_TYPE_GEOMETRY == pSchema->type) {
|
||||
sprintf(type + strlen(type), "(%d)", (int32_t)(pSchema->bytes - VARSTR_HEADER_SIZE));
|
||||
} else if (TSDB_DATA_TYPE_NCHAR == pSchema->type) {
|
||||
sprintf(type + strlen(type), "(%d)", (int32_t)((pSchema->bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE));
|
||||
}
|
||||
if (pSchema->comment[0]) {
|
||||
sprintf(comments, " COMMENT '%s'", pSchema->comment);
|
||||
}
|
||||
|
||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s`%s` %s%s", ((i > 0) ? ", " : ""), pSchema->name, type, comments);
|
||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s`%s` %s", ((i > 0) ? ", " : ""), pSchema->name, type);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7699,10 +7699,6 @@ static int32_t extractDescribeResultSchema(int32_t* numOfCols, SSchema** pSchema
|
|||
(*pSchema)[3].bytes = DESCRIBE_RESULT_NOTE_LEN;
|
||||
strcpy((*pSchema)[3].name, "note");
|
||||
|
||||
(*pSchema)[4].type = TSDB_DATA_TYPE_BINARY;
|
||||
(*pSchema)[4].bytes = DESCRIBE_RESULT_COL_COMMENT_LEN;
|
||||
strcpy((*pSchema)[4].name, "comment");
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -222,15 +222,6 @@ class TDTestCase:
|
|||
tdSql.query('show create table super_table')
|
||||
create_sql = "create stable `super_table` (`ts` timestamp, `c2` int) tags (`tg` int)"
|
||||
tdSql.checkEqual(tdSql.queryResult[0][1].lower(), create_sql)
|
||||
|
||||
tdSql.query("desc normal_table")
|
||||
tdSql.checkCols(5)
|
||||
tdSql.checkData(0, 4, "")
|
||||
|
||||
tdSql.query("desc super_table")
|
||||
tdSql.checkCols(5)
|
||||
tdSql.checkData(0, 4, "")
|
||||
|
||||
tdSql.execute("drop database comment_test_db")
|
||||
|
||||
def alter_table_with_col_comment(self):
|
||||
|
|
Loading…
Reference in New Issue