System.Data.SQLite

Check-in [b438f19d0c]
Login

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

Overview
Comment:1.0.38.0
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | sourceforge
Files: files | file ages | folders
SHA1: b438f19d0c71021f49e4f24715b7e817e3face6c
User & Date: rmsimpson 2006-11-22 07:13:35.000
Context
2006-11-22
07:30
Corrected date check-in: 168625c7ec user: rmsimpson tags: sourceforge
07:13
1.0.38.0 check-in: b438f19d0c user: rmsimpson tags: sourceforge
06:42
1.0.38.0 check-in: 7c57929567 user: rmsimpson tags: sourceforge
Changes
Unified Diff Ignore Whitespace Patch
Changes to Doc/Extra/dbfactorysupport.html.
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<configuration>
  <system.data>
    <DbProviderFactories>
      <remove invariant="System.Data.SQLite"/>
      <add name="SQLite Data Provider" invariant="System.Data.SQLite" 
           description=".Net Framework Data Provider for SQLite"
           type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite,
                 Version=1.0.37.0, Culture=neutral,
                 PublicKeyToken=db937bc2d44ff139"/>
    </DbProviderFactories>
  </system.data>
</configuration>
</pre>
      </div>
      <p>







|







93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
&lt;configuration&gt;
  &lt;system.data&gt;
    &lt;DbProviderFactories&gt;
      &lt;remove invariant="System.Data.SQLite"/&gt;
      &lt;add name="SQLite Data Provider" invariant="System.Data.SQLite" 
           description=".Net Framework Data Provider for SQLite"
           type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite,
                 Version=1.0.38.0, Culture=neutral,
                 PublicKeyToken=db937bc2d44ff139"/&gt;
    &lt;/DbProviderFactories&gt;
  &lt;/system.data&gt;
&lt;/configuration&gt;
</pre>
      </div>
      <p>
Changes to Doc/Extra/version.html.
52
53
54
55
56
57
58






59
60
61
62
63
64
65
        </tr>
      </table>
    </div>
    <div id="mainSection">
    <div id="mainBody">

      <h1 class="heading">Version History</h1>






    <p><b>1.0.37.0 - November 19, 2006</b></p>
    <ul>
    <li>Added support for CommandBehavior.KeyInfo.&nbsp; 
      When specified in a query, additional column(s) will be returned describing the
      key(s) defined for the table(s) selected in the query.&nbsp; This is optimized when
      INTEGER PRIMARY KEY is set for the given tables, but does additional work for other
      kinds of primary keys.</li>







>
>
>
>
>
>







52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
        </tr>
      </table>
    </div>
    <div id="mainSection">
    <div id="mainBody">

      <h1 class="heading">Version History</h1>
    <p><b>1.0.38.0 - November 22, 2006</b></p>
    <ul>
    <li>Fixed a bug when using CommandBehavior.KeyInfo whereby integer primary key columns may be duplicated in the results. </li>
      <li>Enhanced the CommandBuilder so that update/delete statements are optimized when the affected table contains unique constraints and
      a primary key is present.</li>
      <li>Fixed a bug in the DataReader when used in conjunction with CommandBehavior.CloseConnection.</li></ul>
    <p><b>1.0.37.0 - November 19, 2006</b></p>
    <ul>
    <li>Added support for CommandBehavior.KeyInfo.&nbsp; 
      When specified in a query, additional column(s) will be returned describing the
      key(s) defined for the table(s) selected in the query.&nbsp; This is optimized when
      INTEGER PRIMARY KEY is set for the given tables, but does additional work for other
      kinds of primary keys.</li>
Changes to Doc/SQLite.NET.chm.

cannot compute difference between binary files

Changes to SQLite.Interop/SQLite.Interop.rc.
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

/////////////////////////////////////////////////////////////////////////////
//
// Version
//

VS_VERSION_INFO VERSIONINFO
 FILEVERSION 1,0,37,0
 PRODUCTVERSION 1,0,0,0
 FILEFLAGSMASK 0x17L
#ifdef _DEBUG
 FILEFLAGS 0x1L
#else
 FILEFLAGS 0x0L
#endif
 FILEOS 0x4L
 FILETYPE 0x2L
 FILESUBTYPE 0x0L
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904b0"
        BEGIN
            VALUE "Comments", "http://sqlite.phxsoftware.com"
            VALUE "FileDescription", "System.Data.SQLite Interop Library"
            VALUE "FileVersion", "1.0.37.0"
            VALUE "InternalName", "SQLite.Interop.DLL"
            VALUE "LegalCopyright", "Released to the public domain"
            VALUE "OriginalFilename", "SQLite3.DLL 3.3.8"
            VALUE "ProductName", "System.Data.SQLite"
            VALUE "ProductVersion", "1.0"
        END
    END







|

















|







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

/////////////////////////////////////////////////////////////////////////////
//
// Version
//

VS_VERSION_INFO VERSIONINFO
 FILEVERSION 1,0,38,0
 PRODUCTVERSION 1,0,0,0
 FILEFLAGSMASK 0x17L
#ifdef _DEBUG
 FILEFLAGS 0x1L
#else
 FILEFLAGS 0x0L
#endif
 FILEOS 0x4L
 FILETYPE 0x2L
 FILESUBTYPE 0x0L
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904b0"
        BEGIN
            VALUE "Comments", "http://sqlite.phxsoftware.com"
            VALUE "FileDescription", "System.Data.SQLite Interop Library"
            VALUE "FileVersion", "1.0.38.0"
            VALUE "InternalName", "SQLite.Interop.DLL"
            VALUE "LegalCopyright", "Released to the public domain"
            VALUE "OriginalFilename", "SQLite3.DLL 3.3.8"
            VALUE "ProductName", "System.Data.SQLite"
            VALUE "ProductVersion", "1.0"
        END
    END
Changes to SQLite.Interop/SQLite.Interop.vcproj.
138
139
140
141
142
143
144


145
146
147
148
149
150
151
			<Tool
				Name="VCMIDLTool"
			/>
			<Tool
				Name="VCCLCompilerTool"
				ExecutionBucket="7"
				PreprocessorDefinitions="_WIN32_WCE=$(CEVER);UNDER_CE=$(CEVER);WINCE;$(PLATFORMDEFINES);NDEBUG;_WINDOWS;_USRDLL;CPPSMART_EXPORTS;$(ARCHFAM);$(_ARCHFAM_);UNICODE;_UNICODE;SQLITE_HAS_CODEC;SQLITE_ENABLE_COLUMN_METADATA;SQLITE_ENABLE_FTS1"


				BufferSecurityCheck="false"
			/>
			<Tool
				Name="VCManagedResourceCompilerTool"
			/>
			<Tool
				Name="VCResourceCompilerTool"







>
>







138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
			<Tool
				Name="VCMIDLTool"
			/>
			<Tool
				Name="VCCLCompilerTool"
				ExecutionBucket="7"
				PreprocessorDefinitions="_WIN32_WCE=$(CEVER);UNDER_CE=$(CEVER);WINCE;$(PLATFORMDEFINES);NDEBUG;_WINDOWS;_USRDLL;CPPSMART_EXPORTS;$(ARCHFAM);$(_ARCHFAM_);UNICODE;_UNICODE;SQLITE_HAS_CODEC;SQLITE_ENABLE_COLUMN_METADATA;SQLITE_ENABLE_FTS1"
				StringPooling="true"
				ExceptionHandling="0"
				BufferSecurityCheck="false"
			/>
			<Tool
				Name="VCManagedResourceCompilerTool"
			/>
			<Tool
				Name="VCResourceCompilerTool"
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
				Optimization="2"
				FavorSizeOrSpeed="1"
				PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;NO_TCL;THREADSAFE=1;WIN64;SQLITE_HAS_CODEC;SQLITE_ENABLE_COLUMN_METADATA;SQLITE_ENABLE_FTS1"
				StringPooling="true"
				ExceptionHandling="0"
				BufferSecurityCheck="false"
				EnableFunctionLevelLinking="true"
				FloatingPointModel="2"
				RuntimeTypeInfo="false"
			/>
			<Tool
				Name="VCManagedResourceCompilerTool"
			/>
			<Tool
				Name="VCResourceCompilerTool"







<







230
231
232
233
234
235
236

237
238
239
240
241
242
243
				Optimization="2"
				FavorSizeOrSpeed="1"
				PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;NO_TCL;THREADSAFE=1;WIN64;SQLITE_HAS_CODEC;SQLITE_ENABLE_COLUMN_METADATA;SQLITE_ENABLE_FTS1"
				StringPooling="true"
				ExceptionHandling="0"
				BufferSecurityCheck="false"
				EnableFunctionLevelLinking="true"

				RuntimeTypeInfo="false"
			/>
			<Tool
				Name="VCManagedResourceCompilerTool"
			/>
			<Tool
				Name="VCResourceCompilerTool"
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
				Optimization="2"
				FavorSizeOrSpeed="1"
				PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;NO_TCL;THREADSAFE=1;WIN64;SQLITE_HAS_CODEC;SQLITE_ENABLE_COLUMN_METADATA;SQLITE_ENABLE_FTS1"
				StringPooling="true"
				ExceptionHandling="0"
				BufferSecurityCheck="false"
				EnableFunctionLevelLinking="true"
				FloatingPointModel="2"
				RuntimeTypeInfo="false"
			/>
			<Tool
				Name="VCManagedResourceCompilerTool"
			/>
			<Tool
				Name="VCResourceCompilerTool"







<







318
319
320
321
322
323
324

325
326
327
328
329
330
331
				Optimization="2"
				FavorSizeOrSpeed="1"
				PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;NO_TCL;THREADSAFE=1;WIN64;SQLITE_HAS_CODEC;SQLITE_ENABLE_COLUMN_METADATA;SQLITE_ENABLE_FTS1"
				StringPooling="true"
				ExceptionHandling="0"
				BufferSecurityCheck="false"
				EnableFunctionLevelLinking="true"

				RuntimeTypeInfo="false"
			/>
			<Tool
				Name="VCManagedResourceCompilerTool"
			/>
			<Tool
				Name="VCResourceCompilerTool"
Changes to SQLite.Interop/merge.h.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// This code was automatically generated from assembly
// C:\Src\SQLite.NET\System.Data.SQLite\bin\CompactFramework\System.Data.SQLite.dll

#include <windef.h>

#pragma data_seg(".clr")
#pragma comment(linker, "/SECTION:.clr,ER")
  char __ph[127536] = {0}; // The number of bytes to reserve
#pragma data_seg()

typedef BOOL (WINAPI *DLLMAIN)(HANDLE, DWORD, LPVOID);
typedef struct EXTRA_STUFF
{
  DWORD dwNativeEntryPoint;
} EXTRA_STUFF, *LPEXTRA_STUFF;







|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// This code was automatically generated from assembly
// C:\Src\SQLite.NET\System.Data.SQLite\bin\CompactFramework\System.Data.SQLite.dll

#include <windef.h>

#pragma data_seg(".clr")
#pragma comment(linker, "/SECTION:.clr,ER")
  char __ph[128212] = {0}; // The number of bytes to reserve
#pragma data_seg()

typedef BOOL (WINAPI *DLLMAIN)(HANDLE, DWORD, LPVOID);
typedef struct EXTRA_STUFF
{
  DWORD dwNativeEntryPoint;
} EXTRA_STUFF, *LPEXTRA_STUFF;
Changes to SQLite.Interop/merge_full.h.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// This code was automatically generated from assembly
// C:\Src\SQLite.NET\System.Data.SQLite\bin\System.Data.SQLite.dll

#include <windef.h>

#pragma data_seg(".clr")
#pragma comment(linker, "/SECTION:.clr,ER")
  char __ph[136744] = {0}; // The number of bytes to reserve
#pragma data_seg()

typedef BOOL (WINAPI *DLLMAIN)(HANDLE, DWORD, LPVOID);
typedef struct EXTRA_STUFF
{
  DWORD dwNativeEntryPoint;
} EXTRA_STUFF, *LPEXTRA_STUFF;







|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// This code was automatically generated from assembly
// C:\Src\SQLite.NET\System.Data.SQLite\bin\System.Data.SQLite.dll

#include <windef.h>

#pragma data_seg(".clr")
#pragma comment(linker, "/SECTION:.clr,ER")
  char __ph[137404] = {0}; // The number of bytes to reserve
#pragma data_seg()

typedef BOOL (WINAPI *DLLMAIN)(HANDLE, DWORD, LPVOID);
typedef struct EXTRA_STUFF
{
  DWORD dwNativeEntryPoint;
} EXTRA_STUFF, *LPEXTRA_STUFF;
Changes to System.Data.SQLite/AssemblyInfo.cs.
44
45
46
47
48
49
50
51
52
53
54
//      Major Version
//      Minor Version 
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Revision and Build Numbers 
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.37.0")]
#if !PLATFORM_COMPACTFRAMEWORK
[assembly: AssemblyFileVersion("1.0.37.0")]
#endif







|

|

44
45
46
47
48
49
50
51
52
53
54
//      Major Version
//      Minor Version 
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Revision and Build Numbers 
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.38.0")]
#if !PLATFORM_COMPACTFRAMEWORK
[assembly: AssemblyFileVersion("1.0.38.0")]
#endif
Changes to System.Data.SQLite/SQLiteCommandBuilder.cs.
285
286
287
288
289
290
291
















































292
293
        return base.SchemaSeparator;
      }
      set
      {
        base.SchemaSeparator = value;
      }
    }
















































  }
}







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


285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
        return base.SchemaSeparator;
      }
      set
      {
        base.SchemaSeparator = value;
      }
    }

    /// <summary>
    /// Override helper, which can help the base command builder choose the right keys for the given query
    /// </summary>
    /// <param name="sourceCommand"></param>
    /// <returns></returns>
    protected override DataTable GetSchemaTable(DbCommand sourceCommand)
    {
      using (IDataReader reader = sourceCommand.ExecuteReader(CommandBehavior.KeyInfo | CommandBehavior.SchemaOnly))
      {
        DataTable schema = reader.GetSchemaTable();

        // If the query contains a primary key, turn off the IsUnique property
        // for all the non-key columns
        if (HasSchemaPrimaryKey(schema))
          ResetIsUniqueSchemaColumn(schema);

        // if table has no primary key we use unique columns as a fall back
        return schema;
      }
    }

    private bool HasSchemaPrimaryKey(DataTable schema)
    {
      DataColumn IsKeyColumn = schema.Columns[SchemaTableColumn.IsKey];
      
      foreach (DataRow schemaRow in schema.Rows)
      {
        if ((bool)schemaRow[IsKeyColumn] == true)
          return true;
      }

      return false;
    }

    private void ResetIsUniqueSchemaColumn(DataTable schema)
    {
      DataColumn IsUniqueColumn = schema.Columns[SchemaTableColumn.IsUnique];
      DataColumn IsKeyColumn = schema.Columns[SchemaTableColumn.IsKey];

      foreach (DataRow schemaRow in schema.Rows)
      {
        if ((bool)schemaRow[IsKeyColumn] == false)
          schemaRow[IsUniqueColumn] = false;
      }

      schema.AcceptChanges();
    }
  }
}
Changes to System.Data.SQLite/SQLiteConnection.cs.
86
87
88
89
90
91
92


93
94
95
96
97
98
99
  /// <description>N</description>
  /// <description>Y</description>
  /// </item>
  /// </list>
  /// </remarks>
  public sealed class SQLiteConnection : DbConnection, ICloneable
  {


    /// <summary>
    /// State of the current connection
    /// </summary>
    private ConnectionState      _connectionState;
    /// <summary>
    /// The connection string
    /// </summary>







>
>







86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
  /// <description>N</description>
  /// <description>Y</description>
  /// </item>
  /// </list>
  /// </remarks>
  public sealed class SQLiteConnection : DbConnection, ICloneable
  {
    private const string _dataDirectory = "|DataDirectory|";

    /// <summary>
    /// State of the current connection
    /// </summary>
    private ConnectionState      _connectionState;
    /// <summary>
    /// The connection string
    /// </summary>
452
453
454
455
456
457
458




459
460
461
462
463
464
465
466
467
468
469
470
    /// <summary>
    /// When the database connection is closed, all commands linked to this connection are automatically reset.
    /// </summary>
    public override void Close()
    {
      if (_sql != null)
      {




        int x = _commandList.Count;
        for (int n = 0; n < x; n++)
        {
          _commandList[n].ClearCommands();
        }

#if !PLATFORM_COMPACTFRAMEWORK
        if (_enlistment != null)
        {
          // If the connection is enlisted in a transaction scope and the scope is still active,
          // we cannot truly shut down this connection until the scope has completed.  Therefore make a 
          // hidden connection temporarily to hold open the connection until the scope has completed.







>
>
>
>
|
<
<
|
<







454
455
456
457
458
459
460
461
462
463
464
465


466

467
468
469
470
471
472
473
    /// <summary>
    /// When the database connection is closed, all commands linked to this connection are automatically reset.
    /// </summary>
    public override void Close()
    {
      if (_sql != null)
      {
        // Force any commands associated with this connection to release their unmanaged
        // resources.  The commands are still valid and will automatically re-acquire the
        // unmanaged resources the next time they are run -- provided this connection is
        // re-opened before then.
        foreach(SQLiteCommand cmd in _commandList)


          cmd.ClearCommands();


#if !PLATFORM_COMPACTFRAMEWORK
        if (_enlistment != null)
        {
          // If the connection is enlisted in a transaction scope and the scope is still active,
          // we cannot truly shut down this connection until the scope has completed.  Therefore make a 
          // hidden connection temporarily to hold open the connection until the scope has completed.
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907

      if (databasePassword != null)
        if (databasePassword.Length == 0) databasePassword = null;

      _password = databasePassword;
    }

    private const string _dataDirectory = "|DataDirectory|";

    /// <summary>
    /// Expand the filename of the data source, resolving the |DataDirectory| macro as appropriate.
    /// </summary>
    /// <param name="sourceFile">The database filename to expand</param>
    /// <returns>The expanded path and filename of the filename</returns>
    private string ExpandFileName(string sourceFile)
    {







<
<







895
896
897
898
899
900
901


902
903
904
905
906
907
908

      if (databasePassword != null)
        if (databasePassword.Length == 0) databasePassword = null;

      _password = databasePassword;
    }



    /// <summary>
    /// Expand the filename of the data source, resolving the |DataDirectory| macro as appropriate.
    /// </summary>
    /// <param name="sourceFile">The database filename to expand</param>
    /// <returns>The expanded path and filename of the filename</returns>
    private string ExpandFileName(string sourceFile)
    {
Changes to System.Data.SQLite/SQLiteDataReader.cs.
93
94
95
96
97
98
99




100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
      if (_command != null)
      {
        while (NextResult())
        {
        }
        _command.ClearDataReader();





        if (_disposeCommand)
          ((IDisposable)_command).Dispose();
      }

      // If the datareader's behavior includes closing the connection, then do so here.
      if ((_commandBehavior & CommandBehavior.CloseConnection) != 0 && _command.Connection != null)
        _command.Connection.Close();

      _command = null;
      _activeStatement = null;
      _fieldTypeArray = null;

      if (_keyInfo != null)
      {
        _keyInfo.Dispose();







>
>
>
>




<
<
<
<







93
94
95
96
97
98
99
100
101
102
103
104
105
106
107




108
109
110
111
112
113
114
      if (_command != null)
      {
        while (NextResult())
        {
        }
        _command.ClearDataReader();

        // If the datareader's behavior includes closing the connection, then do so here.
        if ((_commandBehavior & CommandBehavior.CloseConnection) != 0 && _command.Connection != null)
          _command.Connection.Close();

        if (_disposeCommand)
          ((IDisposable)_command).Dispose();
      }





      _command = null;
      _activeStatement = null;
      _fieldTypeArray = null;

      if (_keyInfo != null)
      {
        _keyInfo.Dispose();
692
693
694
695
696
697
698

699

700
701
702
703
704
705
706
                (string)rowIndexes["INDEX_NAME"],
                null
                });
              foreach (DataRow rowColumnIndex in tblIndexColumns.Rows)
              {
                if (String.Compare((string)rowColumnIndex["COLUMN_NAME"], strColumn, true, CultureInfo.InvariantCulture) == 0)
                {

                  if (tblIndexColumns.Rows.Count == 1) row[SchemaTableColumn.IsUnique] = rowIndexes["UNIQUE"];

                  break;
                }
              }
            }
          }
        }
        







>
|
>







692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
                (string)rowIndexes["INDEX_NAME"],
                null
                });
              foreach (DataRow rowColumnIndex in tblIndexColumns.Rows)
              {
                if (String.Compare((string)rowColumnIndex["COLUMN_NAME"], strColumn, true, CultureInfo.InvariantCulture) == 0)
                {
                  if (tblIndexColumns.Rows.Count == 1 && (bool)row[SchemaTableColumn.AllowDBNull] == false)
                    row[SchemaTableColumn.IsUnique] = rowIndexes["UNIQUE"];

                  break;
                }
              }
            }
          }
        }
        
Changes to bin/Designer/SQLite.Designer.dll.

cannot compute difference between binary files

Changes to bin/Designer/install.exe.

cannot compute difference between binary files

Changes to readme.htm.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title></title>
  </head>
  <body>
    ADO.NET 2.0 SQLite Data Provider<br>
    Version 1.0.37.0 November 19, 2006<br>
    Using SQLite 3.3.8<br>
    Written by Robert Simpson (<a href="mailto:robert@blackcastlesoft.com">robert@blackcastlesoft.com</a>)<br>
    Released to the public domain, use at your own risk!<br>
    Official provider website:&nbsp; <a href="http://sqlite.phxsoftware.com">http://sqlite.phxsoftware.com</a><br />
    <br>
    The latest version can be downloaded <a href="http://sourceforge.net/projects/sqlite-dotnet2">
      here</a>







|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title></title>
  </head>
  <body>
    ADO.NET 2.0 SQLite Data Provider<br>
    Version 1.0.38.0 November 19, 2006<br>
    Using SQLite 3.3.8<br>
    Written by Robert Simpson (<a href="mailto:robert@blackcastlesoft.com">robert@blackcastlesoft.com</a>)<br>
    Released to the public domain, use at your own risk!<br>
    Official provider website:&nbsp; <a href="http://sqlite.phxsoftware.com">http://sqlite.phxsoftware.com</a><br />
    <br>
    The latest version can be downloaded <a href="http://sourceforge.net/projects/sqlite-dotnet2">
      here</a>
116
117
118
119
120
121
122






123
124
125
126
127
128
129
      The SQLite3 source code is compiled directly from the SQLite.org release
      sources.&nbsp; All builds of sqlite after 3.2.8 have included support for Windows CE.&nbsp; Additionally,
      just one minor modification is made to pager.c, that modification is made automatically by the fixsource.vbs file
      when the VS2005 solution is compiled.</p>
    <p></p>
    <p>
      <b>Version History</b></p>






    <p><b>1.0.37.0 - November 19, 2006</b></p>
    <ul>
    <li>Added support for CommandBehavior.KeyInfo.&nbsp; 
      When specified in a query, additional column(s) will be returned describing the
      key(s) defined for the table(s) selected in the query.&nbsp; This is optimized when
      INTEGER PRIMARY KEY is set for the given tables, but does additional work for other
      kinds of primary keys.</li>







>
>
>
>
>
>







116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
      The SQLite3 source code is compiled directly from the SQLite.org release
      sources.&nbsp; All builds of sqlite after 3.2.8 have included support for Windows CE.&nbsp; Additionally,
      just one minor modification is made to pager.c, that modification is made automatically by the fixsource.vbs file
      when the VS2005 solution is compiled.</p>
    <p></p>
    <p>
      <b>Version History</b></p>
    <p><b>1.0.38.0 - November 22, 2006</b></p>
    <ul>
    <li>Fixed a bug when using CommandBehavior.KeyInfo whereby integer primary key columns may be duplicated in the results. </li>
      <li>Enhanced the CommandBuilder so that update/delete statements are optimized when the affected table contains unique constraints and
      a primary key is present.</li>
      <li>Fixed a bug in the DataReader when used in conjunction with CommandBehavior.CloseConnection.</li></ul>
    <p><b>1.0.37.0 - November 19, 2006</b></p>
    <ul>
    <li>Added support for CommandBehavior.KeyInfo.&nbsp; 
      When specified in a query, additional column(s) will be returned describing the
      key(s) defined for the table(s) selected in the query.&nbsp; This is optimized when
      INTEGER PRIMARY KEY is set for the given tables, but does additional work for other
      kinds of primary keys.</li>
Changes to test/TestCases.cs.
84
85
86
87
88
89
90



91
92
93
94
95
96
97
    {
      Console.WriteLine("\r\nBeginning Test on " + cnn.GetType().ToString());
      try { CreateTable(cnn); Console.WriteLine("SUCCESS - CreateTable"); }
      catch (Exception) { Console.WriteLine("FAIL - CreateTable"); }

      try { FullTextTest(cnn); Console.WriteLine("SUCCESS - Full Text Search"); }
      catch (Exception) { Console.WriteLine("FAIL - Full Text Search"); }




      try { TransactionTest(cnn); Console.WriteLine("SUCCESS - Transaction Enlistment"); }
      catch (Exception) { Console.WriteLine("FAIL - Transaction Enlistment"); }

      try { GuidTest(cnn); Console.WriteLine("SUCCESS - Guid Test"); }
      catch (Exception) { Console.WriteLine("FAIL - Guid Test"); }








>
>
>







84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
    {
      Console.WriteLine("\r\nBeginning Test on " + cnn.GetType().ToString());
      try { CreateTable(cnn); Console.WriteLine("SUCCESS - CreateTable"); }
      catch (Exception) { Console.WriteLine("FAIL - CreateTable"); }

      try { FullTextTest(cnn); Console.WriteLine("SUCCESS - Full Text Search"); }
      catch (Exception) { Console.WriteLine("FAIL - Full Text Search"); }

      try { KeyInfoTest(fact, cnn); Console.WriteLine("SUCCESS - KeyInfo Fetch"); }
      catch (Exception) { Console.WriteLine("FAIL - KeyInfo Fetch"); }

      try { TransactionTest(cnn); Console.WriteLine("SUCCESS - Transaction Enlistment"); }
      catch (Exception) { Console.WriteLine("FAIL - Transaction Enlistment"); }

      try { GuidTest(cnn); Console.WriteLine("SUCCESS - Guid Test"); }
      catch (Exception) { Console.WriteLine("FAIL - Guid Test"); }

115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130

      try { LockTest(cnn); Console.WriteLine("SUCCESS - LockTest"); }
      catch (Exception) { Console.WriteLine("FAIL - LockTest"); }

      try { ParameterizedInsertMissingParams(cnn); Console.WriteLine("FAIL - ParameterizedInsertMissingParams\r\n"); }
      catch (Exception) { Console.WriteLine("SUCCESS - ParameterizedInsertMissingParams\r\n"); }

//      try { TimeoutTest(cnn); Console.WriteLine("SUCCESS - TimeoutTest"); }
//      catch (Exception) { Console.WriteLine("FAIL - TimeoutTest"); }

      try { DataAdapter(fact, cnn, false); Console.WriteLine(""); }
      catch (Exception) { Console.WriteLine("FAIL - DataAdapter"); }

      try { DataAdapter(fact, cnn, true); Console.WriteLine(""); }
      catch (Exception) { Console.WriteLine("FAIL - DataAdapterWithIdentityFetch"); }








|
|







118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133

      try { LockTest(cnn); Console.WriteLine("SUCCESS - LockTest"); }
      catch (Exception) { Console.WriteLine("FAIL - LockTest"); }

      try { ParameterizedInsertMissingParams(cnn); Console.WriteLine("FAIL - ParameterizedInsertMissingParams\r\n"); }
      catch (Exception) { Console.WriteLine("SUCCESS - ParameterizedInsertMissingParams\r\n"); }

      //try { TimeoutTest(cnn); Console.WriteLine("SUCCESS - TimeoutTest"); }
      //catch (Exception) { Console.WriteLine("FAIL - TimeoutTest"); }

      try { DataAdapter(fact, cnn, false); Console.WriteLine(""); }
      catch (Exception) { Console.WriteLine("FAIL - DataAdapter"); }

      try { DataAdapter(fact, cnn, true); Console.WriteLine(""); }
      catch (Exception) { Console.WriteLine("FAIL - DataAdapterWithIdentityFetch"); }

144
145
146
147
148
149
150




































































151
152
153
154
155
156
157
      catch (Exception) { Console.WriteLine("FAIL - UserCollation"); }

      try { DropTable(cnn); Console.WriteLine("SUCCESS - DropTable"); }
      catch (Exception) { Console.WriteLine("FAIL - DropTable"); }

      Console.WriteLine("\r\nTests Finished.");
    }





































































    internal static void FullTextTest(DbConnection cnn)
    {
      using (DbCommand cmd = cnn.CreateCommand())
      {
        cmd.CommandText = "CREATE VIRTUAL TABLE FullText USING FTS1(name, ingredients);";
        cmd.ExecuteNonQuery();







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







147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
      catch (Exception) { Console.WriteLine("FAIL - UserCollation"); }

      try { DropTable(cnn); Console.WriteLine("SUCCESS - DropTable"); }
      catch (Exception) { Console.WriteLine("FAIL - DropTable"); }

      Console.WriteLine("\r\nTests Finished.");
    }

    internal static void KeyInfoTest(DbProviderFactory fact, DbConnection cnn)
    {
      using (DbCommand cmd = cnn.CreateCommand())
      {
        // First test against integer primary key (optimized) keyinfo fetch
        cmd.CommandText = "Create table keyinfotest (id integer primary key, myuniquevalue integer unique not null, myvalue varchar(50))";
        cmd.ExecuteNonQuery();

        cmd.CommandText = "Select * from keyinfotest";
        using (DbDataReader reader = cmd.ExecuteReader(CommandBehavior.KeyInfo | CommandBehavior.SchemaOnly))
        {
          using (DataTable tbl = reader.GetSchemaTable())
          {
            if (tbl.Rows.Count != 3) throw new ArgumentOutOfRangeException("Wrong number of columns returned");
          }
        }

        cmd.CommandText = "SELECT MyValue FROM keyinfotest";
        using (DbDataReader reader = cmd.ExecuteReader(CommandBehavior.KeyInfo | CommandBehavior.SchemaOnly))
        {
          using (DataTable tbl = reader.GetSchemaTable())
          {
            if (tbl.Rows.Count != 2) throw new ArgumentOutOfRangeException("Wrong number of columns returned");
          }
        }

        cmd.CommandText = "DROP TABLE keyinfotest";
        cmd.ExecuteNonQuery();

        // Now test against non-integer primary key (unoptimized) subquery keyinfo fetch
        cmd.CommandText = "Create table keyinfotest (id char primary key, myuniquevalue integer unique not null, myvalue varchar(50))";
        cmd.ExecuteNonQuery();

        cmd.CommandText = "SELECT MyValue FROM keyinfotest";
        using (DbDataReader reader = cmd.ExecuteReader(CommandBehavior.KeyInfo | CommandBehavior.SchemaOnly))
        {
          using (DataTable tbl = reader.GetSchemaTable())
          {
            if (tbl.Rows.Count != 2) throw new ArgumentOutOfRangeException("Wrong number of columns returned");
          }
        }

        cmd.CommandText = "Select * from keyinfotest";
        using (DbDataReader reader = cmd.ExecuteReader(CommandBehavior.KeyInfo | CommandBehavior.SchemaOnly))
        {
          using (DataTable tbl = reader.GetSchemaTable())
          {
            if (tbl.Rows.Count != 3) throw new ArgumentOutOfRangeException("Wrong number of columns returned");
          }
        }

        // Make sure commandbuilder can generate an update command with the correct parameter count
        using (DbDataAdapter adp = fact.CreateDataAdapter())
        using (DbCommandBuilder builder = fact.CreateCommandBuilder())
        {
          adp.SelectCommand = cmd;
          builder.DataAdapter = adp;
          builder.ConflictOption = ConflictOption.OverwriteChanges;

          using (DbCommand updatecmd = builder.GetUpdateCommand())
          {
            if (updatecmd.Parameters.Count != 4)
              throw new ArgumentOutOfRangeException("Wrong number of parameters in update command!");
          }
        }
      }
    }

    internal static void FullTextTest(DbConnection cnn)
    {
      using (DbCommand cmd = cnn.CreateCommand())
      {
        cmd.CommandText = "CREATE VIRTUAL TABLE FullText USING FTS1(name, ingredients);";
        cmd.ExecuteNonQuery();
722
723
724
725
726
727
728


729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751



752
753
754
755
756
757
758
        Console.WriteLine(String.Format("          Intrinsic Function iteration of {0} records in {1} ms", nCount, (dtEnd - dtStart)));

      }
    }

    // Open a reader and then attempt to write to test the writer's command timeout property
    // SQLite doesn't allow a write when a reader is active.


    internal static void TimeoutTest(DbConnection cnn)
    {
      using (DbCommand cmdRead = cnn.CreateCommand())
      {
        cmdRead.CommandText = "SELECT ID FROM TestCase";
        using (DbDataReader rd = cmdRead.ExecuteReader())
        {
          using (DbCommand cmdwrite = cnn.CreateCommand())
          {
            cmdwrite.CommandText = "UPDATE [TestCase] SET [ID] = [ID]";
            cmdwrite.CommandTimeout = 5;

            int dwtick = Environment.TickCount;
            try
            {
              cmdwrite.ExecuteNonQuery();
            }
            catch (SQLiteException)
            {
              dwtick = (Environment.TickCount - dwtick) / 1000;
              if (dwtick < 5 || dwtick > 6)
                throw new ArgumentOutOfRangeException();
            }



          }
        }
      }
    }

    // Causes the user-defined aggregate to be iterated through
    internal static void UserAggregate(DbConnection cnn)







>
>









|












|
>
>
>







793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
        Console.WriteLine(String.Format("          Intrinsic Function iteration of {0} records in {1} ms", nCount, (dtEnd - dtStart)));

      }
    }

    // Open a reader and then attempt to write to test the writer's command timeout property
    // SQLite doesn't allow a write when a reader is active.
    // *** NOTE AS OF 3.3.8 this test no longer blocks because SQLite now allows you to update table(s)
    // while a reader is active on the same connection.  Therefore the timeout test is invalid
    internal static void TimeoutTest(DbConnection cnn)
    {
      using (DbCommand cmdRead = cnn.CreateCommand())
      {
        cmdRead.CommandText = "SELECT ID FROM TestCase";
        using (DbDataReader rd = cmdRead.ExecuteReader())
        {
          using (DbCommand cmdwrite = cnn.CreateCommand())
          {
            cmdwrite.CommandText = "UPDATE [KeyInfoTest] SET [ID] = [ID]";
            cmdwrite.CommandTimeout = 5;

            int dwtick = Environment.TickCount;
            try
            {
              cmdwrite.ExecuteNonQuery();
            }
            catch (SQLiteException)
            {
              dwtick = (Environment.TickCount - dwtick) / 1000;
              if (dwtick < 5 || dwtick > 6)
                throw new ArgumentOutOfRangeException();

              return;
            }
            throw new ArgumentOutOfRangeException("Operation Completed successfully");
          }
        }
      }
    }

    // Causes the user-defined aggregate to be iterated through
    internal static void UserAggregate(DbConnection cnn)
Changes to testce/TestCases.cs.
71
72
73
74
75
76
77






78
79
80
81
82
83
84
      frm = new Form1();

      frm.Show();

      frm.WriteLine("\r\nBeginning Test on " + cnn.GetType().ToString());
      try { CreateTable(cnn); frm.WriteLine("SUCCESS - CreateTable"); }
      catch (Exception) { frm.WriteLine("FAIL - CreateTable"); }







      try { InsertTable(cnn); frm.WriteLine("SUCCESS - InsertTable"); }
      catch (Exception) { frm.WriteLine("FAIL - InsertTable"); }

      try { VerifyInsert(cnn); frm.WriteLine("SUCCESS - VerifyInsert"); }
      catch (Exception) { frm.WriteLine("FAIL - VerifyInsert"); }








>
>
>
>
>
>







71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
      frm = new Form1();

      frm.Show();

      frm.WriteLine("\r\nBeginning Test on " + cnn.GetType().ToString());
      try { CreateTable(cnn); frm.WriteLine("SUCCESS - CreateTable"); }
      catch (Exception) { frm.WriteLine("FAIL - CreateTable"); }

      try { FullTextTest(cnn); frm.WriteLine("SUCCESS - Full Text Search"); }
      catch (Exception) { frm.WriteLine("FAIL - Full Text Search"); }

      try { KeyInfoTest(cnn); frm.WriteLine("SUCCESS - KeyInfo Fetch"); }
      catch (Exception) { frm.WriteLine("FAIL - KeyInfo Fetch"); }

      try { InsertTable(cnn); frm.WriteLine("SUCCESS - InsertTable"); }
      catch (Exception) { frm.WriteLine("FAIL - InsertTable"); }

      try { VerifyInsert(cnn); frm.WriteLine("SUCCESS - VerifyInsert"); }
      catch (Exception) { frm.WriteLine("FAIL - VerifyInsert"); }

122
123
124
125
126
127
128



















































































































129
130
131
132
133
134
135
      catch (Exception) { frm.WriteLine("FAIL - UserCollation"); }

      try { DropTable(cnn); frm.WriteLine("SUCCESS - DropTable"); }
      catch (Exception) { frm.WriteLine("FAIL - DropTable"); }

      frm.WriteLine("\r\nTests Finished.");
    }




















































































































    internal void CreateTable(DbConnection cnn)
    {
      using (DbCommand cmd = cnn.CreateCommand())
      {
        cmd.CommandText = "CREATE TABLE TestCase (ID integer primary key autoincrement, Field1 Integer, Field2 Float, Field3 VARCHAR(50), Field4 CHAR(10), Field5 DateTime, Field6 Image)";
        //cmd.CommandText = "CREATE TABLE TestCase (ID bigint primary key identity, Field1 Integer, Field2 Float, Field3 VARCHAR(50), Field4 CHAR(10), Field5 DateTime, Field6 Image)";







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







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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
      catch (Exception) { frm.WriteLine("FAIL - UserCollation"); }

      try { DropTable(cnn); frm.WriteLine("SUCCESS - DropTable"); }
      catch (Exception) { frm.WriteLine("FAIL - DropTable"); }

      frm.WriteLine("\r\nTests Finished.");
    }

    internal static void KeyInfoTest(DbConnection cnn)
    {
      using (DbCommand cmd = cnn.CreateCommand())
      {
        // First test against integer primary key (optimized) keyinfo fetch
        cmd.CommandText = "Create table keyinfotest (id integer primary key, myuniquevalue integer unique not null, myvalue varchar(50))";
        cmd.ExecuteNonQuery();

        cmd.CommandText = "Select * from keyinfotest";
        using (DbDataReader reader = cmd.ExecuteReader(CommandBehavior.KeyInfo | CommandBehavior.SchemaOnly))
        {
          using (DataTable tbl = reader.GetSchemaTable())
          {
            if (tbl.Rows.Count != 3) throw new ArgumentOutOfRangeException("Wrong number of columns returned");
          }
        }

        cmd.CommandText = "SELECT MyValue FROM keyinfotest";
        using (DbDataReader reader = cmd.ExecuteReader(CommandBehavior.KeyInfo | CommandBehavior.SchemaOnly))
        {
          using (DataTable tbl = reader.GetSchemaTable())
          {
            if (tbl.Rows.Count != 2) throw new ArgumentOutOfRangeException("Wrong number of columns returned");
          }
        }

        cmd.CommandText = "DROP TABLE keyinfotest";
        cmd.ExecuteNonQuery();

        // Now test against non-integer primary key (unoptimized) subquery keyinfo fetch
        cmd.CommandText = "Create table keyinfotest (id char primary key, myuniquevalue integer unique not null, myvalue varchar(50))";
        cmd.ExecuteNonQuery();

        cmd.CommandText = "SELECT MyValue FROM keyinfotest";
        using (DbDataReader reader = cmd.ExecuteReader(CommandBehavior.KeyInfo | CommandBehavior.SchemaOnly))
        {
          using (DataTable tbl = reader.GetSchemaTable())
          {
            if (tbl.Rows.Count != 2) throw new ArgumentOutOfRangeException("Wrong number of columns returned");
          }
        }

        cmd.CommandText = "Select * from keyinfotest";
        using (DbDataReader reader = cmd.ExecuteReader(CommandBehavior.KeyInfo | CommandBehavior.SchemaOnly))
        {
          using (DataTable tbl = reader.GetSchemaTable())
          {
            if (tbl.Rows.Count != 3) throw new ArgumentOutOfRangeException("Wrong number of columns returned");
          }
        }

        // Make sure commandbuilder can generate an update command with the correct parameter count
        using (DbDataAdapter adp = new SQLiteDataAdapter())
        using (DbCommandBuilder builder = new SQLiteCommandBuilder())
        {
          adp.SelectCommand = cmd;
          builder.DataAdapter = adp;
          builder.ConflictOption = ConflictOption.OverwriteChanges;

          using (DbCommand updatecmd = builder.GetUpdateCommand())
          {
            if (updatecmd.Parameters.Count != 4)
              throw new ArgumentOutOfRangeException("Wrong number of parameters in update command!");
          }
        }
      }
    }

    internal static void FullTextTest(DbConnection cnn)
    {
      using (DbCommand cmd = cnn.CreateCommand())
      {
        cmd.CommandText = "CREATE VIRTUAL TABLE FullText USING FTS1(name, ingredients);";
        cmd.ExecuteNonQuery();

        string[] names = { "broccoli stew", "pumpkin stew", "broccoli pie", "pumpkin pie" };
        string[] ingredients = { "broccoli peppers cheese tomatoes", "pumpkin onions garlic celery", "broccoli cheese onions flour", "pumpkin sugar flour butter" };
        int n;

        cmd.CommandText = "insert into FullText (name, ingredients) values (@name, @ingredient);";
        DbParameter name = cmd.CreateParameter();
        DbParameter ingredient = cmd.CreateParameter();

        name.ParameterName = "@name";
        ingredient.ParameterName = "@ingredient";

        cmd.Parameters.Add(name);
        cmd.Parameters.Add(ingredient);

        for (n = 0; n < names.Length; n++)
        {
          name.Value = names[n];
          ingredient.Value = ingredients[n];

          cmd.ExecuteNonQuery();
        }

        cmd.CommandText = "select rowid, name, ingredients from FullText where name match 'pie';";

        int[] rowids = { 3, 4 };
        n = 0;

        using (DbDataReader reader = cmd.ExecuteReader())
        {
          while (reader.Read())
          {
            if (reader.GetInt64(0) != rowids[n++])
              throw new ArgumentException("Unexpected rowid returned");

            if (n > rowids.Length) throw new ArgumentException("Too many rows returned");
          }
        }
      }
    }

    internal void CreateTable(DbConnection cnn)
    {
      using (DbCommand cmd = cnn.CreateCommand())
      {
        cmd.CommandText = "CREATE TABLE TestCase (ID integer primary key autoincrement, Field1 Integer, Field2 Float, Field3 VARCHAR(50), Field4 CHAR(10), Field5 DateTime, Field6 Image)";
        //cmd.CommandText = "CREATE TABLE TestCase (ID bigint primary key identity, Field1 Integer, Field2 Float, Field3 VARCHAR(50), Field4 CHAR(10), Field5 DateTime, Field6 Image)";
Changes to tools/install/Resources/System.Data.SQLite.dll.

cannot compute difference between binary files