[Mono-bugs] [Bug 68978][Nor] New - SqlClient: temporary stored procedures not removed when closing (pooled) connection

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Mon, 1 Nov 2004 10:29:45 -0500 (EST)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by gert.driesen@pandora.be.

http://bugzilla.ximian.com/show_bug.cgi?id=68978

--- shadow/68978	2004-11-01 10:29:45.000000000 -0500
+++ shadow/68978.tmp.24868	2004-11-01 10:29:45.000000000 -0500
@@ -0,0 +1,85 @@
+Bug#: 68978
+Product: Mono: Class Libraries
+Version: unspecified
+OS: All
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Sys.Data
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: gert.driesen@pandora.be               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: SqlClient: temporary stored procedures not removed when closing (pooled) connection
+
+When using connection pooling with SqlClient, a temporary stored 
+procedure is not removed when the connection is closed (returned to the 
+pool).
+
+To reproduce this issue, compile and the following code fragment :
+
+using System;
+using System.Data;
+using System.Data.SqlClient;
+
+public class EntryPoint {
+    public static void Main() {
+        using (SqlConnection conn = new SqlConnection
+("Server=mother;database=master;user id=sa;pwd=;")) {
+            conn.Open();
+            CreateTempSP(conn);
+            conn.Close();
+        }
+
+        using (SqlConnection conn = new SqlConnection
+("Server=mother;database=master;user id=sa;pwd=;")) {
+            conn.Open();
+            CreateTempSP(conn);
+            conn.Close();
+        }
+    }
+
+    private static void CreateTempSP(SqlConnection conn) {
+        SqlCommand cmd = conn.CreateCommand();
+        cmd.CommandType = CommandType.Text;
+        cmd.CommandText = "CREATE PROCEDURE #tempsp (" 
+            + "@Status smallint = 7"
+            + ")"
+            + "AS" + Environment.NewLine
+            + "BEGIN" + Environment.NewLine
+            + "SELECT CAST(5 AS int), @Status" + Environment.NewLine
+            + "END";
+        cmd.ExecuteNonQuery();
+    }
+}
+
+This code fragment opens a connection and create a temporary stored 
+procedure and closes the connection. And performs this twice.
+
+This works fine on MS.NET, but on Mono the following exception is thrown 
+on the second run :
+
+Unhandled Exception: System.Data.SqlClient.SqlException: There is already 
+an object named '#Bug66630' in the database.
+in <0x00103> System.Data.SqlClient.SqlConnection:ErrorHandler 
+(object,Mono.Data.Tds.Protocol.TdsInternalErrorMessageEventArgs)
+in <0x00066> (wrapper delegate-invoke) 
+System.MulticastDelegate:invoke_void_object_TdsInternalErrorMessageEventAr
+gs (object,Mono.Data.Tds.Protocol.TdsInternalErrorMessageEventArgs)
+in <0x0001e> Mono.Data.Tds.Protocol.Tds:OnTdsErrorMessage 
+(Mono.Data.Tds.Protocol.TdsInternalErrorMessageEventArgs)
+in <0x00053> (wrapper remoting-invoke-with-check) 
+Mono.Data.Tds.Protocol.Tds:OnTdsErrorMessage 
+(Mono.Data.Tds.Protocol.TdsInternalErrorMessageEventArgs)
+in <0x00243> Mono.Data.Tds.Protocol.Tds:ProcessMessage 
+(Mono.Data.Tds.Protocol.TdsPacketSubType)
+in <0x0004f> (wrapper remoting-invoke-with-check) 
+Mono.Data.Tds.Protocol.Tds:ProcessMessage 
+(Mono.Data.Tds.Protocol.TdsPacketSubType)
+in <0x0014a> Mono.Data.Tds.Protocol.Tds:ProcessSubPacket ()
+in <0x00050> Mono.Data.Tds.Protocol.Tds:NextResult ()
+...