From 9d2c310616aeb6ce7930968c3eea06eac9905533 Mon Sep 17 00:00:00 2001 From: slzhou Date: Mon, 25 Mar 2024 10:15:50 +0800 Subject: [PATCH] fix: remove the extract space after column type for none pk column --- source/libs/command/src/command.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/libs/command/src/command.c b/source/libs/command/src/command.c index 2136ef7d6d..dc8fa49e27 100644 --- a/source/libs/command/src/command.c +++ b/source/libs/command/src/command.c @@ -501,8 +501,12 @@ void appendColumnFields(char* buf, int32_t* len, STableCfg* pCfg) { } else if (TSDB_DATA_TYPE_NCHAR == pSchema->type) { sprintf(type + strlen(type), "(%d)", (int32_t)((pSchema->bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE)); } - char* pk = (pSchema->flags & COL_IS_KEY) ? "PRIMARY KEY" : ""; - *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s`%s` %s %s", ((i > 0) ? ", " : ""), pSchema->name, type, pk); + if (!(pSchema->flags & COL_IS_KEY)) { + *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s`%s` %s", ((i > 0) ? ", " : ""), pSchema->name, type); + } else { + char* pk = "PRIMARY KEY"; + *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s`%s` %s %s", ((i > 0) ? ", " : ""), pSchema->name, type, pk); + } } }