Hotfix/sangshuduo/td 3877 c sharp query result (#5866)
* [TD-3877]<fix>: C# query result determination mechanism changed. * [TD-3877]<fix>: C# query result determination mechanism changed. change taosdemo and C#checker. Co-authored-by: Shuduo Sang <sdsang@taosdata.com>
This commit is contained in:
parent
3281a5639c
commit
808019af4d
|
@ -244,14 +244,18 @@ namespace TDengineDriver
|
|||
DateTime dt2 = DateTime.Now;
|
||||
TimeSpan span = dt2 - dt1;
|
||||
|
||||
if (res != IntPtr.Zero)
|
||||
if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
|
||||
{
|
||||
Console.WriteLine("[OK] time cost: " + span.ToString() + "ms, execute statement ====> " + sql.ToString());
|
||||
Console.Write(sql.ToString() + " failure, ");
|
||||
if (res != IntPtr.Zero) {
|
||||
Console.Write("reason: " + TDengine.Error(res));
|
||||
}
|
||||
Console.WriteLine("");
|
||||
ExitProgram();
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(res));
|
||||
ExitProgram();
|
||||
Console.WriteLine(sql.ToString() + " success");
|
||||
}
|
||||
TDengine.FreeResult(res);
|
||||
}
|
||||
|
@ -262,9 +266,13 @@ namespace TDengineDriver
|
|||
DateTime dt1 = DateTime.Now;
|
||||
long queryRows = 0;
|
||||
IntPtr res = TDengine.Query(conn, sql);
|
||||
if (res == IntPtr.Zero)
|
||||
if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
|
||||
{
|
||||
Console.WriteLine(sql + " failure, reason: " + TDengine.Error(res));
|
||||
Console.Write(sql.ToString() + " failure, ");
|
||||
if (res != IntPtr.Zero) {
|
||||
Console.Write("reason: " + TDengine.Error(res));
|
||||
}
|
||||
Console.WriteLine("");
|
||||
ExitProgram();
|
||||
}
|
||||
DateTime dt2 = DateTime.Now;
|
||||
|
@ -354,6 +362,7 @@ namespace TDengineDriver
|
|||
{
|
||||
Console.Write("Query is not complete, Error {0:G}", TDengine.ErrorNo(res), TDengine.Error(res));
|
||||
}
|
||||
Console.WriteLine("");
|
||||
|
||||
TDengine.FreeResult(res);
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ namespace TDengineDriver
|
|||
public void ReadArgument(String[] argv)
|
||||
{
|
||||
PrintHelp(argv);
|
||||
host = this.GetArgumentAsString(argv, "-h", "192.168.100.128");
|
||||
host = this.GetArgumentAsString(argv, "-h", "127.0.0.1");
|
||||
user = this.GetArgumentAsString(argv, "-u", "root");
|
||||
password = this.GetArgumentAsString(argv, "-p", "taosdata");
|
||||
dbName = this.GetArgumentAsString(argv, "-d", "db");
|
||||
|
@ -212,42 +212,54 @@ namespace TDengineDriver
|
|||
StringBuilder sql = new StringBuilder();
|
||||
sql.Append("create database if not exists ").Append(this.dbName);
|
||||
IntPtr res = TDengine.Query(this.conn, sql.ToString());
|
||||
if (res != IntPtr.Zero)
|
||||
if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
|
||||
{
|
||||
Console.WriteLine(sql.ToString() + " success");
|
||||
Console.Write(sql.ToString() + " failure, ");
|
||||
if (res != IntPtr.Zero) {
|
||||
Console.Write("reason: " + TDengine.Error(res));
|
||||
}
|
||||
Console.WriteLine("");
|
||||
ExitProgram();
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(res));
|
||||
ExitProgram();
|
||||
Console.WriteLine(sql.ToString() + " success");
|
||||
}
|
||||
TDengine.FreeResult(res);
|
||||
|
||||
sql.Clear();
|
||||
sql.Append("use ").Append(this.dbName);
|
||||
res = TDengine.Query(this.conn, sql.ToString());
|
||||
if (res != IntPtr.Zero)
|
||||
if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
|
||||
{
|
||||
Console.WriteLine(sql.ToString() + " success");
|
||||
Console.Write(sql.ToString() + " failure, ");
|
||||
if (res != IntPtr.Zero) {
|
||||
Console.Write("reason: " + TDengine.Error(res));
|
||||
}
|
||||
Console.WriteLine("");
|
||||
ExitProgram();
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(res));
|
||||
ExitProgram();
|
||||
Console.WriteLine(sql.ToString() + " success");
|
||||
}
|
||||
TDengine.FreeResult(res);
|
||||
|
||||
sql.Clear();
|
||||
sql.Append("create table if not exists ").Append(this.stableName).Append("(ts timestamp, v1 bool, v2 tinyint, v3 smallint, v4 int, v5 bigint, v6 float, v7 double, v8 binary(10), v9 nchar(10)) tags(t1 int)");
|
||||
res = TDengine.Query(this.conn, sql.ToString());
|
||||
if (res != IntPtr.Zero)
|
||||
if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
|
||||
{
|
||||
Console.WriteLine(sql.ToString() + " success");
|
||||
Console.Write(sql.ToString() + " failure, ");
|
||||
if (res != IntPtr.Zero) {
|
||||
Console.Write("reason: " + TDengine.Error(res));
|
||||
}
|
||||
Console.WriteLine("");
|
||||
ExitProgram();
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(res));
|
||||
ExitProgram();
|
||||
Console.WriteLine(sql.ToString() + " success");
|
||||
}
|
||||
TDengine.FreeResult(res);
|
||||
|
||||
|
@ -257,14 +269,18 @@ namespace TDengineDriver
|
|||
sql = sql.Append("create table if not exists ").Append(this.tablePrefix).Append(i)
|
||||
.Append(" using ").Append(this.stableName).Append(" tags(").Append(i).Append(")");
|
||||
res = TDengine.Query(this.conn, sql.ToString());
|
||||
if (res != IntPtr.Zero)
|
||||
if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
|
||||
{
|
||||
Console.WriteLine(sql.ToString() + " success");
|
||||
Console.Write(sql.ToString() + " failure, ");
|
||||
if (res != IntPtr.Zero) {
|
||||
Console.Write("reason: " + TDengine.Error(res));
|
||||
}
|
||||
Console.WriteLine("");
|
||||
ExitProgram();
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(res));
|
||||
ExitProgram();
|
||||
Console.WriteLine(sql.ToString() + " success");
|
||||
}
|
||||
TDengine.FreeResult(res);
|
||||
}
|
||||
|
@ -298,9 +314,13 @@ namespace TDengineDriver
|
|||
.Append(", 5, 6, 7, 'abc', 'def')");
|
||||
}
|
||||
IntPtr res = TDengine.Query(this.conn, sql.ToString());
|
||||
if (res == IntPtr.Zero)
|
||||
if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
|
||||
{
|
||||
Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(res));
|
||||
Console.Write(sql.ToString() + " failure, ");
|
||||
if (res != IntPtr.Zero) {
|
||||
Console.Write("reason: " + TDengine.Error(res));
|
||||
}
|
||||
Console.WriteLine("");
|
||||
}
|
||||
|
||||
int affectRows = TDengine.AffectRows(res);
|
||||
|
@ -333,9 +353,13 @@ namespace TDengineDriver
|
|||
Console.WriteLine(sql);
|
||||
|
||||
IntPtr res = TDengine.Query(conn, sql);
|
||||
if (res == IntPtr.Zero)
|
||||
if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
|
||||
{
|
||||
Console.WriteLine(sql + " failure, reason: " + TDengine.Error(res));
|
||||
Console.Write(sql.ToString() + " failure, ");
|
||||
if (res != IntPtr.Zero) {
|
||||
Console.Write("reason: " + TDengine.Error(res));
|
||||
}
|
||||
Console.WriteLine("");
|
||||
ExitProgram();
|
||||
}
|
||||
|
||||
|
@ -423,8 +447,10 @@ namespace TDengineDriver
|
|||
|
||||
if (TDengine.ErrorNo(res) != 0)
|
||||
{
|
||||
Console.Write("Query is not complete, Error {0:G}", TDengine.ErrorNo(res), TDengine.Error(res));
|
||||
Console.Write("Query is not complete, Error {0:G}",
|
||||
TDengine.ErrorNo(res), TDengine.Error(res));
|
||||
}
|
||||
Console.WriteLine("");
|
||||
|
||||
TDengine.FreeResult(res);
|
||||
}
|
||||
|
|
|
@ -370,16 +370,19 @@ namespace TDengineDriver
|
|||
StringBuilder sql = new StringBuilder();
|
||||
sql.Append("DROP DATABASE IF EXISTS ").Append(this.dbName);
|
||||
IntPtr res = TDengine.Query(this.conn, sql.ToString());
|
||||
if (res != IntPtr.Zero)
|
||||
if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
|
||||
{
|
||||
VerbosePrint(sql.ToString() + " success\n");
|
||||
Console.Write(sql.ToString() + " failure, ");
|
||||
if (res != IntPtr.Zero) {
|
||||
Console.Write("reason: " + TDengine.Error(res));
|
||||
}
|
||||
Console.WriteLine("");
|
||||
CleanAndExitProgram(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(res));
|
||||
CleanAndExitProgram(1);
|
||||
VerbosePrint(sql.ToString() + " success\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void CreateDb()
|
||||
|
@ -387,14 +390,18 @@ namespace TDengineDriver
|
|||
StringBuilder sql = new StringBuilder();
|
||||
sql.Append("CREATE DATABASE IF NOT EXISTS ").Append(this.dbName).Append(" replica ").Append(this.replica);
|
||||
IntPtr res = TDengine.Query(this.conn, sql.ToString());
|
||||
if (res != IntPtr.Zero)
|
||||
if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
|
||||
{
|
||||
VerbosePrint(sql.ToString() + " success\n");
|
||||
Console.Write(sql.ToString() + " failure, ");
|
||||
if (res != IntPtr.Zero) {
|
||||
Console.Write("reason: " + TDengine.Error(res));
|
||||
}
|
||||
Console.WriteLine("");
|
||||
CleanAndExitProgram(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(res));
|
||||
CleanAndExitProgram(1);
|
||||
VerbosePrint(sql.ToString() + " success\n");
|
||||
}
|
||||
TDengine.FreeResult(res);
|
||||
}
|
||||
|
@ -408,14 +415,18 @@ namespace TDengineDriver
|
|||
Append(this.dbName).Append(".").Append(this.stablePrefix).
|
||||
Append("(ts timestamp, v1 bool, v2 tinyint, v3 smallint, v4 int, v5 bigint, v6 float, v7 double, v8 binary(10), v9 nchar(10)) tags(t1 int)");
|
||||
IntPtr res = TDengine.Query(this.conn, sql.ToString());
|
||||
if (res != IntPtr.Zero)
|
||||
if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
|
||||
{
|
||||
VerbosePrint(sql.ToString() + " success\n");
|
||||
Console.Write(sql.ToString() + " failure, ");
|
||||
if (res != IntPtr.Zero) {
|
||||
Console.Write("reason: " + TDengine.Error(res));
|
||||
}
|
||||
Console.WriteLine("");
|
||||
CleanAndExitProgram(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine(sql.ToString() + " failure, reason: " + TDengine.Error(res));
|
||||
CleanAndExitProgram(1);
|
||||
VerbosePrint(sql.ToString() + " success\n");
|
||||
}
|
||||
TDengine.FreeResult(res);
|
||||
}
|
||||
|
@ -495,9 +506,13 @@ namespace TDengineDriver
|
|||
|
||||
IntPtr res = TDengine.Query(conn, sql);
|
||||
DebugPrintFormat("res: {0}\n", res);
|
||||
if (res == IntPtr.Zero)
|
||||
if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
|
||||
{
|
||||
Console.WriteLine(sql + " failure, reason: " + TDengine.Error(res));
|
||||
Console.Write(sql.ToString() + " failure, ");
|
||||
if (res != IntPtr.Zero) {
|
||||
Console.Write("reason: " + TDengine.Error(res));
|
||||
}
|
||||
Console.WriteLine("");
|
||||
CleanAndExitProgram(1);
|
||||
}
|
||||
|
||||
|
@ -761,9 +776,13 @@ namespace TDengineDriver
|
|||
|
||||
}
|
||||
IntPtr res = TDengine.Query(this.conn, sql.ToString());
|
||||
if (res == IntPtr.Zero)
|
||||
if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
|
||||
{
|
||||
VerbosePrint(sql.ToString() + " failure, reason: " + TDengine.Error(res) + "\n");
|
||||
Console.Write(sql.ToString() + " failure, ");
|
||||
if (res != IntPtr.Zero) {
|
||||
Console.Write("reason: " + TDengine.Error(res));
|
||||
}
|
||||
Console.WriteLine("");
|
||||
}
|
||||
|
||||
inserted += this.batchRows;
|
||||
|
@ -840,14 +859,18 @@ namespace TDengineDriver
|
|||
sql = sql.Append("(ts timestamp, v1 bool, v2 tinyint, v3 smallint, v4 int, v5 bigint, v6 float, v7 double, v8 binary(10), v9 nchar(10))");
|
||||
}
|
||||
IntPtr res = TDengine.Query(this.conn, sql.ToString());
|
||||
if (res != IntPtr.Zero)
|
||||
if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0))
|
||||
{
|
||||
VerbosePrint(sql.ToString() + " success\n");
|
||||
Console.Write(sql.ToString() + " failure, ");
|
||||
if (res != IntPtr.Zero) {
|
||||
Console.Write("reason: " + TDengine.Error(res));
|
||||
}
|
||||
Console.WriteLine("");
|
||||
CleanAndExitProgram(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
VerbosePrint(sql.ToString() + " failure, reason: " + TDengine.Error(res) + "\n");
|
||||
CleanAndExitProgram(1);
|
||||
VerbosePrint(sql.ToString() + " success\n");
|
||||
}
|
||||
TDengine.FreeResult(res);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue