fix: truncate show create table result
This commit is contained in:
parent
a5b1cfc9a2
commit
c0463e46c9
|
@ -186,7 +186,6 @@ static FORCE_INLINE void colDataAppendDouble(SColumnInfoData* pColumnInfoData, u
|
||||||
|
|
||||||
int32_t getJsonValueLen(const char* data);
|
int32_t getJsonValueLen(const char* data);
|
||||||
|
|
||||||
int32_t colDataLenAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, uint32_t dataLen);
|
|
||||||
int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, bool isNull);
|
int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, bool isNull);
|
||||||
int32_t colDataAppendNItems(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData,
|
int32_t colDataAppendNItems(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData,
|
||||||
uint32_t numOfRows);
|
uint32_t numOfRows);
|
||||||
|
|
|
@ -104,7 +104,7 @@ typedef int32_t (*TUdfDestroyFunc)();
|
||||||
} while (0)
|
} while (0)
|
||||||
#define udfColDataSetNull_var(pColumn, row) ((pColumn->colData.varLenCol.varOffsets)[row] = -1)
|
#define udfColDataSetNull_var(pColumn, row) ((pColumn->colData.varLenCol.varOffsets)[row] = -1)
|
||||||
|
|
||||||
typedef int16_t VarDataLenT; // maxVarDataLen: 32767
|
typedef uint16_t VarDataLenT; // maxVarDataLen: 65535
|
||||||
#define VARSTR_HEADER_SIZE sizeof(VarDataLenT)
|
#define VARSTR_HEADER_SIZE sizeof(VarDataLenT)
|
||||||
#define varDataLen(v) ((VarDataLenT *)(v))[0]
|
#define varDataLen(v) ((VarDataLenT *)(v))[0]
|
||||||
#define varDataVal(v) ((char *)(v) + VARSTR_HEADER_SIZE)
|
#define varDataVal(v) ((char *)(v) + VARSTR_HEADER_SIZE)
|
||||||
|
|
|
@ -78,7 +78,7 @@ static FORCE_INLINE double taos_align_get_double(const char *pBuf) {
|
||||||
{ (*(double *)(x)) = (*(double *)(y)); }
|
{ (*(double *)(x)) = (*(double *)(y)); }
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
typedef int16_t VarDataLenT; // maxVarDataLen: 32767
|
typedef uint16_t VarDataLenT; // maxVarDataLen: 65535
|
||||||
#define VARSTR_HEADER_SIZE sizeof(VarDataLenT)
|
#define VARSTR_HEADER_SIZE sizeof(VarDataLenT)
|
||||||
|
|
||||||
#define varDataLen(v) ((VarDataLenT *)(v))[0]
|
#define varDataLen(v) ((VarDataLenT *)(v))[0]
|
||||||
|
@ -87,12 +87,6 @@ typedef int16_t VarDataLenT; // maxVarDataLen: 32767
|
||||||
|
|
||||||
#define NCHAR_WIDTH_TO_BYTES(n) ((n)*TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE)
|
#define NCHAR_WIDTH_TO_BYTES(n) ((n)*TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE)
|
||||||
|
|
||||||
typedef uint32_t extVarDataLenT;
|
|
||||||
#define EXTVARSTR_HEADER_SIZE (VARSTR_HEADER_SIZE + sizeof(extVarDataLenT))
|
|
||||||
#define extVarDataLen(v) ((*(VarDataLenT *)(v)) == -1 ? (*(extVarDataLenT*)(((VarDataLenT *)(v)) + 1)) : (*(VarDataLenT *)(v)))
|
|
||||||
#define extVarDataVal(v) ((char *)(v) + EXTVARSTR_HEADER_SIZE)
|
|
||||||
#define setExtVarDataLen(v, l) do { *(VarDataLenT *)(v) = -1; *(extVarDataLenT*)(((VarDataLenT *)(v)) + 1) = (l); } while (0)
|
|
||||||
|
|
||||||
typedef int32_t VarDataOffsetT;
|
typedef int32_t VarDataOffsetT;
|
||||||
|
|
||||||
typedef struct tstr {
|
typedef struct tstr {
|
||||||
|
|
|
@ -1482,10 +1482,6 @@ void doSetOneRowPtr(SReqResultInfo* pResultInfo) {
|
||||||
|
|
||||||
pResultInfo->length[i] = varDataLen(pStart);
|
pResultInfo->length[i] = varDataLen(pStart);
|
||||||
pResultInfo->row[i] = varDataVal(pStart);
|
pResultInfo->row[i] = varDataVal(pStart);
|
||||||
if (-1 == pResultInfo->length[i]) {
|
|
||||||
pResultInfo->length[i] = extVarDataLen(pStart);
|
|
||||||
pResultInfo->row[i] = extVarDataVal(pStart);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
pResultInfo->row[i] = NULL;
|
pResultInfo->row[i] = NULL;
|
||||||
pResultInfo->length[i] = 0;
|
pResultInfo->length[i] = 0;
|
||||||
|
|
|
@ -62,44 +62,6 @@ int32_t getJsonValueLen(const char* data) {
|
||||||
return dataLen;
|
return dataLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t colDataLenAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, uint32_t dataLen) {
|
|
||||||
ASSERT(pColumnInfoData != NULL);
|
|
||||||
|
|
||||||
int32_t type = pColumnInfoData->info.type;
|
|
||||||
if (IS_VAR_DATA_TYPE(type)) {
|
|
||||||
SVarColAttr* pAttr = &pColumnInfoData->varmeta;
|
|
||||||
if (pAttr->allocLen < pAttr->length + dataLen) {
|
|
||||||
uint32_t newSize = pAttr->allocLen;
|
|
||||||
if (newSize <= 1) {
|
|
||||||
newSize = 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (newSize < pAttr->length + dataLen) {
|
|
||||||
newSize = newSize * 1.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
char* buf = taosMemoryRealloc(pColumnInfoData->pData, newSize);
|
|
||||||
if (buf == NULL) {
|
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
pColumnInfoData->pData = buf;
|
|
||||||
pAttr->allocLen = newSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t len = pColumnInfoData->varmeta.length;
|
|
||||||
pColumnInfoData->varmeta.offset[currentRow] = len;
|
|
||||||
|
|
||||||
memcpy(pColumnInfoData->pData + len, pData, dataLen);
|
|
||||||
pColumnInfoData->varmeta.length += dataLen;
|
|
||||||
} else {
|
|
||||||
memcpy(pColumnInfoData->pData + pColumnInfoData->info.bytes * currentRow, pData, pColumnInfoData->info.bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, bool isNull) {
|
int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, bool isNull) {
|
||||||
ASSERT(pColumnInfoData != NULL);
|
ASSERT(pColumnInfoData != NULL);
|
||||||
|
|
||||||
|
|
|
@ -330,7 +330,7 @@ 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));
|
||||||
}
|
}
|
||||||
|
|
||||||
*len += sprintf(buf + EXTVARSTR_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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,14 +345,14 @@ void appendTagFields(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));
|
||||||
}
|
}
|
||||||
|
|
||||||
*len += sprintf(buf + EXTVARSTR_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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void appendTagNameFields(char* buf, int32_t* len, STableCfg* pCfg) {
|
void appendTagNameFields(char* buf, int32_t* len, STableCfg* pCfg) {
|
||||||
for (int32_t i = 0; i < pCfg->numOfTags; ++i) {
|
for (int32_t i = 0; i < pCfg->numOfTags; ++i) {
|
||||||
SSchema* pSchema = pCfg->pSchemas + pCfg->numOfColumns + i;
|
SSchema* pSchema = pCfg->pSchemas + pCfg->numOfColumns + i;
|
||||||
*len += sprintf(buf + EXTVARSTR_HEADER_SIZE + *len, "%s`%s`", ((i > 0) ? ", " : ""), pSchema->name);
|
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s`%s`", ((i > 0) ? ", " : ""), pSchema->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,7 +368,7 @@ int32_t appendTagValues(char* buf, int32_t* len, STableCfg* pCfg) {
|
||||||
if (tTagIsJson(pTag)) {
|
if (tTagIsJson(pTag)) {
|
||||||
char* pJson = parseTagDatatoJson(pTag);
|
char* pJson = parseTagDatatoJson(pTag);
|
||||||
if (pJson) {
|
if (pJson) {
|
||||||
*len += sprintf(buf + EXTVARSTR_HEADER_SIZE + *len, "%s", pJson);
|
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s", pJson);
|
||||||
taosMemoryFree(pJson);
|
taosMemoryFree(pJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,11 +386,11 @@ int32_t appendTagValues(char* buf, int32_t* len, STableCfg* pCfg) {
|
||||||
for (int32_t i = 0; i < pCfg->numOfTags; ++i) {
|
for (int32_t i = 0; i < pCfg->numOfTags; ++i) {
|
||||||
SSchema* pSchema = pCfg->pSchemas + pCfg->numOfColumns + i;
|
SSchema* pSchema = pCfg->pSchemas + pCfg->numOfColumns + i;
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
*len += sprintf(buf + EXTVARSTR_HEADER_SIZE + *len, ", ");
|
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, ", ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (j >= valueNum) {
|
if (j >= valueNum) {
|
||||||
*len += sprintf(buf + EXTVARSTR_HEADER_SIZE + *len, "NULL");
|
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "NULL");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -404,14 +404,14 @@ int32_t appendTagValues(char* buf, int32_t* len, STableCfg* pCfg) {
|
||||||
int32_t tlen = 0;
|
int32_t tlen = 0;
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE(type)) {
|
if (IS_VAR_DATA_TYPE(type)) {
|
||||||
dataConverToStr(buf + EXTVARSTR_HEADER_SIZE + *len, type, pTagVal->pData, pTagVal->nData, &tlen);
|
dataConverToStr(buf + VARSTR_HEADER_SIZE + *len, type, pTagVal->pData, pTagVal->nData, &tlen);
|
||||||
} else {
|
} else {
|
||||||
dataConverToStr(buf + EXTVARSTR_HEADER_SIZE + *len, type, &pTagVal->i64, tDataTypes[type].bytes, &tlen);
|
dataConverToStr(buf + VARSTR_HEADER_SIZE + *len, type, &pTagVal->i64, tDataTypes[type].bytes, &tlen);
|
||||||
}
|
}
|
||||||
*len += tlen;
|
*len += tlen;
|
||||||
j++;
|
j++;
|
||||||
} else {
|
} else {
|
||||||
*len += sprintf(buf + EXTVARSTR_HEADER_SIZE + *len, "NULL");
|
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "NULL");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -450,37 +450,37 @@ int32_t appendTagValues(char* buf, int32_t* len, STableCfg* pCfg) {
|
||||||
|
|
||||||
void appendTableOptions(char* buf, int32_t* len, SDbCfgInfo* pDbCfg, STableCfg* pCfg) {
|
void appendTableOptions(char* buf, int32_t* len, SDbCfgInfo* pDbCfg, STableCfg* pCfg) {
|
||||||
if (pCfg->commentLen > 0) {
|
if (pCfg->commentLen > 0) {
|
||||||
*len += sprintf(buf + EXTVARSTR_HEADER_SIZE + *len, " COMMENT '%s'", pCfg->pComment);
|
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, " COMMENT '%s'", pCfg->pComment);
|
||||||
} else if (0 == pCfg->commentLen) {
|
} else if (0 == pCfg->commentLen) {
|
||||||
*len += sprintf(buf + EXTVARSTR_HEADER_SIZE + *len, " COMMENT ''");
|
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, " COMMENT ''");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL != pDbCfg->pRetensions && pCfg->watermark1 > 0) {
|
if (NULL != pDbCfg->pRetensions && pCfg->watermark1 > 0) {
|
||||||
*len += sprintf(buf + EXTVARSTR_HEADER_SIZE + *len, " WATERMARK %" PRId64 "a", pCfg->watermark1);
|
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, " WATERMARK %" PRId64 "a", pCfg->watermark1);
|
||||||
if (pCfg->watermark2 > 0) {
|
if (pCfg->watermark2 > 0) {
|
||||||
*len += sprintf(buf + EXTVARSTR_HEADER_SIZE + *len, ", %" PRId64 "a", pCfg->watermark2);
|
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, ", %" PRId64 "a", pCfg->watermark2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL != pDbCfg->pRetensions && pCfg->delay1 > 0) {
|
if (NULL != pDbCfg->pRetensions && pCfg->delay1 > 0) {
|
||||||
*len += sprintf(buf + EXTVARSTR_HEADER_SIZE + *len, " MAX_DELAY %" PRId64 "a", pCfg->delay1);
|
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, " MAX_DELAY %" PRId64 "a", pCfg->delay1);
|
||||||
if (pCfg->delay2 > 0) {
|
if (pCfg->delay2 > 0) {
|
||||||
*len += sprintf(buf + EXTVARSTR_HEADER_SIZE + *len, ", %" PRId64 "a", pCfg->delay2);
|
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, ", %" PRId64 "a", pCfg->delay2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t funcNum = taosArrayGetSize(pCfg->pFuncs);
|
int32_t funcNum = taosArrayGetSize(pCfg->pFuncs);
|
||||||
if (NULL != pDbCfg->pRetensions && funcNum > 0) {
|
if (NULL != pDbCfg->pRetensions && funcNum > 0) {
|
||||||
*len += sprintf(buf + EXTVARSTR_HEADER_SIZE + *len, " ROLLUP(");
|
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, " ROLLUP(");
|
||||||
for (int32_t i = 0; i < funcNum; ++i) {
|
for (int32_t i = 0; i < funcNum; ++i) {
|
||||||
char* pFunc = taosArrayGet(pCfg->pFuncs, i);
|
char* pFunc = taosArrayGet(pCfg->pFuncs, i);
|
||||||
*len += sprintf(buf + EXTVARSTR_HEADER_SIZE + *len, "%s%s", ((i > 0) ? ", " : ""), pFunc);
|
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s%s", ((i > 0) ? ", " : ""), pFunc);
|
||||||
}
|
}
|
||||||
*len += sprintf(buf + EXTVARSTR_HEADER_SIZE + *len, ")");
|
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pCfg->ttl > 0) {
|
if (pCfg->ttl > 0) {
|
||||||
*len += sprintf(buf + EXTVARSTR_HEADER_SIZE + *len, " TTL %d", pCfg->ttl);
|
*len += sprintf(buf + VARSTR_HEADER_SIZE + *len, " TTL %d", pCfg->ttl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -504,33 +504,33 @@ static int32_t setCreateTBResultIntoDataBlock(SSDataBlock* pBlock, SDbCfgInfo* p
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
|
|
||||||
if (TSDB_SUPER_TABLE == pCfg->tableType) {
|
if (TSDB_SUPER_TABLE == pCfg->tableType) {
|
||||||
len += sprintf(buf2 + EXTVARSTR_HEADER_SIZE, "CREATE STABLE `%s` (", tbName);
|
len += sprintf(buf2 + VARSTR_HEADER_SIZE, "CREATE STABLE `%s` (", tbName);
|
||||||
appendColumnFields(buf2, &len, pCfg);
|
appendColumnFields(buf2, &len, pCfg);
|
||||||
len += sprintf(buf2 + EXTVARSTR_HEADER_SIZE + len, ") TAGS (");
|
len += sprintf(buf2 + VARSTR_HEADER_SIZE + len, ") TAGS (");
|
||||||
appendTagFields(buf2, &len, pCfg);
|
appendTagFields(buf2, &len, pCfg);
|
||||||
len += sprintf(buf2 + EXTVARSTR_HEADER_SIZE + len, ")");
|
len += sprintf(buf2 + VARSTR_HEADER_SIZE + len, ")");
|
||||||
appendTableOptions(buf2, &len, pDbCfg, pCfg);
|
appendTableOptions(buf2, &len, pDbCfg, pCfg);
|
||||||
} else if (TSDB_CHILD_TABLE == pCfg->tableType) {
|
} else if (TSDB_CHILD_TABLE == pCfg->tableType) {
|
||||||
len += sprintf(buf2 + EXTVARSTR_HEADER_SIZE, "CREATE TABLE `%s` USING `%s` (", tbName, pCfg->stbName);
|
len += sprintf(buf2 + VARSTR_HEADER_SIZE, "CREATE TABLE `%s` USING `%s` (", tbName, pCfg->stbName);
|
||||||
appendTagNameFields(buf2, &len, pCfg);
|
appendTagNameFields(buf2, &len, pCfg);
|
||||||
len += sprintf(buf2 + EXTVARSTR_HEADER_SIZE + len, ") TAGS (");
|
len += sprintf(buf2 + VARSTR_HEADER_SIZE + len, ") TAGS (");
|
||||||
code = appendTagValues(buf2, &len, pCfg);
|
code = appendTagValues(buf2, &len, pCfg);
|
||||||
if (code) {
|
if (code) {
|
||||||
taosMemoryFree(buf2);
|
taosMemoryFree(buf2);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
len += sprintf(buf2 + EXTVARSTR_HEADER_SIZE + len, ")");
|
len += sprintf(buf2 + VARSTR_HEADER_SIZE + len, ")");
|
||||||
appendTableOptions(buf2, &len, pDbCfg, pCfg);
|
appendTableOptions(buf2, &len, pDbCfg, pCfg);
|
||||||
} else {
|
} else {
|
||||||
len += sprintf(buf2 + EXTVARSTR_HEADER_SIZE, "CREATE TABLE `%s` (", tbName);
|
len += sprintf(buf2 + VARSTR_HEADER_SIZE, "CREATE TABLE `%s` (", tbName);
|
||||||
appendColumnFields(buf2, &len, pCfg);
|
appendColumnFields(buf2, &len, pCfg);
|
||||||
len += sprintf(buf2 + EXTVARSTR_HEADER_SIZE + len, ")");
|
len += sprintf(buf2 + VARSTR_HEADER_SIZE + len, ")");
|
||||||
appendTableOptions(buf2, &len, pDbCfg, pCfg);
|
appendTableOptions(buf2, &len, pDbCfg, pCfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
setExtVarDataLen(buf2, len);
|
varDataLen(buf2) = (len > 65535) ? 65535 : len;
|
||||||
|
|
||||||
colDataLenAppend(pCol2, 0, buf2, len + EXTVARSTR_HEADER_SIZE);
|
colDataAppend(pCol2, 0, buf2, false);
|
||||||
|
|
||||||
taosMemoryFree(buf2);
|
taosMemoryFree(buf2);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue