System.Data.SQLite
Check-in [9a1cb354ec]
Not logged in

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

Overview
Comment:Modify test case for [e1b2e0f769] to allow the reported exception to be reproduced.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9a1cb354ec4bc50982988db807ae9bf7f419f5c3
User & Date: mistachkin 2011-07-06 20:59:08
Context
2011-07-06
21:09
Further simplify test case for [e1b2e0f769]. Prevent common.eagle from being treated as a test case file. check-in: bafc84af30 user: mistachkin tags: trunk
20:59
Modify test case for [e1b2e0f769] to allow the reported exception to be reproduced. check-in: 9a1cb354ec user: mistachkin tags: trunk
2011-07-05
10:13
Cleanup leaked variables in test case. check-in: 84d5eb1e69 user: mistachkin tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to Tests/common.eagle.

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
      #
      return $fileName
    }

    return ""
  }
 
  proc setupDb {fileName {mode ""} {delete true} {varName db}} {
    set fileName [file join [getTemporaryPath] $fileName]

    if {$delete} then {
      catch {file delete $fileName}
    }

    upvar 1 $varName db

    set connection {Data Source=${fileName}}

    if {[string length $mode] > 0} then {
      append connection {;Journal Mode=${mode}}
    }





    set db [sql open -type SQLite [subst $connection]]
  }
 
  proc cleanupDb {fileName {varName db}} {
    upvar 1 $varName db
    catch {sql close $db}
    catch {file delete [file join [getTemporaryPath] $fileName]}
  }
}







|


|










>
>
>
>










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
      #
      return $fileName
    }

    return ""
  }
 
  proc setupDb {fileName {mode ""} {delete ""} {extra ""} {varName db}} {
    set fileName [file join [getTemporaryPath] $fileName]

    if {[string length $delete] == 0 || $delete} then {
      catch {file delete $fileName}
    }

    upvar 1 $varName db

    set connection {Data Source=${fileName}}

    if {[string length $mode] > 0} then {
      append connection {;Journal Mode=${mode}}
    }

    if {[string length $extra] > 0} then {
      append connection \; $extra
    }

    set db [sql open -type SQLite [subst $connection]]
  }
 
  proc cleanupDb {fileName {varName db}} {
    upvar 1 $varName db
    catch {sql close $db}
    catch {file delete [file join [getTemporaryPath] $fileName]}
  }
}

Changes to Tests/tkt-e1b2e0f769.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
76
77
78

79
80
81
82
83
84
85
86

87

88




89
90
91
92

93
94
95


96
97
98
99

runTest {test tkt-e1b2e0f769-1.1 {command cleanup} -setup {
  copyAssembly SQLite.Interop.dll
  copyAssembly System.Data.SQLite.dll
  setupDb [set fileName tkt-e1b2e0f769-1.1.db]
} -body {
  sql execute $db "CREATE TABLE t1(x INTEGER);"


  foreach x [list 1 2 3] {
    sql execute $db "INSERT INTO t1 (x) VALUES($x);"
  }

  set id [object invoke Interpreter.GetActive NextId]
  set dataSource [file join [getTemporaryPath] tkt-e1b2e0f769-1.1.db]
  set sql "SELECT * FROM t1 ORDER BY x ASC; SELECT * FROM t1 ORDER BY x DESC;"





  unset -nocomplain results errors

  set code [compileCSharp [subst {

    using System.Data.SQLite;

    namespace _Dynamic${id}
    {
      public class Test${id}
      {
        public static bool Tkt_e1b2e0f769(SQLiteConnection connection)
        {


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

              using (SQLiteDataReader dataReader = command.ExecuteReader())
              {







                if (!dataReader.HasRows)


                  return false;

                while (dataReader.Read())
                  ;


                return true;


              }

            }

            transaction.Commit();
          }
        }




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

            Tkt_e1b2e0f769(connection);
            Tkt_e1b2e0f769(connection);

          }
        }
      }
    }
  }] results errors ReferencedAssemblies.Add System.dll \
      ReferencedAssemblies.Add System.Data.dll \
      ReferencedAssemblies.Add [getAssemblyFileName System.Data.SQLite.dll]]


  list $code $results [expr {[info exists errors] ? $errors : ""}] [expr {$code\

      eq "Ok" ? [object invoke _Dynamic${id}.Test${id} Main] : ""}]




} -cleanup {
  cleanupDb $fileName

  unset -nocomplain code results errors sql dataSource id x db fileName

} -constraints \
{eagle monoBug28 command.sql compile.DATA System.Data.SQLite} -match regexp \
-result {^Ok System#CodeDom#Compiler#CompilerResults#\d+ \{\} \{\}$}}



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

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
95
96
97
98

99
100
101
102

103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128

runTest {test tkt-e1b2e0f769-1.1 {command cleanup} -setup {
  copyAssembly SQLite.Interop.dll
  copyAssembly System.Data.SQLite.dll
  setupDb [set fileName tkt-e1b2e0f769-1.1.db]
} -body {
  sql execute $db "CREATE TABLE t1(x INTEGER);"
  sql execute $db "CREATE TABLE t2(x INTEGER);"

  foreach x [list 1 2 3 NULL] {
    sql execute $db "INSERT INTO t1 (x) VALUES($x);"
  }

  set result1 [list]
  set dataSource [file join [getTemporaryPath] tkt-e1b2e0f769-1.1.db]


  foreach table [list t1 t2] {
    set id [object invoke Interpreter.GetActive NextId]
    set sql "SELECT x FROM $table ORDER BY x;"

    unset -nocomplain results errors

    set code [compileCSharp [subst {
      using System.Collections.Generic;
      using System.Data.SQLite;

      namespace _Dynamic${id}
      {
        public class Test${id}
        {
          public static List<long?> Tkt_e1b2e0f769(SQLiteConnection connection)
          {
            List<long?> result = new List<long?>();

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

                using (SQLiteDataReader dataReader = command.ExecuteReader())
                {
                  //
                  // NOTE: If there are no rows, close the connection and
                  //       return the empty list.  In this case,  an exception
                  //       will be raised when exiting the using block for the
                  //       data reader because we are closing the connection out
                  //       from underneath it.
                  //
                  if (!dataReader.HasRows)
                  {
                    connection.Close();
                    return result;
                  }


                  while (dataReader.Read())
                  {

                    if (!dataReader.IsDBNull(0))
                      result.Add((long?) dataReader\[0\]);
                  }
                } // NOTE: Exception here when no data rows (see comment above).
              }

              transaction.Rollback();
            }

            connection.Close();
            return result;
          }

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

              return Tkt_e1b2e0f769(connection).Count;

            }
          }
        }
      }

    }] results errors ReferencedAssemblies.Add System.dll \
        ReferencedAssemblies.Add System.Data.dll \
        ReferencedAssemblies.Add [getAssemblyFileName System.Data.SQLite.dll]]

    lappend result1 $code $results \
        [expr {[info exists errors] ? $errors : ""}] \
        [expr {$code eq "Ok" ? [catch {
          object invoke _Dynamic${id}.Test${id} Main
        } result2] : [set result2 ""]}] $result2
  }

  set result1
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain result2 result1 code results errors sql dataSource id x db \
      fileName
} -constraints \
{eagle monoBug28 command.sql compile.DATA System.Data.SQLite} -match regexp \
-result {^Ok System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 3 Ok\
System#CodeDom#Compiler#CompilerResults#\d+ \{\} 1 \{.* Connection was closed,\
statement was terminated\s.*\}$}}

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

runTestEpilogue