System.Data.SQLite

Check-in [c726454277]
Login

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

Overview
Comment:Add LastInsertRowId property to the connection class. Also, update docs and tests.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c726454277c13e2dbaffb5cddfb982d96ad78cb4
User & Date: mistachkin 2011-09-20 21:51:52.669
Context
2011-09-21
08:27
Allow finer control over the DateTime parsing and formatting on a per-connection basis. Also, update the Eagle library to the latest trunk. check-in: a5a8b8a682 user: mistachkin tags: trunk
2011-09-20
21:51
Add LastInsertRowId property to the connection class. Also, update docs and tests. check-in: c726454277 user: mistachkin tags: trunk
18:01
Document the official NuGet package. check-in: c505e4b0a9 user: mistachkin tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to Doc/Extra/version.html.
41
42
43
44
45
46
47

48
49

50
51
52
53
54
55
56
      </table>
    </div>
    <div id="mainSection">
    <div id="mainBody">
    <h1 class="heading">Version History</h1>
    <p><b>1.0.75.0 - September XX, 2011</b></p>
    <ul>

      <li>More enhancements to the build system.</li>
      <li>Add official <a href="http://www.nuget.org/">NuGet</a> package.</li>

      <li>Make all the assembly versioning attributes consistent.</li>
      <li>Add unit testing infrastructure using <a href="http://eagle.to/">Eagle</a>.</li>
      <li>Integrate all legacy unit tests, including the &quot;testlinq&quot; project, into the new test suite.</li>
      <li>Add projects to build the interop assembly statically linked to the Visual C++ runtime. Fix for <a href="http://system.data.sqlite.org/index.html/info/53f0c5cbf6">[53f0c5cbf6]</a>.</li>
      <li>Add SQLITE_ENABLE_STAT2 compile-time option to the interop assembly.  Fix for <a href="http://system.data.sqlite.org/index.html/info/74807fbf27">[74807fbf27]</a>.</li>
      <li>Fix mutex issues exposed when running the test suite with the debug version of SQLite.</li>
      <li>Fix transaction enlistment when repeated attempts are made to enlist in the same transaction. Fix for <a href="http://system.data.sqlite.org/index.html/info/ccfa69fc32">[ccfa69fc32]</a>.</li>







>


>







41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
      </table>
    </div>
    <div id="mainSection">
    <div id="mainBody">
    <h1 class="heading">Version History</h1>
    <p><b>1.0.75.0 - September XX, 2011</b></p>
    <ul>
      <li>Updated to SQLite 3.7.8 <a href="http://www.sqlite.org/src/info/3e0da808d2">[3e0da808d2]</a>.</li>
      <li>More enhancements to the build system.</li>
      <li>Add official <a href="http://www.nuget.org/">NuGet</a> package.</li>
      <li>Add Changes and LastInsertRowId properties to the connection class.</li>
      <li>Make all the assembly versioning attributes consistent.</li>
      <li>Add unit testing infrastructure using <a href="http://eagle.to/">Eagle</a>.</li>
      <li>Integrate all legacy unit tests, including the &quot;testlinq&quot; project, into the new test suite.</li>
      <li>Add projects to build the interop assembly statically linked to the Visual C++ runtime. Fix for <a href="http://system.data.sqlite.org/index.html/info/53f0c5cbf6">[53f0c5cbf6]</a>.</li>
      <li>Add SQLITE_ENABLE_STAT2 compile-time option to the interop assembly.  Fix for <a href="http://system.data.sqlite.org/index.html/info/74807fbf27">[74807fbf27]</a>.</li>
      <li>Fix mutex issues exposed when running the test suite with the debug version of SQLite.</li>
      <li>Fix transaction enlistment when repeated attempts are made to enlist in the same transaction. Fix for <a href="http://system.data.sqlite.org/index.html/info/ccfa69fc32">[ccfa69fc32]</a>.</li>
Changes to System.Data.SQLite/SQLite3.cs.
95
96
97
98
99
100
101








102
103
104
105
106
107
108
    internal override bool AutoCommit
    {
      get
      {
        return IsAutocommit(_sql);
      }
    }









    internal override int Changes
    {
      get
      {
        return UnsafeNativeMethods.sqlite3_changes(_sql);
      }







>
>
>
>
>
>
>
>







95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
    internal override bool AutoCommit
    {
      get
      {
        return IsAutocommit(_sql);
      }
    }

    internal override long LastInsertRowId
    {
      get
      {
        return UnsafeNativeMethods.sqlite3_last_insert_rowid(_sql);
      }
    }

    internal override int Changes
    {
      get
      {
        return UnsafeNativeMethods.sqlite3_changes(_sql);
      }
Changes to System.Data.SQLite/SQLiteBase.cs.
20
21
22
23
24
25
26




27
28
29
30
31
32
33

    static internal object _lock = new object();

    /// <summary>
    /// Returns a string representing the active version of SQLite
    /// </summary>
    internal abstract string Version { get; }




    /// <summary>
    /// Returns the number of changes the last executing insert/update caused.
    /// </summary>
    internal abstract int Changes { get; }
    /// <summary>
    /// Shutdown the SQLite engine so that it can be restarted with different config options.
    /// We depend on auto initialization to recover.







>
>
>
>







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

    static internal object _lock = new object();

    /// <summary>
    /// Returns a string representing the active version of SQLite
    /// </summary>
    internal abstract string Version { get; }
    /// <summary>
    /// Returns the rowid of the most recent successful INSERT into the database from this connection.
    /// </summary>
    internal abstract long LastInsertRowId { get; }
    /// <summary>
    /// Returns the number of changes the last executing insert/update caused.
    /// </summary>
    internal abstract int Changes { get; }
    /// <summary>
    /// Shutdown the SQLite engine so that it can be restarted with different config options.
    /// We depend on auto initialization to recover.
Changes to System.Data.SQLite/SQLiteConnection.cs.
963
964
965
966
967
968
969

















970
971
972
973
974
975
976
        return SQLiteVersion;
        //if (_connectionState != ConnectionState.Open)
        //  throw new InvalidOperationException();

        //return _sql.Version;
      }
    }


















    /// <summary>
    /// Returns the number of rows changed by the last INSERT, UPDATE, or DELETE statement executed on
    /// this connection.
    /// </summary>
#if !PLATFORM_COMPACTFRAMEWORK
    [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]







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







963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
        return SQLiteVersion;
        //if (_connectionState != ConnectionState.Open)
        //  throw new InvalidOperationException();

        //return _sql.Version;
      }
    }

    /// <summary>
    /// Returns the rowid of the most recent successful INSERT into the database from this connection.
    /// </summary>
#if !PLATFORM_COMPACTFRAMEWORK
    [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
#endif
    public long LastInsertRowId
    {
      get
      {
        if (_sql == null)
          throw new InvalidOperationException("Database connection not valid for getting last insert rowid.");

        return _sql.LastInsertRowId;
      }
    }

    /// <summary>
    /// Returns the number of rows changed by the last INSERT, UPDATE, or DELETE statement executed on
    /// this connection.
    /// </summary>
#if !PLATFORM_COMPACTFRAMEWORK
    [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
Changes to System.Data.SQLite/UnsafeNativeMethods.cs.
354
355
356
357
358
359
360







361
362
363
364
365
366
367
#if !PLATFORM_COMPACTFRAMEWORK
    [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
    [DllImport(SQLITE_DLL)]
#endif
    internal static extern void sqlite3_interrupt(IntPtr db);








#if !PLATFORM_COMPACTFRAMEWORK
    [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
    [DllImport(SQLITE_DLL)]
#endif
    internal static extern int sqlite3_changes(IntPtr db);








>
>
>
>
>
>
>







354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
#if !PLATFORM_COMPACTFRAMEWORK
    [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
    [DllImport(SQLITE_DLL)]
#endif
    internal static extern void sqlite3_interrupt(IntPtr db);

#if !PLATFORM_COMPACTFRAMEWORK
    [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
    [DllImport(SQLITE_DLL)]
#endif
    internal static extern long sqlite3_last_insert_rowid(IntPtr db);

#if !PLATFORM_COMPACTFRAMEWORK
    [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
    [DllImport(SQLITE_DLL)]
#endif
    internal static extern int sqlite3_changes(IntPtr db);

Changes to Tests/basic.eagle.
539
540
541
542
543
544
545




























































































546
547
548
549
550
551
552
} -cleanup {
  cleanupDb $fileName

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





























































































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

unset -nocomplain testExeFile testLinqExeFile northwindEfDbFile testLinqOutFile

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








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







539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
} -cleanup {
  cleanupDb $fileName

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

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

runTest {test basic-1.10 {Changes property} -setup {
  setupDb [set fileName basic-1.10.db]
} -body {
  set connection [object invoke -flags +NonPublic -objectflags +NoDispose \
      Interpreter.GetActive.connections Item $db]

  set result [list]

  sql execute $db "CREATE TABLE t1(x INTEGER PRIMARY KEY ASC, y, z);"

  sql execute $db "INSERT INTO t1 (x, y, z) VALUES(1, 'foo', 1234);"
  sql execute $db "INSERT INTO t1 (x, y, z) VALUES(2, 'bar', 5678);"
  lappend result [object invoke $connection Changes]

  sql execute $db "UPDATE t1 SET y = 'foobar';"
  lappend result [object invoke $connection Changes]

  sql execute -execute reader $db "SELECT x, y, z FROM t1;"
  lappend result [object invoke $connection Changes]

  foreach name [lsort [array names rows]] {
    lappend result [list $name $rows($name)]
  }

  set result
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain name rows result connection db fileName
} -constraints {eagle monoBug28 command.sql compile.DATA System.Data.SQLite} \
-result {1 2 2 {1 {{x 1} {y foobar} {z 1234}}} {2 {{x 2} {y foobar} {z 5678}}}\
{count 2} {names {x y z}}}}

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

runTest {test basic-1.11 {LastInsertRowId property} -setup {
  setupDb [set fileName basic-1.11.db]
} -body {
  set connection [object invoke -flags +NonPublic -objectflags +NoDispose \
      Interpreter.GetActive.connections Item $db]

  set result [list]

  sql execute $db "CREATE TABLE t1(x INTEGER PRIMARY KEY ASC, y, z);"

  sql execute $db "CREATE TABLE t2(x INTEGER PRIMARY KEY AUTOINCREMENT, y, z);"
  lappend result [object invoke $connection LastInsertRowId]

  sql execute $db "INSERT INTO t1 (x, y, z) VALUES(1, 'foo', 1234);"
  lappend result [object invoke $connection LastInsertRowId]

  sql execute $db "INSERT INTO t1 (x, y, z) VALUES(2, 'bar', 5678);"
  lappend result [object invoke $connection LastInsertRowId]

  sql execute $db "UPDATE t1 SET y = 'foobar';"
  lappend result [object invoke $connection LastInsertRowId]

  sql execute $db "INSERT INTO t2 (y, z) VALUES('foo', 1234);"
  lappend result [object invoke $connection LastInsertRowId]

  sql execute $db "INSERT INTO t2 (y, z) VALUES('bar', 5678);"
  lappend result [object invoke $connection LastInsertRowId]

  sql execute $db "UPDATE t2 SET y = 'foobar';"
  lappend result [object invoke $connection LastInsertRowId]

  sql execute -execute reader $db "SELECT x, y, z FROM t1;"
  lappend result [object invoke $connection LastInsertRowId]

  foreach name [lsort [array names rows]] {
    lappend result [list $name $rows($name)]
  }

  sql execute -execute reader $db "SELECT x, y, z FROM t2;"
  lappend result [object invoke $connection LastInsertRowId]

  foreach name [lsort [array names rows]] {
    lappend result [list $name $rows($name)]
  }

  set result
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain name rows result connection db fileName
} -constraints {eagle monoBug28 command.sql compile.DATA System.Data.SQLite} \
-result {0 1 2 2 1 2 2 2 {1 {{x 1} {y foobar} {z 1234}}} {2 {{x 2} {y foobar}\
{z 5678}}} {count 2} {names {x y z}} 2 {1 {{x 1} {y foobar} {z 1234}}} {2 {{x\
2} {y foobar} {z 5678}}} {count 2} {names {x y z}}}}

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

unset -nocomplain testExeFile testLinqExeFile northwindEfDbFile testLinqOutFile

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

Changes to readme.htm.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
</head>
<body>
ADO.NET SQLite Data Provider<br />
Version 1.0.75.0 September XX, 2011<br />
Using SQLite 3.7.8 <a href="http://www.sqlite.org/src/info/61bda876af">[61bda876af]</a><br />
Originally written by Robert Simpson<br />
Released to the public domain, use at your own risk!<br />
Official provider website:&nbsp; <a href="http://system.data.sqlite.org/">http://system.data.sqlite.org/</a><br />
Legacy versions:&nbsp; <a href="http://sqlite.phxsoftware.com/">http://sqlite.phxsoftware.com/</a><br />
<br />
The current development version can be downloaded from <a href="http://system.data.sqlite.org/index.html/timeline?n=20&y=ci">
http://system.data.sqlite.org/index.html/timeline?n=20&y=ci</a>








|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
</head>
<body>
ADO.NET SQLite Data Provider<br />
Version 1.0.75.0 September XX, 2011<br />
Using SQLite 3.7.8 <a href="http://www.sqlite.org/src/info/3e0da808d2">[3e0da808d2]</a><br />
Originally written by Robert Simpson<br />
Released to the public domain, use at your own risk!<br />
Official provider website:&nbsp; <a href="http://system.data.sqlite.org/">http://system.data.sqlite.org/</a><br />
Legacy versions:&nbsp; <a href="http://sqlite.phxsoftware.com/">http://sqlite.phxsoftware.com/</a><br />
<br />
The current development version can be downloaded from <a href="http://system.data.sqlite.org/index.html/timeline?n=20&y=ci">
http://system.data.sqlite.org/index.html/timeline?n=20&y=ci</a>
189
190
191
192
193
194
195

196
197

198
199
200
201
202
203
204

<h2><b>Version History</b></h2>

<p>
    <b>1.0.75.0 - September XX, 2011</b>
</p>
<ul>

    <li>More enhancements to the build system.</li>
    <li>Add official <a href="http://www.nuget.org/">NuGet</a> package.</li>

    <li>Make all the assembly versioning attributes consistent.</li>
    <li>Add unit testing infrastructure using <a href="http://eagle.to/">Eagle</a>.</li>
    <li>Integrate all legacy unit tests, including the &quot;testlinq&quot; project, into the new test suite.</li>
    <li>Add projects to build the interop assembly statically linked to the Visual C++ runtime. Fix for [53f0c5cbf6].</li>
    <li>Add SQLITE_ENABLE_STAT2 compile-time option to the interop assembly.  Fix for [74807fbf27].</li>
    <li>Fix mutex issues exposed when running the test suite with the debug version of SQLite.</li>
    <li>Fix transaction enlistment when repeated attempts are made to enlist in the same transaction. Fix for [ccfa69fc32].</li>







>


>







189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206

<h2><b>Version History</b></h2>

<p>
    <b>1.0.75.0 - September XX, 2011</b>
</p>
<ul>
    <li>Updated to SQLite 3.7.8 <a href="http://www.sqlite.org/src/info/3e0da808d2">[3e0da808d2]</a>.</li>
    <li>More enhancements to the build system.</li>
    <li>Add official <a href="http://www.nuget.org/">NuGet</a> package.</li>
    <li>Add Changes and LastInsertRowId properties to the connection class.</li>
    <li>Make all the assembly versioning attributes consistent.</li>
    <li>Add unit testing infrastructure using <a href="http://eagle.to/">Eagle</a>.</li>
    <li>Integrate all legacy unit tests, including the &quot;testlinq&quot; project, into the new test suite.</li>
    <li>Add projects to build the interop assembly statically linked to the Visual C++ runtime. Fix for [53f0c5cbf6].</li>
    <li>Add SQLITE_ENABLE_STAT2 compile-time option to the interop assembly.  Fix for [74807fbf27].</li>
    <li>Fix mutex issues exposed when running the test suite with the debug version of SQLite.</li>
    <li>Fix transaction enlistment when repeated attempts are made to enlist in the same transaction. Fix for [ccfa69fc32].</li>
Changes to test/TestCasesDialog.cs.
182
183
184
185
186
187
188














189
190
191
192
        _grid.Rows.Add(args.TestName, "Starting", null, null);
        _grid.FirstDisplayedScrollingRowIndex = _grid.Rows.Count - 1;
      }
    }

    private void closeButton_Click(object sender, EventArgs e)
    {














      Close();
    }
  }
}







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




182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
        _grid.Rows.Add(args.TestName, "Starting", null, null);
        _grid.FirstDisplayedScrollingRowIndex = _grid.Rows.Count - 1;
      }
    }

    private void closeButton_Click(object sender, EventArgs e)
    {
      if (_autoRun)
      {
        try
        {
          Console.Write("canceled...");
        }
        catch
        {
          // do nothing, ignored.
        }

        Environment.Exit(2);
      }

      Close();
    }
  }
}
Changes to www/news.wiki.
1
2
3
4
5
6
7
8

9
10

11
12
13
14
15
16
17
<title>News</title>

<b>Version History</b>

<p>
    <b>1.0.75.0 - September XX, 2011</b>
</p>
<ul>

    <li>More enhancements to the build system.</li>
    <li>Add official <a href="http://www.nuget.org/">NuGet</a> package.</li>

    <li>Make all the assembly versioning attributes consistent.</li>
    <li>Add unit testing infrastructure using <a href="http://eagle.to/">Eagle</a>.</li>
    <li>Integrate all legacy unit tests, including the &quot;testlinq&quot; project, into the new test suite.</li>
    <li>Add projects to build the interop assembly statically linked to the Visual C++ runtime. Fix for [53f0c5cbf6].</li>
    <li>Add SQLITE_ENABLE_STAT2 compile-time option to the interop assembly. Fix for [74807fbf27].</li>
    <li>Fix mutex issues exposed when running the test suite with the debug version of SQLite.</li>
    <li>Fix transaction enlistment when repeated attempts are made to enlist in the same transaction. Fix for [ccfa69fc32].</li>








>


>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<title>News</title>

<b>Version History</b>

<p>
    <b>1.0.75.0 - September XX, 2011</b>
</p>
<ul>
    <li>Updated to SQLite 3.7.8 <a href="http://www.sqlite.org/src/info/3e0da808d2">[3e0da808d2]</a>.</li>
    <li>More enhancements to the build system.</li>
    <li>Add official <a href="http://www.nuget.org/">NuGet</a> package.</li>
    <li>Add Changes and LastInsertRowId properties to the connection class.</li>
    <li>Make all the assembly versioning attributes consistent.</li>
    <li>Add unit testing infrastructure using <a href="http://eagle.to/">Eagle</a>.</li>
    <li>Integrate all legacy unit tests, including the &quot;testlinq&quot; project, into the new test suite.</li>
    <li>Add projects to build the interop assembly statically linked to the Visual C++ runtime. Fix for [53f0c5cbf6].</li>
    <li>Add SQLITE_ENABLE_STAT2 compile-time option to the interop assembly. Fix for [74807fbf27].</li>
    <li>Fix mutex issues exposed when running the test suite with the debug version of SQLite.</li>
    <li>Fix transaction enlistment when repeated attempts are made to enlist in the same transaction. Fix for [ccfa69fc32].</li>