diff --git a/example/insertNow.json b/example/insertNow.json new file mode 100644 index 00000000..8032654d --- /dev/null +++ b/example/insertNow.json @@ -0,0 +1,86 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "connection_pool_size": 8, + "thread_count": 5, + "create_table_thread_count": 7, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "num_of_records_per_req": 2000, + "prepared_rand": 10000, + "chinese": "no", + "escape_character": "yes", + "databases": [ + { + "dbinfo": { + "name": "smart", + "drop": "yes", + "vgroups": 4, + "duration": "10d", + "keep": "100d", + "pages": 512, + "minrows":5000, + "maxrows":10000, + "stt_trigger":1, + "wal_retention_period": 10, + "wal_retention_size": 100, + "cachemodel": "'both'", + "precision": "ms" + }, + "super_tables": [ + { + "name": "meters", + "child_table_exists": "no", + "childtable_count": 10000, + "childtable_prefix": "d", + "auto_create_table": "no", + "batch_create_tbl_num": 5, + "data_source": "rand", + "insert_mode": "taosc", + "non_stop_mode": "no", + "line_protocol": "line", + "insert_rows": 900000000000000, + "interlace_rows": 1, + "insert_interval": 1000, + "start_timestamp": "now", + "sample_format": "csv", + "sample_file": "./sample.csv", + "use_sample_ts": "no", + "tags_file": "", + "columns": [ + { + "type": "FLOAT", + "name": "current", + "count": 1, + "max": 12, + "min": 8 + }, + { "type": "INT", "name": "voltage", "max": 225, "min": 215 }, + { "type": "FLOAT", "name": "phase", "max": 1, "min": 0 } + ], + "tags": [ + { + "type": "TINYINT", + "name": "groupid", + "max": 10, + "min": 1 + }, + { + "name": "location", + "type": "BINARY", + "len": 16, + "values": ["San Francisco", "Los Angles", "San Diego", + "San Jose", "Palo Alto", "Campbell", "Mountain View", + "Sunnyvale", "Santa Clara", "Cupertino"] + } + ] + } + ] + } + ] +} diff --git a/src/benchInsert.c b/src/benchInsert.c index e7e9bab6..f5d871fd 100644 --- a/src/benchInsert.c +++ b/src/benchInsert.c @@ -1544,8 +1544,12 @@ static void *syncWriteInterlace(void *sarg) { int64_t disorderTs = getDisorderTs(stbInfo, &disorderRange); char time_string[BIGINT_BUFF_LEN]; - snprintf(time_string, BIGINT_BUFF_LEN, "%"PRId64"", - disorderTs?disorderTs:timestamp); + if(stbInfo->useNow && stbInfo->interlaceRows == 1) { + snprintf(time_string, BIGINT_BUFF_LEN, "now"); + } else { + snprintf(time_string, BIGINT_BUFF_LEN, "%"PRId64"", + disorderTs?disorderTs:timestamp); + } ds_add_strs(&pThreadInfo->buffer, 5, "(", time_string, @@ -3542,8 +3546,7 @@ int insertTestProcess() { } // check fill child table count valid if(fillChildTblName(database, stbInfo) <= 0) { - errorPrint(" fill child table is zero, please check parameters in json is correct. database:%s stb: %s \n", database->dbName, stbInfo->stbName); - return -1; + infoPrint(" warning fill childs table count is zero, please check parameters in json is correct. database:%s stb: %s \n", database->dbName, stbInfo->stbName); } if (0 != prepareSampleData(database, stbInfo)) { return -1; diff --git a/src/taosdump.c b/src/taosdump.c index 97f5ed99..e0fc0ecb 100644 --- a/src/taosdump.c +++ b/src/taosdump.c @@ -5203,8 +5203,8 @@ static int64_t writeResultToAvroNative( if (0 != avro_value_get_by_name( &record, "tbname", &avro_value, NULL)) { errorPrint("%s() LN%d, avro_value_get_by_name(tbname) " - "failed\n", - __func__, __LINE__); + "failed dbName=%s tbName=%s\n", + __func__, __LINE__, dbName, tbName); break; } avro_value_set_branch(&avro_value, 1, &branch); @@ -5224,9 +5224,9 @@ static int64_t writeResultToAvroNative( if (0 != avro_file_writer_append_value(db, &record)) { errorPrint("%s() LN%d, " - "Unable to write record to file. Message: %s\n", + "Unable to write record to file. Message: %s dbName=%s tbName=%s\n", __func__, __LINE__, - avro_strerror()); + avro_strerror(), dbName, tbName); failed--; } else { success++; @@ -5237,9 +5237,9 @@ static int64_t writeResultToAvroNative( } if (countInBatch != limit) { - errorPrint("%s() LN%d, actual dump out: %d, batch %" PRId64 "\n", + errorPrint("%s() LN%d, table rows is zero. actual dump out: %d, batch %" PRId64 " dbName=%s tbName=%s\n", __func__, __LINE__, - countInBatch, limit); + countInBatch, limit, dbName, tbName); } taos_free_result(res); printDotOrX(offset, &printDot); @@ -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); @@ -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; } @@ -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); @@ -7343,7 +7365,7 @@ static int64_t dumpInAvroDataImpl( } } - freeTbNameIfLooseMode(tbName); + free(tbName); avro_value_decref(&value); avro_value_iface_decref(value_class); tfree(bindArray);