From c81acbc69b576612ddfa67ce40c287425f0097fe Mon Sep 17 00:00:00 2001 From: xiaolei li <85657333+xleili@users.noreply.github.com> Date: Sat, 9 Apr 2022 16:05:40 +0800 Subject: [PATCH] [driver]:csharp change close() return type to void (#11340) --- src/connector/C#/examples/lib/Utils.cs | 14 ++++++-------- .../C#/src/TDengineDriver/TDengineDriver.cs | 2 +- .../C#/src/test/FunctionTest/lib/DBFixture.cs | 12 +++--------- .../C#/src/test/FunctionTest/lib/Utils.cs | 14 ++++++-------- 4 files changed, 16 insertions(+), 26 deletions(-) diff --git a/src/connector/C#/examples/lib/Utils.cs b/src/connector/C#/examples/lib/Utils.cs index add61a2da4..14aa9d4859 100644 --- a/src/connector/C#/examples/lib/Utils.cs +++ b/src/connector/C#/examples/lib/Utils.cs @@ -161,14 +161,12 @@ namespace Sample.UtilsTools ExecuteUpdate(conn, $"drop database if exists {globalDbName}"); if (conn != IntPtr.Zero) { - if (TDengine.Close(conn) == 0) - { - Console.WriteLine("close connection success"); - } - else - { - Console.WriteLine("close Connection failed"); - } + TDengine.Close(conn); + Console.WriteLine("close connection success"); + } + else + { + throw new Exception("connection if already null"); } } public static List GetResField(IntPtr res) diff --git a/src/connector/C#/src/TDengineDriver/TDengineDriver.cs b/src/connector/C#/src/TDengineDriver/TDengineDriver.cs index 8656321e5a..4117406355 100644 --- a/src/connector/C#/src/TDengineDriver/TDengineDriver.cs +++ b/src/connector/C#/src/TDengineDriver/TDengineDriver.cs @@ -280,7 +280,7 @@ namespace TDengineDriver static extern public IntPtr FreeResult(IntPtr res); [DllImport("taos", EntryPoint = "taos_close", CallingConvention = CallingConvention.Cdecl)] - static extern public int Close(IntPtr taos); + static extern public void Close(IntPtr taos); //get precision of restultset [DllImport("taos", EntryPoint = "taos_result_precision", CallingConvention = CallingConvention.Cdecl)] diff --git a/src/connector/C#/src/test/FunctionTest/lib/DBFixture.cs b/src/connector/C#/src/test/FunctionTest/lib/DBFixture.cs index 295726a525..6a335c76bb 100644 --- a/src/connector/C#/src/test/FunctionTest/lib/DBFixture.cs +++ b/src/connector/C#/src/test/FunctionTest/lib/DBFixture.cs @@ -53,15 +53,9 @@ namespace Test.Fixture { if ((res = TDengine.Query(conn, $"drop database if exists {db}")) != IntPtr.Zero) { - if (TDengine.Close(conn) == 0) - { - Console.WriteLine("close connection success"); - } - else - { - throw new Exception("close connection failed"); - } - + TDengine.Close(conn); + Console.WriteLine("close connection success"); + } else { diff --git a/src/connector/C#/src/test/FunctionTest/lib/Utils.cs b/src/connector/C#/src/test/FunctionTest/lib/Utils.cs index 9604a0b043..8ae7656b95 100644 --- a/src/connector/C#/src/test/FunctionTest/lib/Utils.cs +++ b/src/connector/C#/src/test/FunctionTest/lib/Utils.cs @@ -158,14 +158,12 @@ namespace Test.UtilsTools ExecuteUpdate(conn, "drop database if exists csharp"); if (conn != IntPtr.Zero) { - if (TDengine.Close(conn) == 0) - { - Console.WriteLine("close connection success"); - } - else - { - Console.WriteLine("close Connection failed"); - } + TDengine.Close(conn); + Console.WriteLine("close connection success"); + } + else + { + throw new Exception("connection if already null"); } } public static List GetResField(IntPtr res) -- GitLab