[Mono-bugs] [Bug 462947] New: TDS: not enough state reset when executing a query/ stored procedure

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Dec 30 09:45:09 EST 2008


https://bugzilla.novell.com/show_bug.cgi?id=462947


           Summary: TDS: not enough state reset when executing a
                    query/stored procedure
           Product: Mono: Class Libraries
           Version: SVN
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Sys.Data.SqlClient
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: gert.driesen at pandora.be
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


Created an attachment (id=262769)
 --> (https://bugzilla.novell.com/attachment.cgi?id=262769)
Fix for Tds, unit test will be committed later

While adding new (connected) tests for SqlClient (and others), I noticed that
we reset almost none of the state of our Tds connection when we a query/stored
procedure.

This cause the following unit test (which is not yet committed) to fail:

[Test]
public void ExecuteReader_Connection_Reuse ()
{
  cmd.CommandText = "SELECT type_blob FROM binary_family where id = 1";

  CommandBehavior behavior = CommandBehavior.SequentialAccess |
    CommandBehavior.SingleResult;

  using (IDataReader reader = cmd.ExecuteReader (behavior)) {
    Assert.IsTrue (reader.Read (), "#A1");

    long totalsize = reader.GetBytes (0, 0, null, 0, 0);
    byte [] val = new byte [totalsize];
    long ret = reader.GetBytes (0, 0, val, 0, val.Length);
    Assert.AreEqual (5, ret, "#A2");
    Assert.AreEqual (new byte [] { 0x32, 0x56, 0x00, 0x44, 0x22 }, val, "#A3");
  }

  ConnectionManager.Singleton.CloseConnection ();
  conn = ConnectionManager.Singleton.Connection;
  ConnectionManager.Singleton.OpenConnection ();

  using (IDataReader reader = cmd.ExecuteReader (behavior)) {
    Assert.IsTrue (reader.Read (), "#B1");

    long totalsize = reader.GetBytes (0, 0, null, 0, 0);
    byte [] val = new byte [totalsize];
    long ret = reader.GetBytes (0, 0, val, 0, val.Length);
    Assert.AreEqual (5, ret, "#B2");
    Assert.AreEqual (new byte [] { 0x32, 0x56, 0x00, 0x44, 0x22 }, val, "#B3");
  }
}

Actual result:
#B1 fails; meaning no results are produced when you execute the same SQL
statement again.

Note:
Removing the GetBytes calls even gets the test to block indefinitely.

The attached patch fixes this issue, but I'd like someone to verify if I remove
enough / not too much state.

I also noticed that the queryInProgress field is never set to true; I think the
line where it's set to false should probably be changed.


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list