Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set tbname for every one #708

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading