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:
commit
456dad2fc3
|
@ -665,6 +665,14 @@ typedef enum {
|
||||||
ANAL_ALGO_TYPE_END,
|
ANAL_ALGO_TYPE_END,
|
||||||
} EAnalAlgoType;
|
} 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
|
#define MIN_RESERVE_MEM_SIZE 1024 // MB
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -43,7 +43,7 @@ void shellAutoExit();
|
||||||
void callbackAutoTab(char* sqlstr, TAOS* pSql, bool usedb);
|
void callbackAutoTab(char* sqlstr, TAOS* pSql, bool usedb);
|
||||||
|
|
||||||
// introduction
|
// introduction
|
||||||
void printfIntroduction(bool community);
|
void printfIntroduction(EVersionType type);
|
||||||
|
|
||||||
// show enterprise AD at start or end
|
// show enterprise AD at start or end
|
||||||
void showAD(bool end);
|
void showAD(bool end);
|
||||||
|
|
|
@ -453,7 +453,7 @@ SMatch* lastMatch = NULL; // save last match result
|
||||||
int cntDel = 0; // delete byte count after next press tab
|
int cntDel = 0; // delete byte count after next press tab
|
||||||
|
|
||||||
// show auto tab introduction
|
// show auto tab introduction
|
||||||
void printfIntroduction(bool community) {
|
void printfIntroduction(EVersionType type) {
|
||||||
printf(" ********************************* Tab Completion *************************************\n");
|
printf(" ********************************* Tab Completion *************************************\n");
|
||||||
char secondLine[160] = "\0";
|
char secondLine[160] = "\0";
|
||||||
sprintf(secondLine, " * The %s CLI supports tab completion for a variety of items, ", shell.info.cusName);
|
sprintf(secondLine, " * The %s CLI supports tab completion for a variety of items, ", shell.info.cusName);
|
||||||
|
@ -473,11 +473,11 @@ void printfIntroduction(bool community) {
|
||||||
printf(" * [ Ctrl + L ] ...... clear the entire screen *\n");
|
printf(" * [ Ctrl + L ] ...... clear the entire screen *\n");
|
||||||
printf(" * [ Ctrl + K ] ...... clear the screen after the cursor *\n");
|
printf(" * [ Ctrl + K ] ...... clear the screen after the cursor *\n");
|
||||||
printf(" * [ Ctrl + U ] ...... clear the screen before the cursor *\n");
|
printf(" * [ Ctrl + U ] ...... clear the screen before the cursor *\n");
|
||||||
if(community) {
|
if (type == TSDB_VERSION_OSS) {
|
||||||
printf(" * ------------------------------------------------------------------------------------ *\n");
|
printf(" * ------------------------------------------------------------------------------------ *\n");
|
||||||
printf(" * You are using TDengine OSS. To experience advanced features, like backup/restore, *\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");
|
printf(" * privilege control and more, or receive 7x24 technical support, try TDengine *\n");
|
||||||
printf(" * Enterprise or TDengine Cloud. Learn more at https://tdengine.com *\n");
|
printf(" * Enterprise or TDengine Cloud. Learn more at https://tdengine.com *\n");
|
||||||
}
|
}
|
||||||
printf(" ****************************************************************************************\n\n");
|
printf(" ****************************************************************************************\n\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ static void shellWriteHistory();
|
||||||
static void shellPrintError(TAOS_RES *tres, int64_t st);
|
static void shellPrintError(TAOS_RES *tres, int64_t st);
|
||||||
static bool shellIsCommentLine(char *line);
|
static bool shellIsCommentLine(char *line);
|
||||||
static void shellSourceFile(const char *file);
|
static void shellSourceFile(const char *file);
|
||||||
static bool shellGetGrantInfo(char* buf);
|
static int32_t shellGetGrantInfo(char* buf);
|
||||||
|
|
||||||
static void shellCleanup(void *arg);
|
static void shellCleanup(void *arg);
|
||||||
static void *shellCancelHandler(void *arg);
|
static void *shellCancelHandler(void *arg);
|
||||||
|
@ -1163,9 +1163,9 @@ void shellSourceFile(const char *file) {
|
||||||
taosCloseFile(&pFile);
|
taosCloseFile(&pFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool shellGetGrantInfo(char *buf) {
|
int32_t shellGetGrantInfo(char *buf) {
|
||||||
bool community = true;
|
int32_t verType = TSDB_VERSION_UNKNOWN;
|
||||||
char sinfo[256] = {0};
|
char sinfo[256] = {0};
|
||||||
tstrncpy(sinfo, taos_get_server_info(shell.conn), sizeof(sinfo));
|
tstrncpy(sinfo, taos_get_server_info(shell.conn), sizeof(sinfo));
|
||||||
strtok(sinfo, "\r\n");
|
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));
|
fprintf(stderr, "Failed to check Server Edition, Reason:0x%04x:%s\r\n\r\n", code, taos_errstr(tres));
|
||||||
}
|
}
|
||||||
taos_free_result(tres);
|
taos_free_result(tres);
|
||||||
return community;
|
return verType;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t num_fields = taos_field_count(tres);
|
int32_t num_fields = taos_field_count(tres);
|
||||||
|
@ -1208,12 +1208,12 @@ bool shellGetGrantInfo(char *buf) {
|
||||||
memcpy(expired, row[2], fields[2].bytes);
|
memcpy(expired, row[2], fields[2].bytes);
|
||||||
|
|
||||||
if (strcmp(serverVersion, "community") == 0) {
|
if (strcmp(serverVersion, "community") == 0) {
|
||||||
community = true;
|
verType = TSDB_VERSION_OSS;
|
||||||
} else if (strcmp(expiretime, "unlimited") == 0) {
|
} 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);
|
sprintf(buf, "Server is %s, %s and will never expire.\r\n", serverVersion, sinfo);
|
||||||
} else {
|
} else {
|
||||||
community = false;
|
verType = TSDB_VERSION_ENTERPRISE;
|
||||||
sprintf(buf, "Server is %s, %s and will expire at %s.\r\n", serverVersion, sinfo, expiretime);
|
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");
|
fprintf(stdout, "\r\n");
|
||||||
return community;
|
return verType;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
|
@ -1381,22 +1381,21 @@ int32_t shellExecute() {
|
||||||
#ifdef WEBSOCKET
|
#ifdef WEBSOCKET
|
||||||
if (!shell.args.restful && !shell.args.cloud) {
|
if (!shell.args.restful && !shell.args.cloud) {
|
||||||
#endif
|
#endif
|
||||||
char *buf = taosMemoryMalloc(512);
|
char buf[512] = {0};
|
||||||
bool community = shellGetGrantInfo(buf);
|
int32_t verType = shellGetGrantInfo(buf);
|
||||||
#ifndef WINDOWS
|
#ifndef WINDOWS
|
||||||
printfIntroduction(community);
|
printfIntroduction(verType);
|
||||||
#else
|
#else
|
||||||
#ifndef WEBSOCKET
|
#ifndef WEBSOCKET
|
||||||
if (community) {
|
if (verType == TSDB_VERSION_OSS) {
|
||||||
showAD(false);
|
showAD(false);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
// printf version
|
// printf version
|
||||||
if (!community) {
|
if (verType == TSDB_VERSION_ENTERPRISE || verType == TSDB_VERSION_CLOUD) {
|
||||||
printf("%s\n", buf);
|
printf("%s\n", buf);
|
||||||
}
|
}
|
||||||
taosMemoryFree(buf);
|
|
||||||
|
|
||||||
#ifdef WEBSOCKET
|
#ifdef WEBSOCKET
|
||||||
}
|
}
|
||||||
|
@ -1412,7 +1411,7 @@ int32_t shellExecute() {
|
||||||
}
|
}
|
||||||
#ifndef WEBSOCKET
|
#ifndef WEBSOCKET
|
||||||
// commnuity
|
// commnuity
|
||||||
if (community) {
|
if (verType == TSDB_VERSION_OSS) {
|
||||||
showAD(true);
|
showAD(true);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue