提交 65b415d8 编写于 作者: C Cary Xu

Merge branch 'develop' into feature/TS-272

......@@ -243,7 +243,7 @@ repeater 部分添加 { host:'<TDengine server/cluster host>', port: <port for S
{
port: 8125
, backends: ["./backends/repeater"]
, repeater: [{ host: '127.0.0.1', port: 8126}]
, repeater: [{ host: '127.0.0.1', port: 6044}]
}
```
......
......@@ -1601,7 +1601,7 @@ SELECT AVG(current), MAX(current), LEASTSQUARES(current, start_val, step_val), P
**GROUP BY的限制**
TAOS SQL 支持对标签、TBNAME 进行 GROUP BY 操作,也支持普通列进行 GROUP BY,前提是:仅限一列且该列的唯一值小于 10 万个。
TAOS SQL 支持对标签、TBNAME 进行 GROUP BY 操作,也支持普通列进行 GROUP BY,前提是:仅限一列且该列的唯一值小于 10 万个。注意:group by 不支持float,double 类型。
**IS NOT NULL 与不为空的表达式适用范围**
......
......@@ -57,7 +57,7 @@ repeater 部分添加 { host:'<TDengine server/cluster host>', port: <port for S
### 导入 Dashboard
使用 Web 浏览器访问 IP:3000 登录 Grafana 界面,系统初始用户名密码为 admin/admin。
使用 Web 浏览器访问运行 Grafana 的服务器的3000端口 host:3000 登录 Grafana 界面,系统初始用户名密码为 admin/admin。
点击左侧齿轮图标并选择 Plugins,应该可以找到 TDengine data source 插件图标。
#### 导入 collectd 仪表盘
......
......@@ -67,6 +67,8 @@ typedef struct {
SMLProtocolType protocol;
SMLTimeStampType tsType;
SHashObj* smlDataToSchema;
int64_t affectedRows;
} SSmlLinesInfo;
int tscSmlInsert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint, SSmlLinesInfo* info);
......
......@@ -761,7 +761,7 @@ static int32_t doInsertChildTableWithStmt(TAOS* taos, char* sql, char* cTableNam
code = taos_stmt_prepare(stmt, sql, (unsigned long)strlen(sql));
if (code != 0) {
tscError("SML:0x%"PRIx64" taos_stmt_prepare return %d:%s", info->id, code, tstrerror(code));
tscError("SML:0x%"PRIx64" taos_stmt_prepare return %d:%s", info->id, code, taos_stmt_errstr(stmt));
taos_stmt_close(stmt);
return code;
}
......@@ -771,7 +771,11 @@ static int32_t doInsertChildTableWithStmt(TAOS* taos, char* sql, char* cTableNam
do {
code = taos_stmt_set_tbname(stmt, cTableName);
if (code != 0) {
tscError("SML:0x%"PRIx64" taos_stmt_set_tbname return %d:%s", info->id, code, tstrerror(code));
tscError("SML:0x%"PRIx64" taos_stmt_set_tbname return %d:%s", info->id, code, taos_stmt_errstr(stmt));
int affectedRows = taos_stmt_affected_rows(stmt);
info->affectedRows += affectedRows;
taos_stmt_close(stmt);
return code;
}
......@@ -781,13 +785,21 @@ static int32_t doInsertChildTableWithStmt(TAOS* taos, char* sql, char* cTableNam
TAOS_BIND* colsBinds = taosArrayGetP(batchBind, i);
code = taos_stmt_bind_param(stmt, colsBinds);
if (code != 0) {
tscError("SML:0x%"PRIx64" taos_stmt_bind_param return %d:%s", info->id, code, tstrerror(code));
tscError("SML:0x%"PRIx64" taos_stmt_bind_param return %d:%s", info->id, code, taos_stmt_errstr(stmt));
int affectedRows = taos_stmt_affected_rows(stmt);
info->affectedRows += affectedRows;
taos_stmt_close(stmt);
return code;
}
code = taos_stmt_add_batch(stmt);
if (code != 0) {
tscError("SML:0x%"PRIx64" taos_stmt_add_batch return %d:%s", info->id, code, tstrerror(code));
tscError("SML:0x%"PRIx64" taos_stmt_add_batch return %d:%s", info->id, code, taos_stmt_errstr(stmt));
int affectedRows = taos_stmt_affected_rows(stmt);
info->affectedRows += affectedRows;
taos_stmt_close(stmt);
return code;
}
......@@ -795,8 +807,9 @@ static int32_t doInsertChildTableWithStmt(TAOS* taos, char* sql, char* cTableNam
code = taos_stmt_execute(stmt);
if (code != 0) {
tscError("SML:0x%"PRIx64" taos_stmt_execute return %d:%s, try:%d", info->id, code, tstrerror(code), try);
tscError("SML:0x%"PRIx64" taos_stmt_execute return %d:%s, try:%d", info->id, code, taos_stmt_errstr(stmt), try);
}
tscDebug("SML:0x%"PRIx64" taos_stmt_execute inserted %d rows", info->id, taos_stmt_affected_rows(stmt));
tryAgain = false;
if ((code == TSDB_CODE_TDB_INVALID_TABLE_ID
......@@ -825,6 +838,8 @@ static int32_t doInsertChildTableWithStmt(TAOS* taos, char* sql, char* cTableNam
}
} while (tryAgain);
int affectedRows = taos_stmt_affected_rows(stmt);
info->affectedRows += affectedRows;
taos_stmt_close(stmt);
return code;
......@@ -1069,6 +1084,8 @@ int tscSmlInsert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint, SSmlLine
int32_t code = TSDB_CODE_SUCCESS;
info->affectedRows = 0;
tscDebug("SML:0x%"PRIx64" build data point schemas", info->id);
SArray* stableSchemas = taosArrayInit(32, sizeof(SSmlSTableSchema)); // SArray<STableColumnsSchema>
code = buildDataPointSchemas(points, numPoint, stableSchemas, info);
......@@ -1871,7 +1888,7 @@ static int32_t parseSmlKey(TAOS_SML_KV *pKV, const char **index, SHashObj *pHash
//key field cannot start with digit
if (isdigit(*cur)) {
tscError("SML:0x%"PRIx64" Tag key cannnot start with digit", info->id);
tscError("SML:0x%"PRIx64" Tag key cannot start with digit", info->id);
return TSDB_CODE_TSC_LINE_SYNTAX_ERROR;
}
while (*cur != '\0') {
......@@ -1885,6 +1902,8 @@ static int32_t parseSmlKey(TAOS_SML_KV *pKV, const char **index, SHashObj *pHash
}
//Escape special character
if (*cur == '\\') {
//TODO: escape will work after column & tag
//support spcial characters
escapeSpecialCharacter(2, &cur);
}
key[len] = *cur;
......@@ -1911,13 +1930,42 @@ static int32_t parseSmlKey(TAOS_SML_KV *pKV, const char **index, SHashObj *pHash
static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **index,
bool *is_last_kv, SSmlLinesInfo* info, bool isTag) {
const char *start, *cur;
int32_t ret = TSDB_CODE_SUCCESS;
char *value = NULL;
uint16_t len = 0;
bool searchQuote = false;
start = cur = *index;
//if field value is string
if (!isTag) {
if (*cur == '"') {
searchQuote = true;
cur += 1;
len += 1;
} else if (*cur == 'L' && *(cur + 1) == '"') {
searchQuote = true;
cur += 2;
len += 2;
}
}
while (1) {
// unescaped ',' or ' ' or '\0' identifies a value
if ((*cur == ',' || *cur == ' ' || *cur == '\0') && *(cur - 1) != '\\') {
if (((*cur == ',' || *cur == ' ' ) && *(cur - 1) != '\\') || *cur == '\0') {
if (searchQuote == true) {
//first quote ignored while searching
if (*(cur - 1) == '"' && len != 1 && len != 2) {
*is_last_kv = (*cur == ' ' || *cur == '\0') ? true : false;
break;
} else if (*cur == '\0') {
ret = TSDB_CODE_TSC_LINE_SYNTAX_ERROR;
goto error;
} else {
cur++;
len++;
continue;
}
}
//unescaped ' ' or '\0' indicates end of value
*is_last_kv = (*cur == ' ' || *cur == '\0') ? true : false;
if (*cur == ' ' && *(cur + 1) == ' ') {
......@@ -1929,7 +1977,7 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **index,
}
//Escape special character
if (*cur == '\\') {
escapeSpecialCharacter(2, &cur);
escapeSpecialCharacter(isTag ? 2 : 3, &cur);
}
cur++;
len++;
......@@ -1946,16 +1994,20 @@ static int32_t parseSmlValue(TAOS_SML_KV *pKV, const char **index,
if (!convertSmlValueType(pKV, value, len, info, isTag)) {
tscError("SML:0x%"PRIx64" Failed to convert sml value string(%s) to any type",
info->id, value);
//free previous alocated key field
free(pKV->key);
pKV->key = NULL;
free(value);
return TSDB_CODE_TSC_INVALID_VALUE;
ret = TSDB_CODE_TSC_INVALID_VALUE;
goto error;
}
free(value);
*index = (*cur == '\0') ? cur : cur + 1;
return TSDB_CODE_SUCCESS;
return ret;
error:
//free previous alocated key field
free(pKV->key);
pKV->key = NULL;
return ret;
}
static int32_t parseSmlMeasurement(TAOS_SML_DATA_POINT *pSml, const char **index,
......
......@@ -138,14 +138,35 @@ static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const ch
const char *start, *cur;
int32_t ret = TSDB_CODE_SUCCESS;
int len = 0;
bool searchQuote = false;
char key[] = OTD_METRIC_VALUE_COLUMN_NAME;
char *value = NULL;
start = cur = *index;
//if metric value is string
if (*cur == '"') {
searchQuote = true;
cur += 1;
len += 1;
} else if (*cur == 'L' && *(cur + 1) == '"') {
searchQuote = true;
cur += 2;
len += 2;
}
while(*cur != '\0') {
if (*cur == ' ') {
if (*cur == ' ') {
if (searchQuote == true) {
if (*(cur - 1) == '"' && len != 1 && len != 2) {
searchQuote = false;
} else {
cur++;
len++;
continue;
}
}
if (*(cur + 1) != ' ') {
break;
} else {
......@@ -153,7 +174,6 @@ static int32_t parseTelnetMetricValue(TAOS_SML_KV **pKVs, int *num_kvs, const ch
continue;
}
}
}
cur++;
len++;
}
......
......@@ -78,6 +78,8 @@ typedef struct STscStmt {
SSqlObj* pSql;
SMultiTbStmt mtb;
SNormalStmt normal;
int numOfRows;
} STscStmt;
#define STMT_RET(c) do { \
......@@ -1212,6 +1214,8 @@ static int insertStmtExecute(STscStmt* stmt) {
// wait for the callback function to post the semaphore
tsem_wait(&pSql->rspSem);
stmt->numOfRows += pSql->res.numOfRows;
// data block reset
pCmd->batchSize = 0;
for(int32_t i = 0; i < pCmd->insertParam.numOfTables; ++i) {
......@@ -1285,6 +1289,8 @@ static int insertBatchStmtExecute(STscStmt* pStmt) {
code = pStmt->pSql->res.code;
pStmt->numOfRows += pStmt->pSql->res.numOfRows;
insertBatchClean(pStmt);
return code;
......@@ -1521,6 +1527,7 @@ TAOS_STMT* taos_stmt_init(TAOS* taos) {
pSql->maxRetry = TSDB_MAX_REPLICA;
pStmt->pSql = pSql;
pStmt->last = STMT_INIT;
pStmt->numOfRows = 0;
registerSqlObj(pSql);
return pStmt;
......@@ -1564,9 +1571,7 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) {
}
pRes->qId = 0;
pRes->numOfRows = 1;
registerSqlObj(pSql);
pRes->numOfRows = 0;
strtolower(pSql->sqlstr, sql);
tscDebugL("0x%"PRIx64" SQL: %s", pSql->self, pSql->sqlstr);
......@@ -1981,6 +1986,7 @@ int taos_stmt_execute(TAOS_STMT* stmt) {
} else {
taosReleaseRef(tscObjRef, pStmt->pSql->self);
pStmt->pSql = taos_query((TAOS*)pStmt->taos, sql);
pStmt->numOfRows += taos_affected_rows(pStmt->pSql);
ret = taos_errno(pStmt->pSql);
free(sql);
}
......@@ -1989,6 +1995,17 @@ int taos_stmt_execute(TAOS_STMT* stmt) {
STMT_RET(ret);
}
int taos_stmt_affected_rows(TAOS_STMT* stmt) {
STscStmt* pStmt = (STscStmt*)stmt;
if (pStmt == NULL) {
tscError("statement is invalid");
return 0;
}
return pStmt->numOfRows;
}
TAOS_RES *taos_stmt_use_result(TAOS_STMT* stmt) {
if (stmt == NULL) {
tscError("statement is invalid.");
......
......@@ -9,6 +9,7 @@ public abstract class AbstractStatement extends WrapperImpl implements Statement
protected List<String> batchedArgs;
private int fetchSize;
protected int affectedRows = -1;
@Override
public abstract ResultSet executeQuery(String sql) throws SQLException;
......@@ -247,6 +248,7 @@ public abstract class AbstractStatement extends WrapperImpl implements Statement
public boolean getMoreResults(int current) throws SQLException {
if (isClosed())
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED);
this.affectedRows = -1;
switch (current) {
case Statement.CLOSE_CURRENT_RESULT:
return false;
......
......@@ -23,7 +23,6 @@ public class TSDBStatement extends AbstractStatement {
* Status of current statement
*/
private boolean isClosed;
private int affectedRows = -1;
private TSDBConnection connection;
private TSDBResultSet resultSet;
......@@ -85,7 +84,8 @@ public class TSDBStatement extends AbstractStatement {
long pSql = this.connection.getConnector().executeQuery(sql);
// if pSql is create/insert/update/delete/alter SQL
if (this.connection.getConnector().isUpdateQuery(pSql)) {
this.affectedRows = this.connection.getConnector().getAffectedRows(pSql);
int rows = this.connection.getConnector().getAffectedRows(pSql);
this.affectedRows = rows == 0 ? -1 : this.connection.getConnector().getAffectedRows(pSql);
this.connection.getConnector().freeResultSet(pSql);
return false;
}
......
......@@ -22,7 +22,6 @@ public class RestfulStatement extends AbstractStatement {
private final RestfulConnection conn;
private volatile RestfulResultSet resultSet;
private volatile int affectedRows;
public RestfulStatement(RestfulConnection conn, String database) {
this.conn = conn;
......@@ -118,7 +117,7 @@ public class RestfulStatement extends AbstractStatement {
throw TSDBError.createSQLException(resultJson.getInteger("code"), resultJson.getString("desc"));
}
this.resultSet = new RestfulResultSet(database, this, resultJson);
this.affectedRows = 0;
this.affectedRows = -1;
return resultSet;
}
......@@ -140,9 +139,10 @@ public class RestfulStatement extends AbstractStatement {
if (head.size() != 1 || !"affected_rows".equals(head.getString(0)))
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_VARIABLE);
JSONArray data = jsonObject.getJSONArray("data");
if (data != null)
return data.getJSONArray(0).getInteger(0);
if (data != null) {
int rows = data.getJSONArray(0).getInteger(0);
return rows == 0 ? -1 : data.getJSONArray(0).getInteger(0);
}
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_VARIABLE);
}
......
......@@ -141,6 +141,7 @@ DLL_EXPORT int taos_stmt_bind_param_batch(TAOS_STMT* stmt, TAOS_MULTI_BIN
DLL_EXPORT int taos_stmt_bind_single_param_batch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int colIdx);
DLL_EXPORT int taos_stmt_add_batch(TAOS_STMT *stmt);
DLL_EXPORT int taos_stmt_execute(TAOS_STMT *stmt);
DLL_EXPORT int taos_stmt_affected_rows(TAOS_STMT *stmt);
DLL_EXPORT TAOS_RES * taos_stmt_use_result(TAOS_STMT *stmt);
DLL_EXPORT int taos_stmt_close(TAOS_STMT *stmt);
DLL_EXPORT char * taos_stmt_errstr(TAOS_STMT *stmt);
......
此差异已折叠。
......@@ -3005,8 +3005,14 @@ int main(int argc, char *argv[]) {
printf("debug_print: %d\n", g_args.debug_print);
for (int32_t i = 0; i < g_args.arg_list_len; i++) {
if (g_args.databases || g_args.all_databases) {
errorPrint("%s is an invalid input if database(s) be already specified.\n",
g_args.arg_list[i]);
exit(EXIT_FAILURE);
} else {
printf("arg_list[%d]: %s\n", i, g_args.arg_list[i]);
}
}
printf("==============================\n");
if (checkParam(&g_args) < 0) {
......
Subproject commit 4bfae86dcabea0d5a40ff81a72be7c822737269b
Subproject commit c67fcc11bc5e82e3d7aea8db855a8cbf8b109239
......@@ -204,6 +204,7 @@ static void monBuildMonitorSql(char *sql, int32_t cmd) {
", disk_used float, disk_total int"
", band_speed float"
", io_read float, io_write float"
", io_read_rate float, io_write_rate float"
", req_http int, req_select int, req_insert int"
") tags (dnodeid int, fqdn binary(%d))",
tsMonitorDbName, TSDB_FQDN_LEN);
......@@ -325,7 +326,10 @@ static int32_t monBuildIoSql(char *sql) {
monDebug("failed to get io info");
}
return sprintf(sql, ", %f, %f", readKB, writeKB);
float readRate = readKB/tsMonitorInterval;
float writeRate = writeKB/tsMonitorInterval;
return sprintf(sql, ", %f, %f, %f, %f", readKB, writeKB, readRate, writeRate);
}
static void monSaveSystemInfo() {
......
......@@ -365,7 +365,8 @@ int32_t getNumOfResult(SQueryRuntimeEnv *pRuntimeEnv, SQLFunctionCtx* pCtx, int3
* ts, tag, tagprj function can not decide the output number of current query
* the number of output result is decided by main output
*/
if (hasMainFunction && (id == TSDB_FUNC_TS || id == TSDB_FUNC_TAG || id == TSDB_FUNC_TAGPRJ)) {
if (hasMainFunction && (id == TSDB_FUNC_TS || id == TSDB_FUNC_TAG || id == TSDB_FUNC_TAGPRJ ||
id == TSDB_FUNC_TS_DUMMY || id == TSDB_FUNC_TAG_DUMMY)) {
continue;
}
......
......@@ -441,6 +441,7 @@ static int tsdbCompactMeta(STsdbRepo *pRepo) {
if ((tdInitDataCols(pComph->pDataCols, pSchema) < 0) || (tdInitDataCols(pReadh->pDCols[0], pSchema) < 0) ||
(tdInitDataCols(pReadh->pDCols[1], pSchema) < 0)) {
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
tdFreeSchema(pSchema);
return -1;
}
tdFreeSchema(pSchema);
......
......@@ -1620,7 +1620,7 @@ static void mergeTwoRowFromMem(STsdbQueryHandle* pQueryHandle, int32_t capacity,
SColIdx *pColIdx = kvRowColIdxAt(rowBody, chosen_itr);
colId = pColIdx->colId;
offset = pColIdx->offset;
value = tdGetKvRowDataOfCol(rowBody, pColIdx->offset);
value = tdGetKvRowDataOfCol(rowBody, offset);
}
......
......@@ -184,6 +184,10 @@ void verify_prepare(TAOS* taos) {
taos_stmt_close(stmt);
exit(EXIT_FAILURE);
}
int affectedRows = taos_stmt_affected_rows(stmt);
printf("sucessfully inserted %d rows\n", affectedRows);
taos_stmt_close(stmt);
// query the records
......@@ -400,6 +404,9 @@ void verify_prepare2(TAOS* taos) {
exit(EXIT_FAILURE);
}
int affectedRows = taos_stmt_affected_rows(stmt);
printf("sucessfully inserted %d rows\n", affectedRows);
taos_stmt_close(stmt);
// query the records
......@@ -784,6 +791,10 @@ void verify_prepare3(TAOS* taos) {
taos_stmt_close(stmt);
exit(EXIT_FAILURE);
}
int affectedRows = taos_stmt_affected_rows(stmt);
printf("successfully inserted %d rows\n", affectedRows);
taos_stmt_close(stmt);
// query the records
......
......@@ -391,6 +391,7 @@ python3 ./test.py -f tag_lite/alter_tag.py
python3 test.py -f tools/taosdemoAllTest/TD-4985/query-limit-offset.py
python3 test.py -f tools/taosdemoAllTest/TD-5213/insert4096columns_not_use_taosdemo.py
python3 test.py -f tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.py
python3 test.py -f tools/taosdemoAllTest/TD-10539/create_taosdemo.py
python3 ./test.py -f tag_lite/drop_auto_create.py
python3 test.py -f insert/insert_before_use_db.py
python3 test.py -f alter/alter_keep.py
......
......@@ -29,7 +29,6 @@ class TDTestCase:
tdSql.execute("create database if not exists test precision 'us'")
tdSql.execute('use test')
### metric ###
print("============= step1 : test metric ================")
lines0 = [
......@@ -215,7 +214,7 @@ class TDTestCase:
#binary
lines2_7 = [
"stb2_7 1626006833610ms \"binary_val.!@#$%^&*\" host=\"host0\"",
"stb2_7 1626006833610ms \" binary_val .!@#$%^&* \" host=\"host0\"",
"stb2_7 1626006833620ms \"binary_val.:;,./?|+-=\" host=\"host0\"",
"stb2_7 1626006833630ms \"binary_val.()[]{}<>\" host=\"host0\""
]
......@@ -232,7 +231,7 @@ class TDTestCase:
#nchar
lines2_8 = [
"stb2_8 1626006833610ms L\"nchar_val数值一\" host=\"host0\"",
"stb2_8 1626006833610ms L\" nchar_val 数值一 \" host=\"host0\"",
"stb2_8 1626006833620ms L\"nchar_val数值二\" host=\"host0\""
]
......
......@@ -31,9 +31,9 @@ class TDTestCase:
tdSql.execute('create stable ste(ts timestamp, f int) tags(t1 bigint)')
lines = [ "st,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000",
lines = [ "st,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"\"\"a pa,\"s si,t \"\"\",c2=false,c4=4f64 1626006833639000000",
"st,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640000000",
"ste,t2=5f64,t3=L\"ste\" c1=true,c2=4i64,c3=\"iam\" 1626056811823316532",
"ste,t2=5f64,t3=L\"ste\" c1=true,c2=4i64,c3=\" i,\"a \"m,\"\"\" 1626056811823316532",
"stf,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000",
"st,t1=4i64,t2=5f64,t3=\"t4\" c1=3i64,c3=L\"passitagain\",c2=true,c4=5f64 1626006833642000000",
"ste,t2=5f64,t3=L\"ste2\" c3=\"iamszhou\",c4=false 1626056811843316532",
......
......@@ -298,7 +298,6 @@ class TDTestCase:
print("==============step3,#create regular_table; insert regular_table; show regular_table; select regular_table; drop regular_table")
self.regular_table = "regular_table~!@#$%^&*()-_+=[]{}';:,<.>/?stST24680~!@#$%^&*()-_+=[]{}"
#self.regular_table = "regular_table~!@#$%^&*()-_+=[]{}';:,<.>/?stST24680~!@#$%^&*()-_+=[]{}"
tdSql.execute("create table `%s` (ts timestamp,i int) ;" %self.regular_table)
tdSql.query("describe `%s` ; "%self.regular_table)
......@@ -328,9 +327,9 @@ class TDTestCase:
tdSql.checkRows(1)
self.crr_tb = "create_r_table~!@#$%^&*()-_+=[]{}';:,<.>/?stST24680~!@#$%^&*()-_+=[]{}"
# tdSql.execute("create table `%s` as select * from `%s` ;" %(self.crr_tb,self.regular_table))
# tdSql.query("show db.tables like 'create_r_table%' ")
# tdSql.checkRows(1)
tdSql.execute("create table `%s` as select * from `%s` ;" %(self.crr_tb,self.regular_table))
tdSql.query("show db2.tables like 'create_r_table%' ")
tdSql.checkRows(1)
print("==============drop table\stable")
try:
......@@ -341,15 +340,6 @@ class TDTestCase:
tdSql.error("select * from `%s`" %self.regular_table)
#表名:192个字符,还要包含前面的数据库名
#taosdemo 建数据库表 # 单独放
# self.tsdemo = "tsdemo~!@#$%^&*()-_+=[]{}"
# os.system("%staosdemo -d test -m `%s` -t 10 -n 100 -l 10 -y " % (binPath,self.tsdemo))
# tdSql.execute("use #!#!#!")
# tdSql.query("select count (tbname) from #!#!#!")
# tdSql.checkData(0, 0, 1000)
def stop(self):
......
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import sys
import taos
import time
import os
from util.log import tdLog
from util.cases import tdCases
from util.sql import tdSql
class TDTestCase:
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__))
if ("community" in selfPath):
projPath = selfPath[:selfPath.find("community")]
else:
projPath = selfPath[:selfPath.find("tests")]
for root, dirs, files in os.walk(projPath):
if ("taosd" in files):
rootRealPath = os.path.dirname(os.path.realpath(root))
if ("packaging" not in rootRealPath):
buildPath = root[:len(root)-len("/build/bin")]
break
return buildPath
def run(self):
buildPath = self.getBuildPath()
if (buildPath == ""):
tdLog.exit("taosd not found!")
else:
tdLog.info("taosd found in %s" % buildPath)
binPath = buildPath+ "/build/bin/"
os.system("rm -rf tools/taosdemoAllTest/TD-10539/create_taosdemo.py.sql")
tdSql.prepare()
#print("==============taosdemo,#create stable,table; insert table; show table; select table; drop table")
self.tsdemo = "tsdemo~!.@#$%^*[]-_=+{,?.}"
#this escape character is not support in shell . include & () <> | /
os.system("%staosdemo -d test -E -m %s -t 10 -n 100 -l 10 -y " % (binPath,self.tsdemo))
tdSql.execute("use test ;" )
tdSql.query("select count(*) from meters")
tdSql.checkData(0, 0, 1000)
tdSql.query("show test.tables like 'tsdemo%'" )
tdSql.checkRows(10)
tdSql.query("show test.tables like '%s_'" %self.tsdemo)
tdSql.checkRows(10)
tdSql.query("select _block_dist() from `%s1`" %self.tsdemo)
tdSql.checkRows(1)
tdSql.query("describe test.`%s1` ; " %self.tsdemo)
tdSql.checkRows(13)
tdSql.query("show create table test.`%s1` ; " %self.tsdemo)
tdSql.checkData(0, 0, self.tsdemo+str(1))
tdSql.checkData(0, 1, "CREATE TABLE `%s1` USING `meters` TAGS (1,\"beijing\")" %self.tsdemo)
print("==============drop table\stable")
try:
tdSql.execute("drop table test.`%s1` ; " %self.tsdemo)
except Exception as e:
tdLog.exit(e)
tdSql.error("select * from test.`%s1` ; " %self.tsdemo)
tdSql.query("show test.tables like '%s_'" %self.tsdemo)
tdSql.checkRows(9)
try:
tdSql.execute("drop table test.meters ")
except Exception as e:
tdLog.exit(e)
tdSql.error("select * from test.meters ")
tdSql.error("select * from test.`%s2` ; " %self.tsdemo)
# Exception
os.system("%staosdemo -d test -m %s -t 10 -n 100 -l 10 -y " % (binPath,self.tsdemo))
tdSql.query("show test.tables ")
tdSql.checkRows(0)
#print("==============taosdemo,#create regular table; insert table; show table; select table; drop table")
self.tsdemo = "tsdemo~!.@#$%^*[]-_=+{,?.}"
#this escape character is not support in shell . include & () <> | /
os.system("%staosdemo -N -E -m %s -t 10 -n 100 -l 10 -y " % (binPath,self.tsdemo))
tdSql.execute("use test ;" )
tdSql.query("select count(*) from `%s1`" %self.tsdemo)
tdSql.checkData(0, 0, 100)
tdSql.query("show test.tables like 'tsdemo%'" )
tdSql.checkRows(10)
tdSql.query("show test.tables like '%s_'" %self.tsdemo)
tdSql.checkRows(10)
tdSql.query("select _block_dist() from `%s1`" %self.tsdemo)
tdSql.checkRows(1)
tdSql.query("describe test.`%s1` ; " %self.tsdemo)
tdSql.checkRows(11)
tdSql.query("show create table test.`%s1` ; " %self.tsdemo)
tdSql.checkData(0, 0, self.tsdemo+str(1))
tdSql.checkData(0, 1, "create table `%s1` (ts TIMESTAMP,c0 FLOAT,c1 INT,c2 INT,c3 INT,c4 INT,c5 INT,c6 INT,c7 INT,c8 INT,c9 INT)" %self.tsdemo)
print("==============drop table\stable")
try:
tdSql.execute("drop table test.`%s1` ; " %self.tsdemo)
except Exception as e:
tdLog.exit(e)
tdSql.error("select * from test.`%s1` ; " %self.tsdemo)
tdSql.query("show test.tables like '%s_'" %self.tsdemo)
tdSql.checkRows(9)
# Exception
os.system("%staosdemo -N -m %s -t 10 -n 100 -l 10 -y " % (binPath,self.tsdemo))
tdSql.query("show test.tables ")
tdSql.checkRows(0)
#print("==============taosdemo——json_yes,#create stable,table; insert table; show table; select table; drop table")
os.system("%staosdemo -f tools/taosdemoAllTest/TD-10539/create_taosdemo_yes.json -y " % binPath)
tdSql.execute("use dbyes")
self.tsdemo_stable = "tsdemo_stable~!.@#$%^*[]-_=+{,?.}"
self.tsdemo = "tsdemo~!.@#$%^*[]-_=+{,?.}"
tdSql.query("select count(*) from dbyes.`%s`" %self.tsdemo_stable)
tdSql.checkData(0, 0, 1000)
tdSql.query("show dbyes.tables like 'tsdemo%'" )
tdSql.checkRows(10)
tdSql.query("show dbyes.tables like '%s_'" %self.tsdemo)
tdSql.checkRows(10)
tdSql.query("select _block_dist() from `%s1`" %self.tsdemo)
tdSql.checkRows(1)
tdSql.query("describe dbyes.`%s1` ; " %self.tsdemo)
tdSql.checkRows(13)
tdSql.query("show create table dbyes.`%s1` ; " %self.tsdemo)
tdSql.checkData(0, 0, self.tsdemo+str(1))
tdSql.checkData(0, 1, "CREATE TABLE `%s1` USING `%s` TAGS (1,1)" %(self.tsdemo,self.tsdemo_stable))
print("==============drop table\stable")
try:
tdSql.execute("drop table dbyes.`%s1` ; " %self.tsdemo)
except Exception as e:
tdLog.exit(e)
tdSql.error("select * from dbyes.`%s1` ; " %self.tsdemo)
tdSql.query("show dbyes.tables like '%s_'" %self.tsdemo)
tdSql.checkRows(9)
try:
tdSql.execute("drop table dbyes.`%s` ; " %self.tsdemo_stable)
except Exception as e:
tdLog.exit(e)
tdSql.error("select * from dbyes.`%s` ; " %self.tsdemo_stable)
tdSql.error("select * from dbyes.`%s2` ; " %self.tsdemo)
#print("==============taosdemo——json_no,#create stable,table; insert table; show table; select table; drop table")
assert os.system("%staosdemo -f tools/taosdemoAllTest/TD-10539/create_taosdemo_no.json -y " % binPath) == 0
tdSql.query("show dbno.tables ")
tdSql.checkRows(0)
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
{
"filetype": "insert",
"cfgdir": "/etc/taos",
"host": "127.0.0.1",
"port": 6030,
"user": "root",
"password": "taosdata",
"thread_count": 10,
"thread_count_create_tbl": 10,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
"interlace_rows": 10,
"num_of_records_per_req": 1,
"max_sql_len": 1024000,
"databases": [{
"dbinfo": {
"name": "dbno",
"drop": "yes",
"replica": 1,
"days": 10,
"cache": 50,
"blocks": 8,
"precision": "ms",
"keep": 36500,
"minRows": 100,
"maxRows": 4096,
"comp":2,
"walLevel":1,
"cachelast":0,
"quorum":1,
"fsync":3000,
"update": 0
},
"super_tables": [{
"name": "meters",
"child_table_exists":"no",
"childtable_count": 10,
"childtable_prefix": "tsdemo~!.@#$%^*[]-_=+{,?.}",
"escape_character": "no",
"auto_create_table": "no",
"batch_create_tbl_num": 1,
"data_source": "rand",
"insert_mode": "taosc",
"insert_rows": 100,
"childtable_limit": 0,
"childtable_offset":0,
"multi_thread_write_one_tbl": "no",
"interlace_rows": 0,
"insert_interval":0,
"max_sql_len": 1024000,
"disorder_ratio": 0,
"disorder_range": 1000,
"timestamp_step": 1,
"start_timestamp": "2020-10-01 00:00:00.000",
"sample_format": "csv",
"sample_file": "",
"tags_file": "",
"columns": [{"type": "INT","count":9}, {"type": "BINARY", "len": 16, "count":1}],
"tags": [{"type": "INT", "count":2}]
}]
}]
}
{
"filetype": "insert",
"cfgdir": "/etc/taos",
"host": "127.0.0.1",
"port": 6030,
"user": "root",
"password": "taosdata",
"thread_count": 5,
"thread_count_create_tbl": 10,
"result_file": "./insert_res.txt",
"confirm_parameter_prompt": "no",
"insert_interval": 0,
"interlace_rows": 10,
"num_of_records_per_req": 1,
"max_sql_len": 1024000,
"databases": [{
"dbinfo": {
"name": "dbyes",
"drop": "yes",
"replica": 1,
"days": 10,
"cache": 50,
"blocks": 8,
"precision": "ms",
"keep": 36500,
"minRows": 100,
"maxRows": 4096,
"comp":2,
"walLevel":1,
"cachelast":0,
"quorum":1,
"fsync":3000,
"update": 0
},
"super_tables": [{
"name": "tsdemo_stable~!.@#$%^*[]-_=+{,?.}",
"child_table_exists":"no",
"childtable_count": 10,
"childtable_prefix": "tsdemo~!.@#$%^*[]-_=+{,?.}",
"escape_character": "yes",
"auto_create_table": "no",
"batch_create_tbl_num": 1,
"data_source": "rand",
"insert_mode": "taosc",
"insert_rows": 100,
"childtable_limit": 0,
"childtable_offset":0,
"multi_thread_write_one_tbl": "no",
"interlace_rows": 0,
"insert_interval":0,
"max_sql_len": 1024000,
"disorder_ratio": 0,
"disorder_range": 1000,
"timestamp_step": 1,
"start_timestamp": "2020-10-01 00:00:00.000",
"sample_format": "csv",
"sample_file": "",
"tags_file": "",
"columns": [{"type": "INT","count":9}, {"type": "BINARY", "len": 16, "count":1}],
"tags": [{"type": "INT", "count":2}]
}]
}]
}
......@@ -62,8 +62,12 @@ class TDTestCase:
os.makedirs("./taosdumptest/tmp3")
if not os.path.exists("./taosdumptest/tmp4"):
os.makedirs("./taosdumptest/tmp4")
if not os.path.exists("./taosdumptest/tmp5"):
os.makedirs("./taosdumptest/tmp5")
if not os.path.exists("./taosdumptest/tmp6"):
os.makedirs("./taosdumptest/tmp6")
if not os.path.exists("./taosdumptest/tmp7"):
os.makedirs("./taosdumptest/tmp7")
buildPath = self.getBuildPath()
if (buildPath == ""):
tdLog.exit("taosdump not found!")
......@@ -72,6 +76,8 @@ class TDTestCase:
binPath = buildPath + "/build/bin/"
# create db1 , one stables and one table ; create general tables
tdSql.execute("drop database if exists dp1")
tdSql.execute("drop database if exists dp2")
tdSql.execute("create database if not exists dp1")
tdSql.execute("use dp1")
tdSql.execute("create stable st0(ts timestamp, c1 int, c2 nchar(10)) tags(t1 int)")
......@@ -82,9 +88,10 @@ class TDTestCase:
tdSql.execute("create table if not exists gt1 (ts timestamp, c0 int, c1 double) ")
tdSql.execute("insert into gt0 values(1614218412000,637,8.861)")
tdSql.execute("insert into gt1 values(1614218413000,638,8.862)")
# create db1 , three stables:stb0,include ctables stb0_0 \ stb0_1,stb1 include ctables stb1_0 and stb1_1
# \stb3,include ctables stb3_0 and stb3_1
# ; create general three tables gt0 gt1 gt2
# create general three tables gt0 gt1 gt2
tdSql.execute("create database if not exists dp2")
tdSql.execute("use dp2")
tdSql.execute("create stable st0(ts timestamp, c01 int, c02 nchar(10)) tags(t1 int)")
......@@ -102,94 +109,188 @@ class TDTestCase:
tdSql.execute("create table if not exists gt0 (ts timestamp, c00 int, c01 float) ")
tdSql.execute("create table if not exists gt1 (ts timestamp, c10 int, c11 double) ")
tdSql.execute("create table if not exists gt2 (ts timestamp, c20 int, c21 float) ")
tdSql.execute("insert into gt0 values(1614218412000,8637,78.86155)")
tdSql.execute("insert into gt1 values(1614218413000,8638,78.862020199)")
tdSql.execute("insert into gt2 values(1614218413000,8639,78.863)")
tdSql.execute("insert into gt0 values(1614218412700,8637,78.86155)")
tdSql.execute("insert into gt1 values(1614218413800,8638,78.862020199)")
tdSql.execute("insert into gt2 values(1614218413900,8639,78.863)")
# create
tdSql.execute("create database if not exists dp3 precision 'ns'")
tdSql.execute("use dp3")
tdSql.execute("create stable st0(ts timestamp, c01 int, c02 nchar(10)) tags(t1 int)")
tdSql.execute("create table st0_0 using st0 tags(0) st0_1 using st0 tags(1) ")
tdSql.execute("insert into st0_0 values(1614218412000000001,8600,'R')(1614218422000000002,8600,'E')")
tdSql.execute("insert into st0_1 values(1614218413000000001,8601,'A')(1614218423000000002,8601,'D')")
# tdSql.execute("insert into t0 values(1614218422000,8638,'R')")
os.system("rm -rf ./taosdumptest/tmp1/*")
os.system("rm -rf ./taosdumptest/tmp2/*")
os.system("rm -rf ./taosdumptest/tmp3/*")
os.system("rm -rf ./taosdumptest/tmp4/*")
os.system("rm -rf ./taosdumptest/tmp5/*")
# # taosdump stable and general table
# os.system("%staosdump -o ./taosdumptest/tmp1 -D dp1 dp2 " % binPath)
# os.system("%staosdump -o ./taosdumptest/tmp2 dp1 st0 gt0 " % binPath)
# os.system("%staosdump -o ./taosdumptest/tmp3 dp2 st0 st1_0 gt0" % binPath)
# os.system("%staosdump -o ./taosdumptest/tmp4 dp2 st0 st2 gt0 gt2" % binPath)、
os.system("%staosdump -o ./taosdumptest/tmp1 -D dp1,dp2 " % binPath)
os.system("%staosdump -o ./taosdumptest/tmp2 dp1 st0 gt0 " % binPath)
os.system("%staosdump -o ./taosdumptest/tmp3 dp2 st0 st1_0 gt0" % binPath)
os.system("%staosdump -o ./taosdumptest/tmp4 dp2 st0 st2 gt0 gt2" % binPath)
# verify ns
os.system("%staosdump -o ./taosdumptest/tmp6 dp3 st0_0" % binPath)
assert os.system("%staosdump -o ./taosdumptest/tmp6 dp3 st0_0 -C ns " % binPath) != 0
# verify -D:--database
# os.system("%staosdump --databases dp1 -o ./taosdumptest/tmp3 dp2 st0 st1_0 gt0" % binPath)
# os.system("%staosdump --databases dp1,dp2 -o ./taosdumptest/tmp3 " % binPath)
# #check taosdumptest/tmp1
# tdSql.execute("drop database dp1")
# tdSql.execute("drop database dp2")
# os.system("%staosdump -i ./taosdumptest/tmp1 -T 2 " % binPath)
# tdSql.execute("use dp1")
# tdSql.query("show stables")
# tdSql.checkRows(1)
# tdSql.query("show tables")
# tdSql.checkRows(4)
# tdSql.execute("use dp2")
# tdSql.query("show stables")
# tdSql.checkRows(3)
# tdSql.query("show tables")
# tdSql.checkRows(9)
# tdSql.query("select c01 from gt0")
# tdSql.checkData(0,0,78.86155)
# tdSql.query("select c11 from gt1")
# tdSql.checkData(0, 0, 78.862020199)
# tdSql.query("select c21 from gt2")
# tdSql.checkData(0, 0, 78.86300)
# #check taosdumptest/tmp2
# tdSql.execute("drop database dp1")
# tdSql.execute("drop database dp2")
# os.system("%staosdump -i ./taosdumptest/tmp2 -T 2 " % binPath)
# tdSql.execute("use dp1")
# tdSql.query("show stables")
# tdSql.checkRows(1)
# tdSql.query("show tables")
# tdSql.checkRows(3)
# tdSql.error("use dp2")
# tdSql.query("select c01 from gt0")
# tdSql.checkData(0,0,78.86155)
# #check taosdumptest/tmp3
# tdSql.execute("drop database dp1")
# os.system("%staosdump -i ./taosdumptest/tmp3 -T 2 " % binPath)
# tdSql.execute("use dp2")
# tdSql.query("show stables")
# tdSql.checkRows(2)
# tdSql.query("show tables")
# tdSql.checkRows(4)
# tdSql.query("select count(*) from st1_0")
# tdSql.query("select c01 from gt0")
# tdSql.checkData(0,0,78.86155)
# tdSql.error("use dp1")
# tdSql.error("select count(*) from st2_0")
# tdSql.error("select count(*) from gt2")
# #check taosdumptest/tmp4
# tdSql.execute("drop database dp2")
# os.system("%staosdump -i ./taosdumptest/tmp4 -T 2 " % binPath)
# tdSql.execute("use dp2")
# tdSql.query("show stables")
# tdSql.checkRows(2)
# tdSql.query("show tables")
# tdSql.checkRows(6)
# tdSql.query("select c21 from gt2")
# tdSql.checkData(0, 0, 78.86300)
# tdSql.query("select count(*) from st2_0")
# tdSql.error("use dp1")
# tdSql.error("select count(*) from st1_0")
# tdSql.error("select count(*) from gt3")
# tdSql.execute("drop database dp2")
# os.system("rm -rf ./taosdumptest/tmp1")
# os.system("rm -rf ./taosdumptest/tmp2")
# os.system("rm -rf ./dump_result.txt")
# os.system("rm -rf ./db.csv")
os.system("%staosdump -o ./taosdumptest/tmp5 --databases dp1,dp2 " % binPath)
# verify mixed -D:--database and dbname tbname
assert os.system("%staosdump --databases dp1 -o ./taosdumptest/tmp5 dp2 st0 st1_0 gt0" % binPath) != 0
#check taosdumptest/tmp1
tdSql.execute("drop database dp1")
tdSql.execute("drop database dp2")
os.system("%staosdump -i ./taosdumptest/tmp1 -T 2 " % binPath)
tdSql.execute("use dp1")
tdSql.query("show stables")
tdSql.checkRows(1)
tdSql.query("show tables")
tdSql.checkRows(4)
tdSql.query("select c1 from st0_0 order by ts")
tdSql.checkData(0,0,8537)
tdSql.query("select c2 from st0_1 order by ts")
tdSql.checkData(1,0,"D")
tdSql.query("select * from gt0")
tdSql.checkData(0,0,'2021-02-25 10:00:12.000')
tdSql.checkData(0,1,637)
tdSql.execute("use dp2")
tdSql.query("show stables")
tdSql.checkRows(3)
tdSql.query("show tables")
tdSql.checkRows(9)
tdSql.query("select ts from gt0")
tdSql.checkData(0,0,'2021-02-25 10:00:12.700')
tdSql.query("select c10 from gt1")
tdSql.checkData(0, 0, 8638)
tdSql.query("select c20 from gt2")
tdSql.checkData(0, 0, 8639)
#check taosdumptest/tmp2
tdSql.execute("drop database dp1")
tdSql.execute("drop database dp2")
os.system("%staosdump -i ./taosdumptest/tmp2 -T 2 " % binPath)
tdSql.execute("use dp1")
tdSql.query("show stables")
tdSql.checkRows(1)
tdSql.query("show tables")
tdSql.checkRows(3)
tdSql.query("select c1 from st0_0 order by ts")
tdSql.checkData(0,0,8537)
tdSql.query("select c2 from st0_1 order by ts")
tdSql.checkData(1,0,"D")
tdSql.query("select * from gt0")
tdSql.checkData(0,0,'2021-02-25 10:00:12.000')
tdSql.checkData(0,1,637)
tdSql.error("select count(*) from gt1")
tdSql.error("use dp2")
#check taosdumptest/tmp3
tdSql.execute("drop database dp1")
os.system("%staosdump -i ./taosdumptest/tmp3 -T 2 " % binPath)
tdSql.execute("use dp2")
tdSql.query("show stables")
tdSql.checkRows(2)
tdSql.query("show tables")
tdSql.checkRows(4)
tdSql.query("select count(*) from st1_0")
tdSql.checkData(0,0,2)
tdSql.query("select ts from gt0")
tdSql.checkData(0,0,'2021-02-25 10:00:12.700')
tdSql.error("use dp1")
tdSql.error("select count(*) from st2_0")
tdSql.error("select count(*) from gt2")
#check taosdumptest/tmp4
tdSql.execute("drop database dp2")
os.system("%staosdump -i ./taosdumptest/tmp4 -T 2 " % binPath)
tdSql.execute("use dp2")
tdSql.query("show stables")
tdSql.checkRows(2)
tdSql.query("show tables")
tdSql.checkRows(6)
tdSql.query("select c20 from gt2")
tdSql.checkData(0, 0, 8639)
tdSql.query("select count(*) from st0_0")
tdSql.checkData(0, 0, 2)
tdSql.query("select count(*) from st0_1")
tdSql.checkData(0, 0, 2)
tdSql.query("select count(*) from st2_1")
tdSql.checkData(0, 0, 2)
tdSql.query("select count(*) from st2_0")
tdSql.checkData(0, 0, 2)
tdSql.error("use dp1")
tdSql.error("select count(*) from st1_0")
tdSql.error("select count(*) from st1_1")
tdSql.error("select count(*) from gt3")
#check taosdumptest/tmp5
tdSql.execute("drop database dp2")
os.system("%staosdump -i ./taosdumptest/tmp5 -T 2 " % binPath)
tdSql.execute("use dp2")
tdSql.query("show stables")
tdSql.checkRows(3)
tdSql.query("show tables")
tdSql.checkRows(9)
tdSql.query("select c20 from gt2")
tdSql.checkData(0, 0, 8639)
tdSql.query("select count(*) from st0_0")
tdSql.checkData(0, 0, 2)
tdSql.query("select count(*) from st0_1")
tdSql.checkData(0, 0, 2)
tdSql.query("select count(*) from st2_1")
tdSql.checkData(0, 0, 2)
tdSql.query("select count(*) from st2_0")
tdSql.checkData(0, 0, 2)
tdSql.query("select count(*) from st1_1")
tdSql.checkData(0, 0, 2)
tdSql.query("select count(*) from st1_0")
tdSql.checkData(0, 0, 2)
tdSql.execute("use dp1")
tdSql.query("show stables")
tdSql.checkRows(1)
tdSql.query("show tables")
tdSql.checkRows(4)
tdSql.query("select c1 from st0_0 order by ts")
tdSql.checkData(0,0,8537)
tdSql.query("select c2 from st0_1 order by ts")
tdSql.checkData(1,0,"D")
tdSql.query("select * from gt0")
tdSql.checkData(0,0,'2021-02-25 10:00:12.000')
tdSql.checkData(0,1,637)
#check taosdumptest/tmp6
tdSql.execute("drop database dp1")
tdSql.execute("drop database dp2")
tdSql.execute("drop database dp3")
os.system("%staosdump -i ./taosdumptest/tmp6 -T 2 " % binPath)
tdSql.execute("use dp3")
tdSql.query("show stables")
tdSql.checkRows(1)
tdSql.query("show tables")
tdSql.checkRows(1)
tdSql.query("select count(*) from st0_0")
tdSql.checkData(0, 0, 2)
tdSql.query("select * from st0 order by ts")
tdSql.checkData(0,0,'2021-02-25 10:00:12.000000001')
tdSql.checkData(0,1,8600)
os.system("rm -rf ./taosdumptest/tmp1")
os.system("rm -rf ./taosdumptest/tmp2")
os.system("rm -rf ./taosdumptest/tmp3")
os.system("rm -rf ./taosdumptest/tmp4")
os.system("rm -rf ./taosdumptest/tmp5")
os.system("rm -rf ./dump_result.txt")
os.system("rm -rf ./db.csv")
def stop(self):
tdSql.close()
......
......@@ -120,6 +120,10 @@ int stmt_scol_func1(TAOS_STMT *stmt) {
exit(1);
}
int affectedRows = taos_stmt_affected_rows(stmt);
if (affectedRows != 100) {
printf("failed to insert 100 rows");
}
return 0;
}
......
......@@ -46,6 +46,7 @@ void taos_stmt_init_test() {
}
stmt = taos_stmt_init(taos);
assert(stmt != NULL);
assert(taos_stmt_affected_rows(stmt) == 0);
assert(taos_stmt_close(stmt) == 0);
printf("finish taos_stmt_init test\n");
}
......@@ -127,6 +128,7 @@ void taos_stmt_set_tbname_test() {
assert(taos_stmt_set_tbname(stmt, name) == 0);
free(name);
free(stmt_sql);
assert(taos_stmt_affected_rows(stmt) == 0);
taos_stmt_close(stmt);
printf("finish taos_stmt_set_tbname test\n");
}
......@@ -166,6 +168,7 @@ void taos_stmt_set_tbname_tags_test() {
free(stmt_sql);
free(name);
free(tags);
assert(taos_stmt_affected_rows(stmt) == 0);
taos_stmt_close(stmt);
printf("finish taos_stmt_set_tbname_tags test\n");
}
......@@ -194,8 +197,10 @@ void taos_stmt_set_sub_tbname_test() {
assert(taos_stmt_set_sub_tbname(stmt, name) != 0);
sprintf(name, "tb");
assert(taos_stmt_set_sub_tbname(stmt, name) == 0);
assert(taos_stmt_affected_rows(stmt) == 0);
assert(taos_load_table_info(taos, "super, tb") == 0);
assert(taos_stmt_set_sub_tbname(stmt, name) == 0);
assert(taos_stmt_affected_rows(stmt) == 0);
free(name);
free(stmt_sql);
assert(taos_stmt_close(stmt) == 0);
......@@ -238,6 +243,7 @@ void taos_stmt_bind_param_test() {
assert(taos_stmt_bind_param(stmt, params) != 0);
assert(taos_stmt_set_tbname(stmt, "super") == 0);
assert(taos_stmt_bind_param(stmt, params) == 0);
assert(taos_stmt_affected_rows(stmt) == 0);
free(params);
free(stmt_sql);
taos_stmt_close(stmt);
......@@ -249,6 +255,7 @@ void taos_stmt_bind_single_param_batch_test() {
TAOS_STMT * stmt = NULL;
TAOS_MULTI_BIND *bind = NULL;
assert(taos_stmt_bind_single_param_batch(stmt, bind, 0) != 0);
assert(taos_stmt_affected_rows(stmt) == 0);
printf("finish taos_stmt_bind_single_param_batch test\n");
}
......@@ -257,6 +264,7 @@ void taos_stmt_bind_param_batch_test() {
TAOS_STMT * stmt = NULL;
TAOS_MULTI_BIND *bind = NULL;
assert(taos_stmt_bind_param_batch(stmt, bind) != 0);
assert(taos_stmt_affected_rows(stmt) == 0);
printf("finish taos_stmt_bind_param_batch test\n");
}
......@@ -293,10 +301,14 @@ void taos_stmt_add_batch_test() {
params[1].length = &params[1].buffer_length;
params[1].is_null = NULL;
assert(taos_stmt_set_tbname(stmt, "super") == 0);
assert(taos_stmt_affected_rows(stmt) == 0);
assert(taos_stmt_bind_param(stmt, params) == 0);
assert(taos_stmt_affected_rows(stmt) == 0);
assert(taos_stmt_add_batch(stmt) == 0);
assert(taos_stmt_affected_rows(stmt) == 0);
free(params);
free(stmt_sql);
assert(taos_stmt_affected_rows(stmt) == 0);
assert(taos_stmt_close(stmt) == 0);
printf("finish taos_stmt_add_batch test\n");
}
......@@ -317,10 +329,13 @@ void taos_stmt_execute_test() {
stmt = taos_stmt_init(taos);
assert(stmt != NULL);
assert(taos_stmt_execute(stmt) != 0);
assert(taos_stmt_affected_rows(stmt) == 0);
char *stmt_sql = calloc(1, 1000);
sprintf(stmt_sql, "insert into ? values (?,?)");
assert(taos_stmt_prepare(stmt, stmt_sql, 0) == 0);
assert(taos_stmt_affected_rows(stmt) == 0);
assert(taos_stmt_execute(stmt) != 0);
assert(taos_stmt_affected_rows(stmt) == 0);
TAOS_BIND *params = calloc(2, sizeof(TAOS_BIND));
int64_t ts = (int64_t)1591060628000;
params[0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
......@@ -335,11 +350,17 @@ void taos_stmt_execute_test() {
params[1].length = &params[1].buffer_length;
params[1].is_null = NULL;
assert(taos_stmt_set_tbname(stmt, "super") == 0);
assert(taos_stmt_affected_rows(stmt) == 0);
assert(taos_stmt_execute(stmt) != 0);
assert(taos_stmt_affected_rows(stmt) == 0);
assert(taos_stmt_bind_param(stmt, params) == 0);
assert(taos_stmt_affected_rows(stmt) == 0);
assert(taos_stmt_execute(stmt) != 0);
assert(taos_stmt_affected_rows(stmt) == 0);
assert(taos_stmt_add_batch(stmt) == 0);
assert(taos_stmt_affected_rows(stmt) == 0);
assert(taos_stmt_execute(stmt) == 0);
assert(taos_stmt_affected_rows(stmt) == 1);
free(params);
free(stmt_sql);
assert(taos_stmt_close(stmt) == 0);
......
......@@ -229,6 +229,14 @@ int main(int argc, char *argv[]) {
PRINT_SUCCESS
printf("Successfully execute insert statement.\n");
int affectedRows = taos_stmt_affected_rows(stmt);
printf("Successfully inserted %d rows\n", affectedRows);
if (affectedRows != 10) {
PRINT_ERROR
printf("failed to insert 10 rows\n");
exit(EXIT_FAILURE);
}
taos_stmt_close(stmt);
for (int i = 0; i < 10; i++) {
check_result(taos, i, 1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册