[Mono-devel-list] Npgsql possible bug

Jaroslaw Kowalski jaak at zd.com.pl
Thu Dec 25 17:37:06 EST 2003

Hi all!

This is my first post to nant-devel-list, so please excuse any "formal"
mistakes. I'm in progress of porting my O/R mapping solution to
Mono/PostgreSQL and I've encountered the bug in Npgsql. Is this the right
list to report this problem to?

The problem is related to the fact that NpgsqlCommand calls
connection.Dispose() in it's Dispose method. This causes problems with
constructs like the following, which are legal in MS.NET with MSSQL:

---------------------------8<--CUT HERE------------------------------
NpgsqlConnection conn = new NpgsqlConnection();

using (NpgsqlCommand cmd1 = new NpgsqlCommand("select * from ...", conn))
// after exiting from the "using" block the Dispose on "conn"
// is called causing it to close. The following command will
// fail because the connection is no longer open.
using (NpgsqlCommand cmd2 = new NpgsqlCommand("select * from ...", conn))
---------------------------8<--CUT HERE------------------------------

Proposed patch (made against today's AnonCVS) is to comment out the
"connection.Dispose()" call. I believe this to be the correct semantics.

---------------------------8<--CUT HERE------------------------------
cvs server: Diffing .
Index: NpgsqlCommand.cs
RCS file: /mono/mcs/class/Npgsql/Npgsql/NpgsqlCommand.cs,v
retrieving revision 1.11
diff -u -r1.11 NpgsqlCommand.cs
--- NpgsqlCommand.cs    12 Dec 2003 21:00:04 -0000      1.11
+++ NpgsqlCommand.cs    25 Dec 2003 23:34:26 -0000
@@ -619,10 +619,6 @@
             NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME,
             if (disposing)
-                if (connection != null)
-                {
-                    connection.Dispose();
-                }


---------------------------8<--CUT HERE------------------------------

Can anyone review the patch and possibly commit it to CVS. I found it to be
working quite well with my existing codebase.



More information about the Mono-devel-list mailing list