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

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

Overview
Comment:Add IsReadOnly method to the SQLiteConnection class.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c4f8b9e65baa75982d212d26236218d9491ca6a8
User & Date: mistachkin 2016-06-18 21:34:36
Context
2016-06-19
06:42
Fix some test constraints. check-in: f1e6c7c76b user: mistachkin tags: trunk
2016-06-18
22:59
Initial draft of work on being able to customize the bound parameter and data reader value handling. check-in: 4508a3be9e user: mistachkin tags: customDataTypes
21:34
Add IsReadOnly method to the SQLiteConnection class. check-in: c4f8b9e65b user: mistachkin tags: trunk
2016-06-17
17:35
Update Eagle in externals to the beta 36 release. check-in: 9ef15e9c95 user: mistachkin tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to Doc/Extra/Provider/version.html.

45
46
47
48
49
50
51

52
53
54
55
56
57
58
    <h1 class="heading">Version History</h1>
    <p><b>1.0.102.0 - June XX, 2016 <font color="red">(release scheduled)</font></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>Add VerifyOnly method to the SQLiteCommand class.</li>

    </ul>
    <p><b>1.0.101.0 - April 19, 2016</b></p>
    <ul>
      <li>Updated to <a href="https://www.sqlite.org/releaselog/3_12_2.html">SQLite 3.12.2</a>.</li>
      <li>Add binary package release for Mono on POSIX.</li>
    </ul>
    <p><b>1.0.100.0 - April 15, 2016</b></p>







>







45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
    <h1 class="heading">Version History</h1>
    <p><b>1.0.102.0 - June XX, 2016 <font color="red">(release scheduled)</font></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>Add VerifyOnly method to the SQLiteCommand class.</li>
      <li>Add IsReadOnly method to the SQLiteConnection class.</li>
    </ul>
    <p><b>1.0.101.0 - April 19, 2016</b></p>
    <ul>
      <li>Updated to <a href="https://www.sqlite.org/releaselog/3_12_2.html">SQLite 3.12.2</a>.</li>
      <li>Add binary package release for Mono on POSIX.</li>
    </ul>
    <p><b>1.0.100.0 - April 15, 2016</b></p>

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

621
622
623
624
625
626
627
































628
629
630
631
632
633
634
    internal override bool AutoCommit
    {
      get
      {
        return IsAutocommit(_sql, _sql);
      }
    }

































    internal override long LastInsertRowId
    {
      get
      {
#if !PLATFORM_COMPACTFRAMEWORK
        return UnsafeNativeMethods.sqlite3_last_insert_rowid(_sql);







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







621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
    internal override bool AutoCommit
    {
      get
      {
        return IsAutocommit(_sql, _sql);
      }
    }

    internal override bool IsReadOnly(
        string name
        )
    {
        IntPtr pDbName = IntPtr.Zero;

        try
        {
            if (name != null)
                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
        {
            if (pDbName != IntPtr.Zero)
            {
                SQLiteMemory.Free(pDbName);
                pDbName = IntPtr.Zero;
            }
        }
    }

    internal override long LastInsertRowId
    {
      get
      {
#if !PLATFORM_COMPACTFRAMEWORK
        return UnsafeNativeMethods.sqlite3_last_insert_rowid(_sql);

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

37
38
39
40
41
42
43




44
45
46
47
48
49
50
    /// Returns a string representing the active version of SQLite
    /// </summary>
    internal abstract string Version { get; }
    /// <summary>
    /// Returns an integer representing the active version of SQLite
    /// </summary>
    internal abstract int VersionNumber { 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>







>
>
>
>







37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
    /// Returns a string representing the active version of SQLite
    /// </summary>
    internal abstract string Version { get; }
    /// <summary>
    /// Returns an integer representing the active version of SQLite
    /// </summary>
    internal abstract int VersionNumber { get; }
    /// <summary>
    /// Returns non-zero if this connection to the database is read-only.
    /// </summary>
    internal abstract bool IsReadOnly(string name);
    /// <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>

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

3179
3180
3181
3182
3183
3184
3185

























3186
3187
3188
3189
3190
3191
3192

        if (_sql == null)
          throw new InvalidOperationException("Database connection not valid for getting number of changes.");

        return _sql.Changes;
      }
    }


























    /// <summary>
    /// Returns non-zero if the given database connection is in autocommit mode.
    /// Autocommit mode is on by default.  Autocommit mode is disabled by a BEGIN
    /// statement.  Autocommit mode is re-enabled by a COMMIT or ROLLBACK.
    /// </summary>
#if !PLATFORM_COMPACTFRAMEWORK







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







3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217

        if (_sql == null)
          throw new InvalidOperationException("Database connection not valid for getting number of changes.");

        return _sql.Changes;
      }
    }

    /// <summary>
    /// Checks if this connection to the specified database should be considered
    /// read-only.  An exception will be thrown if the database name specified
    /// via <paramref name="name" /> cannot be found.
    /// </summary>
    /// <param name="name">
    /// The name of a database associated with this connection -OR- null for the
    /// main database.
    /// </param>
    /// <returns>
    /// Non-zero if this connection to the specified database should be considered
    /// read-only.
    /// </returns>
    public bool IsReadOnly(
        string name
        )
    {
        CheckDisposed();

        if (_sql == null)
            throw new InvalidOperationException("Database connection not valid for checking read-only status.");

        return _sql.IsReadOnly(name);
    }

    /// <summary>
    /// Returns non-zero if the given database connection is in autocommit mode.
    /// Autocommit mode is on by default.  Autocommit mode is disabled by a BEGIN
    /// statement.  Autocommit mode is re-enabled by a COMMIT or ROLLBACK.
    /// </summary>
#if !PLATFORM_COMPACTFRAMEWORK

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

2658
2659
2660
2661
2662
2663
2664







2665
2666
2667
2668
2669
2670
2671
#if !PLATFORM_COMPACTFRAMEWORK
    [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
    [DllImport(SQLITE_DLL)]
#endif
    internal static extern IntPtr sqlite3_db_filename(IntPtr db, IntPtr dbName);








#if !PLATFORM_COMPACTFRAMEWORK
    [DllImport(SQLITE_DLL, EntryPoint = "sqlite3_db_filename", CallingConvention = CallingConvention.Cdecl)]
#else
    [DllImport(SQLITE_DLL, EntryPoint = "sqlite3_db_filename")]
#endif
    internal static extern IntPtr sqlite3_db_filename_bytes(IntPtr db, byte[] dbName);








>
>
>
>
>
>
>







2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
#if !PLATFORM_COMPACTFRAMEWORK
    [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
    [DllImport(SQLITE_DLL)]
#endif
    internal static extern IntPtr sqlite3_db_filename(IntPtr db, IntPtr dbName);

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

#if !PLATFORM_COMPACTFRAMEWORK
    [DllImport(SQLITE_DLL, EntryPoint = "sqlite3_db_filename", CallingConvention = CallingConvention.Cdecl)]
#else
    [DllImport(SQLITE_DLL, EntryPoint = "sqlite3_db_filename")]
#endif
    internal static extern IntPtr sqlite3_db_filename_bytes(IntPtr db, byte[] dbName);

Changes to Tests/basic.eagle.

4166
4167
4168
4169
4170
4171
4172






























































4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
} -constraints \
{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \
{0 {} 0 {} 0 {} 1 {SQL logic error or missing database -- no such table: t2} 1\
{SQL logic error or missing database -- near "BAD": syntax error} 0 {} 1 {SQL\
logic error or missing database -- no such table: t2} 1 {SQL logic error or\
missing database -- near "BAD": syntax error} 1 {SQL logic error or missing\
database -- no such table: t2} {1 2 3}}}































































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

reportSQLiteResources $test_channel

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

runSQLiteTestFilesEpilogue
runSQLiteTestEpilogue
runTestEpilogue







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










4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
} -constraints \
{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result \
{0 {} 0 {} 0 {} 1 {SQL logic error or missing database -- no such table: t2} 1\
{SQL logic error or missing database -- near "BAD": syntax error} 0 {} 1 {SQL\
logic error or missing database -- no such table: t2} 1 {SQL logic error or\
missing database -- near "BAD": syntax error} 1 {SQL logic error or missing\
database -- no such table: t2} {1 2 3}}}

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

runTest {test data-1.82 {IsReadOnly method} -setup {
  set fileName data-1.82.db
} -body {
  set result [list]

  setupDb $fileName
  set connection [getDbConnection]

  lappend result [catch {$connection IsReadOnly null} error] \
      [extractSystemDataSQLiteExceptionMessage $error]

  lappend result [catch {$connection IsReadOnly wrong} error] \
      [extractSystemDataSQLiteExceptionMessage $error]

  sql execute $db {
    SELECT * FROM sqlite_master WHERE 1 = 0;
  }; # NOTE: Force file creation.

  freeDbConnection
  cleanupDb $fileName db true false false

  setupDb $fileName "" "" "" "" "Read Only=True;" true false
  set connection [getDbConnection]

  lappend result [catch {$connection IsReadOnly null} error] \
      [extractSystemDataSQLiteExceptionMessage $error]

  lappend result [catch {$connection IsReadOnly wrong} error] \
      [extractSystemDataSQLiteExceptionMessage $error]

  freeDbConnection
  cleanupDb $fileName db true false false

  setupDb $fileName "" "" "" "" "Read Only=False;" true false
  set connection [getDbConnection]

  lappend result [catch {$connection IsReadOnly null} error] \
      [extractSystemDataSQLiteExceptionMessage $error]

  lappend result [catch {$connection IsReadOnly wrong} error] \
      [extractSystemDataSQLiteExceptionMessage $error]

  freeDbConnection
  cleanupDb $fileName db true false false

  set result
} -cleanup {
  freeDbConnection

  unset -nocomplain connection

  cleanupDb $fileName

  unset -nocomplain error result db fileName
} -constraints \
{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result {0\
False 1 {unknown error -- database "wrong" not found} 0 True 1 {unknown error\
-- database "wrong" not found} 0 False 1 {unknown error -- database "wrong" not\
found}}}

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

reportSQLiteResources $test_channel

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

runSQLiteTestFilesEpilogue
runSQLiteTestEpilogue
runTestEpilogue

Changes to readme.htm.

212
213
214
215
216
217
218

219
220
221
222
223
224
225
    <b>1.0.102.0 - June XX, 2016 <font color="red">(release scheduled)</font></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>Add VerifyOnly method to the SQLiteCommand class.</li>

</ul>
<p>
    <b>1.0.101.0 - April 19, 2016</b>
</p>
<ul>
    <li>Updated to <a href="https://www.sqlite.org/releaselog/3_12_2.html">SQLite 3.12.2</a>.</li>
    <li>Add binary package release for Mono on POSIX.</li>







>







212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
    <b>1.0.102.0 - June XX, 2016 <font color="red">(release scheduled)</font></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>Add VerifyOnly method to the SQLiteCommand class.</li>
    <li>Add IsReadOnly method to the SQLiteConnection class.</li>
</ul>
<p>
    <b>1.0.101.0 - April 19, 2016</b>
</p>
<ul>
    <li>Updated to <a href="https://www.sqlite.org/releaselog/3_12_2.html">SQLite 3.12.2</a>.</li>
    <li>Add binary package release for Mono on POSIX.</li>

Changes to www/news.wiki.

6
7
8
9
10
11
12

13
14
15
16
17
18
19
    <b>1.0.102.0 - June XX, 2016 <font color="red">(release scheduled)</font></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>
    <li>Prevent the SQLiteCommand.ExecuteScalar method from throwing an exception when there are no result columns.&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Add VerifyOnly method to the SQLiteCommand class.</li>

</ul>
<p>
    <b>1.0.101.0 - April 19, 2016</b>
</p>
<ul>
    <li>Updated to [https://www.sqlite.org/releaselog/3_12_2.html|SQLite 3.12.2].</li>
    <li>Add binary package release for Mono on POSIX.</li>







>







6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
    <b>1.0.102.0 - June XX, 2016 <font color="red">(release scheduled)</font></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>
    <li>Prevent the SQLiteCommand.ExecuteScalar method from throwing an exception when there are no result columns.&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Add VerifyOnly method to the SQLiteCommand class.</li>
    <li>Add IsReadOnly method to the SQLiteConnection class.</li>
</ul>
<p>
    <b>1.0.101.0 - April 19, 2016</b>
</p>
<ul>
    <li>Updated to [https://www.sqlite.org/releaselog/3_12_2.html|SQLite 3.12.2].</li>
    <li>Add binary package release for Mono on POSIX.</li>