Index: System.Data.SQLite/SQLiteModule.cs ================================================================== --- System.Data.SQLite/SQLiteModule.cs +++ System.Data.SQLite/SQLiteModule.cs @@ -1056,10 +1056,28 @@ return false; } /////////////////////////////////////////////////////////////////////// + /// + /// Determines if the native flags field can be used, based on the + /// available version of the SQLite core library. + /// + /// + /// Non-zero if the property is supported by + /// the SQLite core library. + /// + public bool CanUseColUsed() + { + if (UnsafeNativeMethods.sqlite3_libversion_number() >= 3010000) + return true; + + return false; + } + + /////////////////////////////////////////////////////////////////////// + #region Public Properties private SQLiteIndexConstraintUsage[] constraintUsages; /// /// An array of object /// instances, each containing information to be supplied to the SQLite @@ -1163,10 +1181,34 @@ public SQLiteIndexFlags? IdxFlags { get { return idxFlags; } set { idxFlags = value; } } + + /////////////////////////////////////////////////////////////////////// + + private long? colUsed; + /// + /// The colUsed field indicates which columns of the virtual table + /// may be required by the current scan. Virtual table columns are + /// numbered from zero in the order in which they appear within the + /// CREATE TABLE statement passed to sqlite3_declare_vtab(). For the + /// first 63 columns (columns 0-62), the corresponding bit is set + /// within the colUsed mask if the column may be required by SQLite. + /// If the table has at least 64 columns and any column to the right + /// of the first 63 is required, then bit 63 of colUsed is also set. + /// In other words, column iCol may be required if the expression + /// (colUsed & ((sqlite3_uint64)1 << (iCol>=63 ? 63 : iCol))) + /// evaluates to non-zero. Using a null value here indicates that a + /// default flags value should be used. This property has no effect + /// if the SQLite core library is not at least version 3.10.0. + /// + public long? ColUsed + { + get { return colUsed; } + set { colUsed = value; } + } #endregion } #endregion /////////////////////////////////////////////////////////////////////////// @@ -1399,10 +1441,17 @@ index.Outputs.IdxFlags.HasValue) { SQLiteMarshal.WriteInt32(pIndex, offset, (int)index.Outputs.IdxFlags.GetValueOrDefault()); } + + if (index.Outputs.CanUseColUsed() && + index.Outputs.ColUsed.HasValue) + { + SQLiteMarshal.WriteInt64(pIndex, offset, + index.Outputs.ColUsed.GetValueOrDefault()); + } } #endregion ///////////////////////////////////////////////////////////////////////