show create table tbname
This commit is contained in:
parent
066a22443d
commit
b10deacd63
|
@ -76,6 +76,7 @@ uint8_t columnLevelVal(const char* level);
|
||||||
uint8_t columnEncodeVal(const char* encode);
|
uint8_t columnEncodeVal(const char* encode);
|
||||||
uint16_t columnCompressVal(const char* compress);
|
uint16_t columnCompressVal(const char* compress);
|
||||||
|
|
||||||
|
bool useCompress(uint8_t tableType);
|
||||||
bool checkColumnEncode(char encode[TSDB_CL_COMPRESS_OPTION_LEN]);
|
bool checkColumnEncode(char encode[TSDB_CL_COMPRESS_OPTION_LEN]);
|
||||||
bool checkColumnEncodeOrSetDefault(uint8_t type, char encode[TSDB_CL_COMPRESS_OPTION_LEN]);
|
bool checkColumnEncodeOrSetDefault(uint8_t type, char encode[TSDB_CL_COMPRESS_OPTION_LEN]);
|
||||||
bool checkColumnCompress(char compress[TSDB_CL_COMPRESS_OPTION_LEN]);
|
bool checkColumnCompress(char compress[TSDB_CL_COMPRESS_OPTION_LEN]);
|
||||||
|
|
|
@ -1182,23 +1182,24 @@ typedef struct {
|
||||||
} STableCfgReq;
|
} STableCfgReq;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char tbName[TSDB_TABLE_NAME_LEN];
|
char tbName[TSDB_TABLE_NAME_LEN];
|
||||||
char stbName[TSDB_TABLE_NAME_LEN];
|
char stbName[TSDB_TABLE_NAME_LEN];
|
||||||
char dbFName[TSDB_DB_FNAME_LEN];
|
char dbFName[TSDB_DB_FNAME_LEN];
|
||||||
int32_t numOfTags;
|
int32_t numOfTags;
|
||||||
int32_t numOfColumns;
|
int32_t numOfColumns;
|
||||||
int8_t tableType;
|
int8_t tableType;
|
||||||
int64_t delay1;
|
int64_t delay1;
|
||||||
int64_t delay2;
|
int64_t delay2;
|
||||||
int64_t watermark1;
|
int64_t watermark1;
|
||||||
int64_t watermark2;
|
int64_t watermark2;
|
||||||
int32_t ttl;
|
int32_t ttl;
|
||||||
SArray* pFuncs;
|
SArray* pFuncs;
|
||||||
int32_t commentLen;
|
int32_t commentLen;
|
||||||
char* pComment;
|
char* pComment;
|
||||||
SSchema* pSchemas;
|
SSchema* pSchemas;
|
||||||
int32_t tagsLen;
|
int32_t tagsLen;
|
||||||
char* pTags;
|
char* pTags;
|
||||||
|
SSchemaExt* pSchemaExt;
|
||||||
} STableCfg;
|
} STableCfg;
|
||||||
|
|
||||||
typedef STableCfg STableCfgRsp;
|
typedef STableCfg STableCfgRsp;
|
||||||
|
|
|
@ -295,3 +295,7 @@ void setColCompressByOption(uint32_t* compress, uint8_t encode, uint16_t compres
|
||||||
setColLevel(compress, level);
|
setColLevel(compress, level);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool useCompress(uint8_t tableType) {
|
||||||
|
return TSDB_SUPER_TABLE == tableType || TSDB_NORMAL_TABLE == tableType;
|
||||||
|
}
|
||||||
|
|
|
@ -2904,6 +2904,11 @@ int32_t tSerializeSTableCfgRsp(void *buf, int32_t bufLen, STableCfgRsp *pRsp) {
|
||||||
if (tEncodeI32(&encoder, pRsp->tagsLen) < 0) return -1;
|
if (tEncodeI32(&encoder, pRsp->tagsLen) < 0) return -1;
|
||||||
if (tEncodeBinary(&encoder, pRsp->pTags, pRsp->tagsLen) < 0) return -1;
|
if (tEncodeBinary(&encoder, pRsp->pTags, pRsp->tagsLen) < 0) return -1;
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < pRsp->numOfColumns; ++i)
|
||||||
|
{
|
||||||
|
SSchemaExt *pSchemaExt = &pRsp->pSchemaExt[i];
|
||||||
|
if (tEncodeSSchemaExt(&encoder, pSchemaExt) < 0) return -1;
|
||||||
|
}
|
||||||
tEndEncode(&encoder);
|
tEndEncode(&encoder);
|
||||||
|
|
||||||
int32_t tlen = encoder.pos;
|
int32_t tlen = encoder.pos;
|
||||||
|
@ -2962,6 +2967,21 @@ int32_t tDeserializeSTableCfgRsp(void *buf, int32_t bufLen, STableCfgRsp *pRsp)
|
||||||
if (tDecodeI32(&decoder, &pRsp->tagsLen) < 0) return -1;
|
if (tDecodeI32(&decoder, &pRsp->tagsLen) < 0) return -1;
|
||||||
if (tDecodeBinaryAlloc(&decoder, (void **)&pRsp->pTags, NULL) < 0) return -1;
|
if (tDecodeBinaryAlloc(&decoder, (void **)&pRsp->pTags, NULL) < 0) return -1;
|
||||||
|
|
||||||
|
if (1 /*!tDecodeIsEnd(&decoder)*/) {
|
||||||
|
if (pRsp->numOfColumns > 0) {
|
||||||
|
pRsp->pSchemaExt = taosMemoryMalloc(sizeof(SSchemaExt) * pRsp->numOfColumns);
|
||||||
|
if (pRsp->pSchemaExt == NULL) return -1;
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < pRsp->numOfColumns; ++i) {
|
||||||
|
SSchemaExt *pSchemaExt = &pRsp->pSchemaExt[i];
|
||||||
|
if (tDecodeSSchemaExt(&decoder, pSchemaExt) < 0) return -1;
|
||||||
|
pSchemaExt->colId = i;
|
||||||
|
pSchemaExt->compress = 0x02000303;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pRsp->pSchemaExt = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
tEndDecode(&decoder);
|
tEndDecode(&decoder);
|
||||||
|
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
@ -2975,6 +2995,7 @@ void tFreeSTableCfgRsp(STableCfgRsp *pRsp) {
|
||||||
|
|
||||||
taosMemoryFreeClear(pRsp->pComment);
|
taosMemoryFreeClear(pRsp->pComment);
|
||||||
taosMemoryFreeClear(pRsp->pSchemas);
|
taosMemoryFreeClear(pRsp->pSchemas);
|
||||||
|
taosMemoryFreeClear(pRsp->pSchemaExt);
|
||||||
taosMemoryFreeClear(pRsp->pTags);
|
taosMemoryFreeClear(pRsp->pTags);
|
||||||
|
|
||||||
taosArrayDestroy(pRsp->pFuncs);
|
taosArrayDestroy(pRsp->pFuncs);
|
||||||
|
|
|
@ -1630,14 +1630,14 @@ static void* ctgCloneQnodeList(void* pSrc) { return taosArrayDup((const SArray*)
|
||||||
|
|
||||||
static void ctgFreeQnodeList(void* p) { taosArrayDestroy((SArray*)((SMetaRes*)p)->pRes); }
|
static void ctgFreeQnodeList(void* p) { taosArrayDestroy((SArray*)((SMetaRes*)p)->pRes); }
|
||||||
|
|
||||||
static void* ctgCloneTableCfg(void* pSrc) {
|
// static void* ctgCloneTableCfg(void* pSrc) {
|
||||||
STableCfg* pDst = taosMemoryMalloc(sizeof(STableCfg));
|
// STableCfg* pDst = taosMemoryMalloc(sizeof(STableCfg));
|
||||||
if (NULL == pDst) {
|
// if (NULL == pDst) {
|
||||||
return NULL;
|
// return NULL;
|
||||||
}
|
// }
|
||||||
memcpy(pDst, pSrc, sizeof(STableCfg));
|
// memcpy(pDst, pSrc, sizeof(STableCfg));
|
||||||
return pDst;
|
// return pDst;
|
||||||
}
|
// }
|
||||||
|
|
||||||
static void ctgFreeTableCfg(void* p) { taosMemoryFree(((SMetaRes*)p)->pRes); }
|
static void ctgFreeTableCfg(void* p) { taosMemoryFree(((SMetaRes*)p)->pRes); }
|
||||||
|
|
||||||
|
|
|
@ -521,7 +521,7 @@ static int32_t buildCreateViewResultDataBlock(SSDataBlock** pOutput) {
|
||||||
void appendColumnFields(char* buf, int32_t* len, STableCfg* pCfg) {
|
void appendColumnFields(char* buf, int32_t* len, STableCfg* pCfg) {
|
||||||
for (int32_t i = 0; i < pCfg->numOfColumns; ++i) {
|
for (int32_t i = 0; i < pCfg->numOfColumns; ++i) {
|
||||||
SSchema* pSchema = pCfg->pSchemas + i;
|
SSchema* pSchema = pCfg->pSchemas + i;
|
||||||
char type[32];
|
char type[32 + 60]; // 60 byte for compress info
|
||||||
sprintf(type, "%s", tDataTypes[pSchema->type].name);
|
sprintf(type, "%s", tDataTypes[pSchema->type].name);
|
||||||
if (TSDB_DATA_TYPE_VARCHAR == pSchema->type || TSDB_DATA_TYPE_VARBINARY == pSchema->type || TSDB_DATA_TYPE_GEOMETRY == pSchema->type) {
|
if (TSDB_DATA_TYPE_VARCHAR == pSchema->type || TSDB_DATA_TYPE_VARBINARY == pSchema->type || TSDB_DATA_TYPE_GEOMETRY == pSchema->type) {
|
||||||
sprintf(type + strlen(type), "(%d)", (int32_t)(pSchema->bytes - VARSTR_HEADER_SIZE));
|
sprintf(type + strlen(type), "(%d)", (int32_t)(pSchema->bytes - VARSTR_HEADER_SIZE));
|
||||||
|
@ -529,6 +529,12 @@ void appendColumnFields(char* buf, int32_t* len, STableCfg* pCfg) {
|
||||||
sprintf(type + strlen(type), "(%d)", (int32_t)((pSchema->bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE));
|
sprintf(type + strlen(type), "(%d)", (int32_t)((pSchema->bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (useCompress(pCfg->tableType)) {
|
||||||
|
sprintf(type + strlen(type), " ENCODE \'%s\'", columnEncodeStr(COMPRESS_L1_TYPE_U32(pCfg->pSchemaExt[i].compress)));
|
||||||
|
sprintf(type + strlen(type), " COMPRESS \'%s\'", columnCompressStr(COMPRESS_L2_TYPE_U32(pCfg->pSchemaExt[i].compress)));
|
||||||
|
sprintf(type + strlen(type), " LEVEL \'%s\'", columnLevelStr(COMPRESS_L2_TYPE_LEVEL_U32(pCfg->pSchemaExt[i].compress)));
|
||||||
|
}
|
||||||
|
|
||||||
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s`%s` %s", ((i > 0) ? ", " : ""), pSchema->name, type);
|
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s`%s` %s", ((i > 0) ? ", " : ""), pSchema->name, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -683,6 +683,7 @@ static void destroyTableCfg(STableCfg* pCfg) {
|
||||||
taosArrayDestroy(pCfg->pFuncs);
|
taosArrayDestroy(pCfg->pFuncs);
|
||||||
taosMemoryFree(pCfg->pComment);
|
taosMemoryFree(pCfg->pComment);
|
||||||
taosMemoryFree(pCfg->pSchemas);
|
taosMemoryFree(pCfg->pSchemas);
|
||||||
|
taosMemoryFree(pCfg->pSchemaExt);
|
||||||
taosMemoryFree(pCfg->pTags);
|
taosMemoryFree(pCfg->pTags);
|
||||||
taosMemoryFree(pCfg);
|
taosMemoryFree(pCfg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1146,7 +1146,12 @@ STableCfg* tableCfgDup(STableCfg* pCfg) {
|
||||||
SSchema* pSchema = taosMemoryMalloc(schemaSize);
|
SSchema* pSchema = taosMemoryMalloc(schemaSize);
|
||||||
memcpy(pSchema, pCfg->pSchemas, schemaSize);
|
memcpy(pSchema, pCfg->pSchemas, schemaSize);
|
||||||
|
|
||||||
|
int32_t schemaExtSize = pCfg->numOfColumns * sizeof(SSchemaExt);
|
||||||
|
SSchemaExt* pSchemaExt = taosMemoryMalloc(schemaExtSize);
|
||||||
|
memcpy(pSchemaExt, pCfg->pSchemaExt, schemaExtSize);
|
||||||
|
|
||||||
pNew->pSchemas = pSchema;
|
pNew->pSchemas = pSchema;
|
||||||
|
pNew->pSchemaExt = pSchemaExt;
|
||||||
|
|
||||||
return pNew;
|
return pNew;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue