Version History
+
1.0.83.0 - November XX, 2012 (release scheduled)
+
+ - Updated to SQLite 3.7.14.
+ - Add an overload of the SQLiteLog.LogMessage method that takes a single string argument.
+ - All applicable calls into the SQLite core library now return a SQLiteErrorCode instead of an integer error code.
+ - When available, the new sqlite3_errstr function from the core library is used to get the error message for a specific return code.
+ - The SetMemoryStatus, Shutdown, ResultCode, ExtendedResultCode, and SetAvRetry methods of the SQLiteConnection class now return a SQLiteErrorCode instead of an integer error code. ** Potentially Incompatible Change **
+ - The public constructor for the SQLiteException now takes a SQLiteErrorCode instead of an integer error code. ** Potentially Incompatible Change **
+ - The ErrorCode field of the LogEventArgs is now an object instead of an integer. ** Potentially Incompatible Change **
+ - The names and messages associated with the SQLiteErrorCode enumeration values have been normalized to match those in the SQLite core library. ** Potentially Incompatible Change **
+
1.0.82.0 - September 3, 2012
- Updated to SQLite 3.7.14.
- Properly handle quoted data source values in the connection string. Fix for [8c3bee31c8].
- The primary NuGet package now supports x86 / x64 and the .NET Framework 2.0 / 4.0 (i.e. in a single package).
Index: System.Data.SQLite/SQLite3.cs
==================================================================
--- System.Data.SQLite/SQLite3.cs
+++ System.Data.SQLite/SQLite3.cs
@@ -16,14 +16,30 @@
using System.Globalization;
using System.Runtime.InteropServices;
using System.Text;
+ ///
+ /// This is the method signature for the SQLite core library logging callback
+ /// function for use with sqlite3_log() and the SQLITE_CONFIG_LOG.
+ ///
+ /// WARNING: This delegate is used more-or-less directly by native code, do
+ /// not modify its type signature.
+ ///
+ ///
+ /// The extra data associated with this message, if any.
+ ///
+ ///
+ /// The error code associated with this message.
+ ///
+ ///
+ /// The message string to be logged.
+ ///
#if !PLATFORM_COMPACTFRAMEWORK
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
#endif
- internal delegate void SQLiteLogCallback(IntPtr puser, int err_code, IntPtr message);
+ internal delegate void SQLiteLogCallback(IntPtr pUserData, int errorCode, IntPtr pMessage);
///
/// This class implements SQLiteBase completely, and is the guts of the code that interop's SQLite with .NET
///
internal class SQLite3 : SQLiteBase
@@ -229,18 +245,18 @@
{
return UnsafeNativeMethods.sqlite3_memory_highwater(0);
}
}
- internal override int SetMemoryStatus(bool value)
+ internal override SQLiteErrorCode SetMemoryStatus(bool value)
{
return StaticSetMemoryStatus(value);
}
- internal static int StaticSetMemoryStatus(bool value)
+ internal static SQLiteErrorCode StaticSetMemoryStatus(bool value)
{
- int rc = UnsafeNativeMethods.sqlite3_config_int(
+ SQLiteErrorCode rc = UnsafeNativeMethods.sqlite3_config_int(
SQLiteConfigOpsEnum.SQLITE_CONFIG_MEMSTATUS, value ? 1 : 0);
return rc;
}
@@ -247,13 +263,13 @@
///
/// Shutdown the SQLite engine so that it can be restarted with different config options.
/// We depend on auto initialization to recover.
///
/// Returns a result code
- internal override int Shutdown()
+ internal override SQLiteErrorCode Shutdown()
{
- int rc = UnsafeNativeMethods.sqlite3_shutdown();
+ SQLiteErrorCode rc = UnsafeNativeMethods.sqlite3_shutdown();
return rc;
}
internal override bool IsOpen()
{
@@ -279,20 +295,20 @@
if (_sql == null)
{
IntPtr db;
#if !SQLITE_STANDARD
- int n = UnsafeNativeMethods.sqlite3_open_interop(ToUTF8(strFilename), (int)openFlags, out db);
+ SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_open_interop(ToUTF8(strFilename), (int)openFlags, out db);
#else
- int n = UnsafeNativeMethods.sqlite3_open_v2(ToUTF8(strFilename), out db, (int)openFlags, IntPtr.Zero);
+ SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_open_v2(ToUTF8(strFilename), out db, (int)openFlags, IntPtr.Zero);
#endif
#if !NET_COMPACT_20 && TRACE_CONNECTION
Trace.WriteLine(String.Format("Open: {0}", db));
#endif
- if (n > 0) throw new SQLiteException(n, null);
+ if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, null);
_sql = new SQLiteConnectionHandle(db);
lock (_sql) { /* HACK: Force the SyncBlock to be "created" now. */ }
}
// Bind functions to this connection. If any previous functions of the same name
@@ -321,41 +337,41 @@
return totalCount;
}
internal override void SetTimeout(int nTimeoutMS)
{
- int n = UnsafeNativeMethods.sqlite3_busy_timeout(_sql, nTimeoutMS);
- if (n > 0) throw new SQLiteException(n, GetLastError());
+ SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_busy_timeout(_sql, nTimeoutMS);
+ if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
}
internal override bool Step(SQLiteStatement stmt)
{
- int n;
+ SQLiteErrorCode n;
Random rnd = null;
uint starttick = (uint)Environment.TickCount;
uint timeout = (uint)(stmt._command._commandTimeout * 1000);
while (true)
{
n = UnsafeNativeMethods.sqlite3_step(stmt._sqlite_stmt);
- if (n == 100) return true;
- if (n == 101) return false;
+ if (n == SQLiteErrorCode.Row) return true;
+ if (n == SQLiteErrorCode.Done) return false;
- if (n > 0)
+ if (n != SQLiteErrorCode.Ok)
{
- int r;
+ SQLiteErrorCode r;
// An error occurred, attempt to reset the statement. If the reset worked because the
// schema has changed, re-try the step again. If it errored our because the database
// is locked, then keep retrying until the command timeout occurs.
r = Reset(stmt);
- if (r == 0)
+ if (r == SQLiteErrorCode.Ok)
throw new SQLiteException(n, GetLastError());
- else if ((r == 6 || r == 5) && stmt._command != null) // SQLITE_LOCKED || SQLITE_BUSY
+ else if ((r == SQLiteErrorCode.Locked || r == SQLiteErrorCode.Busy) && stmt._command != null)
{
// Keep trying
if (rnd == null) // First time we've encountered the lock
rnd = new Random();
@@ -372,22 +388,22 @@
}
}
}
}
- internal override int Reset(SQLiteStatement stmt)
+ internal override SQLiteErrorCode Reset(SQLiteStatement stmt)
{
- int n;
+ SQLiteErrorCode n;
#if !SQLITE_STANDARD
n = UnsafeNativeMethods.sqlite3_reset_interop(stmt._sqlite_stmt);
#else
n = UnsafeNativeMethods.sqlite3_reset(stmt._sqlite_stmt);
#endif
// If the schema changed, try and re-prepare it
- if (n == 17) // SQLITE_SCHEMA
+ if (n == SQLiteErrorCode.Schema)
{
// Recreate a dummy statement
string str;
using (SQLiteStatement tmp = Prepare(null, stmt._sqlStatement, null, (uint)(stmt._command._commandTimeout * 1000), out str))
{
@@ -398,19 +414,19 @@
tmp._sqlite_stmt = null;
// Reapply parameters
stmt.BindParameters();
}
- return -1; // Reset was OK, with schema change
+ return (SQLiteErrorCode)(-1); // Reset was OK, with schema change
}
- else if (n == 6 || n == 5) // SQLITE_LOCKED || SQLITE_BUSY
+ else if (n == SQLiteErrorCode.Locked || n == SQLiteErrorCode.Busy)
return n;
- if (n > 0)
+ if (n != SQLiteErrorCode.Ok)
throw new SQLiteException(n, GetLastError());
- return 0; // We reset OK, no schema changes
+ return SQLiteErrorCode.Ok; // We reset OK, no schema changes
}
internal override string GetLastError()
{
return SQLiteBase.GetLastError(_sql, _sql);
@@ -445,21 +461,21 @@
#if !PLATFORM_COMPACTFRAMEWORK
if ((flags & SQLiteConnectionFlags.LogPrepare) == SQLiteConnectionFlags.LogPrepare)
{
if ((strSql == null) || (strSql.Length == 0) || (strSql.Trim().Length == 0))
- SQLiteLog.LogMessage(0, "Preparing {}...");
+ SQLiteLog.LogMessage("Preparing {}...");
else
- SQLiteLog.LogMessage(0, String.Format(
+ SQLiteLog.LogMessage(String.Format(
CultureInfo.CurrentCulture, "Preparing {{{0}}}...", strSql));
}
#endif
IntPtr stmt = IntPtr.Zero;
IntPtr ptr = IntPtr.Zero;
int len = 0;
- int n = 17;
+ SQLiteErrorCode n = SQLiteErrorCode.Schema;
int retries = 0;
byte[] b = ToUTF8(strSql);
string typedefs = null;
SQLiteStatement cmd = null;
Random rnd = null;
@@ -467,11 +483,11 @@
GCHandle handle = GCHandle.Alloc(b, GCHandleType.Pinned);
IntPtr psql = handle.AddrOfPinnedObject();
try
{
- while ((n == 17 || n == 6 || n == 5) && retries < 3)
+ while ((n == SQLiteErrorCode.Schema || n == SQLiteErrorCode.Locked || n == SQLiteErrorCode.Busy) && retries < 3)
{
#if !SQLITE_STANDARD
n = UnsafeNativeMethods.sqlite3_prepare_interop(_sql, psql, b.Length - 1, out stmt, out ptr, out len);
#else
n = UnsafeNativeMethods.sqlite3_prepare(_sql, psql, b.Length - 1, out stmt, out ptr);
@@ -480,13 +496,13 @@
#if !NET_COMPACT_20 && TRACE_STATEMENT
Trace.WriteLine(String.Format("Prepare ({0}): {1}", n, stmt));
#endif
- if (n == 17)
+ if (n == SQLiteErrorCode.Schema)
retries++;
- else if (n == 1)
+ else if (n == SQLiteErrorCode.Error)
{
if (String.Compare(GetLastError(), "near \"TYPES\": syntax error", StringComparison.OrdinalIgnoreCase) == 0)
{
int pos = strSql.IndexOf(';');
if (pos == -1) pos = strSql.Length - 1;
@@ -532,11 +548,11 @@
_buildingSchema = false;
}
}
#endif
}
- else if (n == 6 || n == 5) // Locked -- delay a small amount before retrying
+ else if (n == SQLiteErrorCode.Locked || n == SQLiteErrorCode.Busy) // Locked -- delay a small amount before retrying
{
// Keep trying
if (rnd == null) // First time we've encountered the lock
rnd = new Random();
@@ -551,11 +567,11 @@
System.Threading.Thread.Sleep(rnd.Next(1, 150));
}
}
}
- if (n > 0) throw new SQLiteException(n, GetLastError());
+ if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
strRemain = UTF8ToString(ptr, len);
if (stmt != IntPtr.Zero) cmd = new SQLiteStatement(this, flags, new SQLiteStatementHandle(_sql, stmt), strSql.Substring(0, strSql.Length - strRemain.Length), previous);
@@ -570,20 +586,20 @@
#if !PLATFORM_COMPACTFRAMEWORK
protected static void LogBind(SQLiteStatementHandle handle, int index)
{
IntPtr handleIntPtr = handle;
- SQLiteLog.LogMessage(0, String.Format(
+ SQLiteLog.LogMessage(String.Format(
"Binding statement {0} paramter #{1} as NULL...",
handleIntPtr, index));
}
protected static void LogBind(SQLiteStatementHandle handle, int index, ValueType value)
{
IntPtr handleIntPtr = handle;
- SQLiteLog.LogMessage(0, String.Format(
+ SQLiteLog.LogMessage(String.Format(
"Binding statement {0} paramter #{1} as type {2} with value {{{3}}}...",
handleIntPtr, index, value.GetType(), value));
}
private static string FormatDateTime(DateTime value)
@@ -601,20 +617,20 @@
protected static void LogBind(SQLiteStatementHandle handle, int index, DateTime value)
{
IntPtr handleIntPtr = handle;
- SQLiteLog.LogMessage(0, String.Format(
+ SQLiteLog.LogMessage(String.Format(
"Binding statement {0} paramter #{1} as type {2} with value {{{3}}}...",
handleIntPtr, index, typeof(DateTime), FormatDateTime(value)));
}
protected static void LogBind(SQLiteStatementHandle handle, int index, string value)
{
IntPtr handleIntPtr = handle;
- SQLiteLog.LogMessage(0, String.Format(
+ SQLiteLog.LogMessage(String.Format(
"Binding statement {0} paramter #{1} as type {2} with value {{{3}}}...",
handleIntPtr, index, typeof(String), (value != null) ? value : ""));
}
private static string ToHexadecimalString(
@@ -636,11 +652,11 @@
protected static void LogBind(SQLiteStatementHandle handle, int index, byte[] value)
{
IntPtr handleIntPtr = handle;
- SQLiteLog.LogMessage(0, String.Format(
+ SQLiteLog.LogMessage(String.Format(
"Binding statement {0} paramter #{1} as type {2} with value {{{3}}}...",
handleIntPtr, index, typeof(Byte[]), (value != null) ? ToHexadecimalString(value) : ""));
}
#endif
@@ -652,15 +668,15 @@
if ((flags & SQLiteConnectionFlags.LogBind) == SQLiteConnectionFlags.LogBind)
{
LogBind(handle, index, value);
}
- int n = UnsafeNativeMethods.sqlite3_bind_double(handle, index, value);
+ SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_bind_double(handle, index, value);
#else
- int n = UnsafeNativeMethods.sqlite3_bind_double_interop(handle, index, ref value);
+ SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_bind_double_interop(handle, index, ref value);
#endif
- if (n > 0) throw new SQLiteException(n, GetLastError());
+ 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;
@@ -670,12 +686,12 @@
{
LogBind(handle, index, value);
}
#endif
- int n = UnsafeNativeMethods.sqlite3_bind_int(handle, index, value);
- if (n > 0) throw new SQLiteException(n, GetLastError());
+ SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_bind_int(handle, index, value);
+ if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
}
internal override void Bind_UInt32(SQLiteStatement stmt, SQLiteConnectionFlags flags, int index, uint value)
{
SQLiteStatementHandle handle = stmt._sqlite_stmt;
@@ -685,12 +701,12 @@
{
LogBind(handle, index, value);
}
#endif
- int n = UnsafeNativeMethods.sqlite3_bind_uint(handle, index, value);
- if (n > 0) throw new SQLiteException(n, GetLastError());
+ SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_bind_uint(handle, index, value);
+ if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
}
internal override void Bind_Int64(SQLiteStatement stmt, SQLiteConnectionFlags flags, int index, long value)
{
SQLiteStatementHandle handle = stmt._sqlite_stmt;
@@ -699,15 +715,15 @@
if ((flags & SQLiteConnectionFlags.LogBind) == SQLiteConnectionFlags.LogBind)
{
LogBind(handle, index, value);
}
- int n = UnsafeNativeMethods.sqlite3_bind_int64(handle, index, value);
+ SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_bind_int64(handle, index, value);
#else
- int n = UnsafeNativeMethods.sqlite3_bind_int64_interop(handle, index, ref value);
+ SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_bind_int64_interop(handle, index, ref value);
#endif
- if (n > 0) throw new SQLiteException(n, GetLastError());
+ 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;
@@ -716,15 +732,15 @@
if ((flags & SQLiteConnectionFlags.LogBind) == SQLiteConnectionFlags.LogBind)
{
LogBind(handle, index, value);
}
- int n = UnsafeNativeMethods.sqlite3_bind_uint64(handle, index, value);
+ SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_bind_uint64(handle, index, value);
#else
- int n = UnsafeNativeMethods.sqlite3_bind_uint64_interop(handle, index, ref value);
+ SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_bind_uint64_interop(handle, index, ref value);
#endif
- if (n > 0) throw new SQLiteException(n, GetLastError());
+ 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;
@@ -743,12 +759,12 @@
{
LogBind(handle, index, b);
}
#endif
- int n = UnsafeNativeMethods.sqlite3_bind_text(handle, index, b, b.Length - 1, (IntPtr)(-1));
- if (n > 0) throw new SQLiteException(n, GetLastError());
+ SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_bind_text(handle, index, b, b.Length - 1, (IntPtr)(-1));
+ if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
}
internal override void Bind_DateTime(SQLiteStatement stmt, SQLiteConnectionFlags flags, int index, DateTime dt)
{
SQLiteStatementHandle handle = stmt._sqlite_stmt;
@@ -770,15 +786,15 @@
if ((flags & SQLiteConnectionFlags.LogBind) == SQLiteConnectionFlags.LogBind)
{
LogBind(handle, index, value);
}
- int n = UnsafeNativeMethods.sqlite3_bind_int64(handle, index, value);
+ SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_bind_int64(handle, index, value);
#else
- int n = UnsafeNativeMethods.sqlite3_bind_int64_interop(handle, index, ref value);
+ SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_bind_int64_interop(handle, index, ref value);
#endif
- if (n > 0) throw new SQLiteException(n, GetLastError());
+ if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
break;
}
case SQLiteDateFormats.JulianDay:
{
double value = ToJulianDay(dt);
@@ -787,15 +803,15 @@
if ((flags & SQLiteConnectionFlags.LogBind) == SQLiteConnectionFlags.LogBind)
{
LogBind(handle, index, value);
}
- int n = UnsafeNativeMethods.sqlite3_bind_double(handle, index, value);
+ SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_bind_double(handle, index, value);
#else
- int n = UnsafeNativeMethods.sqlite3_bind_double_interop(handle, index, ref value);
+ SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_bind_double_interop(handle, index, ref value);
#endif
- if (n > 0) throw new SQLiteException(n, GetLastError());
+ if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
break;
}
case SQLiteDateFormats.UnixEpoch:
{
long value = Convert.ToInt64(dt.Subtract(UnixEpoch).TotalSeconds);
@@ -804,15 +820,15 @@
if ((flags & SQLiteConnectionFlags.LogBind) == SQLiteConnectionFlags.LogBind)
{
LogBind(handle, index, value);
}
- int n = UnsafeNativeMethods.sqlite3_bind_int64(handle, index, value);
+ SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_bind_int64(handle, index, value);
#else
- int n = UnsafeNativeMethods.sqlite3_bind_int64_interop(handle, index, ref value);
+ SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_bind_int64_interop(handle, index, ref value);
#endif
- if (n > 0) throw new SQLiteException(n, GetLastError());
+ if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
break;
}
default:
{
byte[] b = ToUTF8(dt);
@@ -822,12 +838,12 @@
{
LogBind(handle, index, b);
}
#endif
- int n = UnsafeNativeMethods.sqlite3_bind_text(handle, index, b, b.Length - 1, (IntPtr)(-1));
- if (n > 0) throw new SQLiteException(n, GetLastError());
+ SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_bind_text(handle, index, b, b.Length - 1, (IntPtr)(-1));
+ if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
break;
}
}
}
@@ -840,12 +856,12 @@
{
LogBind(handle, index, blobData);
}
#endif
- int n = UnsafeNativeMethods.sqlite3_bind_blob(handle, index, blobData, blobData.Length, (IntPtr)(-1));
- if (n > 0) throw new SQLiteException(n, GetLastError());
+ SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_bind_blob(handle, index, blobData, blobData.Length, (IntPtr)(-1));
+ if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
}
internal override void Bind_Null(SQLiteStatement stmt, SQLiteConnectionFlags flags, int index)
{
SQLiteStatementHandle handle = stmt._sqlite_stmt;
@@ -855,12 +871,12 @@
{
LogBind(handle, index);
}
#endif
- int n = UnsafeNativeMethods.sqlite3_bind_null(handle, index);
- if (n > 0) throw new SQLiteException(n, GetLastError());
+ SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_bind_null(handle, index);
+ if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
}
internal override int Bind_ParamCount(SQLiteStatement stmt, SQLiteConnectionFlags flags)
{
SQLiteStatementHandle handle = stmt._sqlite_stmt;
@@ -869,11 +885,11 @@
#if !PLATFORM_COMPACTFRAMEWORK
if ((flags & SQLiteConnectionFlags.LogBind) == SQLiteConnectionFlags.LogBind)
{
IntPtr handleIntPtr = handle;
- SQLiteLog.LogMessage(0, String.Format(
+ SQLiteLog.LogMessage(String.Format(
"Statement {0} paramter count is {1}.",
handleIntPtr, value));
}
#endif
@@ -895,11 +911,11 @@
#if !PLATFORM_COMPACTFRAMEWORK
if ((flags & SQLiteConnectionFlags.LogBind) == SQLiteConnectionFlags.LogBind)
{
IntPtr handleIntPtr = handle;
- SQLiteLog.LogMessage(0, String.Format(
+ SQLiteLog.LogMessage(String.Format(
"Statement {0} paramter #{1} name is {{{2}}}.",
handleIntPtr, index, name));
}
#endif
@@ -914,11 +930,11 @@
#if !PLATFORM_COMPACTFRAMEWORK
if ((flags & SQLiteConnectionFlags.LogBind) == SQLiteConnectionFlags.LogBind)
{
IntPtr handleIntPtr = handle;
- SQLiteLog.LogMessage(0, String.Format(
+ SQLiteLog.LogMessage(String.Format(
"Statement {0} paramter index of name {{{1}}} is #{2}.",
handleIntPtr, paramName, index));
}
#endif
@@ -1028,11 +1044,11 @@
IntPtr dataTypePtr;
IntPtr collSeqPtr;
int nnotNull;
int nprimaryKey;
int nautoInc;
- int n;
+ SQLiteErrorCode n;
int dtLen;
int csLen;
#if !SQLITE_STANDARD
n = UnsafeNativeMethods.sqlite3_table_column_metadata_interop(_sql, ToUTF8(dataBase), ToUTF8(table), ToUTF8(column), out dataTypePtr, out collSeqPtr, out nnotNull, out nprimaryKey, out nautoInc, out dtLen, out csLen);
@@ -1040,11 +1056,11 @@
dtLen = -1;
csLen = -1;
n = UnsafeNativeMethods.sqlite3_table_column_metadata(_sql, ToUTF8(dataBase), ToUTF8(table), ToUTF8(column), out dataTypePtr, out collSeqPtr, out nnotNull, out nprimaryKey, out nautoInc);
#endif
- if (n > 0) throw new SQLiteException(n, GetLastError());
+ if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
dataType = UTF8ToString(dataTypePtr, dtLen);
collateSequence = UTF8ToString(collSeqPtr, csLen);
notNull = (nnotNull == 1);
@@ -1155,27 +1171,27 @@
return UnsafeNativeMethods.sqlite3_aggregate_count(context);
}
internal override void CreateFunction(string strFunction, int nArgs, bool needCollSeq, SQLiteCallback func, SQLiteCallback funcstep, SQLiteFinalCallback funcfinal)
{
- int n;
+ SQLiteErrorCode n;
#if !SQLITE_STANDARD
n = UnsafeNativeMethods.sqlite3_create_function_interop(_sql, ToUTF8(strFunction), nArgs, 4, IntPtr.Zero, func, funcstep, funcfinal, (needCollSeq == true) ? 1 : 0);
- if (n == 0) n = UnsafeNativeMethods.sqlite3_create_function_interop(_sql, ToUTF8(strFunction), nArgs, 1, IntPtr.Zero, func, funcstep, funcfinal, (needCollSeq == true) ? 1 : 0);
+ if (n == SQLiteErrorCode.Ok) n = UnsafeNativeMethods.sqlite3_create_function_interop(_sql, ToUTF8(strFunction), nArgs, 1, IntPtr.Zero, func, funcstep, funcfinal, (needCollSeq == true) ? 1 : 0);
#else
n = UnsafeNativeMethods.sqlite3_create_function(_sql, ToUTF8(strFunction), nArgs, 4, IntPtr.Zero, func, funcstep, funcfinal);
- if (n == 0) n = UnsafeNativeMethods.sqlite3_create_function(_sql, ToUTF8(strFunction), nArgs, 1, IntPtr.Zero, func, funcstep, funcfinal);
+ if (n == SQLiteErrorCode.Ok) n = UnsafeNativeMethods.sqlite3_create_function(_sql, ToUTF8(strFunction), nArgs, 1, IntPtr.Zero, func, funcstep, funcfinal);
#endif
- if (n > 0) throw new SQLiteException(n, GetLastError());
+ if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
}
internal override void CreateCollation(string strCollation, SQLiteCollation func, SQLiteCollation func16)
{
- int n = UnsafeNativeMethods.sqlite3_create_collation(_sql, ToUTF8(strCollation), 2, IntPtr.Zero, func16);
- if (n == 0) n = UnsafeNativeMethods.sqlite3_create_collation(_sql, ToUTF8(strCollation), 1, IntPtr.Zero, func);
- if (n > 0) throw new SQLiteException(n, GetLastError());
+ SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_create_collation(_sql, ToUTF8(strCollation), 2, IntPtr.Zero, func16);
+ if (n == SQLiteErrorCode.Ok) n = UnsafeNativeMethods.sqlite3_create_collation(_sql, ToUTF8(strCollation), 1, IntPtr.Zero, func);
+ if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
}
internal override int ContextCollateCompare(CollationEncodingEnum enc, IntPtr context, string s1, string s2)
{
#if !SQLITE_STANDARD
@@ -1375,16 +1391,16 @@
internal override void SetExtendedResultCodes(bool bOnOff)
{
UnsafeNativeMethods.sqlite3_extended_result_codes(_sql, (bOnOff ? -1 : 0));
}
/// Gets the last SQLite error code
- internal override int ResultCode()
+ internal override SQLiteErrorCode ResultCode()
{
return UnsafeNativeMethods.sqlite3_errcode(_sql);
}
/// Gets the last SQLite extended error code
- internal override int ExtendedResultCode()
+ internal override SQLiteErrorCode ExtendedResultCode()
{
return UnsafeNativeMethods.sqlite3_extended_errcode(_sql);
}
/// Add a log message via the SQLite sqlite3_log interface.
@@ -1394,18 +1410,18 @@
}
#if INTEROP_CODEC
internal override void SetPassword(byte[] passwordBytes)
{
- int n = UnsafeNativeMethods.sqlite3_key(_sql, passwordBytes, passwordBytes.Length);
- if (n > 0) throw new SQLiteException(n, GetLastError());
+ SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_key(_sql, passwordBytes, passwordBytes.Length);
+ if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
}
internal override void ChangePassword(byte[] newPasswordBytes)
{
- int n = UnsafeNativeMethods.sqlite3_rekey(_sql, newPasswordBytes, (newPasswordBytes == null) ? 0 : newPasswordBytes.Length);
- if (n > 0) throw new SQLiteException(n, GetLastError());
+ SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_rekey(_sql, newPasswordBytes, (newPasswordBytes == null) ? 0 : newPasswordBytes.Length);
+ if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
}
#endif
internal override void SetUpdateHook(SQLiteUpdateCallback func)
{
@@ -1432,14 +1448,14 @@
/// log event occurs. Only one callback may be set. If NULL is passed,
/// the logging callback is unregistered.
///
/// The callback function to invoke.
/// Returns a result code
- internal override int SetLogCallback(SQLiteLogCallback func)
+ internal override SQLiteErrorCode SetLogCallback(SQLiteLogCallback func)
{
- int rc = UnsafeNativeMethods.sqlite3_config_log(
- SQLiteConfigOpsEnum.SQLITE_CONFIG_LOG, func, (IntPtr)0);
+ SQLiteErrorCode rc = UnsafeNativeMethods.sqlite3_config_log(
+ SQLiteConfigOpsEnum.SQLITE_CONFIG_LOG, func, IntPtr.Zero);
return rc;
}
///////////////////////////////////////////////////////////////////////////////////////////////
@@ -1539,28 +1555,28 @@
if (handlePtr == IntPtr.Zero)
throw new InvalidOperationException(
"Backup object has an invalid handle pointer.");
- int n = UnsafeNativeMethods.sqlite3_backup_step(handlePtr, nPage);
+ SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_backup_step(handlePtr, nPage);
backup._stepResult = n; /* NOTE: Save for use by FinishBackup. */
- if (n == (int)SQLiteErrorCode.Ok)
+ if (n == SQLiteErrorCode.Ok)
+ {
+ return true;
+ }
+ else if (n == SQLiteErrorCode.Busy)
{
+ retry = true;
return true;
}
- else if (n == (int)SQLiteErrorCode.Busy)
+ else if (n == SQLiteErrorCode.Locked)
{
retry = true;
return true;
}
- else if (n == (int)SQLiteErrorCode.Locked)
- {
- retry = true;
- return true;
- }
- else if (n == (int)SQLiteErrorCode.Done)
+ else if (n == SQLiteErrorCode.Done)
{
return false;
}
else
{
@@ -1647,14 +1663,14 @@
if (handlePtr == IntPtr.Zero)
throw new InvalidOperationException(
"Backup object has an invalid handle pointer.");
- int n = UnsafeNativeMethods.sqlite3_backup_finish(handlePtr);
+ SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_backup_finish(handlePtr);
handle.SetHandleAsInvalid();
- if ((n > 0) && (n != backup._stepResult))
+ if ((n != SQLiteErrorCode.Ok) && (n != backup._stepResult))
throw new SQLiteException(n, GetLastError());
}
///////////////////////////////////////////////////////////////////////////////////////////////
@@ -1702,14 +1718,14 @@
// NOTE: This method [ab]uses the fact that SQLite will always
// return SQLITE_ERROR for any unknown configuration option
// *unless* the SQLite library has already been initialized.
// In that case it will always return SQLITE_MISUSE.
//
- int rc = UnsafeNativeMethods.sqlite3_config_none(
+ SQLiteErrorCode rc = UnsafeNativeMethods.sqlite3_config_none(
SQLiteConfigOpsEnum.SQLITE_CONFIG_NONE);
- return (rc == /* SQLITE_MISUSE */ 21);
+ return (rc == SQLiteErrorCode.Misuse);
#if !PLATFORM_COMPACTFRAMEWORK
}
finally
{
SQLiteLog.Enabled = savedEnabled;
@@ -1777,12 +1793,12 @@
internal override long GetRowIdForCursor(SQLiteStatement stmt, int cursor)
{
#if !SQLITE_STANDARD
long rowid;
- int rc = UnsafeNativeMethods.sqlite3_cursor_rowid(stmt._sqlite_stmt, cursor, out rowid);
- if (rc == 0) return rowid;
+ SQLiteErrorCode rc = UnsafeNativeMethods.sqlite3_cursor_rowid(stmt._sqlite_stmt, cursor, out rowid);
+ if (rc == SQLiteErrorCode.Ok) return rowid;
return 0;
#else
return 0;
#endif
@@ -1791,24 +1807,24 @@
internal override void GetIndexColumnExtendedInfo(string database, string index, string column, out int sortMode, out int onError, out string collationSequence)
{
#if !SQLITE_STANDARD
IntPtr coll;
int colllen;
- int rc;
+ SQLiteErrorCode rc;
rc = UnsafeNativeMethods.sqlite3_index_column_info_interop(_sql, ToUTF8(database), ToUTF8(index), ToUTF8(column), out sortMode, out onError, out coll, out colllen);
- if (rc != 0) throw new SQLiteException(rc, "");
+ if (rc != SQLiteErrorCode.Ok) throw new SQLiteException(rc, null);
collationSequence = UTF8ToString(coll, colllen);
#else
sortMode = 0;
onError = 2;
collationSequence = "BINARY";
#endif
}
- internal override int FileControl(string zDbName, int op, IntPtr pArg)
+ internal override SQLiteErrorCode FileControl(string zDbName, int op, IntPtr pArg)
{
return UnsafeNativeMethods.sqlite3_file_control(_sql, (zDbName != null) ? ToUTF8(zDbName) : null, op, pArg);
}
}
}
Index: System.Data.SQLite/SQLite3_UTF16.cs
==================================================================
--- System.Data.SQLite/SQLite3_UTF16.cs
+++ System.Data.SQLite/SQLite3_UTF16.cs
@@ -109,23 +109,23 @@
if (_sql == null)
{
IntPtr db;
#if !SQLITE_STANDARD
- int n = UnsafeNativeMethods.sqlite3_open16_interop(ToUTF8(strFilename), (int)openFlags, out db);
+ SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_open16_interop(ToUTF8(strFilename), (int)openFlags, out db);
#else
if ((openFlags & SQLiteOpenFlagsEnum.Create) == 0 && System.IO.File.Exists(strFilename) == false)
throw new SQLiteException((int)SQLiteErrorCode.CantOpen, strFilename);
- int n = UnsafeNativeMethods.sqlite3_open16(strFilename, out db);
+ SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_open16(strFilename, out db);
#endif
#if !NET_COMPACT_20 && TRACE_CONNECTION
Trace.WriteLine(String.Format("Open: {0}", db));
#endif
- if (n > 0) throw new SQLiteException(n, null);
+ if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, null);
_sql = new SQLiteConnectionHandle(db);
lock (_sql) { /* HACK: Force the SyncBlock to be "created" now. */ }
}
_functionsArray = SQLiteFunction.BindFunctions(this, connectionFlags);
@@ -171,12 +171,12 @@
{
LogBind(handle, index, value);
}
#endif
- int n = UnsafeNativeMethods.sqlite3_bind_text16(handle, index, value, value.Length * 2, (IntPtr)(-1));
- if (n > 0) throw new SQLiteException(n, GetLastError());
+ SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_bind_text16(handle, index, value, value.Length * 2, (IntPtr)(-1));
+ if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
}
internal override DateTime GetDateTime(SQLiteStatement stmt, int index)
{
return ToDateTime(GetText(stmt, index));
Index: System.Data.SQLite/SQLiteBackup.cs
==================================================================
--- System.Data.SQLite/SQLiteBackup.cs
+++ System.Data.SQLite/SQLiteBackup.cs
@@ -48,11 +48,11 @@
/// The last result from the StepBackup method of the SQLite3 class.
/// This is used to determine if the call to the FinishBackup method of
/// the SQLite3 class should throw an exception when it receives a non-Ok
/// return code from the core SQLite library.
///
- internal int _stepResult;
+ internal SQLiteErrorCode _stepResult;
///
/// Initializes the backup.
///
/// The base SQLite object.
Index: System.Data.SQLite/SQLiteBase.cs
==================================================================
--- System.Data.SQLite/SQLiteBase.cs
+++ System.Data.SQLite/SQLiteBase.cs
@@ -6,10 +6,11 @@
********************************************************/
namespace System.Data.SQLite
{
using System;
+ // using System.Runtime.InteropServices;
///
/// This internal class provides the foundation of SQLite support. It defines all the abstract members needed to implement
/// a SQLite data provider, and inherits from SQLiteConvert which allows for simple translations of string to and from SQLite.
///
@@ -45,16 +46,16 @@
/// If this is disabled, memory usage tracking will not be performed. This is not really a per-connection value, it is
/// global to the process.
///
/// Non-zero to enable memory usage tracking, zero otherwise.
/// A standard SQLite return code (i.e. zero for success and non-zero for failure).
- internal abstract int SetMemoryStatus(bool value);
+ internal abstract SQLiteErrorCode SetMemoryStatus(bool value);
///
/// Shutdown the SQLite engine so that it can be restarted with different config options.
/// We depend on auto initialization to recover.
///
- internal abstract int Shutdown();
+ internal abstract SQLiteErrorCode Shutdown();
///
/// Returns non-zero if a database connection is open.
///
///
internal abstract bool IsOpen();
@@ -123,11 +124,11 @@
/// Resets a prepared statement so it can be executed again. If the error returned is SQLITE_SCHEMA,
/// transparently attempt to rebuild the SQL statement and throw an error if that was not possible.
///
/// The statement to reset
/// 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
- internal abstract int Reset(SQLiteStatement stmt);
+ internal abstract SQLiteErrorCode Reset(SQLiteStatement stmt);
internal abstract void Cancel();
internal abstract void Bind_Double(SQLiteStatement stmt, SQLiteConnectionFlags flags, int index, double value);
internal abstract void Bind_Int32(SQLiteStatement stmt, SQLiteConnectionFlags flags, int index, Int32 value);
internal abstract void Bind_UInt32(SQLiteStatement stmt, SQLiteConnectionFlags flags, int index, UInt32 value);
@@ -195,17 +196,17 @@
///
/// Returns the numeric result code for the most recent failed SQLite API call
/// associated with the database connection.
///
/// Result code
- internal abstract int ResultCode();
+ internal abstract SQLiteErrorCode ResultCode();
///
/// Returns the extended numeric result code for the most recent failed SQLite API call
/// associated with the database connection.
///
/// Extended result code
- internal abstract int ExtendedResultCode();
+ internal abstract SQLiteErrorCode ExtendedResultCode();
///
/// Add a log message via the SQLite sqlite3_log interface.
///
/// Error code to be logged with the message.
@@ -222,11 +223,11 @@
internal abstract void SetUpdateHook(SQLiteUpdateCallback func);
internal abstract void SetCommitHook(SQLiteCommitCallback func);
internal abstract void SetTraceCallback(SQLiteTraceCallback func);
internal abstract void SetRollbackHook(SQLiteRollbackCallback func);
- internal abstract int SetLogCallback(SQLiteLogCallback func);
+ internal abstract SQLiteErrorCode SetLogCallback(SQLiteLogCallback func);
///
/// Checks if the SQLite core library has been initialized in the current process.
///
///
@@ -243,11 +244,11 @@
internal abstract bool AutoCommit
{
get;
}
- internal abstract int FileControl(string zDbName, int op, IntPtr pArg);
+ internal abstract SQLiteErrorCode FileControl(string zDbName, int op, IntPtr pArg);
///
/// Creates a new SQLite backup object based on the provided destination
/// database connection. The source database connection is the one
/// associated with this object. The source and destination database
@@ -359,10 +360,74 @@
// These statics are here for lack of a better place to put them.
// They exist here because they are called during the finalization of
// a SQLiteStatementHandle, SQLiteConnectionHandle, and SQLiteFunctionCookieHandle.
// Therefore these functions have to be static, and have to be low-level.
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////
+
+ private static string[] _errorMessages = {
+ /* SQLITE_OK */ "not an error",
+ /* SQLITE_ERROR */ "SQL logic error or missing database",
+ /* SQLITE_INTERNAL */ "internal logic error",
+ /* SQLITE_PERM */ "access permission denied",
+ /* SQLITE_ABORT */ "callback requested query abort",
+ /* SQLITE_BUSY */ "database is locked",
+ /* SQLITE_LOCKED */ "database table is locked",
+ /* SQLITE_NOMEM */ "out of memory",
+ /* SQLITE_READONLY */ "attempt to write a readonly database",
+ /* SQLITE_INTERRUPT */ "interrupted",
+ /* SQLITE_IOERR */ "disk I/O error",
+ /* SQLITE_CORRUPT */ "database disk image is malformed",
+ /* SQLITE_NOTFOUND */ "unknown operation",
+ /* SQLITE_FULL */ "database or disk is full",
+ /* SQLITE_CANTOPEN */ "unable to open database file",
+ /* SQLITE_PROTOCOL */ "locking protocol",
+ /* SQLITE_EMPTY */ "table contains no data",
+ /* SQLITE_SCHEMA */ "database schema has changed",
+ /* SQLITE_TOOBIG */ "string or blob too big",
+ /* SQLITE_CONSTRAINT */ "constraint failed",
+ /* SQLITE_MISMATCH */ "datatype mismatch",
+ /* SQLITE_MISUSE */ "library routine called out of sequence",
+ /* SQLITE_NOLFS */ "large file support is disabled",
+ /* SQLITE_AUTH */ "authorization denied",
+ /* SQLITE_FORMAT */ "auxiliary database format error",
+ /* SQLITE_RANGE */ "bind or column index out of range",
+ /* SQLITE_NOTADB */ "file is encrypted or is not a database",
+ };
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////
+
+ private static string FallbackGetErrorString(SQLiteErrorCode rc)
+ {
+ if (_errorMessages == null)
+ return null;
+
+ int index = (int)rc;
+
+ if ((index < 0) || (index >= _errorMessages.Length))
+ index = (int)SQLiteErrorCode.Error; /* Make into generic error. */
+
+ return _errorMessages[index];
+ }
+
+ internal static string GetErrorString(SQLiteErrorCode rc)
+ {
+ //try
+ //{
+ // IntPtr ptr = UnsafeNativeMethods.sqlite3_errstr(rc);
+ //
+ // if (ptr != IntPtr.Zero)
+ // return Marshal.PtrToStringAnsi(ptr);
+ //}
+ //catch (EntryPointNotFoundException)
+ //{
+ // // do nothing.
+ //}
+
+ return FallbackGetErrorString(rc);
+ }
internal static string GetLastError(SQLiteConnectionHandle hdl, IntPtr db)
{
if ((hdl == null) || (db == IntPtr.Zero))
return "null connection or database handle";
@@ -388,40 +453,40 @@
internal static void FinishBackup(SQLiteConnectionHandle hdl, IntPtr backup)
{
if ((hdl == null) || (backup == IntPtr.Zero)) return;
lock (hdl)
{
- int n = UnsafeNativeMethods.sqlite3_backup_finish(backup);
- if (n > 0) throw new SQLiteException(n, null);
+ SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_backup_finish(backup);
+ if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, null);
}
}
internal static void FinalizeStatement(SQLiteConnectionHandle hdl, IntPtr stmt)
{
if ((hdl == null) || (stmt == IntPtr.Zero)) return;
lock (hdl)
{
#if !SQLITE_STANDARD
- int n = UnsafeNativeMethods.sqlite3_finalize_interop(stmt);
+ SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_finalize_interop(stmt);
#else
- int n = UnsafeNativeMethods.sqlite3_finalize(stmt);
+ SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_finalize(stmt);
#endif
- if (n > 0) throw new SQLiteException(n, null);
+ if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, null);
}
}
internal static void CloseConnection(SQLiteConnectionHandle hdl, IntPtr db)
{
if ((hdl == null) || (db == IntPtr.Zero)) return;
lock (hdl)
{
#if !SQLITE_STANDARD
- int n = UnsafeNativeMethods.sqlite3_close_interop(db);
+ SQLiteErrorCode n = UnsafeNativeMethods.sqlite3_close_interop(db);
#else
ResetConnection(hdl, db);
- int n;
+ SQLiteErrorCode n;
try
{
n = UnsafeNativeMethods.sqlite3_close_v2(db);
}
@@ -428,11 +493,11 @@
catch (EntryPointNotFoundException)
{
n = UnsafeNativeMethods.sqlite3_close(db);
}
#endif
- if (n > 0) throw new SQLiteException(n, GetLastError(hdl, db));
+ if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError(hdl, db));
}
}
internal static void ResetConnection(SQLiteConnectionHandle hdl, IntPtr db)
{
@@ -439,11 +504,11 @@
if ((hdl == null) || (db == IntPtr.Zero)) return;
if (hdl.IsClosed || hdl.IsInvalid) return;
lock (hdl)
{
IntPtr stmt = IntPtr.Zero;
- int n;
+ SQLiteErrorCode n;
do
{
stmt = UnsafeNativeMethods.sqlite3_next_stmt(db, stmt);
if (stmt != IntPtr.Zero)
{
@@ -456,11 +521,11 @@
} while (stmt != IntPtr.Zero);
if (IsAutocommit(hdl, db) == false) // a transaction is pending on the connection
{
n = UnsafeNativeMethods.sqlite3_exec(db, ToUTF8("ROLLBACK"), IntPtr.Zero, IntPtr.Zero, out stmt);
- if (n > 0) throw new SQLiteException(n, GetLastError(hdl, db));
+ if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError(hdl, db));
}
}
GC.KeepAlive(hdl);
}
Index: System.Data.SQLite/SQLiteConnection.cs
==================================================================
--- System.Data.SQLite/SQLiteConnection.cs
+++ System.Data.SQLite/SQLiteConnection.cs
@@ -488,11 +488,11 @@
#if !PLATFORM_COMPACTFRAMEWORK
catch (Exception e)
{
if ((_flags & SQLiteConnectionFlags.LogBackup) == SQLiteConnectionFlags.LogBackup)
{
- SQLiteLog.LogMessage(0, String.Format(
+ SQLiteLog.LogMessage(String.Format(
CultureInfo.CurrentCulture,
"Caught exception while backing up database: {0}", e));
}
throw;
@@ -1537,11 +1537,11 @@
/// If this is disabled, memory usage tracking will not be performed. This is not really a per-connection value, it is
/// global to the process.
///
/// Non-zero to enable memory usage tracking, zero otherwise.
/// A standard SQLite return code (i.e. zero for success and non-zero for failure).
- public static int SetMemoryStatus(bool value)
+ public static SQLiteErrorCode SetMemoryStatus(bool value)
{
return SQLite3.StaticSetMemoryStatus(value);
}
///
@@ -1586,11 +1586,11 @@
return _connectionState;
}
}
/// Passes a shutdown request off to SQLite.
- public int Shutdown()
+ public SQLiteErrorCode Shutdown()
{
CheckDisposed();
// make sure we have an instance of the base class
if (_sql == null)
@@ -1634,20 +1634,20 @@
CheckDisposed();
if (_sql != null) _sql.SetExtendedResultCodes(bOnOff);
}
/// Enables or disabled extended result codes returned by SQLite
- public int ResultCode()
+ public SQLiteErrorCode ResultCode()
{
CheckDisposed();
if (_sql == null)
throw new InvalidOperationException("Database connection not valid for getting result code.");
return _sql.ResultCode();
}
/// Enables or disabled extended result codes returned by SQLite
- public int ExtendedResultCode()
+ public SQLiteErrorCode ExtendedResultCode()
{
CheckDisposed();
if (_sql == null)
throw new InvalidOperationException("Database connection not valid for getting extended result code.");
@@ -1739,19 +1739,19 @@
/// The number of milliseconds to wait before retrying the I/O
/// operation. This number is multiplied by the number of retry attempts so far to come
/// up with the final number of milliseconds to wait. A negative value will cause the
/// current interval to be queried and replace that negative value.
/// Zero for success, non-zero for error.
- public int SetAvRetry(ref int count, ref int interval)
+ public SQLiteErrorCode SetAvRetry(ref int count, ref int interval)
{
CheckDisposed();
if (_connectionState != ConnectionState.Open)
throw new InvalidOperationException(
"Database must be opened before changing the AV retry parameters.");
- int rc;
+ SQLiteErrorCode rc;
IntPtr pArg = IntPtr.Zero;
try
{
pArg = Marshal.AllocHGlobal(sizeof(int) * 2);
Index: System.Data.SQLite/SQLiteDataReader.cs
==================================================================
--- System.Data.SQLite/SQLiteDataReader.cs
+++ System.Data.SQLite/SQLiteDataReader.cs
@@ -229,11 +229,11 @@
if (_command == null)
throw new InvalidOperationException("DataReader has been closed");
if (_version == 0)
- throw new SQLiteException((int)SQLiteErrorCode.Abort, "Execution was aborted by the user");
+ throw new SQLiteException(SQLiteErrorCode.Abort, "Execution was aborted by the user");
if (_command.Connection.State != ConnectionState.Open || _command.Connection._version != _version)
throw new InvalidOperationException("Connection was closed, statement was terminated");
}
Index: System.Data.SQLite/SQLiteException.cs
==================================================================
--- System.Data.SQLite/SQLiteException.cs
+++ System.Data.SQLite/SQLiteException.cs
@@ -34,16 +34,16 @@
#endif
///
/// Public constructor for generating a SQLite error given the base error code
///
- /// The SQLite error code to report
- /// Extra text to go along with the error message text
- public SQLiteException(int errorCode, string extendedInformation)
- : base(GetStockErrorMessage(errorCode, extendedInformation))
+ /// The SQLite error code to report
+ /// Extra text to go along with the error message text
+ public SQLiteException(SQLiteErrorCode errorCode, string message)
+ : base(GetStockErrorMessage(errorCode, message))
{
- _errorCode = (SQLiteErrorCode)errorCode;
+ _errorCode = errorCode;
}
///
/// Various public constructors that just pass along to the base Exception
///
@@ -83,175 +83,145 @@
}
///
/// Initializes the exception class with the SQLite error code.
///
- /// The SQLite error code
- /// A detailed error message
- /// An error message string
- private static string GetStockErrorMessage(int errorCode, string errorMessage)
- {
- if (errorMessage == null) errorMessage = "";
-
- if (errorMessage.Length > 0)
- errorMessage = "\r\n" + errorMessage;
-
- if (errorCode < 0 || errorCode >= _errorMessages.Length)
- errorCode = 1;
-
- return _errorMessages[errorCode] + errorMessage;
- }
-
- private static string[] _errorMessages = {
- "SQLite OK",
- "SQLite error",
- "An internal logic error in SQLite",
- "Access permission denied",
- "Callback routine requested an abort",
- "The database file is locked",
- "A table in the database is locked",
- "malloc() failed",
- "Attempt to write a read-only database",
- "Operation terminated by sqlite3_interrupt()",
- "Some kind of disk I/O error occurred",
- "The database disk image is malformed",
- "Table or record not found",
- "Insertion failed because the database is full",
- "Unable to open the database file",
- "Database lock protocol error",
- "Database is empty",
- "The database schema changed",
- "Too much data for one row of a table",
- "Abort due to constraint violation",
- "Data type mismatch",
- "Library used incorrectly",
- "Uses OS features not supported on host",
- "Authorization denied",
- "Auxiliary database format error",
- "2nd parameter to sqlite3_bind() out of range",
- "File opened that is not a database file",
- };
- }
-
- ///
- /// SQLite error codes
- ///
- public enum SQLiteErrorCode
- {
- ///
- /// Success
- ///
- Ok = 0,
- ///
- /// SQL error or missing database
- ///
- Error,
- ///
- /// Internal logic error in SQLite
- ///
- Internal,
- ///
- /// Access permission denied
- ///
- Perm,
- ///
- /// Callback routine requested an abort
- ///
- Abort,
- ///
- /// The database file is locked
- ///
- Busy,
+ /// The SQLite error code
+ /// A detailed error message
+ /// An error message string
+ private static string GetStockErrorMessage(
+ SQLiteErrorCode errorCode,
+ string message
+ )
+ {
+ return String.Format("{0}{1}{2}",
+ SQLiteBase.GetErrorString(errorCode),
+ Environment.NewLine, message).Trim();
+ }
+ }
+
+ ///
+ /// SQLite error codes. Actually, this enumeration represents a return code,
+ /// which may also indicate success in one of several ways (e.g. SQLITE_OK,
+ /// SQLITE_ROW, and SQLITE_DONE). Therefore, the name of this enumeration is
+ /// something of a misnomer.
+ ///
+ public enum SQLiteErrorCode
+ {
+ ///
+ /// Successful result
+ ///
+ Ok /* 0 */,
+ ///
+ /// SQL error or missing database
+ ///
+ Error /* 1 */,
+ ///
+ /// Internal logic error in SQLite
+ ///
+ Internal /* 2 */,
+ ///
+ /// Access permission denied
+ ///
+ Perm /* 3 */,
+ ///
+ /// Callback routine requested an abort
+ ///
+ Abort /* 4 */,
+ ///
+ /// The database file is locked
+ ///
+ Busy /* 5 */,
///
/// A table in the database is locked
///
- Locked,
- ///
- /// malloc() failed
- ///
- NoMem,
- ///
- /// Attempt to write a read-only database
- ///
- ReadOnly,
- ///
+ Locked /* 6 */,
+ ///
+ /// A malloc() failed
+ ///
+ NoMem /* 7 */,
+ ///
+ /// Attempt to write a readonly database
+ ///
+ ReadOnly /* 8 */,
+ ///
/// Operation terminated by sqlite3_interrupt()
///
- Interrupt,
- ///
+ Interrupt /* 9 */,
+ ///
/// Some kind of disk I/O error occurred
///
- IOErr,
- ///
+ IoErr /* 10 */,
+ ///
/// The database disk image is malformed
///
- Corrupt,
- ///
- /// Table or record not found
+ Corrupt /* 11 */,
+ ///
+ /// Unknown opcode in sqlite3_file_control()
///
- NotFound,
- ///
+ NotFound /* 12 */,
+ ///
/// Insertion failed because database is full
///
- Full,
- ///
+ Full /* 13 */,
+ ///
/// Unable to open the database file
///
- CantOpen,
- ///
+ CantOpen /* 14 */,
+ ///
/// Database lock protocol error
///
- Protocol,
- ///
+ Protocol /* 15 */,
+ ///
/// Database is empty
///
- Empty,
- ///
+ Empty /* 16 */,
+ ///
/// The database schema changed
///
- Schema,
- ///
- /// Too much data for one row of a table
+ Schema /* 17 */,
+ ///
+ /// String or BLOB exceeds size limit
///
- TooBig,
- ///
+ TooBig /* 18 */,
+ ///
/// Abort due to constraint violation
///
- Constraint,
- ///
+ Constraint /* 19 */,
+ ///
/// Data type mismatch
///
- Mismatch,
- ///
+ Mismatch /* 20 */,
+ ///
/// Library used incorrectly
///
- Misuse,
- ///
+ Misuse /* 21 */,
+ ///
/// Uses OS features not supported on host
///
- NOLFS,
- ///
+ NoLfs /* 22 */,
+ ///
/// Authorization denied
///
- Auth,
- ///
+ Auth /* 23 */,
+ ///
/// Auxiliary database format error
///
- Format,
- ///
+ Format /* 24 */,
+ ///
/// 2nd parameter to sqlite3_bind out of range
///
- Range,
- ///
+ Range /* 25 */,
+ ///
/// File opened that is not a database file
///
- NotADatabase,
- ///
+ NotADb /* 26 */,
+ ///
/// sqlite3_step() has another row ready
///
Row = 100,
- ///
+ ///
/// sqlite3_step() has finished executing
///
- Done = 101,
+ Done /* 101 */
}
}
Index: System.Data.SQLite/SQLiteLog.cs
==================================================================
--- System.Data.SQLite/SQLiteLog.cs
+++ System.Data.SQLite/SQLiteLog.cs
@@ -10,18 +10,19 @@
using System;
using System.Data.Common;
using System.Diagnostics;
///
- /// Passed during an Log callback
+ /// Event data for logging event handlers.
///
public class LogEventArgs : EventArgs
{
///
- /// The error code.
+ /// The error code. The type of this object value should be
+ /// System.Int32 or SQLiteErrorCode.
///
- public readonly int ErrorCode;
+ public readonly object ErrorCode;
///
/// SQL statement text as the statement first begins executing
///
public readonly string Message;
@@ -33,16 +34,19 @@
///
/// Constructs the LogEventArgs object.
///
/// Should be null.
- /// The SQLite error code.
+ ///
+ /// The error code. The type of this object value should be
+ /// System.Int32 or SQLiteErrorCode.
+ ///
/// The error message, if any.
/// The extra data, if any.
internal LogEventArgs(
IntPtr pUserData,
- int errorCode,
+ object errorCode,
string message,
object data
)
{
ErrorCode = errorCode;
@@ -167,13 +171,13 @@
//
if (_callback == null)
{
_callback = new SQLiteLogCallback(LogCallback);
- int rc = _sql.SetLogCallback(_callback);
+ SQLiteErrorCode rc = _sql.SetLogCallback(_callback);
- if (rc != 0)
+ if (rc != SQLiteErrorCode.Ok)
throw new SQLiteException(rc,
"Failed to initialize logging.");
}
//
@@ -189,12 +193,12 @@
}
///
/// Handles the AppDomain being unloaded.
///
- ///
- ///
+ /// Should be null.
+ /// The data associated with this event.
private static void DomainUnload(
object sender,
EventArgs e
)
{
@@ -216,19 +220,19 @@
// have any open SQLite connections; however, there is
// currently no way around this limitation.
//
if (_sql != null)
{
- int rc = _sql.Shutdown();
+ SQLiteErrorCode rc = _sql.Shutdown();
- if (rc != 0)
+ if (rc != SQLiteErrorCode.Ok)
throw new SQLiteException(rc,
"Failed to shutdown interface.");
rc = _sql.SetLogCallback(null);
- if (rc != 0)
+ if (rc != SQLiteErrorCode.Ok)
throw new SQLiteException(rc,
"Failed to shutdown logging.");
}
//
@@ -296,16 +300,59 @@
///
/// Log a message to all the registered log event handlers without going
/// through the SQLite library.
///
- /// The error code or zero for success.
+ /// The message to be logged.
+ public static void LogMessage(
+ string message
+ )
+ {
+ LogMessage(null, message);
+ }
+
+ ///
+ /// Log a message to all the registered log event handlers without going
+ /// through the SQLite library.
+ ///
+ /// The SQLite error code.
+ /// The message to be logged.
+ public static void LogMessage(
+ SQLiteErrorCode errorCode,
+ string message
+ )
+ {
+ LogMessage((object)errorCode, message);
+ }
+
+ ///
+ /// Log a message to all the registered log event handlers without going
+ /// through the SQLite library.
+ ///
+ /// The integer error code.
/// The message to be logged.
public static void LogMessage(
int errorCode,
string message
)
+ {
+ LogMessage((object)errorCode, message);
+ }
+
+ ///
+ /// Log a message to all the registered log event handlers without going
+ /// through the SQLite library.
+ ///
+ ///
+ /// The error code. The type of this object value should be
+ /// System.Int32 or SQLiteErrorCode.
+ ///
+ /// The message to be logged.
+ private static void LogMessage(
+ object errorCode,
+ string message
+ )
{
bool enabled;
SQLiteLogEventHandler handlers;
lock (syncRoot)
@@ -350,11 +397,23 @@
}
///
/// Internal proxy function that calls any registered application log
/// event handlers.
+ ///
+ /// WARNING: This method is used more-or-less directly by native code,
+ /// do not modify its type signature.
///
+ ///
+ /// The extra data associated with this message, if any.
+ ///
+ ///
+ /// The error code associated with this message.
+ ///
+ ///
+ /// The message string to be logged.
+ ///
private static void LogCallback(
IntPtr pUserData,
int errorCode,
IntPtr pMessage
)
@@ -403,14 +462,19 @@
if (message.Length == 0)
message = "";
}
- int errorCode = e.ErrorCode;
+ object errorCode = e.ErrorCode;
+ bool success = false;
+
+ if (errorCode is SQLiteErrorCode)
+ success = ((SQLiteErrorCode)errorCode == SQLiteErrorCode.Ok);
+ else if (errorCode is int)
+ success = ((int)errorCode == 0);
- Trace.WriteLine(String.Format(
- "SQLite {0} ({1}): {2}", errorCode == 0 ?
- "message" : "error", errorCode, message));
+ Trace.WriteLine(String.Format("SQLite {0} ({1}): {2}",
+ success ? "message" : "error", errorCode, message));
}
}
#endif
}
Index: System.Data.SQLite/SQLiteStatement.cs
==================================================================
--- System.Data.SQLite/SQLiteStatement.cs
+++ System.Data.SQLite/SQLiteStatement.cs
@@ -254,11 +254,11 @@
case TypeCode.Decimal:
return ((decimal)obj) != Decimal.Zero ? true : false;
case TypeCode.String:
return Convert.ToBoolean(obj, provider);
default:
- throw new SQLiteException((int)SQLiteErrorCode.Error,
+ throw new SQLiteException(SQLiteErrorCode.Error,
String.Format(CultureInfo.CurrentCulture,
"Cannot convert type {0} to boolean", typeCode));
}
}
@@ -268,11 +268,11 @@
/// The index of the parameter to bind
/// The parameter we're binding
private void BindParameter(int index, SQLiteParameter param)
{
if (param == null)
- throw new SQLiteException((int)SQLiteErrorCode.Error, "Insufficient parameters supplied to the command");
+ throw new SQLiteException(SQLiteErrorCode.Error, "Insufficient parameters supplied to the command");
object obj = param.Value;
DbType objType = param.DbType;
if ((obj != null) && (objType == DbType.Object))
@@ -281,11 +281,11 @@
#if !PLATFORM_COMPACTFRAMEWORK
if ((_flags & SQLiteConnectionFlags.LogPreBind) == SQLiteConnectionFlags.LogPreBind)
{
IntPtr handle = _sqlite_stmt;
- SQLiteLog.LogMessage(0, String.Format(
+ SQLiteLog.LogMessage(String.Format(
"Binding statement {0} paramter #{1} with database type {2} and raw value {{{3}}}...",
handle, index, objType, obj));
}
#endif
Index: System.Data.SQLite/SQLiteTransaction.cs
==================================================================
--- System.Data.SQLite/SQLiteTransaction.cs
+++ System.Data.SQLite/SQLiteTransaction.cs
@@ -197,23 +197,23 @@
else return false;
}
if (_cnn._version != _version)
{
- if (throwError == true) throw new SQLiteException((int)SQLiteErrorCode.Misuse, "The connection was closed and re-opened, changes were already rolled back");
+ if (throwError == true) throw new SQLiteException(SQLiteErrorCode.Misuse, "The connection was closed and re-opened, changes were already rolled back");
else return false;
}
if (_cnn.State != ConnectionState.Open)
{
- if (throwError == true) throw new SQLiteException((int)SQLiteErrorCode.Misuse, "Connection was closed");
+ if (throwError == true) throw new SQLiteException(SQLiteErrorCode.Misuse, "Connection was closed");
else return false;
}
if (_cnn._transactionLevel == 0 || _cnn._sql.AutoCommit == true)
{
_cnn._transactionLevel = 0; // Make sure the transaction level is reset before returning
- if (throwError == true) throw new SQLiteException((int)SQLiteErrorCode.Misuse, "No transaction is active on this connection");
+ if (throwError == true) throw new SQLiteException(SQLiteErrorCode.Misuse, "No transaction is active on this connection");
else return false;
}
return true;
}
Index: System.Data.SQLite/UnsafeNativeMethods.cs
==================================================================
--- System.Data.SQLite/UnsafeNativeMethods.cs
+++ System.Data.SQLite/UnsafeNativeMethods.cs
@@ -547,14 +547,14 @@
[DllImport(SQLITE_DLL)]
internal static extern IntPtr sqlite3_errmsg_interop(IntPtr db, out int len);
[DllImport(SQLITE_DLL)]
- internal static extern int sqlite3_prepare_interop(IntPtr db, IntPtr pSql, int nBytes, out IntPtr stmt, out IntPtr ptrRemain, out int nRemain);
+ internal static extern SQLiteErrorCode sqlite3_prepare_interop(IntPtr db, IntPtr pSql, int nBytes, out IntPtr stmt, out IntPtr ptrRemain, out int nRemain);
[DllImport(SQLITE_DLL)]
- internal static extern int sqlite3_table_column_metadata_interop(IntPtr db, byte[] dbName, byte[] tblName, byte[] colName, out IntPtr ptrDataType, out IntPtr ptrCollSeq, out int notNull, out int primaryKey, out int autoInc, out int dtLen, out int csLen);
+ internal static extern SQLiteErrorCode sqlite3_table_column_metadata_interop(IntPtr db, byte[] dbName, byte[] tblName, byte[] colName, out IntPtr ptrDataType, out IntPtr ptrCollSeq, out int notNull, out int primaryKey, out int autoInc, out int dtLen, out int csLen);
[DllImport(SQLITE_DLL)]
internal static extern IntPtr sqlite3_value_text_interop(IntPtr p, out int len);
[DllImport(SQLITE_DLL)]
@@ -570,26 +570,26 @@
#region interop added functionality
#if !SQLITE_STANDARD
[DllImport(SQLITE_DLL)]
- internal static extern int sqlite3_close_interop(IntPtr db);
-
- [DllImport(SQLITE_DLL)]
- internal static extern int sqlite3_create_function_interop(IntPtr db, byte[] strName, int nArgs, int nType, IntPtr pvUser, SQLiteCallback func, SQLiteCallback fstep, SQLiteFinalCallback ffinal, int needCollSeq);
-
- [DllImport(SQLITE_DLL)]
- internal static extern int sqlite3_finalize_interop(IntPtr stmt);
-
- [DllImport(SQLITE_DLL)]
- internal static extern int sqlite3_open_interop(byte[] utf8Filename, int flags, out IntPtr db);
-
- [DllImport(SQLITE_DLL)]
- internal static extern int sqlite3_open16_interop(byte[] utf8Filename, int flags, out IntPtr db);
-
- [DllImport(SQLITE_DLL)]
- internal static extern int sqlite3_reset_interop(IntPtr stmt);
+ internal static extern SQLiteErrorCode sqlite3_close_interop(IntPtr db);
+
+ [DllImport(SQLITE_DLL)]
+ internal static extern SQLiteErrorCode sqlite3_create_function_interop(IntPtr db, byte[] strName, int nArgs, int nType, IntPtr pvUser, SQLiteCallback func, SQLiteCallback fstep, SQLiteFinalCallback ffinal, int needCollSeq);
+
+ [DllImport(SQLITE_DLL)]
+ internal static extern SQLiteErrorCode sqlite3_finalize_interop(IntPtr stmt);
+
+ [DllImport(SQLITE_DLL)]
+ internal static extern SQLiteErrorCode sqlite3_open_interop(byte[] utf8Filename, int flags, out IntPtr db);
+
+ [DllImport(SQLITE_DLL)]
+ internal static extern SQLiteErrorCode sqlite3_open16_interop(byte[] utf8Filename, int flags, out IntPtr db);
+
+ [DllImport(SQLITE_DLL)]
+ internal static extern SQLiteErrorCode sqlite3_reset_interop(IntPtr stmt);
#endif
// !SQLITE_STANDARD
#endregion
@@ -602,53 +602,53 @@
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
#endif
- internal static extern int sqlite3_close(IntPtr db);
+ internal static extern SQLiteErrorCode sqlite3_close(IntPtr db);
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
#endif
- internal static extern int sqlite3_close_v2(IntPtr db);
+ internal static extern SQLiteErrorCode sqlite3_close_v2(IntPtr db);
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
#endif
- internal static extern int sqlite3_create_function(IntPtr db, byte[] strName, int nArgs, int nType, IntPtr pvUser, SQLiteCallback func, SQLiteCallback fstep, SQLiteFinalCallback ffinal);
+ internal static extern SQLiteErrorCode sqlite3_create_function(IntPtr db, byte[] strName, int nArgs, int nType, IntPtr pvUser, SQLiteCallback func, SQLiteCallback fstep, SQLiteFinalCallback ffinal);
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
#endif
- internal static extern int sqlite3_finalize(IntPtr stmt);
+ internal static extern SQLiteErrorCode sqlite3_finalize(IntPtr stmt);
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
#endif
- internal static extern int sqlite3_open_v2(byte[] utf8Filename, out IntPtr db, int flags, IntPtr vfs);
+ internal static extern SQLiteErrorCode sqlite3_open_v2(byte[] utf8Filename, out IntPtr db, int flags, IntPtr vfs);
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
#else
[DllImport(SQLITE_DLL, CharSet = CharSet.Unicode)]
#endif
- internal static extern int sqlite3_open16(string fileName, out IntPtr db);
+ internal static extern SQLiteErrorCode sqlite3_open16(string fileName, out IntPtr db);
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
#endif
- internal static extern int sqlite3_reset(IntPtr stmt);
+ internal static extern SQLiteErrorCode sqlite3_reset(IntPtr stmt);
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
@@ -749,18 +749,18 @@
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
#endif
- internal static extern int sqlite3_prepare(IntPtr db, IntPtr pSql, int nBytes, out IntPtr stmt, out IntPtr ptrRemain);
+ internal static extern SQLiteErrorCode sqlite3_prepare(IntPtr db, IntPtr pSql, int nBytes, out IntPtr stmt, out IntPtr ptrRemain);
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
#endif
- internal static extern int sqlite3_table_column_metadata(IntPtr db, byte[] dbName, byte[] tblName, byte[] colName, out IntPtr ptrDataType, out IntPtr ptrCollSeq, out int notNull, out int primaryKey, out int autoInc);
+ internal static extern SQLiteErrorCode sqlite3_table_column_metadata(IntPtr db, byte[] dbName, byte[] tblName, byte[] colName, out IntPtr ptrDataType, out IntPtr ptrCollSeq, out int notNull, out int primaryKey, out int autoInc);
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
@@ -790,14 +790,14 @@
[DllImport(SQLITE_DLL)]
internal static extern int sqlite3_context_collcompare(IntPtr context, byte[] p1, int p1len, byte[] p2, int p2len);
[DllImport(SQLITE_DLL)]
- internal static extern int sqlite3_cursor_rowid(IntPtr stmt, int cursor, out long rowid);
+ internal static extern SQLiteErrorCode sqlite3_cursor_rowid(IntPtr stmt, int cursor, out long rowid);
[DllImport(SQLITE_DLL)]
- internal static extern int sqlite3_index_column_info_interop(IntPtr db, byte[] catalog, byte[] IndexName, byte[] ColumnName, out int sortOrder, out int onError, out IntPtr Collation, out int colllen);
+ internal static extern SQLiteErrorCode sqlite3_index_column_info_interop(IntPtr db, byte[] catalog, byte[] IndexName, byte[] ColumnName, out int sortOrder, out int onError, out IntPtr Collation, out int colllen);
[DllImport(SQLITE_DLL)]
internal static extern void sqlite3_resetall_interop(IntPtr db);
[DllImport(SQLITE_DLL)]
@@ -814,11 +814,11 @@
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
#else
[DllImport(SQLITE_DLL, CharSet = CharSet.Unicode)]
#endif
- internal static extern int sqlite3_win32_set_directory(uint type, string value);
+ internal static extern SQLiteErrorCode sqlite3_win32_set_directory(uint type, string value);
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
@@ -891,40 +891,40 @@
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
#endif
- internal static extern int sqlite3_shutdown();
-
-#if !PLATFORM_COMPACTFRAMEWORK
- [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
-#else
- [DllImport(SQLITE_DLL)]
-#endif
- internal static extern int sqlite3_busy_timeout(IntPtr db, int ms);
-
-#if !PLATFORM_COMPACTFRAMEWORK
- [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
-#else
- [DllImport(SQLITE_DLL)]
-#endif
- internal static extern int sqlite3_bind_blob(IntPtr stmt, int index, Byte[] value, int nSize, IntPtr nTransient);
-
-#if !PLATFORM_COMPACTFRAMEWORK
- [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
- internal static extern int sqlite3_bind_double(IntPtr stmt, int index, double value);
-#else
- [DllImport(SQLITE_DLL)]
- internal static extern int sqlite3_bind_double_interop(IntPtr stmt, int index, ref double value);
+ internal static extern SQLiteErrorCode sqlite3_shutdown();
+
+#if !PLATFORM_COMPACTFRAMEWORK
+ [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
+#else
+ [DllImport(SQLITE_DLL)]
+#endif
+ internal static extern SQLiteErrorCode sqlite3_busy_timeout(IntPtr db, int ms);
+
+#if !PLATFORM_COMPACTFRAMEWORK
+ [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
+#else
+ [DllImport(SQLITE_DLL)]
+#endif
+ internal static extern SQLiteErrorCode sqlite3_bind_blob(IntPtr stmt, int index, Byte[] value, int nSize, IntPtr nTransient);
+
+#if !PLATFORM_COMPACTFRAMEWORK
+ [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
+ internal static extern SQLiteErrorCode sqlite3_bind_double(IntPtr stmt, int index, double value);
+#else
+ [DllImport(SQLITE_DLL)]
+ internal static extern SQLiteErrorCode sqlite3_bind_double_interop(IntPtr stmt, int index, ref double value);
#endif
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
#endif
- internal static extern int sqlite3_bind_int(IntPtr stmt, int index, int value);
+ internal static extern SQLiteErrorCode sqlite3_bind_int(IntPtr stmt, int index, int value);
//
// NOTE: This really just calls "sqlite3_bind_int"; however, it has the
// correct type signature for an unsigned (32-bit) integer.
//
@@ -931,45 +931,45 @@
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, EntryPoint = "sqlite3_bind_int", CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL, EntryPoint = "sqlite3_bind_int")]
#endif
- internal static extern int sqlite3_bind_uint(IntPtr stmt, int index, uint value);
+ internal static extern SQLiteErrorCode sqlite3_bind_uint(IntPtr stmt, int index, uint value);
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
- internal static extern int sqlite3_bind_int64(IntPtr stmt, int index, long value);
+ internal static extern SQLiteErrorCode sqlite3_bind_int64(IntPtr stmt, int index, long value);
#else
[DllImport(SQLITE_DLL)]
- internal static extern int sqlite3_bind_int64_interop(IntPtr stmt, int index, ref long value);
+ internal static extern SQLiteErrorCode sqlite3_bind_int64_interop(IntPtr stmt, int index, ref long value);
#endif
//
// NOTE: This really just calls "sqlite3_bind_int64"; however, it has the
// correct type signature for an unsigned long (64-bit) integer.
//
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, EntryPoint = "sqlite3_bind_int64", CallingConvention = CallingConvention.Cdecl)]
- internal static extern int sqlite3_bind_uint64(IntPtr stmt, int index, ulong value);
+ internal static extern SQLiteErrorCode sqlite3_bind_uint64(IntPtr stmt, int index, ulong value);
#else
[DllImport(SQLITE_DLL, EntryPoint = "sqlite3_bind_int64_interop")]
- internal static extern int sqlite3_bind_uint64_interop(IntPtr stmt, int index, ref ulong value);
+ internal static extern SQLiteErrorCode sqlite3_bind_uint64_interop(IntPtr stmt, int index, ref ulong value);
#endif
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
#endif
- internal static extern int sqlite3_bind_null(IntPtr stmt, int index);
+ internal static extern SQLiteErrorCode sqlite3_bind_null(IntPtr stmt, int index);
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
#endif
- internal static extern int sqlite3_bind_text(IntPtr stmt, int index, byte[] value, int nlen, IntPtr pvReserved);
+ internal static extern SQLiteErrorCode sqlite3_bind_text(IntPtr stmt, int index, byte[] value, int nlen, IntPtr pvReserved);
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
@@ -993,11 +993,11 @@
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
#endif
- internal static extern int sqlite3_step(IntPtr stmt);
+ internal static extern SQLiteErrorCode sqlite3_step(IntPtr stmt);
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern double sqlite3_column_double(IntPtr stmt, int index);
#else
@@ -1044,11 +1044,11 @@
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
#endif
- internal static extern int sqlite3_create_collation(IntPtr db, byte[] strName, int nType, IntPtr pvUser, SQLiteCollation func);
+ internal static extern SQLiteErrorCode sqlite3_create_collation(IntPtr db, byte[] strName, int nType, IntPtr pvUser, SQLiteCollation func);
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
@@ -1160,11 +1160,11 @@
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
#else
[DllImport(SQLITE_DLL, CharSet = CharSet.Unicode)]
#endif
- internal static extern int sqlite3_bind_text16(IntPtr stmt, int index, string value, int nlen, IntPtr pvReserved);
+ internal static extern SQLiteErrorCode sqlite3_bind_text16(IntPtr stmt, int index, string value, int nlen, IntPtr pvReserved);
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
#else
[DllImport(SQLITE_DLL, CharSet = CharSet.Unicode)]
@@ -1182,18 +1182,18 @@
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
#endif
- internal static extern int sqlite3_key(IntPtr db, byte[] key, int keylen);
+ internal static extern SQLiteErrorCode sqlite3_key(IntPtr db, byte[] key, int keylen);
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
#endif
- internal static extern int sqlite3_rekey(IntPtr db, byte[] key, int keylen);
+ internal static extern SQLiteErrorCode sqlite3_rekey(IntPtr db, byte[] key, int keylen);
#endif
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
@@ -1220,25 +1220,25 @@
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, EntryPoint = "sqlite3_config", CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL, EntryPoint = "sqlite3_config")]
#endif
- internal static extern int sqlite3_config_none(SQLiteConfigOpsEnum op);
+ internal static extern SQLiteErrorCode sqlite3_config_none(SQLiteConfigOpsEnum op);
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, EntryPoint = "sqlite3_config", CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL, EntryPoint = "sqlite3_config")]
#endif
- internal static extern int sqlite3_config_int(SQLiteConfigOpsEnum op, int value);
+ internal static extern SQLiteErrorCode sqlite3_config_int(SQLiteConfigOpsEnum op, int value);
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, EntryPoint = "sqlite3_config", CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL, EntryPoint = "sqlite3_config")]
#endif
- internal static extern int sqlite3_config_log(SQLiteConfigOpsEnum op, SQLiteLogCallback func, IntPtr pvUser);
+ internal static extern SQLiteErrorCode sqlite3_config_log(SQLiteConfigOpsEnum op, SQLiteLogCallback func, IntPtr pvUser);
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
@@ -1262,11 +1262,11 @@
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
#endif
- internal static extern int sqlite3_exec(IntPtr db, byte[] strSql, IntPtr pvCallback, IntPtr pvParam, out IntPtr errMsg);
+ internal static extern SQLiteErrorCode sqlite3_exec(IntPtr db, byte[] strSql, IntPtr pvCallback, IntPtr pvParam, out IntPtr errMsg);
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
@@ -1276,25 +1276,32 @@
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
#endif
- internal static extern int sqlite3_extended_result_codes(IntPtr db, int onoff);
+ internal static extern SQLiteErrorCode sqlite3_extended_result_codes(IntPtr db, int onoff);
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
#endif
- internal static extern int sqlite3_errcode(IntPtr db);
+ internal static extern SQLiteErrorCode sqlite3_errcode(IntPtr db);
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
#endif
- internal static extern int sqlite3_extended_errcode(IntPtr db);
+ internal static extern SQLiteErrorCode sqlite3_extended_errcode(IntPtr db);
+
+//#if !PLATFORM_COMPACTFRAMEWORK
+// [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
+//#else
+// [DllImport(SQLITE_DLL)]
+//#endif
+// internal static extern IntPtr sqlite3_errstr(SQLiteErrorCode rc); /* 3.7.15+ */
// Since sqlite3_log() takes a variable argument list, we have to overload declarations
// for all possible calls. For now, we are only exposing a single string, and
// depend on the caller to format the string.
#if !PLATFORM_COMPACTFRAMEWORK
@@ -1307,11 +1314,11 @@
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
#endif
- internal static extern int sqlite3_file_control(IntPtr db, byte[] zDbName, int op, IntPtr pArg);
+ internal static extern SQLiteErrorCode sqlite3_file_control(IntPtr db, byte[] zDbName, int op, IntPtr pArg);
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
@@ -1321,18 +1328,18 @@
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
#endif
- internal static extern int sqlite3_backup_step(IntPtr backup, int nPage);
+ internal static extern SQLiteErrorCode sqlite3_backup_step(IntPtr backup, int nPage);
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
#endif
- internal static extern int sqlite3_backup_finish(IntPtr backup);
+ internal static extern SQLiteErrorCode sqlite3_backup_finish(IntPtr backup);
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
Index: Tests/backup.eagle
==================================================================
--- Tests/backup.eagle
+++ Tests/backup.eagle
@@ -33,26 +33,26 @@
1048576 1048576 10\\} 0\$" \
"0 \\{1 1048576 1048576 1048576 1048576 1048576 1048576 1048576 1048576\
1048576 1048576 10\\} 0\$" \
"1 \\{System\\.Reflection\\.TargetInvocationException: Exception has been\
thrown by the target of an invocation\\. --->\
- System\\.Data\\.SQLite\\.SQLiteException: SQLite error\\r\\nno such table:\
- t1\\r\\n.*?" \
+ System\\.Data\\.SQLite\\.SQLiteException: SQL logic error or missing\
+ database\\r\\nno such table: t1\\r\\n.*?" \
"1 \\{System\\.Reflection\\.TargetInvocationException: Exception has been\
thrown by the target of an invocation\\. --->\
- System\\.Data\\.SQLite\\.SQLiteException: SQLite error\\r\\nno such table:\
- t1\\r\\n.*?" \
+ System\\.Data\\.SQLite\\.SQLiteException: SQL logic error or missing\
+ database\\r\\nno such table: t1\\r\\n.*?" \
"0 \\{1 1048576 1048576 1048576 1048576 1048576 1048576 1048576 1048576\
1048576 1048576 10\\} 0\$" \
"0 \\{1 1048576 1048576 1048576 1048576 1048576 1048576 1048576 1048576\
1048576 1048576 10\\} 10283\$" \
"0 \\{1 1048576 1048576 1048576 1048576 1048576 1048576 1048576 1048576\
1048576 1048576 10\\} 0\$" \
"1 \\{System\\.Reflection\\.TargetInvocationException: Exception has been\
thrown by the target of an invocation\\. --->\
- System\\.Data\\.SQLite\\.SQLiteException: SQLite error\\r\\nno such table:\
- t1\\r\\n.*?" \
+ System\\.Data\\.SQLite\\.SQLiteException: SQL logic error or missing\
+ database\\r\\nno such table: t1\\r\\n.*?" \
"0 \\{1 1048576 1048576 1048576 1048576 1048576 1048576 1048576 1048576\
1048576 1048576 10\\} \\{\\}\$" \
"0 \\{1 1048576 1048576 1048576 1048576 1048576 1048576 1048576 1048576\
1048576 1048576 10\\} \\{System\\.Data\\.SQLite\\.SQLiteConnection main\
System\\.Data\\.SQLite\\.SQLiteConnection main 1000 9284 10284 False\
Index: Tests/basic.eagle
==================================================================
--- Tests/basic.eagle
+++ Tests/basic.eagle
@@ -1259,11 +1259,11 @@
} -constraints \
{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -match \
regexp -result {^Ok System#CodeDom#Compiler#CompilerResults#\d+ \{\} 1\
\{System\.Reflection\.TargetInvocationException: Exception has been thrown by\
the target of an invocation\. ---> System\.Data\.SQLite\.SQLiteException:\
-Operation terminated by sqlite3_interrupt\(\).*$}}
+interrupted.*$}}
###############################################################################
runTest {test data-1.23 {LINQ SQL_CONSTRAINTCOLUMNS resource} -body {
object invoke -flags +NonPublic System.Data.SQLite.Properties.Resources \
@@ -1514,12 +1514,12 @@
}
unset -nocomplain result sqlite3
} -constraints \
{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -match \
-regexp -result {^0 21 0 0 System#IntPtr#\d+ System#IntPtr#\d+ \d+ \d+ \d+ \d+\
-\d+ True True True True True True$}}
+regexp -result {^Ok Misuse Ok Ok System#IntPtr#\d+ System#IntPtr#\d+ \d+ \d+ \d+\
+\d+ \d+ True True True True True True$}}
###############################################################################
runTest {test data-1.29 {SQLiteConnection.Open with SetDefaults=False} -setup {
setupDb [set fileName data-1.29.db] "" "" "" "" SetDefaults=False
@@ -1757,11 +1757,11 @@
unset -nocomplain t found i db fileName result directory
rename threadStart ""
} -constraints {eagle windows monoBug28 command.sql compile.DATA SQLite\
-System.Data.SQLite sqlite3_win32_set_directory} -result {0 0 True True}}
+System.Data.SQLite sqlite3_win32_set_directory} -result {Ok Ok True True}}
###############################################################################
unset -nocomplain systemDataSQLiteDllFile systemDataSQLiteLinqDllFile \
testExeFile testLinqExeFile northwindEfDbFile testLinqOutFile
Index: Tests/tkt-ccfa69fc32.eagle
==================================================================
--- Tests/tkt-ccfa69fc32.eagle
+++ Tests/tkt-ccfa69fc32.eagle
@@ -82,11 +82,11 @@
} -cleanup {
unset -nocomplain code output error result add
} -constraints {eagle monoToDo SQLite file_System.Data.SQLite.dll\
file_System.Data.SQLite.Linq.dll file_testlinq.exe file_northwindEF.db} -match \
glob -result {0 {1581 1730 1833 2116 2139} 0 {System.Data.UpdateException: *\
----> System.Data.SQLite.SQLiteException: Abort due to constraint violation
+---> System.Data.SQLite.SQLiteException: constraint failed
PRIMARY KEY must be unique
*} 0 {1 2 3 4 5 6 7 8 9 10 1576 1577 1578 1579 1580 1581 1730 1833 2116 2139}}}
###############################################################################
Index: readme.htm
==================================================================
--- readme.htm
+++ readme.htm
@@ -3,11 +3,11 @@
ADO.NET SQLite Data Provider
-Version 1.0.82.0 September 3, 2012
+Version 1.0.83.0 November XX, 2012 (release scheduled)
Using SQLite 3.7.14
Originally written by Robert Simpson
Released to the public domain, use at your own risk!
Official provider website: http://system.data.sqlite.org/
Legacy versions: http://sqlite.phxsoftware.com/
@@ -184,10 +184,23 @@
Version History
+
+ 1.0.83.0 - November XX, 2012
+
+
+ - Updated to SQLite 3.7.14.
+ - Add an overload of the SQLiteLog.LogMessage method that takes a single string argument.
+ - All applicable calls into the SQLite core library now return a SQLiteErrorCode instead of an integer error code.
+ - When available, the new sqlite3_errstr function from the core library is used to get the error message for a specific return code.
+ - The SetMemoryStatus, Shutdown, ResultCode, ExtendedResultCode, and SetAvRetry methods of the SQLiteConnection class now return a SQLiteErrorCode instead of an integer error code. ** Potentially Incompatible Change **
+ - The public constructor for the SQLiteException now takes a SQLiteErrorCode instead of an integer error code. ** Potentially Incompatible Change **
+ - The ErrorCode field of the LogEventArgs is now an object instead of an integer. ** Potentially Incompatible Change **
+ - The names and messages associated with the SQLiteErrorCode enumeration values have been normalized to match those in the SQLite core library. ** Potentially Incompatible Change **
+
1.0.82.0 - September 3, 2012
- Updated to SQLite 3.7.14.
Index: test/TestCases.cs
==================================================================
--- test/TestCases.cs
+++ test/TestCases.cs
@@ -1620,21 +1620,21 @@
cnn.Open();
// Turn on extended result codes
cnn.SetExtendedResultCodes(true);
- int rc = cnn.ResultCode();
- int xrc = cnn.ExtendedResultCode();
+ SQLiteErrorCode rc = cnn.ResultCode();
+ SQLiteErrorCode xrc = cnn.ExtendedResultCode();
cnn.Close();
}
}
//Logging EventHandler
public void OnLogEvent(object sender, LogEventArgs logEvent)
{
- int err_code = logEvent.ErrorCode;
+ object errorCode = logEvent.ErrorCode;
string err_msg = logEvent.Message;
logevents++;
}
///
Index: www/news.wiki
==================================================================
--- www/news.wiki
+++ www/news.wiki
@@ -1,9 +1,22 @@
News
Version History
+
+ 1.0.83.0 - November XX, 2012 (release scheduled)
+
+
+ - Updated to [http://www.sqlite.org/releaselog/3_7_14.html|SQLite 3.7.14].
+ - Add an overload of the SQLiteLog.LogMessage method that takes a single string argument.
+ - All applicable calls into the SQLite core library now return a SQLiteErrorCode instead of an integer error code.
+ - When available, the new sqlite3_errstr function from the core library is used to get the error message for a specific return code.
+ - The SetMemoryStatus, Shutdown, ResultCode, ExtendedResultCode, and SetAvRetry methods of the SQLiteConnection class now return a SQLiteErrorCode instead of an integer error code. ** Potentially Incompatible Change **
+ - The public constructor for the SQLiteException now takes a SQLiteErrorCode instead of an integer error code. ** Potentially Incompatible Change **
+ - The ErrorCode field of the LogEventArgs is now an object instead of an integer. ** Potentially Incompatible Change **
+ - The names and messages associated with the SQLiteErrorCode enumeration values have been normalized to match those in the SQLite core library. ** Potentially Incompatible Change **
+
1.0.82.0 - September 3, 2012
- Updated to [http://www.sqlite.org/releaselog/3_7_14.html|SQLite 3.7.14].