Index: Doc/Extra/Provider/version.html
==================================================================
--- Doc/Extra/Provider/version.html
+++ Doc/Extra/Provider/version.html
@@ -45,10 +45,12 @@
Version History
1.0.98.0 - August XX, 2015 (release scheduled)
- Updated to SQLite 3.8.11.
- Implement the Substring method for LINQ using the "substr" core SQL function. ** Potentially Incompatible Change **
+ - Add the VfsName connection string property to allow a non-default VFS to be used by the SQLite core library.
+ - Enable integration with the ZipVFS extension.
1.0.97.0 - May 26, 2015
- Updated to SQLite 3.8.10.2.
- Updated to Entity Framework 6.1.3.
Index: SQLite.Interop/props/SQLite.Interop.2005.vsprops
==================================================================
--- SQLite.Interop/props/SQLite.Interop.2005.vsprops
+++ SQLite.Interop/props/SQLite.Interop.2005.vsprops
@@ -57,11 +57,11 @@
Value="INTEROP_DEBUG=0x31F;INTEROP_LOG=1;INTEROP_TEST_EXTENSION=1"
PerformEnvironmentSet="true"
/>
1,0,98,0
src\core
INTEROP_DEBUG=0x31F;INTEROP_LOG=1;INTEROP_TEST_EXTENSION=1
- INTEROP_EXTENSION_FUNCTIONS=1;INTEROP_CODEC=1;INTEROP_VIRTUAL_TABLE=1;INTEROP_PERCENTILE_EXTENSION=1;INTEROP_TOTYPE_EXTENSION=1;INTEROP_REGEXP_EXTENSION=1
+ INTEROP_PLACEHOLDER=1;INTEROP_EXTENSION_FUNCTIONS=1;INTEROP_CODEC=1;INTEROP_VIRTUAL_TABLE=1;INTEROP_PERCENTILE_EXTENSION=1;INTEROP_TOTYPE_EXTENSION=1;INTEROP_REGEXP_EXTENSION=1
/ASSEMBLYRESOURCE:..\System.Data.SQLite\Resources\SQLiteCommand.bmp,System.Data.SQLite.SQLiteCommand.bmp /ASSEMBLYRESOURCE:..\System.Data.SQLite\Resources\SQLiteConnection.bmp,System.Data.SQLite.SQLiteConnection.bmp /ASSEMBLYRESOURCE:..\System.Data.SQLite\Resources\SQLiteDataAdapter.bmp,System.Data.SQLite.SQLiteDataAdapter.bmp
$(ProjectDir)..\Keys\System.Data.SQLite.snk
SQLite.Interop
System.Data.SQLite
Index: SQLite.Interop/props/SQLite.Interop.2012.props
==================================================================
--- SQLite.Interop/props/SQLite.Interop.2012.props
+++ SQLite.Interop/props/SQLite.Interop.2012.props
@@ -16,11 +16,11 @@
1,0,98,0
src\core
INTEROP_DEBUG=0x31F;INTEROP_LOG=1;INTEROP_TEST_EXTENSION=1
- INTEROP_EXTENSION_FUNCTIONS=1;INTEROP_CODEC=1;INTEROP_VIRTUAL_TABLE=1;INTEROP_PERCENTILE_EXTENSION=1;INTEROP_TOTYPE_EXTENSION=1;INTEROP_REGEXP_EXTENSION=1
+ INTEROP_PLACEHOLDER=1;INTEROP_EXTENSION_FUNCTIONS=1;INTEROP_CODEC=1;INTEROP_VIRTUAL_TABLE=1;INTEROP_PERCENTILE_EXTENSION=1;INTEROP_TOTYPE_EXTENSION=1;INTEROP_REGEXP_EXTENSION=1
/ASSEMBLYRESOURCE:..\System.Data.SQLite\Resources\SQLiteCommand.bmp,System.Data.SQLite.SQLiteCommand.bmp /ASSEMBLYRESOURCE:..\System.Data.SQLite\Resources\SQLiteConnection.bmp,System.Data.SQLite.SQLiteConnection.bmp /ASSEMBLYRESOURCE:..\System.Data.SQLite\Resources\SQLiteDataAdapter.bmp,System.Data.SQLite.SQLiteDataAdapter.bmp
$(ProjectDir)..\Keys\System.Data.SQLite.snk
SQLite.Interop
System.Data.SQLite
Index: SQLite.Interop/props/SQLite.Interop.2013.props
==================================================================
--- SQLite.Interop/props/SQLite.Interop.2013.props
+++ SQLite.Interop/props/SQLite.Interop.2013.props
@@ -16,11 +16,11 @@
1,0,98,0
src\core
INTEROP_DEBUG=0x31F;INTEROP_LOG=1;INTEROP_TEST_EXTENSION=1
- INTEROP_EXTENSION_FUNCTIONS=1;INTEROP_CODEC=1;INTEROP_VIRTUAL_TABLE=1;INTEROP_PERCENTILE_EXTENSION=1;INTEROP_TOTYPE_EXTENSION=1;INTEROP_REGEXP_EXTENSION=1
+ INTEROP_PLACEHOLDER=1;INTEROP_EXTENSION_FUNCTIONS=1;INTEROP_CODEC=1;INTEROP_VIRTUAL_TABLE=1;INTEROP_PERCENTILE_EXTENSION=1;INTEROP_TOTYPE_EXTENSION=1;INTEROP_REGEXP_EXTENSION=1
/ASSEMBLYRESOURCE:..\System.Data.SQLite\Resources\SQLiteCommand.bmp,System.Data.SQLite.SQLiteCommand.bmp /ASSEMBLYRESOURCE:..\System.Data.SQLite\Resources\SQLiteConnection.bmp,System.Data.SQLite.SQLiteConnection.bmp /ASSEMBLYRESOURCE:..\System.Data.SQLite\Resources\SQLiteDataAdapter.bmp,System.Data.SQLite.SQLiteDataAdapter.bmp
$(ProjectDir)..\Keys\System.Data.SQLite.snk
SQLite.Interop
System.Data.SQLite
Index: SQLite.Interop/props/sqlite3.props
==================================================================
--- SQLite.Interop/props/sqlite3.props
+++ SQLite.Interop/props/sqlite3.props
@@ -10,11 +10,11 @@
3.8.11.0
3,8,11,0
_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;SQLITE_THREADSAFE=1;SQLITE_USE_URI=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_STAT4=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_LOAD_EXTENSION=1;SQLITE_ENABLE_RTREE=1;SQLITE_SOUNDEX=1;SQLITE_ENABLE_MEMORY_MANAGEMENT=1
- SQLITE_HAS_CODEC=1
+ SQLITE_PLACEHOLDER=1;SQLITE_HAS_CODEC=1
SQLITE_OMIT_WAL=1
HAVE_ERRNO_H=1;SQLITE_MSVC_LOCALTIME_API=1
SQLITE_DEBUG=1;SQLITE_MEMDEBUG=1;SQLITE_ENABLE_EXPENSIVE_ASSERT=1
SQLITE_WIN32_MALLOC=1
4055;4100;4127;4146;4210;4232;4244;4245;4267;4306;4389;4701;4703;4706
Index: SQLite.Interop/props/sqlite3.vsprops
==================================================================
--- SQLite.Interop/props/sqlite3.vsprops
+++ SQLite.Interop/props/sqlite3.vsprops
@@ -27,11 +27,11 @@
Value="_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;SQLITE_THREADSAFE=1;SQLITE_USE_URI=1;SQLITE_ENABLE_COLUMN_METADATA=1;SQLITE_ENABLE_STAT4=1;SQLITE_ENABLE_FTS3=1;SQLITE_ENABLE_LOAD_EXTENSION=1;SQLITE_ENABLE_RTREE=1;SQLITE_SOUNDEX=1;SQLITE_ENABLE_MEMORY_MANAGEMENT=1"
PerformEnvironmentSet="true"
/>
= 3004001
#include "../ext/vtshim.c"
#endif
@@ -106,10 +111,13 @@
#ifdef INTEROP_INCLUDE_EXTRA
"INCLUDE_EXTRA",
#endif
#ifdef INTEROP_INCLUDE_SEE
"INCLUDE_SEE",
+#endif
+#ifdef INTEROP_INCLUDE_ZIPVFS
+ "INCLUDE_ZIPVFS",
#endif
#ifdef INTEROP_LEGACY_CLOSE
"LEGACY_CLOSE",
#endif
#ifdef INTEROP_LOG
@@ -355,44 +363,44 @@
SQLITE_API const char *WINAPI interop_sourceid(void)
{
return INTEROP_SOURCE_ID " " INTEROP_SOURCE_TIMESTAMP;
}
-SQLITE_API int WINAPI sqlite3_open_interop(const char *filename, int flags, sqlite3 **ppdb)
+SQLITE_API int WINAPI sqlite3_open_interop(const char *filename, const char *vfsName, int flags, int extFuncs, sqlite3 **ppdb)
{
int ret;
#if defined(INTEROP_DEBUG) && (INTEROP_DEBUG & INTEROP_DEBUG_OPEN)
- sqlite3InteropDebug("sqlite3_open_interop(): calling sqlite3_open_v2(\"%s\", %d, %p)...\n", filename, flags, ppdb);
+ sqlite3InteropDebug("sqlite3_open_interop(): calling sqlite3_open_v2(\"%s\", \"%s\", %d, %d, %p)...\n", filename, vfsName, flags, extFuncs, ppdb);
#endif
- ret = sqlite3_open_v2(filename, ppdb, flags, NULL);
+ ret = sqlite3_open_v2(filename, ppdb, flags, vfsName);
#if defined(INTEROP_DEBUG) && (INTEROP_DEBUG & INTEROP_DEBUG_OPEN)
- sqlite3InteropDebug("sqlite3_open_interop(): sqlite3_open_v2(\"%s\", %d, %p) returned %d.\n", filename, flags, ppdb, ret);
+ sqlite3InteropDebug("sqlite3_open_interop(): sqlite3_open_v2(\"%s\", \"%s\", %d, %d, %p) returned %d.\n", filename, vfsName, flags, extFuncs, ppdb, ret);
#endif
#if defined(INTEROP_EXTENSION_FUNCTIONS)
- if ((ret == SQLITE_OK) && ppdb)
+ if ((ret == SQLITE_OK) && ppdb && extFuncs)
RegisterExtensionFunctions(*ppdb);
#endif
return ret;
}
-SQLITE_API int WINAPI sqlite3_open16_interop(const char *filename, int flags, sqlite3 **ppdb)
+SQLITE_API int WINAPI sqlite3_open16_interop(const char *filename, const char *vfsName, int flags, int extFuncs, sqlite3 **ppdb)
{
int ret;
#if defined(INTEROP_DEBUG) && (INTEROP_DEBUG & INTEROP_DEBUG_OPEN16)
- sqlite3InteropDebug("sqlite3_open16_interop(): calling sqlite3_open_interop(\"%s\", %d, %p)...\n", filename, flags, ppdb);
+ sqlite3InteropDebug("sqlite3_open16_interop(): calling sqlite3_open_interop(\"%s\", \"%s\", %d, %d, %p)...\n", filename, vfsName, flags, extFuncs, ppdb);
#endif
- ret = sqlite3_open_interop(filename, flags, ppdb);
+ ret = sqlite3_open_interop(filename, vfsName, flags, extFuncs, ppdb);
#if defined(INTEROP_DEBUG) && (INTEROP_DEBUG & INTEROP_DEBUG_OPEN16)
- sqlite3InteropDebug("sqlite3_open16_interop(): sqlite3_open_interop(\"%s\", %d, %p) returned %d.\n", filename, flags, ppdb, ret);
+ sqlite3InteropDebug("sqlite3_open16_interop(): sqlite3_open_interop(\"%s\", \"%s\", %d, %d, %p) returned %d.\n", filename, vfsName, flags, extFuncs, ppdb, ret);
#endif
if ((ret == SQLITE_OK) && ppdb && !DbHasProperty(*ppdb, 0, DB_SchemaLoaded))
{
ENC(*ppdb) = SQLITE_UTF16NATIVE;
Index: System.Data.SQLite/SQLite3.cs
==================================================================
--- System.Data.SQLite/SQLite3.cs
+++ System.Data.SQLite/SQLite3.cs
@@ -690,11 +690,11 @@
internal override bool IsOpen()
{
return (_sql != null) && !_sql.IsInvalid && !_sql.IsClosed;
}
- internal override void Open(string strFilename, SQLiteConnectionFlags connectionFlags, SQLiteOpenFlagsEnum openFlags, int maxPoolSize, bool usePool)
+ internal override void Open(string strFilename, string vfsName, SQLiteConnectionFlags connectionFlags, SQLiteOpenFlagsEnum openFlags, int maxPoolSize, bool usePool)
{
//
// NOTE: If the database connection is currently open, attempt to
// close it now. This must be done because the file name or
// other parameters that may impact the underlying database
@@ -731,18 +731,20 @@
{
IntPtr db = IntPtr.Zero;
SQLiteErrorCode n;
#if !SQLITE_STANDARD
- if ((connectionFlags & SQLiteConnectionFlags.NoExtensionFunctions) != SQLiteConnectionFlags.NoExtensionFunctions)
+ int extFuncs = ((connectionFlags & SQLiteConnectionFlags.NoExtensionFunctions) != SQLiteConnectionFlags.NoExtensionFunctions) ? 1 : 0;
+
+ if (extFuncs != 0)
{
- n = UnsafeNativeMethods.sqlite3_open_interop(ToUTF8(strFilename), openFlags, ref db);
+ n = UnsafeNativeMethods.sqlite3_open_interop(ToUTF8(strFilename), ToUTF8(vfsName), openFlags, extFuncs, ref db);
}
else
#endif
{
- n = UnsafeNativeMethods.sqlite3_open_v2(ToUTF8(strFilename), ref db, openFlags, IntPtr.Zero);
+ n = UnsafeNativeMethods.sqlite3_open_v2(ToUTF8(strFilename), ref db, openFlags, ToUTF8(vfsName));
}
#if !NET_COMPACT_20 && TRACE_CONNECTION
Trace.WriteLine(String.Format("Open: {0}", db));
#endif
@@ -753,11 +755,11 @@
lock (_sql) { /* HACK: Force the SyncBlock to be "created" now. */ }
SQLiteConnection.OnChanged(null, new ConnectionEventArgs(
SQLiteConnectionEventType.NewCriticalHandle, null, null,
null, null, _sql, strFilename, new object[] { strFilename,
- connectionFlags, openFlags, maxPoolSize, usePool }));
+ vfsName, connectionFlags, openFlags, maxPoolSize, usePool }));
}
// Bind functions to this connection. If any previous functions of the same name
// were already bound, then the new bindings replace the old.
if ((connectionFlags & SQLiteConnectionFlags.NoBindFunctions) != SQLiteConnectionFlags.NoBindFunctions)
Index: System.Data.SQLite/SQLite3_UTF16.cs
==================================================================
--- System.Data.SQLite/SQLite3_UTF16.cs
+++ System.Data.SQLite/SQLite3_UTF16.cs
@@ -126,11 +126,11 @@
return Marshal.PtrToStringUni(b);
else
return Marshal.PtrToStringUni(b, nbytelen / 2);
}
- internal override void Open(string strFilename, SQLiteConnectionFlags connectionFlags, SQLiteOpenFlagsEnum openFlags, int maxPoolSize, bool usePool)
+ internal override void Open(string strFilename, string vfsName, SQLiteConnectionFlags connectionFlags, SQLiteOpenFlagsEnum openFlags, int maxPoolSize, bool usePool)
{
//
// NOTE: If the database connection is currently open, attempt to
// close it now. This must be done because the file name or
// other parameters that may impact the underlying database
@@ -166,14 +166,16 @@
finally /* NOTE: Thread.Abort() protection. */
{
IntPtr db = IntPtr.Zero;
SQLiteErrorCode n;
+ int extFuncs = ((connectionFlags & SQLiteConnectionFlags.NoExtensionFunctions) != SQLiteConnectionFlags.NoExtensionFunctions) ? 1 : 0;
+
#if !SQLITE_STANDARD
- if ((connectionFlags & SQLiteConnectionFlags.NoExtensionFunctions) != SQLiteConnectionFlags.NoExtensionFunctions)
+ if ((vfsName != null) || (extFuncs != 0))
{
- n = UnsafeNativeMethods.sqlite3_open16_interop(ToUTF8(strFilename), openFlags, ref db);
+ n = UnsafeNativeMethods.sqlite3_open16_interop(ToUTF8(strFilename), ToUTF8(vfsName), openFlags, extFuncs, ref db);
}
else
#endif
{
//
@@ -182,10 +184,16 @@
// "Create" flag, even when a native API is used that does not accept
// a flags parameter.
//
if (((openFlags & SQLiteOpenFlagsEnum.Create) != SQLiteOpenFlagsEnum.Create) && !File.Exists(strFilename))
throw new SQLiteException(SQLiteErrorCode.CantOpen, strFilename);
+
+ if (vfsName != null)
+ {
+ throw new SQLiteException(SQLiteErrorCode.CantOpen, String.Format(
+ "cannot open using UTF-16 and VFS \"{0}\": need interop assembly", vfsName));
+ }
n = UnsafeNativeMethods.sqlite3_open16(strFilename, ref db);
}
#if !NET_COMPACT_20 && TRACE_CONNECTION
@@ -198,11 +206,11 @@
lock (_sql) { /* HACK: Force the SyncBlock to be "created" now. */ }
SQLiteConnection.OnChanged(null, new ConnectionEventArgs(
SQLiteConnectionEventType.NewCriticalHandle, null, null,
null, null, _sql, strFilename, new object[] { strFilename,
- connectionFlags, openFlags, maxPoolSize, usePool }));
+ vfsName, connectionFlags, openFlags, maxPoolSize, usePool }));
}
// Bind functions to this connection. If any previous functions of the same name
// were already bound, then the new bindings replace the old.
if ((connectionFlags & SQLiteConnectionFlags.NoBindFunctions) != SQLiteConnectionFlags.NoBindFunctions)
Index: System.Data.SQLite/SQLiteBase.cs
==================================================================
--- System.Data.SQLite/SQLiteBase.cs
+++ System.Data.SQLite/SQLiteBase.cs
@@ -93,15 +93,16 @@
///
/// Implementers should call SQLiteFunction.BindFunctions() and save the array after opening a connection
/// to bind all attributed user-defined functions and collating sequences to the new connection.
///
/// The filename of the database to open. SQLite automatically creates it if it doesn't exist.
+ /// The name of the VFS to use -OR- null to use the default VFS.
/// The flags associated with the parent connection object
/// The open flags to use when creating the connection
/// The maximum size of the pool for the given filename
/// If true, the connection can be pulled from the connection pool
- internal abstract void Open(string strFilename, SQLiteConnectionFlags connectionFlags, SQLiteOpenFlagsEnum openFlags, int maxPoolSize, bool usePool);
+ internal abstract void Open(string strFilename, string vfsName, SQLiteConnectionFlags connectionFlags, SQLiteOpenFlagsEnum openFlags, int maxPoolSize, bool usePool);
///
/// Closes the currently-open database.
///
///
/// After the database has been closed implemeters should call SQLiteFunction.UnbindFunctions() to deallocate all interop allocated
Index: System.Data.SQLite/SQLiteConnection.cs
==================================================================
--- System.Data.SQLite/SQLiteConnection.cs
+++ System.Data.SQLite/SQLiteConnection.cs
@@ -140,10 +140,29 @@
/// would become "\\\\Network\Share\test.db").
///
/// Y
///
///
+ /// -
+ /// Uri
+ ///
+ /// If specified, this must be a file name that starts with "file://", "file:", or "/". Any leading
+ /// "file://" or "file:" prefix will be stripped off and the resulting file name will be used to open
+ /// the database.
+ ///
+ /// N
+ /// null
+ ///
+ /// -
+ /// FullUri
+ ///
+ /// If specified, this must be a URI in a format recognized by the SQLite core library (starting with
+ /// SQLite 3.7.7). It will be passed verbatim to the SQLite core library.
+ ///
+ /// N
+ /// null
+ ///
/// -
/// Version
/// 3
/// N
/// 3
@@ -152,10 +171,62 @@
/// UseUTF16Encoding
/// True
False
/// N
/// False
///
+ /// -
+ /// DefaultDbType
+ ///
+ /// This is the default to use when one cannot be determined based on the
+ /// column metadata and the configured type mappings.
+ ///
+ /// N
+ /// null
+ ///
+ /// -
+ /// DefaultTypeName
+ ///
+ /// This is the default type name to use when one cannot be determined based on the column metadata
+ /// and the configured type mappings.
+ ///
+ /// N
+ /// null
+ ///
+ /// -
+ /// NoSharedFlags
+ ///
+ /// True - Do not combine the specified (or default) connection flags with the value of the
+ /// property.
+ ///
+ /// False - Combine the specified (or default) connection flags with the value of the
+ /// property.
+ ///
+ /// N
+ /// false
+ ///
+ /// -
+ /// VfsName
+ ///
+ /// The name of the VFS to use when opening the database connection.
+ /// If this is not specified, the default VFS will be used.
+ ///
+ /// N
+ /// null
+ ///
+ /// -
+ /// ZipVfsVersion
+ ///
+ /// If non-null, this is the "version" of ZipVFS to use. This requires
+ /// the System.Data.SQLite interop assembly -AND- primary managed assembly
+ /// to be compiled with the INTEROP_INCLUDE_ZIPVFS option; otherwise, this
+ /// property does nothing. The valid values are "v2" and "v3". Using
+ /// anyother value will cause an exception to be thrown. Please see the
+ /// ZipVFS documentation for more information on how to use this parameter.
+ ///
+ /// N
+ /// null
+ ///
/// -
/// DateTimeFormat
///
/// Ticks - Use the value of DateTime.Ticks.
/// ISO8601 - Use the ISO-8601 format. Uses the "yyyy-MM-dd HH:mm:ss.FFFFFFFK" format for UTC
@@ -386,10 +457,18 @@
private const bool DefaultLegacyFormat = false;
private const bool DefaultForeignKeys = false;
private const bool DefaultEnlist = true;
private const bool DefaultSetDefaults = true;
internal const int DefaultPrepareRetries = 3;
+ private const string DefaultVfsName = null;
+
+#if INTEROP_INCLUDE_ZIPVFS
+ private const string ZipVfs_V2 = "v2";
+ private const string ZipVfs_V3 = "v3";
+
+ private const string DefaultZipVfsVersion = null;
+#endif
private const int SQLITE_FCNTL_CHUNK_SIZE = 6;
private const int SQLITE_FCNTL_WIN32_AV_RETRY = 9;
private const string _dataDirectory = "|DataDirectory|";
@@ -523,10 +602,15 @@
/// be used if the
/// flag is set.
///
private string _defaultTypeName;
+ ///
+ /// The name of the VFS to be used when opening the database connection.
+ ///
+ private string _vfsName;
+
///
/// Default command timeout
///
private int _defaultTimeout = DefaultConnectionTimeout;
@@ -678,10 +762,11 @@
_typeNames = new SQLiteDbTypeMap();
_parseViaFramework = parseViaFramework;
_flags = SQLiteConnectionFlags.Default;
_defaultDbType = null;
_defaultTypeName = null;
+ _vfsName = null;
_connectionState = ConnectionState.Closed;
_connectionString = null;
if (connectionString != null)
ConnectionString = connectionString;
@@ -2496,19 +2581,42 @@
//
if ((_defaultDbType != null) && ((DbType)_defaultDbType == BadDbType))
_defaultDbType = null;
_defaultTypeName = FindKey(opts, "DefaultTypeName", null);
+ _vfsName = FindKey(opts, "VfsName", DefaultVfsName);
#if !NET_COMPACT_20 && TRACE_WARNING
bool uri = false;
#endif
bool fullUri = false;
string fileName;
if (Convert.ToInt32(FindKey(opts, "Version", DefaultVersion.ToString()), CultureInfo.InvariantCulture) != DefaultVersion)
throw new NotSupportedException(String.Format(CultureInfo.CurrentCulture, "Only SQLite Version {0} is supported at this time", DefaultVersion));
+
+#if INTEROP_INCLUDE_ZIPVFS
+ string zipVfsVersion = FindKey(opts, "ZipVfsVersion", DefaultZipVfsVersion);
+
+ if (zipVfsVersion != null)
+ {
+ if (String.Compare(zipVfsVersion, ZipVfs_V2) == 0)
+ {
+ UnsafeNativeMethods.zipvfsInit_v2();
+ }
+ else if (String.Compare(zipVfsVersion, ZipVfs_V3) == 0)
+ {
+ UnsafeNativeMethods.zipvfsInit_v3(0);
+ }
+ else
+ {
+ throw new NotSupportedException(String.Format(
+ CultureInfo.CurrentCulture, "Only ZipVFS versions {0} and {1} are supported at this time",
+ ZipVfs_V2, ZipVfs_V3));
+ }
+ }
+#endif
fileName = FindKey(opts, "Data Source", DefaultDataSource);
if (String.IsNullOrEmpty(fileName))
{
@@ -2602,11 +2710,11 @@
}
if (fullUri)
flags |= SQLiteOpenFlagsEnum.Uri;
- _sql.Open(fileName, _flags, flags, maxPoolSize, usePooling);
+ _sql.Open(fileName, _vfsName, _flags, flags, maxPoolSize, usePooling);
_binaryGuid = SQLiteConvert.ToBoolean(FindKey(opts, "BinaryGUID", DefaultBinaryGUID.ToString()));
#if INTEROP_CODEC || INTEROP_INCLUDE_SEE
string hexPassword = FindKey(opts, "HexPassword", DefaultHexPassword);
@@ -2836,10 +2944,20 @@
public string DefaultTypeName
{
get { CheckDisposed(); return _defaultTypeName; }
set { CheckDisposed(); _defaultTypeName = value; }
}
+
+ ///
+ /// Gets/sets the VFS name for this connection. This value will only be
+ /// used when opening the database.
+ ///
+ public string VfsName
+ {
+ get { CheckDisposed(); return _vfsName; }
+ set { CheckDisposed(); _vfsName = value; }
+ }
///
/// Returns non-zero if the underlying native connection handle is
/// owned by this instance.
///
Index: System.Data.SQLite/SQLiteConnectionStringBuilder.cs
==================================================================
--- System.Data.SQLite/SQLiteConnectionStringBuilder.cs
+++ System.Data.SQLite/SQLiteConnectionStringBuilder.cs
@@ -181,11 +181,11 @@
{
get
{
object value;
TryGetValue("data source", out value);
- return value.ToString();
+ return (value != null) ? value.ToString() : null;
}
set
{
this["data source"] = value;
}
@@ -201,11 +201,11 @@
{
get
{
object value;
TryGetValue("uri", out value);
- return value.ToString();
+ return (value != null) ? value.ToString() : null;
}
set
{
this["uri"] = value;
}
@@ -221,11 +221,11 @@
{
get
{
object value;
TryGetValue("fulluri", out value);
- return value.ToString();
+ return (value != null) ? value.ToString() : null;
}
set
{
this["fulluri"] = value;
}
@@ -366,11 +366,11 @@
{
get
{
object value;
TryGetValue("password", out value);
- return value.ToString();
+ return (value != null) ? value.ToString() : null;
}
set
{
this["password"] = value;
}
@@ -666,17 +666,37 @@
{
get
{
object value;
TryGetValue("defaulttypename", out value);
- return value.ToString();
+ return (value != null) ? value.ToString() : null;
}
set
{
this["defaulttypename"] = value;
}
}
+
+ ///
+ /// Gets/sets the VFS name for the connection.
+ ///
+ [DisplayName("VFS Name")]
+ [Browsable(true)]
+ [DefaultValue(null)]
+ public string VfsName
+ {
+ get
+ {
+ object value;
+ TryGetValue("vfsname", out value);
+ return (value != null) ? value.ToString() : null;
+ }
+ set
+ {
+ this["vfsname"] = value;
+ }
+ }
///
/// If enabled, use foreign key constraints
///
[DisplayName("Foreign Keys")]
@@ -693,10 +713,33 @@
set
{
this["foreign keys"] = value;
}
}
+
+ ///
+ /// If non-null, this is the version of ZipVFS to use. This requires the
+ /// System.Data.SQLite interop assembly -AND- primary managed assembly to
+ /// be compiled with the INTEROP_INCLUDE_ZIPVFS option; otherwise, this
+ /// property does nothing.
+ ///
+ [DisplayName("ZipVFS Version")]
+ [Browsable(true)]
+ [DefaultValue(null)]
+ public string ZipVfsVersion
+ {
+ get
+ {
+ object value;
+ TryGetValue("zipvfsversion", out value);
+ return (value != null) ? value.ToString() : null;
+ }
+ set
+ {
+ this["zipvfsversion"] = value;
+ }
+ }
///
/// Gets/Sets the extra behavioral flags.
///
[Browsable(true)]
Index: System.Data.SQLite/SQLiteConvert.cs
==================================================================
--- System.Data.SQLite/SQLiteConvert.cs
+++ System.Data.SQLite/SQLiteConvert.cs
@@ -154,10 +154,11 @@
///
/// The string to convert to UTF-8
/// A byte array containing the converted string plus an extra 0 terminating byte at the end of the array.
public static byte[] ToUTF8(string sourceText)
{
+ if (sourceText == null) return null;
Byte[] byteArray;
int nlen = _utf8.GetByteCount(sourceText) + 1;
byteArray = new byte[nlen];
nlen = _utf8.GetBytes(sourceText, 0, sourceText.Length, byteArray, 0);
Index: System.Data.SQLite/SQLiteDefineConstants.cs
==================================================================
--- System.Data.SQLite/SQLiteDefineConstants.cs
+++ System.Data.SQLite/SQLiteDefineConstants.cs
@@ -45,10 +45,14 @@
#endif
#if INTEROP_INCLUDE_SEE
"INTEROP_INCLUDE_SEE",
#endif
+
+#if INTEROP_INCLUDE_ZIPVFS
+ "INTEROP_INCLUDE_ZIPVFS",
+#endif
#if INTEROP_LEGACY_CLOSE
"INTEROP_LEGACY_CLOSE",
#endif
Index: System.Data.SQLite/Targets/System.Data.SQLite.Properties.targets
==================================================================
--- System.Data.SQLite/Targets/System.Data.SQLite.Properties.targets
+++ System.Data.SQLite/Targets/System.Data.SQLite.Properties.targets
@@ -170,10 +170,18 @@
-->
$(DefineConstants);INTEROP_INCLUDE_CEROD
+
+
+ $(DefineConstants);INTEROP_INCLUDE_ZIPVFS
+
+
Index: System.Data.SQLite/UnsafeNativeMethods.cs
==================================================================
--- System.Data.SQLite/UnsafeNativeMethods.cs
+++ System.Data.SQLite/UnsafeNativeMethods.cs
@@ -1366,14 +1366,14 @@
[DllImport(SQLITE_DLL)]
internal static extern SQLiteErrorCode sqlite3_backup_finish_interop(IntPtr backup);
[DllImport(SQLITE_DLL)]
- internal static extern SQLiteErrorCode sqlite3_open_interop(byte[] utf8Filename, SQLiteOpenFlagsEnum flags, ref IntPtr db);
+ internal static extern SQLiteErrorCode sqlite3_open_interop(byte[] utf8Filename, byte[] vfsName, SQLiteOpenFlagsEnum flags, int extFuncs, ref IntPtr db);
[DllImport(SQLITE_DLL)]
- internal static extern SQLiteErrorCode sqlite3_open16_interop(byte[] utf8Filename, SQLiteOpenFlagsEnum flags, ref IntPtr db);
+ internal static extern SQLiteErrorCode sqlite3_open16_interop(byte[] utf8Filename, byte[] vfsName, SQLiteOpenFlagsEnum flags, int extFuncs, ref IntPtr db);
[DllImport(SQLITE_DLL)]
internal static extern SQLiteErrorCode sqlite3_reset_interop(IntPtr stmt);
[DllImport(SQLITE_DLL)]
@@ -1735,11 +1735,11 @@
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
#endif
- internal static extern SQLiteErrorCode sqlite3_open_v2(byte[] utf8Filename, ref IntPtr db, SQLiteOpenFlagsEnum flags, IntPtr vfs);
+ internal static extern SQLiteErrorCode sqlite3_open_v2(byte[] utf8Filename, ref IntPtr db, SQLiteOpenFlagsEnum flags, byte[] vfsName);
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
#else
[DllImport(SQLITE_DLL, CharSet = CharSet.Unicode)]
@@ -2107,10 +2107,26 @@
#else
[DllImport(SQLITE_DLL)]
#endif
internal static extern SQLiteErrorCode sqlite3_rekey(IntPtr db, byte[] key, int keylen);
#endif
+
+#if INTEROP_INCLUDE_ZIPVFS
+#if !PLATFORM_COMPACTFRAMEWORK
+ [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
+#else
+ [DllImport(SQLITE_DLL)]
+#endif
+ internal static extern void zipvfsInit_v2();
+
+#if !PLATFORM_COMPACTFRAMEWORK
+ [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
+#else
+ [DllImport(SQLITE_DLL)]
+#endif
+ internal static extern void zipvfsInit_v3(int regDflt);
+#endif
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
Index: Targets/SQLite.NET.Settings.targets
==================================================================
--- Targets/SQLite.NET.Settings.targets
+++ Targets/SQLite.NET.Settings.targets
@@ -374,10 +374,30 @@
both for the corresponding version(s) of Visual Studio.
-->
false
+
+ false
+