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: csv file read need copy end char #755

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 1 addition & 5 deletions src/benchCommandOpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ extern char g_configDir[MAX_PATH_LEN];
#define TAOSBENCHMARK_STATUS "unknown"
#endif

#ifndef TD_PRODUCT_NAME
#define TD_PRODUCT_NAME "TDengine"
#endif

// libtaos.so
extern char buildinfo[];

Expand All @@ -52,7 +48,7 @@ void printVersion() {
char taosBenchmark_status[] = TAOSBENCHMARK_STATUS;

// version
printf("%s\ntaosBenchmark version: %s\ngit: %s\n", TD_PRODUCT_NAME, taosBenchmark_ver, taosBenchmark_commit);
printf("taosBenchmark version: %s\ngit: %s\n", taosBenchmark_ver, taosBenchmark_commit);
#ifdef LINUX
printf("build: %s\n ", buildinfo);
#endif
Expand Down
15 changes: 12 additions & 3 deletions src/benchData.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,17 @@ static int generateSampleFromCsv(char *buffer, char* file, FILE* fp, int32_t len
continue;
}

if (('\r' == line[readLen - 1]) || ('\n' == line[readLen - 1])) {
line[--readLen] = 0;
int32_t pos = (int32_t)(readLen - 1);
if(pos > 0) {
if (('\r' == line[pos]) || ('\n' == line[pos])) {
line[pos] = 0;
}
}
pos = (int32_t)(readLen - 2);
if(pos > 0) {
if (('\r' == line[pos]) || ('\n' == line[pos])) {
line[pos] = 0;
}
}

if (readLen == 0) {
Expand All @@ -339,7 +348,7 @@ static int generateSampleFromCsv(char *buffer, char* file, FILE* fp, int32_t len
continue;
}

memcpy(buffer + getRows * length, line, readLen);
memcpy(buffer + getRows * length, line, readLen + 1);
getRows++;

if (getRows == size) {
Expand Down
1 change: 1 addition & 0 deletions src/benchInsert.c
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,7 @@ static void *createTable(void *sarg) {

pThreadInfo->tables_created += batchNum;
batchNum = 0;
memset(pThreadInfo->buffer, 0, TSDB_MAX_ALLOWED_SQL_LEN);
uint64_t currentPrintTime = toolsGetTimestampMs();
if (currentPrintTime - lastPrintTime > PRINT_STAT_INTERVAL) {
infoPrint(
Expand Down
9 changes: 2 additions & 7 deletions src/taosdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@
#define TAOSDUMP_STATUS "unknown"
#endif

#ifndef TD_PRODUCT_NAME
#define TD_PRODUCT_NAME "TDengine"
#endif

// use 256 as normal buffer length
#define BUFFER_LEN 256

Expand Down Expand Up @@ -673,7 +669,7 @@ static void printVersion(FILE *file) {

char taosdump_commit[] = TAOSDUMP_COMMIT_SHA1;

fprintf(file,"%s\ntaosdump version: %s\ngit: %s\n", TD_PRODUCT_NAME, taostools_ver, taosdump_commit);
fprintf(file,"taosdump version: %s\ngit: %s\n", taostools_ver, taosdump_commit);
#ifdef LINUX
printf("build: %s\n ", buildinfo);
#endif
Expand Down Expand Up @@ -2181,7 +2177,6 @@ static int64_t getTbCountOfStbNative(const char *dbName, const char *stbName) {
int32_t code = taos_errno(res);
if (code != 0) {
cleanIfQueryFailed(__func__, __LINE__, command, res);
free(command);
taos_close(taos);
return -1;
}
Expand Down Expand Up @@ -9980,7 +9975,7 @@ int readNextTableDesWS(void* ws_res, TableDes* tbDes, int *idx, int *cnt) {
// read next table tags to tbDes
int readNextTableDesNative(void* res, TableDes* tbDes) {
// tbname, tagName , tagValue
TAOS_ROW row;
TAOS_ROW row = NULL;
int index = 0;
while( index < tbDes->tags && NULL != (row = taos_fetch_row(res))) {
// tbname changed check
Expand Down
Loading