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

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

Overview
Comment:In the SQLiteFunction class, check if the database connection is open prior to attempting to call the Cancel method. Add NoFunctions connection flag to skip binding functions registered in the application domain. Fixes and adjustments to comments. Add several data-types for compatibility purposes. Fix for [fe50b8c2e8].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: dff9a878ddb106e63223043439cedeae4c917894
User & Date: mistachkin 2013-07-01 18:22:31
References
2013-07-01
18:23 Closed ticket [fe50b8c2e8]: Oracle DataTypes plus 3 other changes artifact: 31e4ce2082 user: mistachkin
Context
2013-07-02
07:07
Enable setting of the logging related SQLiteModule properties via the connection flags. check-in: 7c20d612a1 user: mistachkin tags: trunk
2013-07-01
18:22
In the SQLiteFunction class, check if the database connection is open prior to attempting to call the Cancel method. Add NoFunctions connection flag to skip binding functions registered in the application domain. Fixes and adjustments to comments. Add several data-types for compatibility purposes. Fix for [fe50b8c2e8]. check-in: dff9a878dd user: mistachkin tags: trunk
10:16
Allow virtual tables implemented in managed code to implement functions. check-in: 3e1da60858 user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to Doc/Extra/version.html.

    44     44       <div id="mainBody">
    45     45       <h1 class="heading">Version History</h1>
    46     46       <p><b>1.0.87.0 - June XX, 2013 <font color="red">(release scheduled)</font></b></p>
    47     47       <ul>
    48     48         <li>Add all the necessary infrastructure to allow virtual tables to be implemented in managed code. Fix for <a href="http://system.data.sqlite.org/index.html/info/9a544991be">[9a544991be]</a>.</li>
    49     49         <li>The DbType to type name translation needs to prioritize the Entity Framework type names. Fix for <a href="http://system.data.sqlite.org/index.html/info/47f4bac575">[47f4bac575]</a>.</li>
    50     50         <li>Add DateTimeFormatString connection string property to allow the DateTime format string used for all parsing and formatting to be overridden.</li>
           51  +      <li>Add NoFunctions connection flag to skip binding functions registered in the application domain.</li>
           52  +      <li>Add several data-types for compatibility purposes. Fix for <a href="http://system.data.sqlite.org/index.html/info/fe50b8c2e8">[fe50b8c2e8]</a>.</li>
    51     53         <li>When reading a DateTime value, avoid unnecessary string conversions. Fix for <a href="http://system.data.sqlite.org/index.html/info/4d87fbc742">[4d87fbc742]</a>.</li>
    52     54         <li>Modify the index introspection code so that it does not treat PRAGMA table_info &quot;pk&quot; column values as boolean. Fix for <a href="http://system.data.sqlite.org/index.html/info/f2c47a01eb">[f2c47a01eb]</a>.</li>
    53     55         <li>Disable use of the new connection string parsing algorithm when the No_SQLiteConnectionNewParser environment variable is set. Pursuant to <a href="http://system.data.sqlite.org/index.html/info/bbdda6eae2">[bbdda6eae2]</a>.</li>
    54     56         <li>Rename the ReturnCode property of the SQLiteException class to ResultCode.&nbsp;<b>** Potentially Incompatible Change **</b></li>
    55     57       </ul>
    56     58       <p><b>1.0.86.0 - May 23, 2013</b></p>
    57     59       <ul>

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

   232    232             }
   233    233             _sql = null;
   234    234         }
   235    235       }
   236    236   
   237    237       ///////////////////////////////////////////////////////////////////////////////////////////////
   238    238   
          239  +    /// <summary>
          240  +    /// Attempts to interrupt the query currently executing on the associated
          241  +    /// native database connection.
          242  +    /// </summary>
   239    243       internal override void Cancel()
   240    244       {
   241    245         UnsafeNativeMethods.sqlite3_interrupt(_sql);
   242    246       }
   243    247   
   244    248       internal override string Version
   245    249       {
................................................................................
   409    413       /// <returns>Returns a result code</returns>
   410    414       internal override SQLiteErrorCode Shutdown()
   411    415       {
   412    416           SQLiteErrorCode rc = UnsafeNativeMethods.sqlite3_shutdown();
   413    417           return rc;
   414    418       }
   415    419   
          420  +    /// <summary>
          421  +    /// Determines if the associated native connection handle is open.
          422  +    /// </summary>
          423  +    /// <returns>
          424  +    /// Non-zero if the associated native connection handle is open.
          425  +    /// </returns>
   416    426       internal override bool IsOpen()
   417    427       {
   418    428           return (_sql != null) && !_sql.IsInvalid && !_sql.IsClosed;
   419    429       }
   420    430   
   421    431       internal override void Open(string strFilename, SQLiteConnectionFlags connectionFlags, SQLiteOpenFlagsEnum openFlags, int maxPoolSize, bool usePool)
   422    432       {
................................................................................
   474    484   #endif
   475    485   
   476    486             if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, null);
   477    487             _sql = new SQLiteConnectionHandle(db, true);
   478    488           }
   479    489           lock (_sql) { /* HACK: Force the SyncBlock to be "created" now. */ }
   480    490         }
          491  +
   481    492         // Bind functions to this connection.  If any previous functions of the same name
   482    493         // were already bound, then the new bindings replace the old.
   483         -      _functionsArray = SQLiteFunction.BindFunctions(this, connectionFlags);
          494  +      if ((connectionFlags & SQLiteConnectionFlags.NoFunctions) != SQLiteConnectionFlags.NoFunctions)
          495  +          _functionsArray = SQLiteFunction.BindFunctions(this, connectionFlags);
          496  +
   484    497         SetTimeout(0);
   485    498         GC.KeepAlive(_sql);
   486    499       }
   487    500   
   488    501       internal override void ClearPool()
   489    502       {
   490    503         SQLiteConnectionPool.ClearPool(_fileName);

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

   189    189   #endif
   190    190   
   191    191             if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, null);
   192    192             _sql = new SQLiteConnectionHandle(db, true);
   193    193           }
   194    194           lock (_sql) { /* HACK: Force the SyncBlock to be "created" now. */ }
   195    195         }
   196         -      _functionsArray = SQLiteFunction.BindFunctions(this, connectionFlags);
          196  +
          197  +      // Bind functions to this connection.  If any previous functions of the same name
          198  +      // were already bound, then the new bindings replace the old.
          199  +      if ((connectionFlags & SQLiteConnectionFlags.NoFunctions) != SQLiteConnectionFlags.NoFunctions)
          200  +          _functionsArray = SQLiteFunction.BindFunctions(this, connectionFlags);
          201  +
   197    202         SetTimeout(0);
   198    203         GC.KeepAlive(_sql);
   199    204       }
   200    205   
   201    206       internal override void Bind_DateTime(SQLiteStatement stmt, SQLiteConnectionFlags flags, int index, DateTime dt)
   202    207       {
   203    208           switch (_datetimeFormat)

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

    72     72       internal abstract SQLiteErrorCode SetMemoryStatus(bool value);
    73     73       /// <summary>
    74     74       /// Shutdown the SQLite engine so that it can be restarted with different config options.
    75     75       /// We depend on auto initialization to recover.
    76     76       /// </summary>
    77     77       internal abstract SQLiteErrorCode Shutdown();
    78     78       /// <summary>
    79         -    /// Returns non-zero if a database connection is open.
           79  +    /// Determines if the associated native connection handle is open.
    80     80       /// </summary>
    81         -    /// <returns></returns>
           81  +    /// <returns>
           82  +    /// Non-zero if a database connection is open.
           83  +    /// </returns>
    82     84       internal abstract bool IsOpen();
    83     85       /// <summary>
    84     86       /// Opens a database.
    85     87       /// </summary>
    86     88       /// <remarks>
    87     89       /// Implementers should call SQLiteFunction.BindFunctions() and save the array after opening a connection
    88     90       /// to bind all attributed user-defined functions and collating sequences to the new connection.
................................................................................
   145    147       /// <summary>
   146    148       /// Resets a prepared statement so it can be executed again.  If the error returned is SQLITE_SCHEMA, 
   147    149       /// transparently attempt to rebuild the SQL statement and throw an error if that was not possible.
   148    150       /// </summary>
   149    151       /// <param name="stmt">The statement to reset</param>
   150    152       /// <returns>Returns -1 if the schema changed while resetting, 0 if the reset was sucessful or 6 (SQLITE_LOCKED) if the reset failed due to a lock</returns>
   151    153       internal abstract SQLiteErrorCode Reset(SQLiteStatement stmt);
          154  +
          155  +    /// <summary>
          156  +    /// Attempts to interrupt the query currently executing on the associated
          157  +    /// native database connection.
          158  +    /// </summary>
   152    159       internal abstract void Cancel();
   153    160   
   154    161       internal abstract void Bind_Double(SQLiteStatement stmt, SQLiteConnectionFlags flags, int index, double value);
   155    162       internal abstract void Bind_Int32(SQLiteStatement stmt, SQLiteConnectionFlags flags, int index, Int32 value);
   156    163       internal abstract void Bind_UInt32(SQLiteStatement stmt, SQLiteConnectionFlags flags, int index, UInt32 value);
   157    164       internal abstract void Bind_Int64(SQLiteStatement stmt, SQLiteConnectionFlags flags, int index, Int64 value);
   158    165       internal abstract void Bind_UInt64(SQLiteStatement stmt, SQLiteConnectionFlags flags, int index, UInt64 value);
................................................................................
   894    901   
   895    902         /// <summary>
   896    903         /// Prevent this <see cref="SQLiteConnection" /> object instance from
   897    904         /// creating virtual table modules.
   898    905         /// </summary>
   899    906         NoCreateModule = 0x400,
   900    907   
          908  +      /// <summary>
          909  +      /// Skip adding the any functions provided by other managed assemblies
          910  +      /// when opening the connection.
          911  +      /// </summary>
          912  +      NoFunctions = 0x800,
          913  +
   901    914         /// <summary>
   902    915         /// When binding and returning column values, always treat them as though
   903    916         /// they were plain text (i.e. no numeric, date/time, or other conversions
   904    917         /// should be attempted).
   905    918         /// </summary>
   906    919         BindAndGetAllAsText = BindAllAsText | GetAllAsText,
   907    920   

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

  1084   1084               new SQLiteDbTypeMapping("BIGUINT", DbType.UInt64, false),
  1085   1085               new SQLiteDbTypeMapping("BINARY", DbType.Binary, false),
  1086   1086               new SQLiteDbTypeMapping("BIT", DbType.Boolean, true),
  1087   1087               new SQLiteDbTypeMapping("BLOB", DbType.Binary, true),
  1088   1088               new SQLiteDbTypeMapping("BOOL", DbType.Boolean, false),
  1089   1089               new SQLiteDbTypeMapping("BOOLEAN", DbType.Boolean, false),
  1090   1090               new SQLiteDbTypeMapping("CHAR", DbType.AnsiStringFixedLength, true),
         1091  +            new SQLiteDbTypeMapping("CLOB", DbType.String, false),
  1091   1092               new SQLiteDbTypeMapping("COUNTER", DbType.Int64, false),
  1092   1093               new SQLiteDbTypeMapping("CURRENCY", DbType.Decimal, false),
  1093   1094               new SQLiteDbTypeMapping("DATE", DbType.DateTime, false),
  1094   1095               new SQLiteDbTypeMapping("DATETIME", DbType.DateTime, true),
  1095   1096               new SQLiteDbTypeMapping("DECIMAL", DbType.Decimal, true),
  1096   1097               new SQLiteDbTypeMapping("DOUBLE", DbType.Double, false),
  1097   1098               new SQLiteDbTypeMapping("FLOAT", DbType.Double, false),
................................................................................
  1115   1116               new SQLiteDbTypeMapping("LONGTEXT", DbType.String, false),
  1116   1117               new SQLiteDbTypeMapping("LONGVARCHAR", DbType.String, false),
  1117   1118               new SQLiteDbTypeMapping("MEMO", DbType.String, false),
  1118   1119               new SQLiteDbTypeMapping("MONEY", DbType.Decimal, false),
  1119   1120               new SQLiteDbTypeMapping("NCHAR", DbType.StringFixedLength, true),
  1120   1121               new SQLiteDbTypeMapping("NOTE", DbType.String, false),
  1121   1122               new SQLiteDbTypeMapping("NTEXT", DbType.String, false),
         1123  +            new SQLiteDbTypeMapping("NUMBER", DbType.Decimal, false),
  1122   1124               new SQLiteDbTypeMapping("NUMERIC", DbType.Decimal, false),
  1123   1125               new SQLiteDbTypeMapping("NVARCHAR", DbType.String, true),
  1124   1126               new SQLiteDbTypeMapping("OLEOBJECT", DbType.Binary, false),
         1127  +            new SQLiteDbTypeMapping("RAW", DbType.Binary, false),
  1125   1128               new SQLiteDbTypeMapping("REAL", DbType.Double, true),
  1126   1129               new SQLiteDbTypeMapping("SINGLE", DbType.Single, true),
  1127   1130               new SQLiteDbTypeMapping("SMALLDATE", DbType.DateTime, false),
  1128   1131               new SQLiteDbTypeMapping("SMALLINT", DbType.Int16, true),
  1129   1132               new SQLiteDbTypeMapping("SMALLUINT", DbType.UInt16, true),
  1130   1133               new SQLiteDbTypeMapping("STRING", DbType.String, false),
  1131   1134               new SQLiteDbTypeMapping("TEXT", DbType.String, false),
................................................................................
  1143   1146               new SQLiteDbTypeMapping("UNSIGNEDINTEGER", DbType.UInt64, true),
  1144   1147               new SQLiteDbTypeMapping("UNSIGNEDINTEGER8", DbType.Byte, false),
  1145   1148               new SQLiteDbTypeMapping("UNSIGNEDINTEGER16", DbType.UInt16, false),
  1146   1149               new SQLiteDbTypeMapping("UNSIGNEDINTEGER32", DbType.UInt32, false),
  1147   1150               new SQLiteDbTypeMapping("UNSIGNEDINTEGER64", DbType.UInt64, false),
  1148   1151               new SQLiteDbTypeMapping("VARBINARY", DbType.Binary, false),
  1149   1152               new SQLiteDbTypeMapping("VARCHAR", DbType.AnsiString, true),
         1153  +            new SQLiteDbTypeMapping("VARCHAR2", DbType.AnsiString, false),
  1150   1154               new SQLiteDbTypeMapping("YESNO", DbType.Boolean, false)
  1151   1155           });
  1152   1156       }
  1153   1157   
  1154   1158       /// <summary>
  1155   1159       /// For a given type name, return a closest-match .NET type
  1156   1160       /// </summary>

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

   464    464               }
   465    465           }
   466    466   
   467    467           //
   468    468           // NOTE: This must be done to prevent the core SQLite library from
   469    469           //       using our (invalid) result.
   470    470           //
   471         -        if (_base != null)
          471  +        if ((_base != null) && _base.IsOpen())
   472    472               _base.Cancel();
   473    473   
   474    474           return 0;
   475    475       }
   476    476   
   477    477       /// <summary>
   478    478       /// Internal collation sequence function, which wraps up the raw string pointers and executes the Compare() virtual function.
................................................................................
   511    511               }
   512    512           }
   513    513   
   514    514           //
   515    515           // NOTE: This must be done to prevent the core SQLite library from
   516    516           //       using our (invalid) result.
   517    517           //
   518         -        if (_base != null)
          518  +        if ((_base != null) && _base.IsOpen())
   519    519               _base.Cancel();
   520    520   
   521    521           return 0;
   522    522       }
   523    523   
   524    524       /// <summary>
   525    525       /// The internal aggregate Step function callback, which wraps the raw context pointer and calls the virtual Step() method.

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

  5876   5876               return sqliteBase.DeclareVirtualTable(this, sql, ref error);
  5877   5877           }
  5878   5878           #endregion
  5879   5879   
  5880   5880           ///////////////////////////////////////////////////////////////////////
  5881   5881   
  5882   5882           #region Function Declaration Helper Methods
         5883  +        /// <summary>
         5884  +        /// Calls the native SQLite core library in order to declare a virtual
         5885  +        /// table function in response to a call into the
         5886  +        /// <see cref="ISQLiteNativeModule.xCreate" />
         5887  +        /// or <see cref="ISQLiteNativeModule.xConnect" /> virtual table
         5888  +        /// methods.
         5889  +        /// </summary>
         5890  +        /// <param name="connection">
         5891  +        /// The <see cref="SQLiteConnection" /> object instance to use when
         5892  +        /// declaring the schema of the virtual table.
         5893  +        /// </param>
         5894  +        /// <param name="argumentCount">
         5895  +        /// The number of arguments to the function being declared.
         5896  +        /// </param>
         5897  +        /// <param name="name">
         5898  +        /// The name of the function being declared.
         5899  +        /// </param>
         5900  +        /// <param name="error">
         5901  +        /// Upon success, the contents of this parameter are undefined.  Upon
         5902  +        /// failure, it should contain an appropriate error message.
         5903  +        /// </param>
         5904  +        /// <returns>
         5905  +        /// A standard SQLite return code.
         5906  +        /// </returns>
  5883   5907           protected virtual SQLiteErrorCode DeclareFunction(
  5884   5908               SQLiteConnection connection,
  5885   5909               int argumentCount,
  5886   5910               string name,
  5887   5911               ref string error
  5888   5912               )
  5889   5913           {

Changes to Tests/basic.eagle.

  1457   1457   } -constraints {eagle SQLite System.Data.SQLite System.Data.SQLite.Linq} \
  1458   1458   -result {}}
  1459   1459   
  1460   1460   ###############################################################################
  1461   1461   
  1462   1462   runTest {test data-1.27 {VARCHAR / NVARCHAR types with spaces} -body {
  1463   1463     list [object invoke -flags +NonPublic System.Data.SQLite.SQLiteConvert \
  1464         -      TypeNameToDbType "VARCHAR"] \
         1464  +      TypeNameToDbType VARCHAR] \
         1465  +      [object invoke -flags +NonPublic System.Data.SQLite.SQLiteConvert \
         1466  +      TypeNameToDbType NVARCHAR] \
  1465   1467         [object invoke -flags +NonPublic System.Data.SQLite.SQLiteConvert \
  1466         -      TypeNameToDbType "NVARCHAR"] \
         1468  +      TypeNameToDbType VARCHAR(1)] \
  1467   1469         [object invoke -flags +NonPublic System.Data.SQLite.SQLiteConvert \
  1468         -      TypeNameToDbType "VARCHAR(1)"] \
  1469         -      [object invoke -flags +NonPublic System.Data.SQLite.SQLiteConvert \
  1470         -      TypeNameToDbType "NVARCHAR(1)"] \
         1470  +      TypeNameToDbType NVARCHAR(1)] \
  1471   1471         [object invoke -flags +NonPublic System.Data.SQLite.SQLiteConvert \
  1472   1472         TypeNameToDbType "VARCHAR (1)"] \
  1473   1473         [object invoke -flags +NonPublic System.Data.SQLite.SQLiteConvert \
  1474   1474         TypeNameToDbType "NVARCHAR (1)"] \
  1475   1475   } -constraints {eagle System.Data.SQLite} -result \
  1476   1476   {AnsiString String AnsiString String AnsiString String}}
  1477   1477   

Added Tests/tkt-fe50b8c2e8.eagle.

            1  +###############################################################################
            2  +#
            3  +# tkt-fe50b8c2e8.eagle --
            4  +#
            5  +# Written by Joe Mistachkin.
            6  +# Released to the public domain, use at your own risk!
            7  +#
            8  +###############################################################################
            9  +
           10  +package require Eagle
           11  +package require Eagle.Library
           12  +package require Eagle.Test
           13  +
           14  +runTestPrologue
           15  +
           16  +###############################################################################
           17  +
           18  +package require System.Data.SQLite.Test
           19  +runSQLiteTestPrologue
           20  +
           21  +###############################################################################
           22  +
           23  +runTest {test tkt-fe50b8c2e8-1.1 {compatibility data types} -body {
           24  +  list [object invoke -flags +NonPublic System.Data.SQLite.SQLiteConvert \
           25  +      TypeNameToDbType VARCHAR2] \
           26  +      [object invoke -flags +NonPublic System.Data.SQLite.SQLiteConvert \
           27  +      TypeNameToDbType CLOB] \
           28  +      [object invoke -flags +NonPublic System.Data.SQLite.SQLiteConvert \
           29  +      TypeNameToDbType NUMBER] \
           30  +      [object invoke -flags +NonPublic System.Data.SQLite.SQLiteConvert \
           31  +      TypeNameToDbType RAW] \
           32  +      [object invoke -flags +NonPublic System.Data.SQLite.SQLiteConvert \
           33  +      DbTypeToTypeName AnsiString] \
           34  +      [object invoke -flags +NonPublic System.Data.SQLite.SQLiteConvert \
           35  +      DbTypeToTypeName String] \
           36  +      [object invoke -flags +NonPublic System.Data.SQLite.SQLiteConvert \
           37  +      DbTypeToTypeName Decimal] \
           38  +      [object invoke -flags +NonPublic System.Data.SQLite.SQLiteConvert \
           39  +      DbTypeToTypeName Binary]
           40  +} -constraints {eagle System.Data.SQLite} -result \
           41  +{AnsiString String Decimal Binary VARCHAR NVARCHAR DECIMAL BLOB}}
           42  +
           43  +###############################################################################
           44  +
           45  +runSQLiteTestEpilogue
           46  +runTestEpilogue

Changes to Tests/vtab.eagle.

    17     17   
    18     18   package require System.Data.SQLite.Test
    19     19   runSQLiteTestPrologue
    20     20   
    21     21   ###############################################################################
    22     22   
    23     23   runTest {test vtab-1.1 {basic virtual table support} -setup {
    24         -  setupDb [set fileName vtab-1.1.db]
           24  +  set fileName vtab-1.1.db
    25     25   } -body {
    26     26     set id [object invoke Interpreter.GetActive NextId]
    27     27     set dataSource [file join [getDatabaseDirectory] $fileName]
    28     28   
    29     29     set sql { \
    30     30       CREATE VIRTUAL TABLE t${id} USING mod${id}; \
    31     31     }
................................................................................
    96     96         [expr {[info exists errors] ? $errors : ""}] \
    97     97         [expr {$code eq "Ok" ? [catch {
    98     98           object invoke _Dynamic${id}.Test${id} Main
    99     99         } result] : [set result ""]}] $result
   100    100   } -cleanup {
   101    101     cleanupDb $fileName
   102    102   
   103         -  unset -nocomplain result code results errors sql dataSource id db fileName
          103  +  unset -nocomplain result code results errors sql dataSource id fileName
   104    104   } -constraints \
   105    105   {eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite\
   106    106   defineConstant.System.Data.SQLite.INTEROP_VIRTUAL_TABLE} -match regexp -result \
   107    107   {^Ok System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\}$}}
   108    108   
   109    109   ###############################################################################
   110    110   
   111    111   runTest {test vtab-1.2 {IEnumerable virtual table} -setup {
   112         -  setupDb [set fileName vtab-1.2.db]
          112  +  set fileName vtab-1.2.db
   113    113   } -body {
   114    114     set id [object invoke Interpreter.GetActive NextId]
   115    115     set dataSource [file join [getDatabaseDirectory] $fileName]
   116    116   
   117    117     set sql(1) { \
   118    118       CREATE VIRTUAL TABLE t${id} USING mod${id}; \
   119    119     }
................................................................................
   201    201         [expr {[info exists errors] ? $errors : ""}] \
   202    202         [expr {$code eq "Ok" ? [catch {
   203    203           object invoke _Dynamic${id}.Test${id} GetList one two three 4 5.0
   204    204         } result] : [set result ""]}] $result
   205    205   } -cleanup {
   206    206     cleanupDb $fileName
   207    207   
   208         -  unset -nocomplain result code results errors sql dataSource id db fileName
          208  +  unset -nocomplain result code results errors sql dataSource id fileName
   209    209   } -constraints \
   210    210   {eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite\
   211    211   defineConstant.System.Data.SQLite.INTEROP_VIRTUAL_TABLE} -match regexp -result \
   212    212   [string map [list \n \r\n] {^Ok System#CodeDom#Compiler#CompilerResults#\d+\
   213    213   \{\} 0 \{one two three 4 5.0 Error \{SQL logic error or missing database
   214    214   virtual table "t\d+" is read-only\}\}$}]}
   215    215   
   216    216   ###############################################################################
   217    217   
   218    218   runTest {test vtab-1.3 {IEnumerable<T> virtual table} -setup {
   219         -  setupDb [set fileName vtab-1.3.db]
          219  +  set fileName vtab-1.3.db
   220    220   } -body {
   221    221     set id [object invoke Interpreter.GetActive NextId]
   222    222     set dataSource [file join [getDatabaseDirectory] $fileName]
   223    223   
   224    224     set sql(1) { \
   225    225       CREATE VIRTUAL TABLE t${id} USING mod${id}; \
   226    226     }
................................................................................
   309    309         [expr {[info exists errors] ? $errors : ""}] \
   310    310         [expr {$code eq "Ok" ? [catch {
   311    311           object invoke _Dynamic${id}.Test${id} GetList 1 2 3 4 5
   312    312         } result] : [set result ""]}] $result
   313    313   } -cleanup {
   314    314     cleanupDb $fileName
   315    315   
   316         -  unset -nocomplain result code results errors sql dataSource id db fileName
          316  +  unset -nocomplain result code results errors sql dataSource id fileName
   317    317   } -constraints \
   318    318   {eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite\
   319    319   defineConstant.System.Data.SQLite.INTEROP_VIRTUAL_TABLE} -match regexp -result \
   320    320   [string map [list \n \r\n] {^Ok System#CodeDom#Compiler#CompilerResults#\d+\
   321    321   \{\} 0 \{1 2 3 4 5 Error \{SQL logic error or missing database
   322    322   virtual table "t\d+" is read-only\}\}$}]}
   323    323   
   324    324   ###############################################################################
   325    325   
   326    326   runTest {test vtab-1.4 {virtual table function support} -setup {
   327         -  setupDb [set fileName vtab-1.4.db]
          327  +  set fileName vtab-1.4.db
          328  +} -body {
          329  +  set id [object invoke Interpreter.GetActive NextId]
          330  +  set dataSource [file join [getDatabaseDirectory] $fileName]
          331  +
          332  +  set sql(1) { \
          333  +    CREATE VIRTUAL TABLE t${id} USING mod${id}; \
          334  +  }
          335  +
          336  +  set sql(2) { \
          337  +    SELECT Base64(x, CAST('one' AS BLOB)) FROM t${id}; \
          338  +  }
          339  +
          340  +  set sql(3) { \
          341  +    SELECT Base64(x, CAST('one' AS BLOB), 'two') FROM t${id}; \
          342  +  }
          343  +
          344  +  set sql(4) { \
          345  +    SELECT Base65(x, CAST('one' AS BLOB)) FROM t${id}; \
          346  +  }
          347  +
          348  +  unset -nocomplain results errors
          349  +
          350  +  set code [compileCSharpWith [subst {
          351  +    using System;
          352  +    using System.Data.SQLite;
          353  +    using Eagle._Containers.Public;
          354  +
          355  +    namespace _Dynamic${id}
          356  +    {
          357  +      public class SQLiteFunction${id} : SQLiteFunction
          358  +      {
          359  +        public SQLiteFunction${id}()
          360  +          : base(SQLiteDateFormats.Default, DateTimeKind.Unspecified,
          361  +                 null, false)
          362  +        {
          363  +          // do nothing.
          364  +        }
          365  +
          366  +        ///////////////////////////////////////////////////////////////////////
          367  +
          368  +        public override object Invoke(
          369  +          object\[\] args
          370  +          )
          371  +        {
          372  +          if (args == null)
          373  +            return null;
          374  +
          375  +          if (args.Length != 2)
          376  +            return new ArgumentException(String.Format(
          377  +              "need exactly two arguments, got {0}", args.Length));
          378  +
          379  +          object arg = args\[1\];
          380  +
          381  +          if (arg == null)
          382  +            return String.Empty;
          383  +
          384  +          Type type = arg.GetType();
          385  +
          386  +          if (type == typeof(DBNull))
          387  +            return String.Empty;
          388  +
          389  +          if (type != typeof(byte\[\]))
          390  +            return new ArgumentException(String.Format(
          391  +              "argument must be byte array, got {0}", type));
          392  +
          393  +          return Convert.ToBase64String((byte\[\]) arg);
          394  +        }
          395  +      }
          396  +
          397  +      /////////////////////////////////////////////////////////////////////////
          398  +
          399  +      public sealed class SQLiteModuleTest${id} : SQLiteModuleNoop
          400  +      {
          401  +        public SQLiteModuleTest${id}(string name)
          402  +          : base(name)
          403  +        {
          404  +          // do nothing.
          405  +        }
          406  +
          407  +        ///////////////////////////////////////////////////////////////////////
          408  +
          409  +        public override SQLiteErrorCode Create(
          410  +          SQLiteConnection connection,
          411  +          IntPtr pClientData,
          412  +          string\[\] arguments,
          413  +          ref SQLiteVirtualTable table,
          414  +          ref string error
          415  +          )
          416  +        {
          417  +          SQLiteErrorCode rc = DeclareTable(
          418  +            connection, "CREATE TABLE ignored(x);", ref error);
          419  +
          420  +          if (rc != SQLiteErrorCode.Ok)
          421  +            return rc;
          422  +
          423  +          rc = DeclareFunction(connection, -1, "Base64", ref error);
          424  +
          425  +          if (rc != SQLiteErrorCode.Ok)
          426  +            return rc;
          427  +
          428  +          table = new SQLiteVirtualTable(arguments);
          429  +          return SQLiteErrorCode.Ok;
          430  +        }
          431  +
          432  +        ///////////////////////////////////////////////////////////////////////
          433  +
          434  +        public override SQLiteErrorCode Open(
          435  +          SQLiteVirtualTable table,
          436  +          ref SQLiteVirtualTableCursor cursor
          437  +          )
          438  +        {
          439  +          cursor = new SQLiteVirtualTableCursor(table);
          440  +          return SQLiteErrorCode.Ok;
          441  +        }
          442  +
          443  +        ///////////////////////////////////////////////////////////////////////
          444  +
          445  +        public override bool FindFunction(
          446  +          SQLiteVirtualTable table,
          447  +          int argumentCount,
          448  +          string name,
          449  +          ref SQLiteFunction function,
          450  +          ref IntPtr pClientData
          451  +          )
          452  +        {
          453  +          if (argumentCount != 2)
          454  +          {
          455  +            SetTableError(table, String.Format(
          456  +              "no \\"{0}\\" functions accept {1} argument(s)",
          457  +              base.Name, argumentCount));
          458  +
          459  +            return false;
          460  +          }
          461  +
          462  +          if (!String.Equals(name, "Base64",
          463  +              StringComparison.OrdinalIgnoreCase))
          464  +          {
          465  +            SetTableError(table, String.Format(
          466  +              "no \\"{0}\\" functions are named \\"{1}\\"",
          467  +              base.Name, name));
          468  +
          469  +            return false;
          470  +          }
          471  +
          472  +          function = new SQLiteFunction${id}();
          473  +          return true;
          474  +        }
          475  +      }
          476  +
          477  +      /////////////////////////////////////////////////////////////////////////
          478  +
          479  +      public static class Test${id}
          480  +      {
          481  +        public static StringList GetList()
          482  +        {
          483  +          StringList result = new StringList();
          484  +
          485  +          using (SQLiteConnection connection = new SQLiteConnection(
          486  +              "Data Source=${dataSource};Flags=NoFunctions;"))
          487  +          {
          488  +            connection.Open();
          489  +            connection.CreateModule(new SQLiteModuleTest${id}("mod${id}"));
          490  +
          491  +            try
          492  +            {
          493  +              using (SQLiteCommand command = connection.CreateCommand())
          494  +              {
          495  +                command.CommandText = "[subst ${sql(1)}]";
          496  +                result.Add(String.Format("{0}", command.ExecuteScalar()));
          497  +              }
          498  +            }
          499  +            catch (Exception e)
          500  +            {
          501  +              result.Add(e.Message);
          502  +            }
          503  +
          504  +            try
          505  +            {
          506  +              using (SQLiteCommand command = connection.CreateCommand())
          507  +              {
          508  +                command.CommandText = "[subst ${sql(2)}]";
          509  +                result.Add(String.Format("{0}", command.ExecuteScalar()));
          510  +              }
          511  +            }
          512  +            catch (Exception e)
          513  +            {
          514  +              result.Add(e.Message);
          515  +            }
          516  +
          517  +            try
          518  +            {
          519  +              using (SQLiteCommand command = connection.CreateCommand())
          520  +              {
          521  +                command.CommandText = "[subst ${sql(3)}]";
          522  +                result.Add(String.Format("{0}", command.ExecuteScalar()));
          523  +              }
          524  +            }
          525  +            catch (Exception e)
          526  +            {
          527  +              result.Add(e.Message);
          528  +            }
          529  +
          530  +            try
          531  +            {
          532  +              using (SQLiteCommand command = connection.CreateCommand())
          533  +              {
          534  +                command.CommandText = "[subst ${sql(4)}]";
          535  +                result.Add(String.Format("{0}", command.ExecuteScalar()));
          536  +              }
          537  +            }
          538  +            catch (Exception e)
          539  +            {
          540  +              result.Add(e.Message);
          541  +            }
          542  +
          543  +            connection.Close();
          544  +          }
          545  +
          546  +          return result;
          547  +        }
          548  +
          549  +        ///////////////////////////////////////////////////////////////////////
          550  +
          551  +        public static void Main()
          552  +        {
          553  +          // do nothing.
          554  +        }
          555  +      }
          556  +    }
          557  +  }] true true true results errors [list System.Data.SQLite.dll Eagle.dll]]
          558  +
          559  +  list $code $results \
          560  +      [expr {[info exists errors] ? $errors : ""}] \
          561  +      [expr {$code eq "Ok" ? [catch {
          562  +        object invoke _Dynamic${id}.Test${id} GetList
          563  +      } result] : [set result ""]}] $result
          564  +} -cleanup {
          565  +  cleanupDb $fileName
          566  +
          567  +  unset -nocomplain result code results errors sql dataSource id fileName
          568  +} -constraints \
          569  +{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite\
          570  +defineConstant.System.Data.SQLite.INTEROP_VIRTUAL_TABLE} -match regexp -result \
          571  +[string map [list \n \r\n] {^Ok System#CodeDom#Compiler#CompilerResults#\d+\
          572  +\{\} 0 \{\{\} b25l \{SQL logic error or missing database
          573  +unable to use function Base64 in the requested context\} \{SQL logic error or\
          574  +missing database
          575  +no such function: Base65\}\}$}]}
          576  +
          577  +###############################################################################
          578  +
          579  +runTest {test vtab-1.5 {virtual table function support} -setup {
          580  +  set fileName vtab-1.5.db
   328    581   } -body {
   329    582     set id [object invoke Interpreter.GetActive NextId]
   330    583     set dataSource [file join [getDatabaseDirectory] $fileName]
   331    584   
   332    585     set sql(1) { \
   333    586       CREATE VIRTUAL TABLE t${id} USING mod${id}; \
   334    587     }
................................................................................
   560    813         [expr {[info exists errors] ? $errors : ""}] \
   561    814         [expr {$code eq "Ok" ? [catch {
   562    815           object invoke _Dynamic${id}.Test${id} GetList
   563    816         } result] : [set result ""]}] $result
   564    817   } -cleanup {
   565    818     cleanupDb $fileName
   566    819   
   567         -  unset -nocomplain result code results errors sql dataSource id db fileName
          820  +  unset -nocomplain result code results errors sql dataSource id fileName
   568    821   } -constraints \
   569    822   {eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite\
   570    823   defineConstant.System.Data.SQLite.INTEROP_VIRTUAL_TABLE} -match regexp -result \
   571    824   [string map [list \n \r\n] {^Ok System#CodeDom#Compiler#CompilerResults#\d+\
   572    825   \{\} 0 \{\{\} b25l \{SQL logic error or missing database
   573         -unable to use function Base64 in the requested context\} \{SQL logic error or\
   574         -missing database
          826  +(?:unable to use function Base64 in the requested context|need exactly one\
          827  +argument, got 3)\} \{SQL logic error or missing database
   575    828   no such function: Base65\}\}$}]}
   576    829   
   577    830   ###############################################################################
   578    831   
   579    832   runSQLiteTestEpilogue
   580    833   runTestEpilogue

Changes to readme.htm.

   189    189   <p>
   190    190       <b>1.0.87.0 - June XX, 2013 <font color="red">(release scheduled)</font></b>
   191    191   </p>
   192    192   <ul>
   193    193       <li>Add all the necessary infrastructure to allow virtual tables to be implemented in managed code. Fix for [9a544991be].</li>
   194    194       <li>The DbType to type name translation needs to prioritize the Entity Framework type names. Fix for [47f4bac575].</li>
   195    195       <li>Add DateTimeFormatString connection string property to allow the DateTime format string used for all parsing and formatting to be overridden.</li>
          196  +    <li>Add NoFunctions connection flag to skip binding functions registered in the application domain.</li>
          197  +    <li>Add several data-types for compatibility purposes. Fix for [fe50b8c2e8].</li>
   196    198       <li>When reading a DateTime value, avoid unnecessary string conversions. Fix for [4d87fbc742].</li>
   197    199       <li>Modify the index introspection code so that it does not treat PRAGMA table_info &quot;pk&quot; column values as boolean. Fix for [f2c47a01eb].</li>
   198    200       <li>Disable use of the new connection string parsing algorithm when the No_SQLiteConnectionNewParser environment variable is set. Pursuant to [bbdda6eae2].</li>
   199    201       <li>Rename the ReturnCode property of the SQLiteException class to ResultCode.&nbsp;<b>** Potentially Incompatible Change **</b></li>
   200    202   </ul>
   201    203   <p>
   202    204       <b>1.0.86.0 - May 23, 2013</b>

Changes to www/news.wiki.

     5      5   <p>
     6      6       <b>1.0.87.0 - June XX, 2013 <font color="red">(release scheduled)</font></b>
     7      7   </p>
     8      8   <ul>
     9      9       <li>Add all the necessary infrastructure to allow virtual tables to be implemented in managed code. Fix for [9a544991be].</li>
    10     10       <li>The DbType to type name translation needs to prioritize the Entity Framework type names. Fix for [47f4bac575].</li>
    11     11       <li>Add DateTimeFormatString connection string property to allow the DateTime format string used for all parsing and formatting to be overridden.</li>
           12  +    <li>Add NoFunctions connection flag to skip binding functions registered in the application domain.</li>
           13  +    <li>Add several data-types for compatibility purposes. Fix for [fe50b8c2e8].</li>
    12     14       <li>When reading a DateTime value, avoid unnecessary string conversions. Fix for [4d87fbc742].</li>
    13     15       <li>Modify the index introspection code so that it does not treat PRAGMA table_info &quot;pk&quot; column values as boolean. Fix for [f2c47a01eb].</li>
    14     16       <li>Disable use of the new connection string parsing algorithm when the No_SQLiteConnectionNewParser environment variable is set. Pursuant to [bbdda6eae2].</li>
    15     17       <li>Rename the ReturnCode property of the SQLiteException class to ResultCode.&nbsp;<b>** Potentially Incompatible Change **</b></li>
    16     18   </ul>
    17     19   <p>
    18     20       <b>1.0.86.0 - May 23, 2013</b>