2005-11-23 Senganal T <tsenganal@novell.com>
authorSenganal T <senga@mono-cvs.ximian.com>
Wed, 23 Nov 2005 14:15:11 +0000 (14:15 -0000)
committerSenganal T <senga@mono-cvs.ximian.com>
Wed, 23 Nov 2005 14:15:11 +0000 (14:15 -0000)
* Mono.Data.Tds/Mono.Data.Tds.Protocol/TdsComm.cs :
- ResizeOutBuf : Modified to shrink the output buffer if
the block size is reduced. Fixed bug #76778
* System.Data/Test/ProviderTests/System.Data.SqlClient/SqlCommandTest.cs :
- Added testcases for bug #76778

svn path=/trunk/mcs/; revision=53395

mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/ChangeLog
mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/TdsComm.cs
mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/ChangeLog
mcs/class/System.Data/Test/ProviderTests/System.Data.SqlClient/SqlCommandTest.cs

index 016919562812998b8de09aff7053ffbabc24ae72..814abf2722ba90c2e6218e9adb911cee82757d0d 100644 (file)
@@ -1,3 +1,9 @@
+2005-11-23  Senganal T  <tsenganal@novell.com>
+       
+       * TdsComm.cs : 
+               - ResizeOutBuf : Modified to shrink the output buffer if
+               the block size is reduced. Fixed bug #76778     
+
 2005-10-27  Senganal T  <tsenganal@novell.com>
        
        * Tds.cs :
index 00a39a660826c292f0e08a3315c1188beaeee9c2..06cf7ca4f1a9bd170bd9b07df028959ed124f632 100644 (file)
@@ -478,9 +478,9 @@ namespace Mono.Data.Tds.Protocol {
 
                internal void ResizeOutBuf (int newSize)
                {
-                       if (newSize > outBufferLength) {
+                       if (newSize != outBufferLength) {
                                byte[] newBuf = new byte [newSize];
-                               Array.Copy (outBuffer, 0, newBuf, 0, outBufferLength);
+                               Array.Copy (outBuffer, 0, newBuf, 0, newSize);
                                outBufferLength = newSize;
                                outBuffer = newBuf;
                        }
index f40d70fb888afac215bda925e7a839cb31451897..9bcd9eab2498deb7ff7898a95c5b41014b900242 100644 (file)
@@ -1,3 +1,7 @@
+2005-11-23  Senganal T  <tsenganal@novell.com>
+
+       * SqlCommandTest.cs : Added testcases for bug #76778
+
 2005-10-27  Senganal T  <tsenganal@novell.com>
 
        * SqlCommandTest.cs : Added Testcase for bug #75698
index d5b0cc3f07f6ced82e4cd5be201e5f90467a7df2..3b62092f1e2898b605f150cfa43358d6fc2fe770 100644 (file)
@@ -583,6 +583,84 @@ namespace MonoTests.System.Data.SqlClient
                        }
                }
 
+               // Test for bug #76778
+               // Test for a case, when query size is greater than the block size
+               [Test]
+               public void LongQueryTest ()
+               {
+                       SqlConnection conn = new SqlConnection (
+                                                       connectionString + ";Pooling=false");
+                       using (conn) {
+                               conn.Open ();
+                               SqlCommand cmd = conn.CreateCommand ();
+                               String value =  new String ('a', 10000);
+                               cmd.CommandText = String.Format ("Select '{0}'", value); 
+                               cmd.ExecuteNonQuery ();
+                       }
+               }
+
+               // Test for bug #76778
+               // To make sure RPC (when implemented) works ok.. 
+               [Test]
+               public void LongStoredProcTest()
+               {
+                       SqlConnection conn = new SqlConnection (
+                                                       connectionString + ";Pooling=false");
+                       using (conn) {
+                               conn.Open ();
+                               int size = conn.PacketSize ; 
+                               SqlCommand cmd = conn.CreateCommand ();
+                               // create a temp stored proc .. 
+                               cmd.CommandText  = "Create Procedure #sp_tmp_long_params ";
+                               cmd.CommandText += "@p1 nvarchar (4000), ";
+                               cmd.CommandText += "@p2 nvarchar (4000), ";
+                               cmd.CommandText += "@p3 nvarchar (4000), ";
+                               cmd.CommandText += "@p4 nvarchar (4000) out ";
+                               cmd.CommandText += "As ";
+                               cmd.CommandText += "Begin ";
+                               cmd.CommandText += "Set @p4 = N'Hello' ";
+                               cmd.CommandText += "Return 2 "; 
+                               cmd.CommandText += "End"; 
+                               cmd.ExecuteNonQuery ();
+
+                               //execute the proc 
+                               cmd.CommandType = CommandType.StoredProcedure;
+                               cmd.CommandText = "#sp_tmp_long_params"; 
+
+                               String value =  new String ('a', 4000);
+                               SqlParameter p1 = new SqlParameter ("@p1",
+                                                       SqlDbType.NVarChar,4000);
+                               p1.Value = value;
+
+                               SqlParameter p2 = new SqlParameter ("@p2",
+                                                       SqlDbType.NVarChar,4000);
+                               p2.Value = value;
+
+                               SqlParameter p3 = new SqlParameter ("@p3",
+                                                       SqlDbType.NVarChar,4000);
+                               p3.Value = value;
+
+                               SqlParameter p4 = new SqlParameter ("@p4",
+                                                       SqlDbType.NVarChar,4000);
+                               p4.Direction = ParameterDirection.Output; 
+
+                               // for now, name shud be @RETURN_VALUE  
+                               // can be changed once RPC is implemented 
+                               SqlParameter p5 = new SqlParameter ("@RETURN_VALUE", SqlDbType.Int);
+                               p5.Direction = ParameterDirection.ReturnValue ;
+
+                               cmd.Parameters.Add (p1);
+                               cmd.Parameters.Add (p2);
+                               cmd.Parameters.Add (p3);
+                               cmd.Parameters.Add (p4);
+                               cmd.Parameters.Add (p5);
+
+                               cmd.ExecuteNonQuery ();
+                               Assert.AreEqual ("Hello", p4.Value, "#1");
+                               Assert.AreEqual (2, p5.Value, "#2");
+                       }
+               }
+
                /**
                 * Verifies whether an enum value is converted to a numeric value when
                 * used as value for a numeric parameter (bug #66630)