System.Data.SQLite

Check-in [4ebae8bc82]
Login

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

Overview
Comment:Fix-up spacing on section separators.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | tkt-e235a52c82
Files: files | file ages | folders
SHA1: 4ebae8bc8233dac2ffaf9060738e1cbcdb94ff95
User & Date: mistachkin 2013-01-29 06:35:36.132
Context
2013-01-29
06:35
Fix-up spacing on section separators. Closed-Leaf check-in: 4ebae8bc82 user: mistachkin tags: tkt-e235a52c82
05:33
Enhance test case for ticket [e235a52c82] to demonstrate the effects that different default isolation levels have on created transactions. check-in: a354a124a5 user: mistachkin tags: tkt-e235a52c82
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to Tests/tkt-e235a52c82.eagle.
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
149
150
151
152
153
154
155
156
157
158
159

160
161
162
163
164
165
166
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
149
150
151
152
153
154
155
156
157
158

159
160
161
162
163
164
165
166







-
+



















-
+













-
+














-
+



















-
+
















-
+











-
+







      {
        public sealed class Query${id}
        {
          private IDbConnection connection;
          private IDbTransaction transaction;
          private bool opened;

          ///////////////////////////////////////////////////////////////////////
          /////////////////////////////////////////////////////////////////////

          private void EnsureConnection()
          {
            if (connection == null)
            {
              connection = new SQLiteConnection("Data Source=${dataSource};" +
                  "Default IsolationLevel=${isolationLevel};");
            }

            if (connection.State == ConnectionState.Closed)
            {
              connection.Open();
              opened = true;
            }

            if (transaction == null)
              transaction = connection.BeginTransaction();
          }

          ///////////////////////////////////////////////////////////////////////
          /////////////////////////////////////////////////////////////////////

          private void ReleaseConnection()
          {
            if (connection == null)
              throw new Exception("cannot release connection");

            if (opened)
            {
              connection.Close();
              opened = false;
            }
          }

          ///////////////////////////////////////////////////////////////////////
          /////////////////////////////////////////////////////////////////////

          private IDbCommand CreateCommand(
            string commandText
            )
          {
            if (connection == null)
              throw new Exception("cannot create command");

            IDbCommand command = connection.CreateCommand();
            command.CommandText = commandText;

            return command;
          }

          ///////////////////////////////////////////////////////////////////////
          /////////////////////////////////////////////////////////////////////

          public object ExecuteReader(
            string commandText
            )
          {
            object result;
            EnsureConnection();
            IDataReader reader = null;

            try
            {
              reader = CreateCommand(commandText).ExecuteReader();
            }
            catch
            {
              ReleaseConnection();
              throw;
            }

            /////////////////////////////////////////////////////////////////////
            ///////////////////////////////////////////////////////////////////

            try
            {
              result = reader.GetValue(0);
            }
            catch
            {
              reader.Dispose();
              ReleaseConnection();
              throw;
            }

            return result;
          }
        }

        /////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////

        public static class Test${id}
        {
          public static string\[\] GetData()
          {
            return new string\[\] {
              new Query${id}().ExecuteReader("${sql}").ToString(),
              new Query${id}().ExecuteReader("${sql}").ToString()
            };
          }

          ///////////////////////////////////////////////////////////////////////
          /////////////////////////////////////////////////////////////////////

          public static void Main()
          {
            // do nothing.
          }
        }
      }