enh: add return len
This commit is contained in:
parent
e84376c461
commit
14a2cb073a
|
@ -513,21 +513,18 @@ void appendColumnFields(char* buf, int32_t* len, STableCfg* pCfg) {
|
||||||
int typeLen = strlen(type);
|
int typeLen = strlen(type);
|
||||||
if (TSDB_DATA_TYPE_VARCHAR == pSchema->type || TSDB_DATA_TYPE_VARBINARY == pSchema->type ||
|
if (TSDB_DATA_TYPE_VARCHAR == pSchema->type || TSDB_DATA_TYPE_VARBINARY == pSchema->type ||
|
||||||
TSDB_DATA_TYPE_GEOMETRY == pSchema->type) {
|
TSDB_DATA_TYPE_GEOMETRY == pSchema->type) {
|
||||||
snprintf(type + typeLen, LTYPE_LEN - typeLen, "(%d)", (int32_t)(pSchema->bytes - VARSTR_HEADER_SIZE));
|
typeLen += tsnprintf(type + typeLen, LTYPE_LEN - typeLen, "(%d)", (int32_t)(pSchema->bytes - VARSTR_HEADER_SIZE));
|
||||||
} else if (TSDB_DATA_TYPE_NCHAR == pSchema->type) {
|
} else if (TSDB_DATA_TYPE_NCHAR == pSchema->type) {
|
||||||
snprintf(type + typeLen, LTYPE_LEN - typeLen, "(%d)",
|
typeLen += snprintf(type + typeLen, LTYPE_LEN - typeLen, "(%d)",
|
||||||
(int32_t)((pSchema->bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE));
|
(int32_t)((pSchema->bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useCompress(pCfg->tableType) && pCfg->pSchemaExt) {
|
if (useCompress(pCfg->tableType) && pCfg->pSchemaExt) {
|
||||||
typeLen = strlen(type);
|
typeLen += tsnprintf(type + typeLen, LTYPE_LEN - typeLen, " ENCODE \'%s\'",
|
||||||
snprintf(type + typeLen, LTYPE_LEN - typeLen, " ENCODE \'%s\'",
|
|
||||||
columnEncodeStr(COMPRESS_L1_TYPE_U32(pCfg->pSchemaExt[i].compress)));
|
columnEncodeStr(COMPRESS_L1_TYPE_U32(pCfg->pSchemaExt[i].compress)));
|
||||||
typeLen = strlen(type);
|
typeLen += tsnprintf(type + typeLen, LTYPE_LEN - typeLen, " COMPRESS \'%s\'",
|
||||||
snprintf(type + typeLen, LTYPE_LEN - typeLen, " COMPRESS \'%s\'",
|
|
||||||
columnCompressStr(COMPRESS_L2_TYPE_U32(pCfg->pSchemaExt[i].compress)));
|
columnCompressStr(COMPRESS_L2_TYPE_U32(pCfg->pSchemaExt[i].compress)));
|
||||||
typeLen = strlen(type);
|
typeLen += tsnprintf(type + typeLen, LTYPE_LEN - typeLen, " LEVEL \'%s\'",
|
||||||
snprintf(type + typeLen, LTYPE_LEN - typeLen, " LEVEL \'%s\'",
|
|
||||||
columnLevelStr(COMPRESS_L2_TYPE_LEVEL_U32(pCfg->pSchemaExt[i].compress)));
|
columnLevelStr(COMPRESS_L2_TYPE_LEVEL_U32(pCfg->pSchemaExt[i].compress)));
|
||||||
}
|
}
|
||||||
if (!(pSchema->flags & COL_IS_KEY)) {
|
if (!(pSchema->flags & COL_IS_KEY)) {
|
||||||
|
|
|
@ -306,7 +306,7 @@ uint64_t schGenUUID(void) {
|
||||||
qError("Failed to get the system uid, reason:%s", tstrerror(TAOS_SYSTEM_ERROR(errno)));
|
qError("Failed to get the system uid, reason:%s", tstrerror(TAOS_SYSTEM_ERROR(errno)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ßßß
|
|
||||||
int64_t ts = taosGetTimestampMs();
|
int64_t ts = taosGetTimestampMs();
|
||||||
uint64_t pid = taosGetPId();
|
uint64_t pid = taosGetPId();
|
||||||
int32_t val = atomic_add_fetch_32(&requestSerialId, 1);
|
int32_t val = atomic_add_fetch_32(&requestSerialId, 1);
|
||||||
|
|
|
@ -712,13 +712,20 @@ int32_t taosAscii2Hex(const char *z, uint32_t n, void **data, uint32_t *size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t tsnprintf(char *dst, int64_t size, const char *format, ...) {
|
int64_t tsnprintf(char *dst, int64_t size, const char *format, ...) {
|
||||||
if (size <= 0 || size > SIZE_MAX) return 0;
|
if (size <= 0) return 0;
|
||||||
|
if (size == 1) {
|
||||||
|
dst[0] = '\0';
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (size > SIZE_MAX) {
|
||||||
|
size = SIZE_MAX;
|
||||||
|
}
|
||||||
|
|
||||||
int64_t ret;
|
int64_t ret;
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
ret = vsnprintf(dst, size, format, args);
|
ret = vsnprintf(dst, size, format, args);
|
||||||
va_end(args );
|
va_end(args);
|
||||||
if (ret >= size) {
|
if (ret >= size) {
|
||||||
return size - 1;
|
return size - 1;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue