enh: add return len

This commit is contained in:
xsren 2024-10-12 18:40:56 +08:00
parent e84376c461
commit 14a2cb073a
3 changed files with 24 additions and 20 deletions

View File

@ -513,21 +513,18 @@ void appendColumnFields(char* buf, int32_t* len, STableCfg* pCfg) {
int typeLen = strlen(type);
if (TSDB_DATA_TYPE_VARCHAR == pSchema->type || TSDB_DATA_TYPE_VARBINARY == 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) {
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));
}
if (useCompress(pCfg->tableType) && pCfg->pSchemaExt) {
typeLen = strlen(type);
snprintf(type + typeLen, LTYPE_LEN - typeLen, " ENCODE \'%s\'",
typeLen += tsnprintf(type + typeLen, LTYPE_LEN - typeLen, " ENCODE \'%s\'",
columnEncodeStr(COMPRESS_L1_TYPE_U32(pCfg->pSchemaExt[i].compress)));
typeLen = strlen(type);
snprintf(type + typeLen, LTYPE_LEN - typeLen, " COMPRESS \'%s\'",
typeLen += tsnprintf(type + typeLen, LTYPE_LEN - typeLen, " COMPRESS \'%s\'",
columnCompressStr(COMPRESS_L2_TYPE_U32(pCfg->pSchemaExt[i].compress)));
typeLen = strlen(type);
snprintf(type + typeLen, LTYPE_LEN - typeLen, " LEVEL \'%s\'",
typeLen += tsnprintf(type + typeLen, LTYPE_LEN - typeLen, " LEVEL \'%s\'",
columnLevelStr(COMPRESS_L2_TYPE_LEVEL_U32(pCfg->pSchemaExt[i].compress)));
}
if (!(pSchema->flags & COL_IS_KEY)) {

View File

@ -306,7 +306,7 @@ uint64_t schGenUUID(void) {
qError("Failed to get the system uid, reason:%s", tstrerror(TAOS_SYSTEM_ERROR(errno)));
}
}
ßßß
int64_t ts = taosGetTimestampMs();
uint64_t pid = taosGetPId();
int32_t val = atomic_add_fetch_32(&requestSerialId, 1);

View File

@ -712,16 +712,23 @@ 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, ...) {
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;
va_list args;
va_start(args, format);
ret = vsnprintf(dst, size, format, args);
va_end(args );
if (ret >= size) {
return size - 1;
} else {
return ret;
}
int64_t ret;
va_list args;
va_start(args, format);
ret = vsnprintf(dst, size, format, args);
va_end(args);
if (ret >= size) {
return size - 1;
} else {
return ret;
}
}