Imported Upstream version 4.6.0.243

Former-commit-id: ff34202749e8df2aa83f2578b16260b444f50987
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-09-09 07:19:48 +00:00
parent 804b15604f
commit 3cc9601fd9
113 changed files with 1476 additions and 4439 deletions

View File

@@ -125,9 +125,9 @@ namespace Mono.Data.Sqlite
// Compatibility with versions < 3.5.0
int n;
try {
if (UnsafeNativeMethods.use_sqlite3_open_v2) {
n = UnsafeNativeMethods.sqlite3_open_v2(ToUTF8(strFilename), out db, (int)flags, IntPtr.Zero);
} catch (EntryPointNotFoundException) {
} else {
Console.WriteLine ("Your sqlite3 version is old - please upgrade to at least v3.5.0!");
n = UnsafeNativeMethods.sqlite3_open (ToUTF8 (strFilename), out db);
}

View File

@@ -208,9 +208,9 @@ namespace Mono.Data.Sqlite
#else
ResetConnection(db);
int n;
try {
if (UnsafeNativeMethods.use_sqlite3_close_v2) {
n = UnsafeNativeMethods.sqlite3_close_v2(db);
} catch (EntryPointNotFoundException) {
} else {
n = UnsafeNativeMethods.sqlite3_close(db);
}
#endif

View File

@@ -16,6 +16,27 @@ namespace Mono.Data.Sqlite
#endif
internal static class UnsafeNativeMethods
{
internal static readonly bool use_sqlite3_close_v2 = false;
internal static readonly bool use_sqlite3_open_v2 = false;
internal static readonly bool use_sqlite3_create_function_v2 = false;
static UnsafeNativeMethods()
{
// calculate the version number parts
// https://www.sqlite.org/c3ref/c_source_id.html
// (<major> * 1000000) + (<minor> * 1000) + (<release>)
int versionNumber = sqlite3_libversion_number();
int release = versionNumber % 1000;
int minor = (versionNumber / 1000) % 1000;
int major = versionNumber / 1000000;
Version version = new Version(major, minor, release);
// set the various versions
// https://sqlite.org/changes.html
use_sqlite3_open_v2 = version >= new Version(3, 5, 0);
use_sqlite3_close_v2 = version >= new Version(3, 7, 14);
use_sqlite3_create_function_v2 = version >= new Version(3, 7, 3);
}
#if !SQLITE_STANDARD
#if !USE_INTEROP_DLL
@@ -730,6 +751,13 @@ namespace Mono.Data.Sqlite
#endif
internal static extern int sqlite3_free (IntPtr ptr);
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
#endif
internal static extern int sqlite3_libversion_number();
#endregion
}