提交 6d6ee1ea 编写于 作者: H hjxilinx

[td-168] fix bug in var string

上级 f6067e1b
...@@ -613,7 +613,7 @@ int shellDumpResult(TAOS *con, char *fname, int *error_no, bool printMode) { ...@@ -613,7 +613,7 @@ int shellDumpResult(TAOS *con, char *fname, int *error_no, bool printMode) {
case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_BINARY:
case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_NCHAR:
memset(t_str, 0, TSDB_MAX_BYTES_PER_ROW); memset(t_str, 0, TSDB_MAX_BYTES_PER_ROW);
memcpy(t_str, row[i], fields[i].bytes); memcpy(t_str, row[i], length[i]);
fprintf(fp, "\'%s\'", t_str); fprintf(fp, "\'%s\'", t_str);
break; break;
case TSDB_DATA_TYPE_TIMESTAMP: case TSDB_DATA_TYPE_TIMESTAMP:
......
...@@ -676,6 +676,8 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) { ...@@ -676,6 +676,8 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) {
while ((row = taos_fetch_row(result))) { while ((row = taos_fetch_row(result))) {
if (numOfRows < MAX_QUERY_ROW_NUM) { if (numOfRows < MAX_QUERY_ROW_NUM) {
TAOS_FIELD *fields = taos_fetch_fields(result); TAOS_FIELD *fields = taos_fetch_fields(result);
int* length = taos_fetch_lengths(result);
for (int i = 0; i < num_fields; i++) { for (int i = 0; i < num_fields; i++) {
char *value = NULL; char *value = NULL;
if (i < MAX_QUERY_COL_NUM) { if (i < MAX_QUERY_COL_NUM) {
...@@ -733,8 +735,8 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) { ...@@ -733,8 +735,8 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) {
break; break;
case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_BINARY:
case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_NCHAR:
memcpy(value, row[i], fields[i].bytes); memcpy(value, row[i], length[i]);
value[fields[i].bytes] = 0; value[length[i]] = 0;
// snprintf(value, fields[i].bytes, "%s", (char *)row[i]); // snprintf(value, fields[i].bytes, "%s", (char *)row[i]);
break; break;
case TSDB_DATA_TYPE_TIMESTAMP: case TSDB_DATA_TYPE_TIMESTAMP:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册