System.Data.SQLite

Check-in [3a27201398]
Login

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

Overview
Comment:Add support for setting all the on/off style database configuration options, including SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER. Fix for [f64f4aee95].
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3a27201398f252b9f81803e4f07b55b86beadd6f
User & Date: mistachkin 2016-07-22 22:18:13.599
Context
2016-07-22
22:21
Update version history docs. check-in: eb23ed0cb0 user: mistachkin tags: trunk
22:18
Add support for setting all the on/off style database configuration options, including SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER. Fix for [f64f4aee95]. check-in: 3a27201398 user: mistachkin tags: trunk
2016-07-08
21:23
Adapt to internal changes in the upstream SQLite core library. check-in: bae5ecaea3 user: mistachkin tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to Doc/Extra/Provider/version.html.
48
49
50
51
52
53
54

55
56
57
58
59
60
61
      <li>Change the SQLiteReadValueCallback delegate &quot;eventArgs&quot; parameter to be of type SQLiteReadEventArgs.&nbsp;<b>** Potentially Incompatible Change **</b></li>
      <li>Make SQLiteReadValueEventArgs and SQLiteReadArrayEventArgs derive from SQLiteReadEventArgs.&nbsp;<b>** Potentially Incompatible Change **</b></li>
      <li>Rename SQLiteReadValueEventArgs.ArrayEventArgs property to ExtraEventArgs.&nbsp;<b>** Potentially Incompatible Change **</b></li>
      <li>Add No_SQLiteGetSettingValue and No_SQLiteXmlConfigFile environment variables.</li>
      <li>Reduce the number of calls to GetSettingValue from SQLiteConnection. Pursuant to <a href="https://system.data.sqlite.org/index.html/info/25d53b48f6">[25d53b48f6]</a>.&nbsp;<b>** Potentially Incompatible Change **</b></li>
      <li>Add NoVerifyTypeAffinity connection flag to disable all type affinity checking.</li>
      <li>Add support for <a href="https://www.sqlite.org/c3ref/blob_open.html">incremental blob I/O</a>.</li>

    </ul>
    <p><b>1.0.102.0 - June 23, 2016</b></p>
    <ul>
      <li>Updated to <a href="https://www.sqlite.org/releaselog/3_13_0.html">SQLite 3.13.0</a>.</li>
      <li>Update the SQLiteConnection.EnableExtensions method to make use of the new SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION option, when available.&nbsp;<b>** Potentially Incompatible Change **</b></li>
      <li>Prevent the SQLiteCommand.ExecuteScalar method from throwing an exception when there are no result columns.&nbsp;<b>** Potentially Incompatible Change **</b></li>
      <li>Support per-connection customization for binding parameters and reading values, based on the database type name.</li>







>







48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
      <li>Change the SQLiteReadValueCallback delegate &quot;eventArgs&quot; parameter to be of type SQLiteReadEventArgs.&nbsp;<b>** Potentially Incompatible Change **</b></li>
      <li>Make SQLiteReadValueEventArgs and SQLiteReadArrayEventArgs derive from SQLiteReadEventArgs.&nbsp;<b>** Potentially Incompatible Change **</b></li>
      <li>Rename SQLiteReadValueEventArgs.ArrayEventArgs property to ExtraEventArgs.&nbsp;<b>** Potentially Incompatible Change **</b></li>
      <li>Add No_SQLiteGetSettingValue and No_SQLiteXmlConfigFile environment variables.</li>
      <li>Reduce the number of calls to GetSettingValue from SQLiteConnection. Pursuant to <a href="https://system.data.sqlite.org/index.html/info/25d53b48f6">[25d53b48f6]</a>.&nbsp;<b>** Potentially Incompatible Change **</b></li>
      <li>Add NoVerifyTypeAffinity connection flag to disable all type affinity checking.</li>
      <li>Add support for <a href="https://www.sqlite.org/c3ref/blob_open.html">incremental blob I/O</a>.</li>
      <li>Improve support for the <a href="https://www.sqlite.org/c3ref/db_config.html">sqlite3_db_config()</a> interface.</li>
    </ul>
    <p><b>1.0.102.0 - June 23, 2016</b></p>
    <ul>
      <li>Updated to <a href="https://www.sqlite.org/releaselog/3_13_0.html">SQLite 3.13.0</a>.</li>
      <li>Update the SQLiteConnection.EnableExtensions method to make use of the new SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION option, when available.&nbsp;<b>** Potentially Incompatible Change **</b></li>
      <li>Prevent the SQLiteCommand.ExecuteScalar method from throwing an exception when there are no result columns.&nbsp;<b>** Potentially Incompatible Change **</b></li>
      <li>Support per-connection customization for binding parameters and reading values, based on the database type name.</li>
Changes to System.Data.SQLite/SQLite3.cs.
638
639
640
641
642
643
644
645

646
647
648
649
650
651
652
                pDbName = SQLiteString.Utf8IntPtrFromString(name);

            int result = UnsafeNativeMethods.sqlite3_db_readonly(
                _sql, pDbName);

            if (result == -1) /* database not found */
            {
                throw new SQLiteException(String.Format(

                    "database \"{0}\" not found", name));
            }

            return result == 0 ? false : true;
        }
        finally
        {







|
>







638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
                pDbName = SQLiteString.Utf8IntPtrFromString(name);

            int result = UnsafeNativeMethods.sqlite3_db_readonly(
                _sql, pDbName);

            if (result == -1) /* database not found */
            {
                throw new SQLiteException(HelperMethods.StringFormat(
                    CultureInfo.CurrentCulture,
                    "database \"{0}\" not found", name));
            }

            return result == 0 ? false : true;
        }
        finally
        {
2722
2723
2724
2725
2726
2727
2728




































2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
                pName = IntPtr.Zero;
            }
        }
    }
#endif

    /// <summary>




































    /// Enables or disabled extension loading by SQLite.
    /// </summary>
    /// <param name="bOnOff">
    /// True to enable loading of extensions, false to disable.
    /// </param>
    internal override void SetLoadExtension(bool bOnOff)
    {
        SQLiteErrorCode n;

        if (SQLiteVersionNumber >= 3013000)
        {
            int result = 0; /* NOT USED */

            n = UnsafeNativeMethods.sqlite3_db_config_int_refint(
                _sql, SQLiteConfigDbOpsEnum.SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION,
                (bOnOff ? 1 : 0), ref result);
        }
        else
        {
            n = UnsafeNativeMethods.sqlite3_enable_load_extension(
                _sql, (bOnOff ? -1 : 0));
        }








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|










<
|
<
|
|







2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776

2777

2778
2779
2780
2781
2782
2783
2784
2785
2786
                pName = IntPtr.Zero;
            }
        }
    }
#endif

    /// <summary>
    /// Enables or disables a configuration option for the database.
    /// connection.
    /// </summary>
    /// <param name="option">
    /// The database configuration option to enable or disable.
    /// </param>
    /// <param name="bOnOff">
    /// True to enable loading of extensions, false to disable.
    /// </param>
    /// <returns>
    /// A standard SQLite return code.
    /// </returns>
    internal override SQLiteErrorCode SetConfigurationOption(
        SQLiteConfigDbOpsEnum option,
        bool bOnOff
        )
    {
        if ((option < SQLiteConfigDbOpsEnum.SQLITE_DBCONFIG_ENABLE_FKEY) ||
            (option > SQLiteConfigDbOpsEnum.SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION))
        {
            throw new SQLiteException(HelperMethods.StringFormat(
                CultureInfo.CurrentCulture,
                "unsupported configuration option, must be: {0}, {1}, {2}, or {3}",
                SQLiteConfigDbOpsEnum.SQLITE_DBCONFIG_ENABLE_FKEY,
                SQLiteConfigDbOpsEnum.SQLITE_DBCONFIG_ENABLE_TRIGGER,
                SQLiteConfigDbOpsEnum.SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER,
                SQLiteConfigDbOpsEnum.SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION));
        }

        int result = 0; /* NOT USED */

        return UnsafeNativeMethods.sqlite3_db_config_int_refint(
            _sql, option, (bOnOff ? 1 : 0), ref result);
    }

    /// <summary>
    /// Enables or disables extension loading by SQLite.
    /// </summary>
    /// <param name="bOnOff">
    /// True to enable loading of extensions, false to disable.
    /// </param>
    internal override void SetLoadExtension(bool bOnOff)
    {
        SQLiteErrorCode n;

        if (SQLiteVersionNumber >= 3013000)
        {

            n = SetConfigurationOption(

                SQLiteConfigDbOpsEnum.SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION,
                bOnOff);
        }
        else
        {
            n = UnsafeNativeMethods.sqlite3_enable_load_extension(
                _sql, (bOnOff ? -1 : 0));
        }

Changes to System.Data.SQLite/SQLiteBase.cs.
369
370
371
372
373
374
375














376
377
378
379
380
381
382
383
    /// <returns>
    /// A standard SQLite return code.
    /// </returns>
    internal abstract SQLiteErrorCode DeclareVirtualFunction(SQLiteModule module, int argumentCount, string name, ref string error);
#endif

    /// <summary>














    /// Enables or disabled extension loading by SQLite.
    /// </summary>
    /// <param name="bOnOff">
    /// True to enable loading of extensions, false to disable.
    /// </param>
    internal abstract void SetLoadExtension(bool bOnOff);
    /// <summary>
    /// Loads a SQLite extension library from the named file.







>
>
>
>
>
>
>
>
>
>
>
>
>
>
|







369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
    /// <returns>
    /// A standard SQLite return code.
    /// </returns>
    internal abstract SQLiteErrorCode DeclareVirtualFunction(SQLiteModule module, int argumentCount, string name, ref string error);
#endif

    /// <summary>
    /// Enables or disables a configuration option for the database.
    /// connection.
    /// </summary>
    /// <param name="option">
    /// The database configuration option to enable or disable.
    /// </param>
    /// <param name="bOnOff">
    /// True to enable loading of extensions, false to disable.
    /// </param>
    /// <returns>
    /// A standard SQLite return code.
    /// </returns>
    internal abstract SQLiteErrorCode SetConfigurationOption(SQLiteConfigDbOpsEnum option, bool bOnOff);
    /// <summary>
    /// Enables or disables extension loading by SQLite.
    /// </summary>
    /// <param name="bOnOff">
    /// True to enable loading of extensions, false to disable.
    /// </param>
    internal abstract void SetLoadExtension(bool bOnOff);
    /// <summary>
    /// Loads a SQLite extension library from the named file.
1289
1290
1291
1292
1293
1294
1295

1296



1297
1298



1299





1300





1301




1302






1303




1304
1305
1306
1307
1308
1309
1310

      /// <summary>
      /// The default extra flags for new connections with all logging enabled.
      /// </summary>
      DefaultAndLogAll = Default | LogAll
  }


  // These are the options to the internal sqlite3_db_config call.



  internal enum SQLiteConfigDbOpsEnum
  {



    SQLITE_DBCONFIG_NONE = 0, // nil





    SQLITE_DBCONFIG_LOOKASIDE = 1001, // void* int int





    SQLITE_DBCONFIG_ENABLE_FKEY = 1002, // int int*




    SQLITE_DBCONFIG_ENABLE_TRIGGER = 1003, // int int*






    SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER = 1004, // int int*




    SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION = 1005 // int int*
  }

  // These are the options to the internal sqlite3_config call.
  internal enum SQLiteConfigOpsEnum
  {
    SQLITE_CONFIG_NONE = 0, // nil







>
|
>
>
>
|

>
>
>

>
>
>
>
>

>
>
>
>
>

>
>
>
>

>
>
>
>
>
>

>
>
>
>







1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355

      /// <summary>
      /// The default extra flags for new connections with all logging enabled.
      /// </summary>
      DefaultAndLogAll = Default | LogAll
  }

  /// <summary>
  /// These are the supported configuration verbs for use with the native
  /// SQLite library.  They are used with the
  /// <see cref="SQLiteConnection.SetConfigurationOption" /> method.
  /// </summary>
  public enum SQLiteConfigDbOpsEnum
  {
    /// <summary>
    /// This value represents an unknown (or invalid) option, do not use it.
    /// </summary>
    SQLITE_DBCONFIG_NONE = 0, // nil

    /// <summary>
    /// This option is not currently supported by System.Data.SQLite.  It
    /// may be supported in the future.
    /// </summary>
    SQLITE_DBCONFIG_LOOKASIDE = 1001, // void* int int

    /// <summary>
    /// This option is used to enable or disable the enforcement of
    /// foreign key constraints.
    /// </summary>
    SQLITE_DBCONFIG_ENABLE_FKEY = 1002, // int int*

    /// <summary>
    /// This option is used to enable or disable triggers.
    /// </summary>
    SQLITE_DBCONFIG_ENABLE_TRIGGER = 1003, // int int*

    /// <summary>
    /// This option is used to enable or disable the two-argument version
    /// of the fts3_tokenizer() function which is part of the FTS3 full-text
    /// search engine extension.
    /// </summary>
    SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER = 1004, // int int*

    /// <summary>
    /// This option is used to enable or disable the loading of extensions.
    /// </summary>
    SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION = 1005 // int int*
  }

  // These are the options to the internal sqlite3_config call.
  internal enum SQLiteConfigOpsEnum
  {
    SQLITE_CONFIG_NONE = 0, // nil
Changes to System.Data.SQLite/SQLiteConnection.cs.
3321
3322
3323
3324
3325
3326
3327

































3328
3329
3330
3331
3332
3333
3334
        catch
        {
            result = 0;
            return false;
        }
#endif
    }


































    /// <summary>
    /// Enables or disabled extension loading.
    /// </summary>
    /// <param name="enable">
    /// True to enable loading of extensions, false to disable.
    /// </param>







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







3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
        catch
        {
            result = 0;
            return false;
        }
#endif
    }

    /// <summary>
    /// Enables or disables a configuration option for the database.
    /// </summary>
    /// <param name="option">
    /// The database configuration option to enable or disable.
    /// </param>
    /// <param name="enable">
    /// True to enable loading of extensions, false to disable.
    /// </param>
    public void SetConfigurationOption(
        SQLiteConfigDbOpsEnum option,
        bool enable
        )
    {
        CheckDisposed();

        if (_sql == null)
        {
            throw new InvalidOperationException(HelperMethods.StringFormat(
                CultureInfo.CurrentCulture,
                "Database connection not valid for {0} a configuration option.",
                enable ? "enabling" : "disabling"));
        }

        if ((option == SQLiteConfigDbOpsEnum.SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION) &&
            ((_flags & SQLiteConnectionFlags.NoLoadExtension) == SQLiteConnectionFlags.NoLoadExtension))
        {
            throw new SQLiteException("Loading extensions is disabled for this database connection.");
        }

        _sql.SetConfigurationOption(option, enable);
    }

    /// <summary>
    /// Enables or disabled extension loading.
    /// </summary>
    /// <param name="enable">
    /// True to enable loading of extensions, false to disable.
    /// </param>
Changes to readme.htm.
215
216
217
218
219
220
221

222
223
224
225
226
227
228
    <li>Change the SQLiteReadValueCallback delegate &quot;eventArgs&quot; parameter to be of type SQLiteReadEventArgs.&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Make SQLiteReadValueEventArgs and SQLiteReadArrayEventArgs derive from SQLiteReadEventArgs.&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Rename SQLiteReadValueEventArgs.ArrayEventArgs property to ExtraEventArgs.&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Add No_SQLiteGetSettingValue and No_SQLiteXmlConfigFile environment variables.</li>
    <li>Reduce the number of calls to GetSettingValue from SQLiteConnection. Pursuant to [25d53b48f6].&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Add NoVerifyTypeAffinity connection flag to disable all type affinity checking.</li>
    <li>Add support for <a href="https://www.sqlite.org/c3ref/blob_open.html">incremental blob I/O</a>.</li>

</ul>
<p>
    <b>1.0.102.0 - June 23, 2016</b>
</p>
<ul>
    <li>Updated to <a href="https://www.sqlite.org/releaselog/3_13_0.html">SQLite 3.13.0</a>.</li>
    <li>Update the SQLiteConnection.EnableExtensions method to make use of the new SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION option, when available.&nbsp;<b>** Potentially Incompatible Change **</b></li>







>







215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
    <li>Change the SQLiteReadValueCallback delegate &quot;eventArgs&quot; parameter to be of type SQLiteReadEventArgs.&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Make SQLiteReadValueEventArgs and SQLiteReadArrayEventArgs derive from SQLiteReadEventArgs.&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Rename SQLiteReadValueEventArgs.ArrayEventArgs property to ExtraEventArgs.&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Add No_SQLiteGetSettingValue and No_SQLiteXmlConfigFile environment variables.</li>
    <li>Reduce the number of calls to GetSettingValue from SQLiteConnection. Pursuant to [25d53b48f6].&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Add NoVerifyTypeAffinity connection flag to disable all type affinity checking.</li>
    <li>Add support for <a href="https://www.sqlite.org/c3ref/blob_open.html">incremental blob I/O</a>.</li>
    <li>Improve support for the <a href="https://www.sqlite.org/c3ref/db_config.html">sqlite3_db_config()</a> interface.</li>
</ul>
<p>
    <b>1.0.102.0 - June 23, 2016</b>
</p>
<ul>
    <li>Updated to <a href="https://www.sqlite.org/releaselog/3_13_0.html">SQLite 3.13.0</a>.</li>
    <li>Update the SQLiteConnection.EnableExtensions method to make use of the new SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION option, when available.&nbsp;<b>** Potentially Incompatible Change **</b></li>
Changes to www/news.wiki.
9
10
11
12
13
14
15

16
17
18
19
20
21
22
    <li>Change the SQLiteReadValueCallback delegate &quot;eventArgs&quot; parameter to be of type SQLiteReadEventArgs.&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Make SQLiteReadValueEventArgs and SQLiteReadArrayEventArgs derive from SQLiteReadEventArgs.&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Rename SQLiteReadValueEventArgs.ArrayEventArgs property to ExtraEventArgs.&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Add No_SQLiteGetSettingValue and No_SQLiteXmlConfigFile environment variables.</li>
    <li>Reduce the number of calls to GetSettingValue from SQLiteConnection. Pursuant to [25d53b48f6].&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Add NoVerifyTypeAffinity connection flag to disable all type affinity checking.</li>
    <li>Add support for [https://www.sqlite.org/c3ref/blob_open.html|incremental blob I/O].</li>

</ul>
<p>
    <b>1.0.102.0 - June 23, 2016</b>
</p>
<ul>
    <li>Updated to [https://www.sqlite.org/releaselog/3_13_0.html|SQLite 3.13.0].</li>
    <li>Update the SQLiteConnection.EnableExtensions method to make use of the new SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION option, when available.&nbsp;<b>** Potentially Incompatible Change **</b></li>







>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
    <li>Change the SQLiteReadValueCallback delegate &quot;eventArgs&quot; parameter to be of type SQLiteReadEventArgs.&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Make SQLiteReadValueEventArgs and SQLiteReadArrayEventArgs derive from SQLiteReadEventArgs.&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Rename SQLiteReadValueEventArgs.ArrayEventArgs property to ExtraEventArgs.&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Add No_SQLiteGetSettingValue and No_SQLiteXmlConfigFile environment variables.</li>
    <li>Reduce the number of calls to GetSettingValue from SQLiteConnection. Pursuant to [25d53b48f6].&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Add NoVerifyTypeAffinity connection flag to disable all type affinity checking.</li>
    <li>Add support for [https://www.sqlite.org/c3ref/blob_open.html|incremental blob I/O].</li>
    <li>Improve support for the [https://www.sqlite.org/c3ref/db_config.html|sqlite3_db_config()] interface.</li>
</ul>
<p>
    <b>1.0.102.0 - June 23, 2016</b>
</p>
<ul>
    <li>Updated to [https://www.sqlite.org/releaselog/3_13_0.html|SQLite 3.13.0].</li>
    <li>Update the SQLiteConnection.EnableExtensions method to make use of the new SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION option, when available.&nbsp;<b>** Potentially Incompatible Change **</b></li>