提交 4b72c79f 编写于 作者: H hjxilinx

refactor some codes.

上级 f8c150da
......@@ -84,7 +84,6 @@ int shellDumpResult(TAOS* con, char* fname, int* error_no, bool printMode);
void shellPrintNChar(char* str, int width, bool printMode);
void shellGetGrantInfo(void *con);
int isCommentLine(char *line);
#define max(a, b) ((int)(a) < (int)(b) ? (int)(b) : (int)(a))
/**************** Global variable declarations ****************/
extern char PROMPT_HEADER[];
......
......@@ -375,29 +375,29 @@ int shellDumpResult(TAOS *con, char *fname, int *error_no, bool printMode) {
for (int col = 0; col < num_fields; col++) {
switch (fields[col].type) {
case TSDB_DATA_TYPE_BOOL:
l[col] = max(BOOL_OUTPUT_LENGTH, strlen(fields[col].name));
l[col] = MAX(BOOL_OUTPUT_LENGTH, strlen(fields[col].name));
break;
case TSDB_DATA_TYPE_TINYINT:
l[col] = max(TINYINT_OUTPUT_LENGTH, strlen(fields[col].name));
l[col] = MAX(TINYINT_OUTPUT_LENGTH, strlen(fields[col].name));
break;
case TSDB_DATA_TYPE_SMALLINT:
l[col] = max(SMALLINT_OUTPUT_LENGTH, strlen(fields[col].name));
l[col] = MAX(SMALLINT_OUTPUT_LENGTH, strlen(fields[col].name));
break;
case TSDB_DATA_TYPE_INT:
l[col] = max(INT_OUTPUT_LENGTH, strlen(fields[col].name));
l[col] = MAX(INT_OUTPUT_LENGTH, strlen(fields[col].name));
break;
case TSDB_DATA_TYPE_BIGINT:
l[col] = max(BIGINT_OUTPUT_LENGTH, strlen(fields[col].name));
l[col] = MAX(BIGINT_OUTPUT_LENGTH, strlen(fields[col].name));
break;
case TSDB_DATA_TYPE_FLOAT:
l[col] = max(FLOAT_OUTPUT_LENGTH, strlen(fields[col].name));
l[col] = MAX(FLOAT_OUTPUT_LENGTH, strlen(fields[col].name));
break;
case TSDB_DATA_TYPE_DOUBLE:
l[col] = max(DOUBLE_OUTPUT_LENGTH, strlen(fields[col].name));
l[col] = MAX(DOUBLE_OUTPUT_LENGTH, strlen(fields[col].name));
break;
case TSDB_DATA_TYPE_BINARY:
case TSDB_DATA_TYPE_NCHAR:
l[col] = max(fields[col].bytes, strlen(fields[col].name));
l[col] = MAX(fields[col].bytes, strlen(fields[col].name));
/* l[col] = max(BINARY_OUTPUT_LENGTH, strlen(fields[col].name)); */
break;
case TSDB_DATA_TYPE_TIMESTAMP: {
......@@ -408,7 +408,7 @@ int shellDumpResult(TAOS *con, char *fname, int *error_no, bool printMode) {
if (taos_result_precision(result) == TSDB_TIME_PRECISION_MICRO) {
defaultWidth += 3;
}
l[col] = max(defaultWidth, strlen(fields[col].name));
l[col] = MAX(defaultWidth, strlen(fields[col].name));
break;
}
......@@ -567,7 +567,7 @@ int shellDumpResult(TAOS *con, char *fname, int *error_no, bool printMode) {
case TSDB_DATA_TYPE_NCHAR:
memset(t_str, 0, TSDB_MAX_BYTES_PER_ROW);
memcpy(t_str, row[i], fields[i].bytes);
l[i] = max(fields[i].bytes, strlen(fields[i].name));
l[i] = MAX(fields[i].bytes, strlen(fields[i].name));
shellPrintNChar(t_str, l[i], printMode);
break;
case TSDB_DATA_TYPE_TIMESTAMP:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册