Skip to content

Commit

Permalink
Merge pull request #708 from taosdata/fix/alexduan
Browse files Browse the repository at this point in the history
fix: set tbname for every one
  • Loading branch information
DuanKuanJun committed Sep 21, 2023
2 parents 6aa5b97 + 655652a commit 232faca
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions src/taosdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -6969,8 +6969,10 @@ static int64_t dumpInAvroDataImpl(
avro_value_get_current_branch(&tbname_value, &tbname_branch);

size_t tbname_size;
char * avroName = NULL;
avro_value_get_string(&tbname_branch,
(const char **)&tbName, &tbname_size);
(const char **)&avroName, &tbname_size);
tbName = strdup(avroName);
} else {
tbName = malloc(TSDB_TABLE_NAME_LEN+1);
ASSERT(tbName);
Expand Down Expand Up @@ -7040,7 +7042,7 @@ static int64_t dumpInAvroDataImpl(
"reason: %s\n",
escapedTbName, taos_stmt_errstr(stmt));
free(escapedTbName);
freeTbNameIfLooseMode(tbName);
free(tbName);
tbName = NULL;
continue;
}
Expand All @@ -7061,8 +7063,28 @@ static int64_t dumpInAvroDataImpl(
#ifdef WEBSOCKET
}
#endif
}
}
} // tbName
#ifndef TD_VER_COMPATIBLE_3_0_0_0
else {
// 2.6 need call taos_stmt_set_tbname every loop
const int escapedTbNameLen = TSDB_DB_NAME_LEN + TSDB_TABLE_NAME_LEN + 3;
char *escapedTbName = calloc(1, escapedTbNameLen);
snprintf(escapedTbName, escapedTbNameLen, "%s%s%s",
g_escapeChar, tbName, g_escapeChar);

if (0 != taos_stmt_set_tbname(stmt, escapedTbName)) {
errorPrint("Failed to execute taos_stmt_set_tbname(%s)."
"reason: %s\n",
escapedTbName, taos_stmt_errstr(stmt));
free(escapedTbName);
freeTbNameIfLooseMode(tbName);
tbName = NULL;
continue;
}
free(escapedTbName);
}
#endif

debugPrint("%s() LN%d, count: %"PRId64"\n",
__func__, __LINE__, count);
Expand Down Expand Up @@ -7343,7 +7365,7 @@ static int64_t dumpInAvroDataImpl(
}
}

freeTbNameIfLooseMode(tbName);
free(tbName);
avro_value_decref(&value);
avro_value_iface_decref(value_class);
tfree(bindArray);
Expand Down

0 comments on commit 232faca

Please sign in to comment.