Index: System.Data.SQLite/SQLite3.cs
==================================================================
--- System.Data.SQLite/SQLite3.cs
+++ System.Data.SQLite/SQLite3.cs
@@ -1530,17 +1530,17 @@
LogBind(handle, index, value);
}
#if !PLATFORM_COMPACTFRAMEWORK
SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_bind_double(handle, index, value);
+ if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
#elif !SQLITE_STANDARD
SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_bind_double_interop(handle, index, ref value);
+ if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
#else
- SQLiteErrorCode n = SQLiteErrorCode.Ok;
throw new NotImplementedException();
#endif
- if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
}
internal override void Bind_Int32(SQLiteStatement stmt, SQLiteConnectionFlags flags, int index, int value)
{
SQLiteStatementHandle handle = stmt._sqlite_stmt;
@@ -1595,17 +1595,17 @@
{
LogBind(handle, index, value);
}
SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_bind_int64(handle, index, value);
+ if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
#elif !SQLITE_STANDARD
SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_bind_int64_interop(handle, index, ref value);
+ if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
#else
- SQLiteErrorCode n = SQLiteErrorCode.Ok;
throw new NotImplementedException();
#endif
- if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
}
internal override void Bind_UInt64(SQLiteStatement stmt, SQLiteConnectionFlags flags, int index, ulong value)
{
SQLiteStatementHandle handle = stmt._sqlite_stmt;
@@ -1615,17 +1615,17 @@
{
LogBind(handle, index, value);
}
SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_bind_uint64(handle, index, value);
+ if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
#elif !SQLITE_STANDARD
SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_bind_uint64_interop(handle, index, ref value);
+ if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
#else
- SQLiteErrorCode n = SQLiteErrorCode.Ok;
throw new NotImplementedException();
#endif
- if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
}
internal override void Bind_Text(SQLiteStatement stmt, SQLiteConnectionFlags flags, int index, string value)
{
SQLiteStatementHandle handle = stmt._sqlite_stmt;
@@ -1685,18 +1685,19 @@
{
LogBind(handle, index, value);
}
SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_bind_int64(handle, index, value);
+ if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
+ break;
#elif !SQLITE_STANDARD
SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_bind_int64_interop(handle, index, ref value);
+ if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
+ break;
#else
- SQLiteErrorCode n = SQLiteErrorCode.Ok;
throw new NotImplementedException();
#endif
- if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
- break;
}
case SQLiteDateFormats.JulianDay:
{
double value = ToJulianDay(dt);
@@ -1705,18 +1706,19 @@
{
LogBind(handle, index, value);
}
SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_bind_double(handle, index, value);
+ if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
+ break;
#elif !SQLITE_STANDARD
SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_bind_double_interop(handle, index, ref value);
+ if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
+ break;
#else
- SQLiteErrorCode n = SQLiteErrorCode.Ok;
throw new NotImplementedException();
#endif
- if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
- break;
}
case SQLiteDateFormats.UnixEpoch:
{
long value = Convert.ToInt64(dt.Subtract(UnixEpoch).TotalSeconds);
@@ -1725,18 +1727,19 @@
{
LogBind(handle, index, value);
}
SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_bind_int64(handle, index, value);
+ if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
+ break;
#elif !SQLITE_STANDARD
SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_bind_int64_interop(handle, index, ref value);
+ if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
+ break;
#else
- SQLiteErrorCode n = SQLiteErrorCode.Ok;
throw new NotImplementedException();
#endif
- if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
- break;
}
default:
{
byte[] b = ToUTF8(dt);
@@ -1982,20 +1985,19 @@
autoIncrement = (nautoInc == 1);
}
internal override double GetDouble(SQLiteStatement stmt, int index)
{
- double value;
#if !PLATFORM_COMPACTFRAMEWORK
- value = UnsafeNativeMethods.sqlite3_column_double(stmt._sqlite_stmt, index);
+ return UnsafeNativeMethods.sqlite3_column_double(stmt._sqlite_stmt, index);
#elif !SQLITE_STANDARD
- value = 0.0;
+ double value = 0.0;
UnsafeNativeMethods.sqlite3_column_double_interop(stmt._sqlite_stmt, index, ref value);
-#else
- throw new NotImplementedException();
-#endif
return value;
+#else
+ throw new NotImplementedException();
+#endif
}
internal override sbyte GetSByte(SQLiteStatement stmt, int index)
{
return unchecked((sbyte)(GetInt32(stmt, index) & byte.MaxValue));
@@ -2026,20 +2028,19 @@
return unchecked((uint)GetInt32(stmt, index));
}
internal override long GetInt64(SQLiteStatement stmt, int index)
{
- long value;
#if !PLATFORM_COMPACTFRAMEWORK
- value = UnsafeNativeMethods.sqlite3_column_int64(stmt._sqlite_stmt, index);
+ return UnsafeNativeMethods.sqlite3_column_int64(stmt._sqlite_stmt, index);
#elif !SQLITE_STANDARD
- value = 0;
+ long value = 0;
UnsafeNativeMethods.sqlite3_column_int64_interop(stmt._sqlite_stmt, index, ref value);
-#else
- throw new NotImplementedException();
-#endif
return value;
+#else
+ throw new NotImplementedException();
+#endif
}
internal override ulong GetUInt64(SQLiteStatement stmt, int index)
{
return unchecked((ulong)GetInt64(stmt, index));
@@ -2257,39 +2258,37 @@
return nCopied;
}
internal override double GetParamValueDouble(IntPtr ptr)
{
- double value;
#if !PLATFORM_COMPACTFRAMEWORK
- value = UnsafeNativeMethods.sqlite3_value_double(ptr);
+ return UnsafeNativeMethods.sqlite3_value_double(ptr);
#elif !SQLITE_STANDARD
- value = 0.0;
+ double value = 0.0;
UnsafeNativeMethods.sqlite3_value_double_interop(ptr, ref value);
+ return value;
#else
throw new NotImplementedException();
#endif
- return value;
}
internal override int GetParamValueInt32(IntPtr ptr)
{
return UnsafeNativeMethods.sqlite3_value_int(ptr);
}
internal override long GetParamValueInt64(IntPtr ptr)
{
- Int64 value;
#if !PLATFORM_COMPACTFRAMEWORK
- value = UnsafeNativeMethods.sqlite3_value_int64(ptr);
+ return UnsafeNativeMethods.sqlite3_value_int64(ptr);
#elif !SQLITE_STANDARD
- value = 0;
+ Int64 value = 0;
UnsafeNativeMethods.sqlite3_value_int64_interop(ptr, ref value);
+ return value;
#else
throw new NotImplementedException();
#endif
- return value;
}
internal override string GetParamValueText(IntPtr ptr)
{
#if !SQLITE_STANDARD
Index: System.Data.SQLite/SQLiteBase.cs
==================================================================
--- System.Data.SQLite/SQLiteBase.cs
+++ System.Data.SQLite/SQLiteBase.cs
@@ -949,22 +949,25 @@
/// Prevent this object instance from
/// loading extensions.
///
NoLoadExtension = 0x200,
+#if INTEROP_VIRTUAL_TABLE
///
/// Prevent this object instance from
/// creating virtual table modules.
///
NoCreateModule = 0x400,
+#endif
///
/// Skip binding any functions provided by other managed assemblies when
/// opening the connection.
///
NoBindFunctions = 0x800,
+#if INTEROP_VIRTUAL_TABLE
///
/// Skip setting the logging related properties of the
/// object instance that was passed to
/// the method.
///
@@ -979,10 +982,11 @@
///
/// Enable logging of certain virtual table module exceptions that cannot
/// be easily discovered via other means.
///
LogModuleException = 0x4000,
+#endif
///
/// Enable tracing of potentially important [non-fatal] error conditions
/// that cannot be easily reported through other means.
///
@@ -1163,18 +1167,27 @@
ConvertAndBindInvariantText,
///
/// Enable all logging.
///
+#if INTEROP_VIRTUAL_TABLE
LogAll = LogPrepare | LogPreBind | LogBind |
LogCallbackException | LogBackup | LogModuleError |
LogModuleException,
+#else
+ LogAll = LogPrepare | LogPreBind | LogBind |
+ LogCallbackException | LogBackup,
+#endif
///
/// The default extra flags for new connections.
///
+#if INTEROP_VIRTUAL_TABLE
Default = LogCallbackException | LogModuleException,
+#else
+ Default = LogCallbackException,
+#endif
///
/// The default extra flags for new connections with all logging enabled.
///
DefaultAndLogAll = Default | LogAll
Index: System.Data.SQLite/SQLiteConnection.cs
==================================================================
--- System.Data.SQLite/SQLiteConnection.cs
+++ System.Data.SQLite/SQLiteConnection.cs
@@ -805,10 +805,11 @@
: this(connectionString, false)
{
// do nothing.
}
+#if INTEROP_VIRTUAL_TABLE
///
/// Initializes the connection with a pre-existing native connection handle.
/// This constructor overload is intended to be used only by the private
/// method.
///
@@ -834,10 +835,11 @@
_connectionState = (db != IntPtr.Zero) ?
ConnectionState.Open : ConnectionState.Closed;
_connectionString = null; /* unknown */
}
+#endif
///
/// Initializes the connection with the specified connection string.
///
///
Index: testce/TestCases.cs
==================================================================
--- testce/TestCases.cs
+++ testce/TestCases.cs
@@ -290,13 +290,15 @@
total++;
try { Int64Properties(cnn); frm.WriteLine("SUCCESS - Int64Properties"); passed++; }
catch (Exception) { frm.WriteLine("FAIL - Int64Properties"); failed++; }
+#if INTEROP_VIRTUAL_TABLE
total++;
try { ManagedVirtualTable(cnn); frm.WriteLine("SUCCESS - ManagedVirtualTable"); passed++; }
catch (Exception) { frm.WriteLine("FAIL - ManagedVirtualTable"); failed++; }
+#endif
total++;
try { MultipleThreadStress(cnn); frm.WriteLine("SUCCESS - MultipleThreadStress"); passed++; }
catch (Exception) { frm.WriteLine("FAIL - MultipleThreadStress"); failed++; }
@@ -1037,10 +1039,11 @@
}
throw new NotSupportedException("not a SQLite connection");
}
+#if INTEROP_VIRTUAL_TABLE
// Make sure that managed virtual table support works on the .NET Compact Framework.
internal void ManagedVirtualTable(DbConnection cnn)
{
SQLiteConnection cnn2 = cnn as SQLiteConnection;
@@ -1097,10 +1100,11 @@
return;
}
throw new NotSupportedException("not a SQLite connection");
}
+#endif
private int nextId = 0;
private const int MAX_THREADS = 3;
private const int MAX_ITERATIONS = 100;
private ManualResetEvent goEvent = new ManualResetEvent(false);
Index: testce/testce.2005.csproj
==================================================================
--- testce/testce.2005.csproj
+++ testce/testce.2005.csproj
@@ -103,10 +103,11 @@
{AC139951-261A-4463-B6FA-AEBC25283A66}
System.Data.SQLite.Compact.2005
+
Index: testce/testce.2008.csproj
==================================================================
--- testce/testce.2008.csproj
+++ testce/testce.2008.csproj
@@ -104,10 +104,11 @@
{AC139951-261A-4463-B6FA-AEBC25283A66}
System.Data.SQLite.Compact.2008
+
Index: testce/testce.2012.csproj
==================================================================
--- testce/testce.2012.csproj
+++ testce/testce.2012.csproj
@@ -88,10 +88,11 @@
{AC139951-261A-4463-B6FA-AEBC25283A66}
System.Data.SQLite.Compact.2012
+
Index: testlinq/Program.cs
==================================================================
--- testlinq/Program.cs
+++ testlinq/Program.cs
@@ -92,14 +92,16 @@
}
case "substring":
{
return SubStringTest();
}
+#if USE_INTEROP_DLL && INTEROP_EXTENSION_FUNCTIONS
case "unionall":
{
return UnionAllTest();
}
+#endif
case "endswith":
{
string value = null;
if (args.Length > 1)
@@ -366,10 +368,11 @@
}
return 0;
}
+#if USE_INTEROP_DLL && INTEROP_EXTENSION_FUNCTIONS
//
// NOTE: Used to test the fix for ticket [0a32885109].
//
private static int UnionAllTest()
{
@@ -436,10 +439,11 @@
}
}
return 0;
}
+#endif
//
// NOTE: Used to test the fix for ticket [ccfa69fc32].
//
private static int EFTransactionTest(bool add)
@@ -557,14 +561,10 @@
// the SQL statement after the actual INSERT statement in
// the follow-up SELECT statement).
//
private static int InsertTest()
{
- long[] orderIds = new long[] {
- 0
- };
-
using (northwindEFEntities db = new northwindEFEntities())
{
int[] counts = { 0 };
//