System.Data.SQLite
Check-in [5578f853af]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:When compiling with DEBUG defined, complain about failures to release CriticalHandle objects. Also, add more diagnostics to test case for ticket [e30b820248].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tkt-e30b820248
Files: files | file ages | folders
SHA1:5578f853affe2960834416452ec2c48646a85dba
User & Date: mistachkin 2011-11-13 23:47:02
Context
2011-11-14
05:12
Revise and improve diagnostics for opening/closing connections and preparing/finalizing statements. check-in: 40cdd9c8a0 user: mistachkin tags: tkt-e30b820248
2011-11-13
23:47
When compiling with DEBUG defined, complain about failures to release CriticalHandle objects. Also, add more diagnostics to test case for ticket [e30b820248]. check-in: 5578f853af user: mistachkin tags: tkt-e30b820248
22:16
Merge updates from trunk. check-in: 8f3314a825 user: mistachkin tags: tkt-e30b820248
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to Externals/Eagle/lib/Eagle1.0/init.eagle.

764
765
766
767
768
769
770






























771
772
773
774
775
776
777
          System.CodeDom.Compiler.CompilerParameters]

      #
      # NOTE: By default, we do not want to persist the generated assembly
      #       to disk.
      #
      $parameters GenerateInMemory true































      #
      # NOTE: Process any extra compiler settings the caller may have
      #       provided.
      #
      foreach {name value} $args {
        $parameters -nocase $name $value







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
          System.CodeDom.Compiler.CompilerParameters]

      #
      # NOTE: By default, we do not want to persist the generated assembly
      #       to disk.
      #
      $parameters GenerateInMemory true

      #
      # NOTE: Make sure that the "standard" preprocessor defines match those
      #       for the platform (i.e. the ones used to compile the Eagle core
      #       library assembly).
      #
      set platformOptions [expr { \
          [info exists ::eagle_platform(compileOptions)] ? \
          $::eagle_platform(compileOptions) : [list]}]

      if {[llength $platformOptions] > 0} then {
        #
        # NOTE: Grab the existing compiler options, if any.
        #
        set compilerOptions [$parameters CompilerOptions]

        if {"DEBUG" in $platformOptions} then {
          append compilerOptions " /define:DEBUG"
        }

        if {"TRACE" in $platformOptions} then {
          append compilerOptions " /define:TRACE"
        }

        #
        # NOTE: Reset the compiler options to the pre-existing ones plus the
        #       extra defines we may have added (above).
        #
        $parameters CompilerOptions $compilerOptions
      }

      #
      # NOTE: Process any extra compiler settings the caller may have
      #       provided.
      #
      foreach {name value} $args {
        $parameters -nocase $name $value

Changes to System.Data.SQLite/UnsafeNativeMethods.cs.

870
871
872
873
874
875
876



877
878
879
880



881

882
883
884
885
886
887
888
...
912
913
914
915
916
917
918



919
920
921
922



923

924
925
926
927
928
929
930
931
    }

    protected override bool ReleaseHandle()
    {
      try
      {
        SQLiteBase.CloseConnection(this);



      }
      catch (SQLiteException)
      {
      }



      return true;

    }

    public override bool IsInvalid
    {
      get { return (handle == IntPtr.Zero); }
    }
  }
................................................................................
    }

    protected override bool ReleaseHandle()
    {
      try
      {
        SQLiteBase.FinalizeStatement(this);



      }
      catch (SQLiteException)
      {
      }



      return true;

    }

    public override bool IsInvalid
    {
      get { return (handle == IntPtr.Zero); }
    }
  }
}







>
>
>




>
>
>

>







 







>
>
>




>
>
>

>








870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
...
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
    }

    protected override bool ReleaseHandle()
    {
      try
      {
        SQLiteBase.CloseConnection(this);
#if DEBUG
        return true;
#endif
      }
      catch (SQLiteException)
      {
      }
#if DEBUG
      return false;
#else
      return true;
#endif
    }

    public override bool IsInvalid
    {
      get { return (handle == IntPtr.Zero); }
    }
  }
................................................................................
    }

    protected override bool ReleaseHandle()
    {
      try
      {
        SQLiteBase.FinalizeStatement(this);
#if DEBUG
        return true;
#endif
      }
      catch (SQLiteException)
      {
      }
#if DEBUG
      return false;
#else
      return true;
#endif
    }

    public override bool IsInvalid
    {
      get { return (handle == IntPtr.Zero); }
    }
  }
}

Changes to Tests/tkt-e30b820248.eagle.

21
22
23
24
25
26
27

28
29
30
31
32
33
34
..
35
36
37
38
39
40
41

42
43
44
45
46
47
48






49
50
51
52

53
54
55
56


57
58
59
60

61
62
63

64

65
66
67

68




69
70
71
72
73
74
75
..
78
79
80
81
82
83
84
85
86

87
88
89
90
91
###############################################################################

runTest {test tkt-e30b820248-1.1 {statement disposal ordering} -setup {
  setupDb [set fileName tkt-e30b820248-1.1.db]
} -body {
  set id [object invoke Interpreter.GetActive NextId]
  set dataSource [file join [getTemporaryPath] $fileName]


  set sql { \
    CREATE TABLE t1 (id1 INTEGER); \
    INSERT INTO t1 (id1) VALUES (1); \
    INSERT INTO t1 (id1) VALUES (2); \
    INSERT INTO t1 (id1) VALUES (?); \
    INSERT INTO t1 (id1) VALUES (?); \
................................................................................
    INSERT INTO t1 (id1) VALUES (?); \
  }

  unset -nocomplain results errors

  set code [compileCSharpWith [subst {
    using System.Data.SQLite;


    namespace _Dynamic${id}
    {
      public class Test${id}
      {
        public static void Main()
        {






          using (SQLiteConnection connection = new SQLiteConnection(
              "Data Source=${dataSource};"))
          {
            connection.Open();


            using (SQLiteTransaction transaction =
                connection.BeginTransaction())
            {


              using (SQLiteCommand command = connection.CreateCommand())
              {
                command.Transaction = transaction;
                command.CommandText = "${sql}";

                command.Parameters.AddWithValue("x", 3);
                command.Parameters.AddWithValue("y", 4);
                command.Parameters.AddWithValue("z", 5);

                command.ExecuteNonQuery();

              }

              transaction.Commit();

            }




          }
        }
      }
    }
  }] results errors System.Data.SQLite.dll]

  list $code $results \
................................................................................
        object invoke _Dynamic${id}.Test${id} Main
      } result] : [set result ""]}] $result
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain result code results errors sql dataSource id db fileName
} -constraints \
{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -match \
regexp -result {^Ok System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\}$}}


###############################################################################

runSQLiteTestEpilogue
runTestEpilogue







>







 







>







>
>
>
>
>
>
|
|
|
|
>

|
|
|
>
>
|
|
|
|
>
|
|
|
>
|
>
|

|
>
|
>
>
>
>







 







|
|
>





21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
..
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
..
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
###############################################################################

runTest {test tkt-e30b820248-1.1 {statement disposal ordering} -setup {
  setupDb [set fileName tkt-e30b820248-1.1.db]
} -body {
  set id [object invoke Interpreter.GetActive NextId]
  set dataSource [file join [getTemporaryPath] $fileName]
  set name [file rootname [file tail $fileName]]

  set sql { \
    CREATE TABLE t1 (id1 INTEGER); \
    INSERT INTO t1 (id1) VALUES (1); \
    INSERT INTO t1 (id1) VALUES (2); \
    INSERT INTO t1 (id1) VALUES (?); \
    INSERT INTO t1 (id1) VALUES (?); \
................................................................................
    INSERT INTO t1 (id1) VALUES (?); \
  }

  unset -nocomplain results errors

  set code [compileCSharpWith [subst {
    using System.Data.SQLite;
    using System.Diagnostics;

    namespace _Dynamic${id}
    {
      public class Test${id}
      {
        public static void Main()
        {
          using (TraceListener listener = new TextWriterTraceListener(
              "${test_log}", "${name}"))
          {
            Trace.Listeners.Add(listener);
            Trace.WriteLine("---- START TRACE \\"${name}\\"");

            using (SQLiteConnection connection = new SQLiteConnection(
                "Data Source=${dataSource};"))
            {
              connection.Open();
              connection.LogMessage(0, "Connection opened.");

              using (SQLiteTransaction transaction =
                  connection.BeginTransaction())
              {
                connection.LogMessage(0, "Transaction started.");

                using (SQLiteCommand command = connection.CreateCommand())
                {
                  command.Transaction = transaction;
                  command.CommandText = "${sql}";

                  command.Parameters.AddWithValue("x", 3);
                  command.Parameters.AddWithValue("y", 4);
                  command.Parameters.AddWithValue("z", 5);

                  command.ExecuteNonQuery();
                  connection.LogMessage(0, "Command executed.");
                }

                transaction.Commit();
                connection.LogMessage(0, "Transaction committed.");
              }
            }

            Trace.WriteLine("---- END TRACE \\"${name}\\"");
            Trace.Listeners.Remove(listener);
          }
        }
      }
    }
  }] results errors System.Data.SQLite.dll]

  list $code $results \
................................................................................
        object invoke _Dynamic${id}.Test${id} Main
      } result] : [set result ""]}] $result
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain result code results errors sql dataSource id db fileName
} -constraints \
{eagle logFile monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} \
-match regexp -result {^Ok System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0\
\{\}$}}

###############################################################################

runSQLiteTestEpilogue
runTestEpilogue