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); + } } }