Merge branch 'develop' into feature/TD-1568

This commit is contained in:
Hongze Cheng 2021-03-02 13:35:45 +08:00
commit 128afc5ade
6 changed files with 57 additions and 25 deletions

View File

@ -47,7 +47,7 @@ char tsEmail[TSDB_FQDN_LEN] = {0};
// common // common
int32_t tsRpcTimer = 1000; int32_t tsRpcTimer = 1000;
int32_t tsRpcMaxTime = 600; // seconds; int32_t tsRpcMaxTime = 600; // seconds;
int32_t tsMaxShellConns = 5000; int32_t tsMaxShellConns = 50000;
int32_t tsMaxConnections = 5000; int32_t tsMaxConnections = 5000;
int32_t tsShellActivityTimer = 3; // second int32_t tsShellActivityTimer = 3; // second
float tsNumOfThreadsPerCore = 1.0f; float tsNumOfThreadsPerCore = 1.0f;

View File

@ -64,7 +64,7 @@ extern TAOS* shellInit(SShellArguments* args);
extern void* shellLoopQuery(void* arg); extern void* shellLoopQuery(void* arg);
extern void taos_error(TAOS_RES* tres, int64_t st); extern void taos_error(TAOS_RES* tres, int64_t st);
extern int regex_match(const char* s, const char* reg, int cflags); extern int regex_match(const char* s, const char* reg, int cflags);
void shellReadCommand(TAOS* con, char command[]); int32_t shellReadCommand(TAOS* con, char command[]);
int32_t shellRunCommand(TAOS* con, char* command); int32_t shellRunCommand(TAOS* con, char* command);
void shellRunCommandOnServer(TAOS* con, char command[]); void shellRunCommandOnServer(TAOS* con, char command[]);
void read_history(); void read_history();

View File

@ -180,7 +180,7 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
} }
} }
void shellReadCommand(TAOS *con, char *command) { int32_t shellReadCommand(TAOS *con, char *command) {
unsigned hist_counter = history.hend; unsigned hist_counter = history.hend;
char utf8_array[10] = "\0"; char utf8_array[10] = "\0";
Command cmd; Command cmd;
@ -233,7 +233,7 @@ void shellReadCommand(TAOS *con, char *command) {
sprintf(command, "%s%s", cmd.buffer, cmd.command); sprintf(command, "%s%s", cmd.buffer, cmd.command);
tfree(cmd.buffer); tfree(cmd.buffer);
tfree(cmd.command); tfree(cmd.command);
return; return 0;
} else { } else {
updateBuffer(&cmd); updateBuffer(&cmd);
} }
@ -324,6 +324,8 @@ void shellReadCommand(TAOS *con, char *command) {
insertChar(&cmd, &c, 1); insertChar(&cmd, &c, 1);
} }
} }
return 0;
} }
void *shellLoopQuery(void *arg) { void *shellLoopQuery(void *arg) {
@ -342,11 +344,16 @@ void *shellLoopQuery(void *arg) {
return NULL; return NULL;
} }
int32_t err = 0;
do { do {
// Read command from shell. // Read command from shell.
memset(command, 0, MAX_COMMAND_SIZE); memset(command, 0, MAX_COMMAND_SIZE);
set_terminal_mode(); set_terminal_mode();
shellReadCommand(con, command); err = shellReadCommand(con, command);
if (err) {
break;
}
reset_terminal_mode(); reset_terminal_mode();
} while (shellRunCommand(con, command) == 0); } while (shellRunCommand(con, command) == 0);

View File

@ -172,7 +172,7 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
} }
} }
void shellReadCommand(TAOS *con, char *command) { int32_t shellReadCommand(TAOS *con, char *command) {
unsigned hist_counter = history.hend; unsigned hist_counter = history.hend;
char utf8_array[10] = "\0"; char utf8_array[10] = "\0";
Command cmd; Command cmd;
@ -186,6 +186,10 @@ void shellReadCommand(TAOS *con, char *command) {
while (1) { while (1) {
c = (char)getchar(); // getchar() return an 'int' value c = (char)getchar(); // getchar() return an 'int' value
if (c == EOF) {
return c;
}
if (c < 0) { // For UTF-8 if (c < 0) { // For UTF-8
int count = countPrefixOnes(c); int count = countPrefixOnes(c);
utf8_array[0] = c; utf8_array[0] = c;
@ -225,7 +229,7 @@ void shellReadCommand(TAOS *con, char *command) {
sprintf(command, "%s%s", cmd.buffer, cmd.command); sprintf(command, "%s%s", cmd.buffer, cmd.command);
tfree(cmd.buffer); tfree(cmd.buffer);
tfree(cmd.command); tfree(cmd.command);
return; return 0;
} else { } else {
updateBuffer(&cmd); updateBuffer(&cmd);
} }
@ -316,6 +320,8 @@ void shellReadCommand(TAOS *con, char *command) {
insertChar(&cmd, &c, 1); insertChar(&cmd, &c, 1);
} }
} }
return 0;
} }
void *shellLoopQuery(void *arg) { void *shellLoopQuery(void *arg) {
@ -333,12 +339,17 @@ void *shellLoopQuery(void *arg) {
uError("failed to malloc command"); uError("failed to malloc command");
return NULL; return NULL;
} }
int32_t err = 0;
do { do {
// Read command from shell. // Read command from shell.
memset(command, 0, MAX_COMMAND_SIZE); memset(command, 0, MAX_COMMAND_SIZE);
set_terminal_mode(); set_terminal_mode();
shellReadCommand(con, command); err = shellReadCommand(con, command);
if (err) {
break;
}
reset_terminal_mode(); reset_terminal_mode();
} while (shellRunCommand(con, command) == 0); } while (shellRunCommand(con, command) == 0);

View File

@ -221,7 +221,7 @@ void insertChar(Command *cmd, char c) {
cmd->command[cmd->cursorOffset++] = c; cmd->command[cmd->cursorOffset++] = c;
} }
void shellReadCommand(TAOS *con, char command[]) { int32_t shellReadCommand(TAOS *con, char command[]) {
Command cmd; Command cmd;
memset(&cmd, 0, sizeof(cmd)); memset(&cmd, 0, sizeof(cmd));
cmd.buffer = (char *)calloc(1, MAX_COMMAND_SIZE); cmd.buffer = (char *)calloc(1, MAX_COMMAND_SIZE);
@ -241,7 +241,7 @@ void shellReadCommand(TAOS *con, char command[]) {
cmd.buffer = NULL; cmd.buffer = NULL;
free(cmd.command); free(cmd.command);
cmd.command = NULL; cmd.command = NULL;
return; return 0;
} else { } else {
shellPrintContinuePrompt(); shellPrintContinuePrompt();
updateBuffer(&cmd); updateBuffer(&cmd);
@ -251,6 +251,8 @@ void shellReadCommand(TAOS *con, char command[]) {
insertChar(&cmd, c); insertChar(&cmd, c);
} }
} }
return 0;
} }
void *shellLoopQuery(void *arg) { void *shellLoopQuery(void *arg) {
@ -258,12 +260,17 @@ void *shellLoopQuery(void *arg) {
char *command = malloc(MAX_COMMAND_SIZE); char *command = malloc(MAX_COMMAND_SIZE);
if (command == NULL) return NULL; if (command == NULL) return NULL;
int32_t err = 0;
do { do {
memset(command, 0, MAX_COMMAND_SIZE); memset(command, 0, MAX_COMMAND_SIZE);
shellPrintPrompt(); shellPrintPrompt();
// Read command from shell. // Read command from shell.
shellReadCommand(con, command); err = shellReadCommand(con, command);
if (err) {
break;
}
} while (shellRunCommand(con, command) == 0); } while (shellRunCommand(con, command) == 0);
return NULL; return NULL;

View File

@ -92,8 +92,9 @@ typedef struct SSpreadInfo {
typedef struct SSumInfo { typedef struct SSumInfo {
union { union {
int64_t isum; int64_t isum;
double dsum; uint64_t usum;
double dsum;
}; };
int8_t hasResult; int8_t hasResult;
} SSumInfo; } SSumInfo;
@ -595,6 +596,18 @@ static void do_sum_f(SQLFunctionCtx *pCtx, int32_t index) {
*res += GET_INT32_VAL(pData); *res += GET_INT32_VAL(pData);
} else if (pCtx->inputType == TSDB_DATA_TYPE_BIGINT) { } else if (pCtx->inputType == TSDB_DATA_TYPE_BIGINT) {
*res += GET_INT64_VAL(pData); *res += GET_INT64_VAL(pData);
} else if (pCtx->inputType == TSDB_DATA_TYPE_UTINYINT) {
uint64_t *r = (uint64_t *)pCtx->pOutput;
*r += GET_UINT8_VAL(pData);
} else if (pCtx->inputType == TSDB_DATA_TYPE_USMALLINT) {
uint64_t *r = (uint64_t *)pCtx->pOutput;
*r += GET_UINT16_VAL(pData);
} else if (pCtx->inputType == TSDB_DATA_TYPE_UINT) {
uint64_t *r = (uint64_t *)pCtx->pOutput;
*r += GET_UINT32_VAL(pData);
} else if (pCtx->inputType == TSDB_DATA_TYPE_UBIGINT) {
uint64_t *r = (uint64_t *)pCtx->pOutput;
*r += GET_UINT64_VAL(pData);
} else if (pCtx->inputType == TSDB_DATA_TYPE_DOUBLE) { } else if (pCtx->inputType == TSDB_DATA_TYPE_DOUBLE) {
double *retVal = (double*) pCtx->pOutput; double *retVal = (double*) pCtx->pOutput;
*retVal += GET_DOUBLE_VAL(pData); *retVal += GET_DOUBLE_VAL(pData);
@ -644,18 +657,12 @@ static void sum_func_merge(SQLFunctionCtx *pCtx) {
notNullElems++; notNullElems++;
switch (type) { if (IS_SIGNED_NUMERIC_TYPE(type)) {
case TSDB_DATA_TYPE_TINYINT: *(int64_t *)pCtx->pOutput += pInput->isum;
case TSDB_DATA_TYPE_SMALLINT: } else if (IS_UNSIGNED_NUMERIC_TYPE(type)) {
case TSDB_DATA_TYPE_INT: *(uint64_t *) pCtx->pOutput += pInput->usum;
case TSDB_DATA_TYPE_BIGINT: { } else {
*(int64_t *)pCtx->pOutput += pInput->isum; *(double *)pCtx->pOutput += pInput->dsum;
break;
};
case TSDB_DATA_TYPE_FLOAT:
case TSDB_DATA_TYPE_DOUBLE: {
*(double *)pCtx->pOutput += pInput->dsum;
}
} }
} }