System.Data.SQLite
Check-in [dcbda7101e]
Not logged in

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

Overview
Comment:Tweaks and optimizations
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | sourceforge
Files: files | file ages | folders
SHA1: dcbda7101ee5d885a04d743a348b3b756cb6e5f1
User & Date: rmsimpson 2005-08-26 05:04:57
Context
2005-08-27
23:17
Added itanium and x64 platform build settings check-in: 065c6034ae user: rmsimpson tags: sourceforge
2005-08-26
05:04
Tweaks and optimizations check-in: dcbda7101e user: rmsimpson tags: sourceforge
03:08
no message check-in: c2d292b29a user: rmsimpson tags: sourceforge
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to System.Data.SQLite/SQLiteConnection.cs.

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
        throw new ArgumentException("Data Source cannot be empty.  Use :MEMORY: to open an in-memory database");

      try
      {
        bool bUTF16 = (Convert.ToBoolean(FindKey(opts, "UseUTF16Encoding", "False"), CultureInfo.InvariantCulture) == true);
        SQLiteDateFormats dateFormat = String.Compare(FindKey(opts, "DateTimeFormat", "ISO8601"), "ticks", true, CultureInfo.CurrentCulture) == 0 ? SQLiteDateFormats.Ticks : SQLiteDateFormats.ISO8601;

        if (bUTF16)
          _sql = new SQLite3_UTF16(dateFormat);
        else
          _sql = new SQLite3(dateFormat);

          _sql.Open(strFile);

        _dataSource = System.IO.Path.GetFileNameWithoutExtension(strFile);

        if (bUTF16 == true)
          _sql.Execute("PRAGMA encoding = 'UTF-16'");
        else
          _sql.Execute("PRAGMA encoding = 'UTF-8'");

        _sql.Execute(String.Format(CultureInfo.InvariantCulture, "PRAGMA Synchronous={0}", FindKey(opts, "Synchronous", "Normal")));
        _sql.Execute(String.Format(CultureInfo.InvariantCulture, "PRAGMA Cache_Size={0}", FindKey(opts, "Cache Size", "2000")));
        if (String.Compare(":MEMORY:", strFile, true, CultureInfo.CurrentCulture) == 0)
          _sql.Execute(String.Format(CultureInfo.InvariantCulture, "PRAGMA Page_Size={0}", FindKey(opts, "Page Size", "1024")));
      }
      catch (SQLiteException)
      {







|








<
<
<
<
<







541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556





557
558
559
560
561
562
563
        throw new ArgumentException("Data Source cannot be empty.  Use :MEMORY: to open an in-memory database");

      try
      {
        bool bUTF16 = (Convert.ToBoolean(FindKey(opts, "UseUTF16Encoding", "False"), CultureInfo.InvariantCulture) == true);
        SQLiteDateFormats dateFormat = String.Compare(FindKey(opts, "DateTimeFormat", "ISO8601"), "ticks", true, CultureInfo.CurrentCulture) == 0 ? SQLiteDateFormats.Ticks : SQLiteDateFormats.ISO8601;

        if (bUTF16) // SQLite automatically sets the encoding of the database to UTF16 if called from sqlite3_open16()
          _sql = new SQLite3_UTF16(dateFormat);
        else
          _sql = new SQLite3(dateFormat);

          _sql.Open(strFile);

        _dataSource = System.IO.Path.GetFileNameWithoutExtension(strFile);






        _sql.Execute(String.Format(CultureInfo.InvariantCulture, "PRAGMA Synchronous={0}", FindKey(opts, "Synchronous", "Normal")));
        _sql.Execute(String.Format(CultureInfo.InvariantCulture, "PRAGMA Cache_Size={0}", FindKey(opts, "Cache Size", "2000")));
        if (String.Compare(":MEMORY:", strFile, true, CultureInfo.CurrentCulture) == 0)
          _sql.Execute(String.Format(CultureInfo.InvariantCulture, "PRAGMA Page_Size={0}", FindKey(opts, "Page Size", "1024")));
      }
      catch (SQLiteException)
      {

Changes to System.Data.SQLite/UnsafeNativeMethods.cs.

22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
...
231
232
233
234
235
236
237
238
239
240
    private const string SQLITE_DLL = "SQLite.Interop.DLL";
#endif

    private UnsafeNativeMethods()
    {
    }

    [DllImport("kernel32.dll")]
    internal static extern void Sleep(uint dwMilliseconds);

    [DllImport(SQLITE_DLL)]
    internal static extern IntPtr sqlite3_libversion_interop(out int len);

    [DllImport(SQLITE_DLL)]
    internal static extern void sqlite3_free_interop(IntPtr p);

................................................................................
    internal static extern int sqlite3_encryptedstatus(string fileName, out long fileStatus);

    [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode, SetLastError = true)]
    internal static extern int sqlite3_compressfile(string fileName);

    [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode, SetLastError = true)]
    internal static extern int sqlite3_decompressfile(string fileName);

  }
}







|
|







 







|
|
<
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
...
231
232
233
234
235
236
237
238
239

    private const string SQLITE_DLL = "SQLite.Interop.DLL";
#endif

    private UnsafeNativeMethods()
    {
    }

    [DllImport(SQLITE_DLL)]
    internal static extern void sqlite3_sleep_interop(uint dwMilliseconds);

    [DllImport(SQLITE_DLL)]
    internal static extern IntPtr sqlite3_libversion_interop(out int len);

    [DllImport(SQLITE_DLL)]
    internal static extern void sqlite3_free_interop(IntPtr p);

................................................................................
    internal static extern int sqlite3_encryptedstatus(string fileName, out long fileStatus);

    [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode, SetLastError = true)]
    internal static extern int sqlite3_compressfile(string fileName);

    [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode, SetLastError = true)]
    internal static extern int sqlite3_decompressfile(string fileName);
  }
}

Changes to test/Program.cs.

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
  class Program
  {
    static void Main(string[] args)
    {
      DbProviderFactory fact;
      DbConnection cnn;

      //fact = DbProviderFactories.GetFactory("System.Data.SqlClient");
      //using (cnn = fact.CreateConnection())
      //{
      //  cnn.ConnectionString = "Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=dlink;Data Source=(LOCAL)";
      //  cnn.Open();
      //  TestCases.Run(fact, cnn);
      //}
//      cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Temp\\db.mdb;Persist Security Info=False";
//      cnn.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=DirectLink;Data Source=MASTER";
//      cnn.Open();

//      TestCases.Run(fact, cnn);

      using (cnn = new SQLiteConnection())
      {
        fact = DbProviderFactories.GetFactory("System.Data.SQLite");
        cnn.ConnectionString = "Data Source=test.db3;Synchronous=Off;UseUTF16Encoding=TRUE";
        cnn.Open();
        TestCases.Run(fact, cnn);
      }

      System.IO.File.Delete("test.db3");

      Console.ReadKey();
    }
  }
}







<
<
<
<
<
<
<
<
<
<
<
<
<



|










9
10
11
12
13
14
15













16
17
18
19
20
21
22
23
24
25
26
27
28
29
  class Program
  {
    static void Main(string[] args)
    {
      DbProviderFactory fact;
      DbConnection cnn;














      using (cnn = new SQLiteConnection())
      {
        fact = DbProviderFactories.GetFactory("System.Data.SQLite");
        cnn.ConnectionString = "Data Source=test.db3";
        cnn.Open();
        TestCases.Run(fact, cnn);
      }

      System.IO.File.Delete("test.db3");

      Console.ReadKey();
    }
  }
}

Changes to testce/Program.cs.

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
  class Program
  {
    [MTAThread]
    static void Main()
    {
      DbConnection cnn;

      //fact = DbProviderFactories.GetFactory("System.Data.SqlClient");
      //using (cnn = fact.CreateConnection())
      //{
      //  cnn.ConnectionString = "Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=dlink;Data Source=(LOCAL)";
      //  cnn.Open();
      //  TestCases.Run(fact, cnn);
      //}
//      cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Temp\\db.mdb;Persist Security Info=False";
//      cnn.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=DirectLink;Data Source=MASTER";
//      cnn.Open();

//      TestCases.Run(fact, cnn);

      SQLiteFunction.RegisterFunction(typeof(TestFunc));
      SQLiteFunction.RegisterFunction(typeof(MyCount));
      SQLiteFunction.RegisterFunction(typeof(MySequence));

      using (cnn = new SQLiteConnection())
      {
        TestCases tests = new TestCases();

        cnn.ConnectionString = "Data Source=test.db3;Synchronous=Off;UseUTF16Encoding=TRUE";
        cnn.Open();
        tests.Run(cnn);

        System.Windows.Forms.Application.Run(tests.frm);
      }

      System.IO.File.Delete("test.db3");
    }
  }
}







<
<
<
<
<
<
<
<
<
<
<
<
<








|










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
  class Program
  {
    [MTAThread]
    static void Main()
    {
      DbConnection cnn;














      SQLiteFunction.RegisterFunction(typeof(TestFunc));
      SQLiteFunction.RegisterFunction(typeof(MyCount));
      SQLiteFunction.RegisterFunction(typeof(MySequence));

      using (cnn = new SQLiteConnection())
      {
        TestCases tests = new TestCases();

        cnn.ConnectionString = "Data Source=test.db3";
        cnn.Open();
        tests.Run(cnn);

        System.Windows.Forms.Application.Run(tests.frm);
      }

      System.IO.File.Delete("test.db3");
    }
  }
}