System.Data.SQLite

Check-in [3f4c3359f3]
Login

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

Overview
Comment:Add test case for ticket [ae5267b863].
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | tkt-ae5267b863
Files: files | file ages | folders
SHA1: 3f4c3359f3328f7ac8c72524ef2e34537b025e74
User & Date: mistachkin 2012-12-17 23:14:37.156
Context
2012-12-17
23:44
Enhance the test case for [ae5267b863] to increase the odds of hitting the underlying object disposal issue. check-in: 838feb48ec user: mistachkin tags: tkt-ae5267b863
23:14
Add test case for ticket [ae5267b863]. check-in: 3f4c3359f3 user: mistachkin tags: tkt-ae5267b863
22:53
Fix typo in comment. check-in: 82dedce10b user: mistachkin tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Added Tests/tkt-ae5267b863.eagle.








































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
###############################################################################
#
# tkt-ae5267b863.eagle --
#
# Written by Joe Mistachkin.
# Released to the public domain, use at your own risk!
#
###############################################################################

package require Eagle
package require Eagle.Library
package require Eagle.Test

runTestPrologue

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

package require System.Data.SQLite.Test
runSQLiteTestPrologue

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

runTest {test tkt-ae5267b863-1.1 {segfault during command GC} -setup {
  setupDb [set fileName tkt-ae5267b863-1.1.db]
} -body {
  set id [object invoke Interpreter.GetActive NextId]
  set dataSource [file join [getDatabaseDirectory] $fileName]

  set sql(1) { \
    CREATE TABLE t1( \
      __rowid INTEGER PRIMARY KEY AUTOINCREMENT, \
      z STRING \
    ); \
  }

  set sql(2) { \
    CREATE VIRTUAL TABLE t2 USING RTREE( \
      id, minx, maxx, miny, maxy \
    ); \
  }

  set sql(3) { \
    INSERT INTO t1 VALUES({0}, \"value {0}\"); \
  }

  set sql(4) { \
    INSERT INTO t2 VALUES({0}, {0}, {0}, {0}, {0}); \
  }

  set sql(5) { \
    SELECT COUNT(*) FROM t1, t2 \
    WHERE t1.__rowid = t2.id AND \
    (t2.minx <= :xmax and t2.miny <= :ymax and \
     t2.maxx >= :xmin and t2.maxy >= :ymin); \
  }

  unset -nocomplain results errors

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

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

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

              command.CommandText = "${sql(2)}";
              command.ExecuteNonQuery();
            }

            using (SQLiteCommand command = connection.CreateCommand())
            {
              using (SQLiteTransaction transaction =
                  connection.BeginTransaction())
              {
                for (int index = 0; index < 10; index++)
                {
                  command.CommandText = String.Format("${sql(3)}", index);
                  command.ExecuteNonQuery();

                  command.CommandText = String.Format("${sql(4)}", index);
                  command.ExecuteNonQuery();
                }

                transaction.Commit();
              }
            }

            for (int index = 0; index < 10000; index++)
            {
              //
              // NOTE: Purposely omit the 'using' block here to test
              //       command disposal via the garbage collector.
              //
              SQLiteCommand command = connection.CreateCommand();

              command.CommandText = "${sql(5)}";
              command.Parameters.Add(new SQLiteParameter(":xmin", 2));
              command.Parameters.Add(new SQLiteParameter(":xmax", 8));
              command.Parameters.Add(new SQLiteParameter(":ymin", 2));
              command.Parameters.Add(new SQLiteParameter(":ymax", 8));

              using (SQLiteDataReader reader = command.ExecuteReader())
              {
                while (reader.Read()) {
                  //
                  // do nothing.
                  //
                }
              }
            }

            connection.Close();
          }
        }
      }
    }
  }] true true true results errors System.Data.SQLite.dll]

  list $code $results \
      [expr {[info exists errors] ? $errors : ""}] \
      [expr {$code eq "Ok" ? [catch {
        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