Merge pull request #29503 from taosdata/fix/TS-5861-3.0m

fix: incorrect prompt when log on taos without sysinfo privilege
This commit is contained in:
Shengliang Guan 2025-01-08 11:31:16 +08:00 committed by GitHub
commit 456dad2fc3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 30 additions and 23 deletions

View File

@ -665,6 +665,14 @@ typedef enum {
ANAL_ALGO_TYPE_END,
} EAnalAlgoType;
typedef enum {
TSDB_VERSION_UNKNOWN = 0,
TSDB_VERSION_OSS,
TSDB_VERSION_ENTERPRISE,
TSDB_VERSION_CLOUD,
TSDB_VERSION_END,
} EVersionType;
#define MIN_RESERVE_MEM_SIZE 1024 // MB
#ifdef __cplusplus

View File

@ -43,7 +43,7 @@ void shellAutoExit();
void callbackAutoTab(char* sqlstr, TAOS* pSql, bool usedb);
// introduction
void printfIntroduction(bool community);
void printfIntroduction(EVersionType type);
// show enterprise AD at start or end
void showAD(bool end);

View File

@ -453,7 +453,7 @@ SMatch* lastMatch = NULL; // save last match result
int cntDel = 0; // delete byte count after next press tab
// show auto tab introduction
void printfIntroduction(bool community) {
void printfIntroduction(EVersionType type) {
printf(" ********************************* Tab Completion *************************************\n");
char secondLine[160] = "\0";
sprintf(secondLine, " * The %s CLI supports tab completion for a variety of items, ", shell.info.cusName);
@ -473,7 +473,7 @@ void printfIntroduction(bool community) {
printf(" * [ Ctrl + L ] ...... clear the entire screen *\n");
printf(" * [ Ctrl + K ] ...... clear the screen after the cursor *\n");
printf(" * [ Ctrl + U ] ...... clear the screen before the cursor *\n");
if(community) {
if (type == TSDB_VERSION_OSS) {
printf(" * ------------------------------------------------------------------------------------ *\n");
printf(" * You are using TDengine OSS. To experience advanced features, like backup/restore, *\n");
printf(" * privilege control and more, or receive 7x24 technical support, try TDengine *\n");

View File

@ -58,7 +58,7 @@ static void shellWriteHistory();
static void shellPrintError(TAOS_RES *tres, int64_t st);
static bool shellIsCommentLine(char *line);
static void shellSourceFile(const char *file);
static bool shellGetGrantInfo(char* buf);
static int32_t shellGetGrantInfo(char* buf);
static void shellCleanup(void *arg);
static void *shellCancelHandler(void *arg);
@ -1163,8 +1163,8 @@ void shellSourceFile(const char *file) {
taosCloseFile(&pFile);
}
bool shellGetGrantInfo(char *buf) {
bool community = true;
int32_t shellGetGrantInfo(char *buf) {
int32_t verType = TSDB_VERSION_UNKNOWN;
char sinfo[256] = {0};
tstrncpy(sinfo, taos_get_server_info(shell.conn), sizeof(sinfo));
strtok(sinfo, "\r\n");
@ -1180,7 +1180,7 @@ bool shellGetGrantInfo(char *buf) {
fprintf(stderr, "Failed to check Server Edition, Reason:0x%04x:%s\r\n\r\n", code, taos_errstr(tres));
}
taos_free_result(tres);
return community;
return verType;
}
int32_t num_fields = taos_field_count(tres);
@ -1208,12 +1208,12 @@ bool shellGetGrantInfo(char *buf) {
memcpy(expired, row[2], fields[2].bytes);
if (strcmp(serverVersion, "community") == 0) {
community = true;
verType = TSDB_VERSION_OSS;
} else if (strcmp(expiretime, "unlimited") == 0) {
community = false;
verType = TSDB_VERSION_ENTERPRISE;
sprintf(buf, "Server is %s, %s and will never expire.\r\n", serverVersion, sinfo);
} else {
community = false;
verType = TSDB_VERSION_ENTERPRISE;
sprintf(buf, "Server is %s, %s and will expire at %s.\r\n", serverVersion, sinfo, expiretime);
}
@ -1221,7 +1221,7 @@ bool shellGetGrantInfo(char *buf) {
}
fprintf(stdout, "\r\n");
return community;
return verType;
}
#ifdef WINDOWS
@ -1381,22 +1381,21 @@ int32_t shellExecute() {
#ifdef WEBSOCKET
if (!shell.args.restful && !shell.args.cloud) {
#endif
char *buf = taosMemoryMalloc(512);
bool community = shellGetGrantInfo(buf);
char buf[512] = {0};
int32_t verType = shellGetGrantInfo(buf);
#ifndef WINDOWS
printfIntroduction(community);
printfIntroduction(verType);
#else
#ifndef WEBSOCKET
if (community) {
if (verType == TSDB_VERSION_OSS) {
showAD(false);
}
#endif
#endif
// printf version
if (!community) {
if (verType == TSDB_VERSION_ENTERPRISE || verType == TSDB_VERSION_CLOUD) {
printf("%s\n", buf);
}
taosMemoryFree(buf);
#ifdef WEBSOCKET
}
@ -1412,7 +1411,7 @@ int32_t shellExecute() {
}
#ifndef WEBSOCKET
// commnuity
if (community) {
if (verType == TSDB_VERSION_OSS) {
showAD(true);
}
#endif