Index: SQLite.Interop/src/win/interop.c
==================================================================
--- SQLite.Interop/src/win/interop.c
+++ SQLite.Interop/src/win/interop.c
@@ -345,11 +345,11 @@
#if defined(INTEROP_DEBUG) && (INTEROP_DEBUG & INTEROP_DEBUG_OPEN)
sqlite3InteropDebug("sqlite3_open_interop(): sqlite3_open_v2(\"%s\", %d, %p) returned %d.\n", filename, flags, ppdb, ret);
#endif
#if defined(INTEROP_EXTENSION_FUNCTIONS)
- if (ret == SQLITE_OK)
+ if ((ret == SQLITE_OK) && ppdb)
RegisterExtensionFunctions(*ppdb);
#endif
return ret;
}
@@ -366,20 +366,20 @@
#if defined(INTEROP_DEBUG) && (INTEROP_DEBUG & INTEROP_DEBUG_OPEN16)
sqlite3InteropDebug("sqlite3_open16_interop(): sqlite3_open_interop(\"%s\", %d, %p) returned %d.\n", filename, flags, ppdb, ret);
#endif
- if ((ret == SQLITE_OK) && !DbHasProperty(*ppdb, 0, DB_SchemaLoaded))
+ if ((ret == SQLITE_OK) && ppdb && !DbHasProperty(*ppdb, 0, DB_SchemaLoaded))
ENC(*ppdb) = SQLITE_UTF16NATIVE;
return ret;
}
SQLITE_API const char *WINAPI sqlite3_errmsg_interop(sqlite3 *db, int *plen)
{
const char *pval = sqlite3_errmsg(db);
- *plen = (pval != 0) ? strlen(pval) : 0;
+ if (plen) *plen = pval ? strlen(pval) : 0;
return pval;
}
SQLITE_API int WINAPI sqlite3_changes_interop(sqlite3 *db)
{
@@ -419,11 +419,11 @@
#if defined(INTEROP_DEBUG) && (INTEROP_DEBUG & INTEROP_DEBUG_PREPARE)
sqlite3InteropDebug("sqlite3_prepare_interop(): sqlite3_prepare(%p, \"%s\", %d, %p) returned %d.\n", db, sql, nbytes, ppstmt, n);
#endif
- *plen = (*pztail != 0) ? strlen(*pztail) : 0;
+ if (plen) *plen = (pztail && *pztail) ? strlen(*pztail) : 0;
return n;
}
SQLITE_API int WINAPI sqlite3_prepare16_interop(sqlite3 *db, const void *sql, int nchars, sqlite3_stmt **ppstmt, const void **pztail, int *plen)
@@ -442,11 +442,11 @@
#if defined(INTEROP_DEBUG) && (INTEROP_DEBUG & INTEROP_DEBUG_PREPARE16)
sqlite3InteropDebug("sqlite3_prepare_interop(): sqlite3_prepare16(%p, \"%s\", %d, %p) returned %d.\n", db, sql, nchars, ppstmt, n);
#endif
- *plen = (*pztail != 0) ? wcslen((wchar_t *)*pztail) * sizeof(wchar_t) : 0;
+ if (plen) *plen = (pztail && *pztail) ? wcslen((wchar_t *)*pztail) * sizeof(wchar_t) : 0;
return n;
}
#if defined(INTEROP_VIRTUAL_TABLE) && SQLITE_VERSION_NUMBER >= 3004001
@@ -478,10 +478,11 @@
int (*xRelease)(sqlite3_vtab *, int),
int (*xRollbackTo)(sqlite3_vtab *, int),
void *pClientData,
void(*xDestroyModule)(void*)
){
+ if (!pModule) return 0;
memset(pModule, 0, sizeof(*pModule));
pModule->iVersion = iVersion;
pModule->xCreate = xCreate;
pModule->xConnect = xConnect;
pModule->xBestIndex = xBestIndex;
@@ -508,89 +509,96 @@
}
#endif
SQLITE_API int WINAPI sqlite3_bind_double_interop(sqlite3_stmt *stmt, int iCol, double *val)
{
- return sqlite3_bind_double(stmt,iCol,*val);
+ if (!val) return SQLITE_ERROR;
+ return sqlite3_bind_double(stmt,iCol,*val);
}
SQLITE_API int WINAPI sqlite3_bind_int64_interop(sqlite3_stmt *stmt, int iCol, sqlite_int64 *val)
{
- return sqlite3_bind_int64(stmt,iCol,*val);
+ if (!val) return SQLITE_ERROR;
+ return sqlite3_bind_int64(stmt,iCol,*val);
}
SQLITE_API const char * WINAPI sqlite3_bind_parameter_name_interop(sqlite3_stmt *stmt, int iCol, int *plen)
{
const char *pval = sqlite3_bind_parameter_name(stmt, iCol);
- *plen = (pval != 0) ? strlen(pval) : 0;
+ if (plen) *plen = pval ? strlen(pval) : 0;
return pval;
}
SQLITE_API const char * WINAPI sqlite3_column_name_interop(sqlite3_stmt *stmt, int iCol, int *plen)
{
const char *pval = sqlite3_column_name(stmt, iCol);
- *plen = (pval != 0) ? strlen(pval) : 0;
+ if (plen) *plen = pval ? strlen(pval) : 0;
return pval;
}
SQLITE_API const void * WINAPI sqlite3_column_name16_interop(sqlite3_stmt *stmt, int iCol, int *plen)
{
const void *pval = sqlite3_column_name16(stmt, iCol);
- *plen = (pval != 0) ? wcslen((wchar_t *)pval) * sizeof(wchar_t) : 0;
+ if (plen) *plen = pval ? wcslen((wchar_t *)pval) * sizeof(wchar_t) : 0;
return pval;
}
SQLITE_API const char * WINAPI sqlite3_column_decltype_interop(sqlite3_stmt *stmt, int iCol, int *plen)
{
const char *pval = sqlite3_column_decltype(stmt, iCol);
- *plen = (pval != 0) ? strlen(pval) : 0;
+ if (plen) *plen = pval ? strlen(pval) : 0;
return pval;
}
SQLITE_API const void * WINAPI sqlite3_column_decltype16_interop(sqlite3_stmt *stmt, int iCol, int *plen)
{
const void *pval = sqlite3_column_decltype16(stmt, iCol);
- *plen = (pval != 0) ? wcslen((wchar_t *)pval) * sizeof(wchar_t) : 0;
+ if (plen) *plen = pval ? wcslen((wchar_t *)pval) * sizeof(wchar_t) : 0;
return pval;
}
SQLITE_API void WINAPI sqlite3_column_double_interop(sqlite3_stmt *stmt, int iCol, double *val)
{
- *val = sqlite3_column_double(stmt,iCol);
+ if (!val) return;
+ *val = sqlite3_column_double(stmt,iCol);
}
SQLITE_API void WINAPI sqlite3_column_int64_interop(sqlite3_stmt *stmt, int iCol, sqlite_int64 *val)
{
- *val = sqlite3_column_int64(stmt,iCol);
+ if (!val) return;
+ *val = sqlite3_column_int64(stmt,iCol);
}
SQLITE_API void WINAPI sqlite3_last_insert_rowid_interop(sqlite3 *db, sqlite_int64 *rowId)
{
- *rowId = sqlite3_last_insert_rowid(db);
+ if (!rowId) return;
+ *rowId = sqlite3_last_insert_rowid(db);
}
SQLITE_API void WINAPI sqlite3_memory_used_interop(sqlite_int64 *nBytes)
{
- *nBytes = sqlite3_memory_used();
+ if (!nBytes) return;
+ *nBytes = sqlite3_memory_used();
}
SQLITE_API void WINAPI sqlite3_memory_highwater_interop(int resetFlag, sqlite_int64 *nBytes)
{
- *nBytes = sqlite3_memory_highwater(resetFlag);
+ if (!nBytes) return;
+ *nBytes = sqlite3_memory_highwater(resetFlag);
}
SQLITE_API const unsigned char * WINAPI sqlite3_column_text_interop(sqlite3_stmt *stmt, int iCol, int *plen)
{
const unsigned char *pval = sqlite3_column_text(stmt, iCol);
- *plen = sqlite3_column_bytes(stmt, iCol);
+ if (plen) *plen = sqlite3_column_bytes(stmt, iCol);
return pval;
}
SQLITE_API const void * WINAPI sqlite3_column_text16_interop(sqlite3_stmt *stmt, int iCol, int *plen)
{
const void *pval = sqlite3_column_text16(stmt, iCol);
- *plen = sqlite3_column_bytes16(stmt, iCol);
+ if (plen) *plen = sqlite3_column_bytes16(stmt, iCol);
return pval;
}
SQLITE_API int WINAPI sqlite3_finalize_interop(sqlite3_stmt *stmt)
{
@@ -597,11 +605,11 @@
int ret;
#if !defined(INTEROP_LEGACY_CLOSE) && SQLITE_VERSION_NUMBER >= 3007014
#if defined(INTEROP_DEBUG) && (INTEROP_DEBUG & INTEROP_DEBUG_FINALIZE)
Vdbe *p = (Vdbe *)stmt;
- sqlite3 *db = p->db;
+ sqlite3 *db = p ? p->db : 0;
sqlite3InteropDebug("sqlite3_finalize_interop(): calling sqlite3_finalize(%p, %p)...\n", db, stmt);
#endif
ret = sqlite3_finalize(stmt);
@@ -642,12 +650,12 @@
SQLITE_API int WINAPI sqlite3_backup_finish_interop(sqlite3_backup *p)
{
int ret;
#if defined(INTEROP_DEBUG) && (INTEROP_DEBUG & INTEROP_DEBUG_BACKUP_FINISH)
- sqlite3* pDestDb = p->pDestDb;
- sqlite3* pSrcDb = p->pSrcDb;
+ sqlite3* pDestDb = p ? p->pDestDb : 0;
+ sqlite3* pSrcDb = p ? p->pSrcDb : 0;
sqlite3InteropDebug("sqlite3_backup_finish_interop(): calling sqlite3_backup_finish(%p, %p, %p)...\n", pDestDb, pSrcDb, p);
#endif
ret = sqlite3_backup_finish(p);
@@ -673,11 +681,11 @@
sqlite3InteropDebug("sqlite3_reset_interop(): sqlite3_reset(%p) returned %d.\n", stmt, ret);
#endif
return ret;
#else
- if (((Vdbe *)stmt)->magic == VDBE_MAGIC_DEAD) return SQLITE_SCHEMA;
+ if (stmt && ((Vdbe *)stmt)->magic == VDBE_MAGIC_DEAD) return SQLITE_SCHEMA;
ret = sqlite3_reset(stmt);
return ret;
#endif
}
@@ -686,11 +694,11 @@
int n;
if (eTextRep == SQLITE_UTF16)
eTextRep = SQLITE_UTF16NATIVE;
- n = sqlite3_create_function(psql, zFunctionName, nArg, eTextRep, 0, func, funcstep, funcfinal);
+ n = sqlite3_create_function(psql, zFunctionName, nArg, eTextRep, pvUser, func, funcstep, funcfinal);
if (n == SQLITE_OK)
{
if (needCollSeq)
{
FuncDef *pFunc = sqlite3FindFunction(psql, zFunctionName, strlen(zFunctionName), nArg, eTextRep, 0);
@@ -708,127 +716,134 @@
return n;
}
SQLITE_API void WINAPI sqlite3_value_double_interop(sqlite3_value *pval, double *val)
{
+ if (!val) return;
*val = sqlite3_value_double(pval);
}
SQLITE_API void WINAPI sqlite3_value_int64_interop(sqlite3_value *pval, sqlite_int64 *val)
{
+ if (!val) return;
*val = sqlite3_value_int64(pval);
}
SQLITE_API const unsigned char * WINAPI sqlite3_value_text_interop(sqlite3_value *val, int *plen)
{
const unsigned char *pval = sqlite3_value_text(val);
- *plen = sqlite3_value_bytes(val);
+ if (plen) *plen = sqlite3_value_bytes(val);
return pval;
}
SQLITE_API const void * WINAPI sqlite3_value_text16_interop(sqlite3_value *val, int *plen)
{
const void *pval = sqlite3_value_text16(val);
- *plen = sqlite3_value_bytes16(val);
+ if (plen) *plen = sqlite3_value_bytes16(val);
return pval;
}
SQLITE_API void WINAPI sqlite3_result_double_interop(sqlite3_context *pctx, double *val)
{
+ if (!val) return;
sqlite3_result_double(pctx, *val);
}
SQLITE_API void WINAPI sqlite3_result_int64_interop(sqlite3_context *pctx, sqlite_int64 *val)
{
+ if (!val) return;
sqlite3_result_int64(pctx, *val);
}
SQLITE_API int WINAPI sqlite3_context_collcompare_interop(sqlite3_context *ctx, const void *p1, int p1len, const void *p2, int p2len)
{
+ if (!ctx || !ctx->pFunc || !ctx->pColl || !ctx->pColl->xCmp) return 3; /* ERROR */
#if SQLITE_VERSION_NUMBER >= 3008001
- if ((ctx->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL) == 0) return 2;
+ if ((ctx->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL) == 0) return 2; /* ERROR */
#else
- if ((ctx->pFunc->flags & SQLITE_FUNC_NEEDCOLL) == 0) return 2;
+ if ((ctx->pFunc->flags & SQLITE_FUNC_NEEDCOLL) == 0) return 2; /* ERROR */
#endif
return ctx->pColl->xCmp(ctx->pColl->pUser, p1len, p1, p2len, p2);
}
SQLITE_API const char * WINAPI sqlite3_context_collseq_interop(sqlite3_context *ctx, int *ptype, int *enc, int *plen)
{
- CollSeq *pColl = ctx->pColl;
- *ptype = 0;
- *plen = 0;
- *enc = 0;
+ CollSeq *pColl = ctx ? ctx->pColl : 0;
+ if (ptype) *ptype = 0;
+ if (plen) *plen = 0;
+ if (enc) *enc = 0;
+ if (!ctx || !ctx->pFunc) return NULL;
#if SQLITE_VERSION_NUMBER >= 3008001
if ((ctx->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL) == 0) return NULL;
#else
if ((ctx->pFunc->flags & SQLITE_FUNC_NEEDCOLL) == 0) return NULL;
#endif
if (pColl)
{
- *enc = pColl->enc;
+ if (enc) *enc = pColl->enc;
#if SQLITE_VERSION_NUMBER < 3007010
- *ptype = pColl->type;
+ if (ptype) *ptype = pColl->type;
#endif
- *plen = (pColl->zName != 0) ? strlen(pColl->zName) : 0;
+ if (plen) *plen = pColl->zName ? strlen(pColl->zName) : 0;
return pColl->zName;
}
return NULL;
}
SQLITE_API const char * WINAPI sqlite3_column_database_name_interop(sqlite3_stmt *stmt, int iCol, int *plen)
{
const char *pval = sqlite3_column_database_name(stmt, iCol);
- *plen = (pval != 0) ? strlen(pval) : 0;
+ if (plen) *plen = pval ? strlen(pval) : 0;
return pval;
}
SQLITE_API const void * WINAPI sqlite3_column_database_name16_interop(sqlite3_stmt *stmt, int iCol, int *plen)
{
const void *pval = sqlite3_column_database_name16(stmt, iCol);
- *plen = (pval != 0) ? wcslen((wchar_t *)pval) * sizeof(wchar_t) : 0;
+ if (plen) *plen = pval ? wcslen((wchar_t *)pval) * sizeof(wchar_t) : 0;
return pval;
}
SQLITE_API const char * WINAPI sqlite3_column_table_name_interop(sqlite3_stmt *stmt, int iCol, int *plen)
{
const char *pval = sqlite3_column_table_name(stmt, iCol);
- *plen = (pval != 0) ? strlen(pval) : 0;
+ if (plen) *plen = pval ? strlen(pval) : 0;
return pval;
}
SQLITE_API const void * WINAPI sqlite3_column_table_name16_interop(sqlite3_stmt *stmt, int iCol, int *plen)
{
const void *pval = sqlite3_column_table_name16(stmt, iCol);
- *plen = (pval != 0) ? wcslen((wchar_t *)pval) * sizeof(wchar_t) : 0;
+ if (plen) *plen = pval ? wcslen((wchar_t *)pval) * sizeof(wchar_t) : 0;
return pval;
}
SQLITE_API const char * WINAPI sqlite3_column_origin_name_interop(sqlite3_stmt *stmt, int iCol, int *plen)
{
const char *pval = sqlite3_column_origin_name(stmt, iCol);
- *plen = (pval != 0) ? strlen(pval) : 0;
+ if (plen) *plen = pval ? strlen(pval) : 0;
return pval;
}
SQLITE_API const void * WINAPI sqlite3_column_origin_name16_interop(sqlite3_stmt *stmt, int iCol, int *plen)
{
const void *pval = sqlite3_column_origin_name16(stmt, iCol);
- *plen = (pval != 0) ? wcslen((wchar_t *)pval) * sizeof(wchar_t) : 0;
+ if (plen) *plen = pval ? wcslen((wchar_t *)pval) * sizeof(wchar_t) : 0;
return pval;
}
SQLITE_API int WINAPI sqlite3_table_column_metadata_interop(sqlite3 *db, const char *zDbName, const char *zTableName, const char *zColumnName, char **pzDataType, char **pzCollSeq, int *pNotNull, int *pPrimaryKey, int *pAutoinc, int *pdtLen, int *pcsLen)
{
int n;
n = sqlite3_table_column_metadata(db, zDbName, zTableName, zColumnName, pzDataType, pzCollSeq, pNotNull, pPrimaryKey, pAutoinc);
- *pdtLen = (*pzDataType != 0) ? strlen(*pzDataType) : 0;
- *pcsLen = (*pzCollSeq != 0) ? strlen(*pzCollSeq) : 0;
+
+ if (pdtLen) *pdtLen = (pzDataType && *pzDataType) ? strlen(*pzDataType) : 0;
+ if (pcsLen) *pcsLen = (pzCollSeq && *pzCollSeq) ? strlen(*pzCollSeq) : 0;
return n;
}
SQLITE_API int WINAPI sqlite3_index_column_info_interop(sqlite3 *db, const char *zDb, const char *zIndexName, const char *zColumnName, int *sortOrder, int *onError, char **pzColl, int *plen)
@@ -835,10 +850,11 @@
{
Index *pIdx;
Table *pTab;
int n;
+ if (!db) return SQLITE_ERROR;
sqlite3_mutex_enter(db->mutex);
sqlite3BtreeEnterAll(db);
pIdx = sqlite3FindIndex(db, zIndexName, zDb);
@@ -851,14 +867,14 @@
for (n = 0; n < pIdx->nColumn; n++)
{
int cnum = pIdx->aiColumn[n];
if (sqlite3StrICmp(pTab->aCol[cnum].zName, zColumnName) == 0)
{
- *sortOrder = pIdx->aSortOrder[n];
- *pzColl = pIdx->azColl[n];
- *plen = strlen(*pzColl);
- *onError = pIdx->onError;
+ if ( sortOrder ) *sortOrder = pIdx->aSortOrder[n];
+ if ( pzColl ) *pzColl = pIdx->azColl[n];
+ if ( plen ) *plen = strlen(*pzColl);
+ if ( onError ) *onError = pIdx->onError;
return SQLITE_OK;
}
}
return SQLITE_ERROR;
@@ -867,12 +883,13 @@
SQLITE_API int WINAPI sqlite3_table_cursor_interop(sqlite3_stmt *pstmt, int iDb, Pgno tableRootPage)
{
Vdbe *p = (Vdbe *)pstmt;
sqlite3 *db = (p == NULL) ? NULL : p->db;
int n;
- int ret = -1;
+ int ret = -1; /* NOT FOUND */
+ if (!p || !db) return ret;
sqlite3_mutex_enter(db->mutex);
for (n = 0; n < p->nCursor && p->apCsr[n] != NULL; n++)
{
if (p->apCsr[n]->isTable == FALSE) continue;
if (p->apCsr[n]->iDb != iDb) continue;
@@ -892,10 +909,11 @@
Vdbe *p = (Vdbe *)pstmt;
sqlite3 *db = (p == NULL) ? NULL : p->db;
VdbeCursor *pC;
int ret = SQLITE_OK;
+ if (!p || !db) return SQLITE_ERROR;
sqlite3_mutex_enter(db->mutex);
while (1)
{
if (cursor < 0 || cursor >= p->nCursor)
{
@@ -914,11 +932,11 @@
if(ret)
break;
if(pC->rowidIsValid)
{
- *prowid = pC->lastRowid;
+ if (prowid) *prowid = pC->lastRowid;
}
else if(pC->pseudoTableReg > 0)
{
ret = SQLITE_ERROR;
break;
@@ -934,11 +952,11 @@
{
ret = SQLITE_ERROR;
break;
}
sqlite3BtreeKeySize(pC->pCursor, prowid);
- *prowid = *prowid;
+ if (prowid) *prowid = *prowid;
}
break;
}
sqlite3_mutex_leave(db->mutex);
Index: System.Data.SQLite/SQLite3.cs
==================================================================
--- System.Data.SQLite/SQLite3.cs
+++ System.Data.SQLite/SQLite3.cs
@@ -720,22 +720,22 @@
{
// do nothing.
}
finally /* NOTE: Thread.Abort() protection. */
{
- IntPtr db;
+ IntPtr db = IntPtr.Zero;
SQLiteErrorCode n;
#if !SQLITE_STANDARD
if ((connectionFlags & SQLiteConnectionFlags.NoExtensionFunctions) != SQLiteConnectionFlags.NoExtensionFunctions)
{
- n = UnsafeNativeMethods.sqlite3_open_interop(ToUTF8(strFilename), openFlags, out db);
+ n = UnsafeNativeMethods.sqlite3_open_interop(ToUTF8(strFilename), openFlags, ref db);
}
else
#endif
{
- n = UnsafeNativeMethods.sqlite3_open_v2(ToUTF8(strFilename), out db, openFlags, IntPtr.Zero);
+ n = UnsafeNativeMethods.sqlite3_open_v2(ToUTF8(strFilename), ref db, openFlags, IntPtr.Zero);
}
#if !NET_COMPACT_20 && TRACE_CONNECTION
Trace.WriteLine(String.Format("Open: {0}", db));
#endif
@@ -851,12 +851,12 @@
// If the schema changed, try and re-prepare it
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))
+ string str = null;
+ using (SQLiteStatement tmp = Prepare(null, stmt._sqlStatement, null, (uint)(stmt._command._commandTimeout * 1000), ref str))
{
// Finalize the existing statement
stmt._sqlite_stmt.Dispose();
// Reassign a new statement pointer to the old statement and clear the temporary one
stmt._sqlite_stmt = tmp._sqlite_stmt;
@@ -886,11 +886,11 @@
string result = SQLiteBase.GetLastError(_sql, _sql);
if (String.IsNullOrEmpty(result)) result = defValue;
return result;
}
- internal override SQLiteStatement Prepare(SQLiteConnection cnn, string strSql, SQLiteStatement previous, uint timeoutMS, out string strRemain)
+ internal override SQLiteStatement Prepare(SQLiteConnection cnn, string strSql, SQLiteStatement previous, uint timeoutMS, ref string strRemain)
{
if (!String.IsNullOrEmpty(strSql))
{
//
// NOTE: SQLite does not support the concept of separate schemas
@@ -946,17 +946,21 @@
{
// do nothing.
}
finally /* NOTE: Thread.Abort() protection. */
{
+ stmt = IntPtr.Zero;
+ ptr = IntPtr.Zero;
+
#if !SQLITE_STANDARD
- n = UnsafeNativeMethods.sqlite3_prepare_interop(_sql, psql, b.Length - 1, out stmt, out ptr, out len);
+ len = 0;
+ n = UnsafeNativeMethods.sqlite3_prepare_interop(_sql, psql, b.Length - 1, ref stmt, ref ptr, ref len);
#else
#if USE_PREPARE_V2
- n = UnsafeNativeMethods.sqlite3_prepare_v2(_sql, psql, b.Length - 1, out stmt, out ptr);
+ n = UnsafeNativeMethods.sqlite3_prepare_v2(_sql, psql, b.Length - 1, ref stmt, ref ptr);
#else
- n = UnsafeNativeMethods.sqlite3_prepare(_sql, psql, b.Length - 1, out stmt, out ptr);
+ n = UnsafeNativeMethods.sqlite3_prepare(_sql, psql, b.Length - 1, ref stmt, ref ptr);
#endif
len = -1;
#endif
#if !NET_COMPACT_20 && TRACE_STATEMENT
@@ -992,11 +996,11 @@
strRemain = "";
while (cmd == null && strSql.Length > 0)
{
- cmd = Prepare(cnn, strSql, previous, timeoutMS, out strRemain);
+ cmd = Prepare(cnn, strSql, previous, timeoutMS, ref strRemain);
strSql = strRemain;
}
if (cmd != null)
cmd.SetTypes(typedefs);
@@ -1015,11 +1019,11 @@
if (ext != null)
ext.BuildTempSchema(cnn);
while (cmd == null && strSql.Length > 0)
{
- cmd = Prepare(cnn, strSql, previous, timeoutMS, out strRemain);
+ cmd = Prepare(cnn, strSql, previous, timeoutMS, ref strRemain);
strSql = strRemain;
}
return cmd;
}
@@ -1405,12 +1409,12 @@
{
SQLiteStatementHandle handle = stmt._sqlite_stmt;
string name;
#if !SQLITE_STANDARD
- int len;
- name = UTF8ToString(UnsafeNativeMethods.sqlite3_bind_parameter_name_interop(handle, index, out len), len);
+ int len = 0;
+ name = UTF8ToString(UnsafeNativeMethods.sqlite3_bind_parameter_name_interop(handle, index, ref len), len);
#else
name = UTF8ToString(UnsafeNativeMethods.sqlite3_bind_parameter_name(handle, index), -1);
#endif
if ((flags & SQLiteConnectionFlags.LogBind) == SQLiteConnectionFlags.LogBind)
@@ -1450,12 +1454,12 @@
}
internal override string ColumnName(SQLiteStatement stmt, int index)
{
#if !SQLITE_STANDARD
- int len;
- IntPtr p = UnsafeNativeMethods.sqlite3_column_name_interop(stmt._sqlite_stmt, index, out len);
+ int len = 0;
+ IntPtr p = UnsafeNativeMethods.sqlite3_column_name_interop(stmt._sqlite_stmt, index, ref len);
#else
IntPtr p = UnsafeNativeMethods.sqlite3_column_name(stmt._sqlite_stmt, index);
#endif
if (p == IntPtr.Zero)
throw new SQLiteException(SQLiteErrorCode.NoMem, GetLastError());
@@ -1469,15 +1473,16 @@
internal override TypeAffinity ColumnAffinity(SQLiteStatement stmt, int index)
{
return UnsafeNativeMethods.sqlite3_column_type(stmt._sqlite_stmt, index);
}
- internal override string ColumnType(SQLiteStatement stmt, int index, out TypeAffinity nAffinity)
+ internal override string ColumnType(SQLiteStatement stmt, int index, ref TypeAffinity nAffinity)
{
int len;
#if !SQLITE_STANDARD
- IntPtr p = UnsafeNativeMethods.sqlite3_column_decltype_interop(stmt._sqlite_stmt, index, out len);
+ len = 0;
+ IntPtr p = UnsafeNativeMethods.sqlite3_column_decltype_interop(stmt._sqlite_stmt, index, ref len);
#else
len = -1;
IntPtr p = UnsafeNativeMethods.sqlite3_column_decltype(stmt._sqlite_stmt, index);
#endif
nAffinity = ColumnAffinity(stmt, index);
@@ -1520,55 +1525,57 @@
}
internal override string ColumnOriginalName(SQLiteStatement stmt, int index)
{
#if !SQLITE_STANDARD
- int len;
- return UTF8ToString(UnsafeNativeMethods.sqlite3_column_origin_name_interop(stmt._sqlite_stmt, index, out len), len);
+ int len = 0;
+ return UTF8ToString(UnsafeNativeMethods.sqlite3_column_origin_name_interop(stmt._sqlite_stmt, index, ref len), len);
#else
return UTF8ToString(UnsafeNativeMethods.sqlite3_column_origin_name(stmt._sqlite_stmt, index), -1);
#endif
}
internal override string ColumnDatabaseName(SQLiteStatement stmt, int index)
{
#if !SQLITE_STANDARD
- int len;
- return UTF8ToString(UnsafeNativeMethods.sqlite3_column_database_name_interop(stmt._sqlite_stmt, index, out len), len);
+ int len = 0;
+ return UTF8ToString(UnsafeNativeMethods.sqlite3_column_database_name_interop(stmt._sqlite_stmt, index, ref len), len);
#else
return UTF8ToString(UnsafeNativeMethods.sqlite3_column_database_name(stmt._sqlite_stmt, index), -1);
#endif
}
internal override string ColumnTableName(SQLiteStatement stmt, int index)
{
#if !SQLITE_STANDARD
- int len;
- return UTF8ToString(UnsafeNativeMethods.sqlite3_column_table_name_interop(stmt._sqlite_stmt, index, out len), len);
+ int len = 0;
+ return UTF8ToString(UnsafeNativeMethods.sqlite3_column_table_name_interop(stmt._sqlite_stmt, index, ref len), len);
#else
return UTF8ToString(UnsafeNativeMethods.sqlite3_column_table_name(stmt._sqlite_stmt, index), -1);
#endif
}
- internal override void ColumnMetaData(string dataBase, string table, string column, out string dataType, out string collateSequence, out bool notNull, out bool primaryKey, out bool autoIncrement)
+ internal override void ColumnMetaData(string dataBase, string table, string column, ref string dataType, ref string collateSequence, ref bool notNull, ref bool primaryKey, ref bool autoIncrement)
{
- IntPtr dataTypePtr;
- IntPtr collSeqPtr;
- int nnotNull;
- int nprimaryKey;
- int nautoInc;
+ IntPtr dataTypePtr = IntPtr.Zero;
+ IntPtr collSeqPtr = IntPtr.Zero;
+ int nnotNull = 0;
+ int nprimaryKey = 0;
+ int nautoInc = 0;
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);
+ dtLen = 0;
+ csLen = 0;
+ n = UnsafeNativeMethods.sqlite3_table_column_metadata_interop(_sql, ToUTF8(dataBase), ToUTF8(table), ToUTF8(column), ref dataTypePtr, ref collSeqPtr, ref nnotNull, ref nprimaryKey, ref nautoInc, ref dtLen, ref csLen);
#else
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);
+ n = UnsafeNativeMethods.sqlite3_table_column_metadata(_sql, ToUTF8(dataBase), ToUTF8(table), ToUTF8(column), ref dataTypePtr, ref collSeqPtr, ref nnotNull, ref nprimaryKey, ref nautoInc);
#endif
if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError());
dataType = UTF8ToString(dataTypePtr, dtLen);
collateSequence = UTF8ToString(collSeqPtr, csLen);
@@ -1582,11 +1589,12 @@
{
double value;
#if !PLATFORM_COMPACTFRAMEWORK
value = UnsafeNativeMethods.sqlite3_column_double(stmt._sqlite_stmt, index);
#elif !SQLITE_STANDARD
- UnsafeNativeMethods.sqlite3_column_double_interop(stmt._sqlite_stmt, index, out value);
+ value = 0.0;
+ UnsafeNativeMethods.sqlite3_column_double_interop(stmt._sqlite_stmt, index, ref value);
#else
throw new NotImplementedException();
#endif
return value;
}
@@ -1625,11 +1633,12 @@
{
long value;
#if !PLATFORM_COMPACTFRAMEWORK
value = UnsafeNativeMethods.sqlite3_column_int64(stmt._sqlite_stmt, index);
#elif !SQLITE_STANDARD
- UnsafeNativeMethods.sqlite3_column_int64_interop(stmt._sqlite_stmt, index, out value);
+ value = 0;
+ UnsafeNativeMethods.sqlite3_column_int64_interop(stmt._sqlite_stmt, index, ref value);
#else
throw new NotImplementedException();
#endif
return value;
}
@@ -1640,12 +1649,12 @@
}
internal override string GetText(SQLiteStatement stmt, int index)
{
#if !SQLITE_STANDARD
- int len;
- return UTF8ToString(UnsafeNativeMethods.sqlite3_column_text_interop(stmt._sqlite_stmt, index, out len), len);
+ int len = 0;
+ return UTF8ToString(UnsafeNativeMethods.sqlite3_column_text_interop(stmt._sqlite_stmt, index, ref len), len);
#else
return UTF8ToString(UnsafeNativeMethods.sqlite3_column_text(stmt._sqlite_stmt, index),
UnsafeNativeMethods.sqlite3_column_bytes(stmt._sqlite_stmt, index));
#endif
}
@@ -1658,12 +1667,12 @@
return ToDateTime(GetDouble(stmt, index), _datetimeKind);
else if (_datetimeFormat == SQLiteDateFormats.UnixEpoch)
return ToDateTime(GetInt32(stmt, index), _datetimeKind);
#if !SQLITE_STANDARD
- int len;
- return ToDateTime(UnsafeNativeMethods.sqlite3_column_text_interop(stmt._sqlite_stmt, index, out len), len);
+ int len = 0;
+ return ToDateTime(UnsafeNativeMethods.sqlite3_column_text_interop(stmt._sqlite_stmt, index, ref len), len);
#else
return ToDateTime(UnsafeNativeMethods.sqlite3_column_text(stmt._sqlite_stmt, index),
UnsafeNativeMethods.sqlite3_column_bytes(stmt._sqlite_stmt, index));
#endif
}
@@ -1805,14 +1814,14 @@
internal override CollationSequence GetCollationSequence(SQLiteFunction func, IntPtr context)
{
#if !SQLITE_STANDARD
CollationSequence seq = new CollationSequence();
- int len;
- int type;
- int enc;
- IntPtr p = UnsafeNativeMethods.sqlite3_context_collseq_interop(context, out type, out enc, out len);
+ int len = 0;
+ int type = 0;
+ int enc = 0;
+ IntPtr p = UnsafeNativeMethods.sqlite3_context_collseq_interop(context, ref type, ref enc, ref len);
if (p != null) seq.Name = UTF8ToString(p, len);
seq.Type = (CollationTypeEnum)type;
seq._func = func;
seq.Encoding = (CollationEncodingEnum)enc;
@@ -1853,11 +1862,12 @@
{
double value;
#if !PLATFORM_COMPACTFRAMEWORK
value = UnsafeNativeMethods.sqlite3_value_double(ptr);
#elif !SQLITE_STANDARD
- UnsafeNativeMethods.sqlite3_value_double_interop(ptr, out value);
+ value = 0.0;
+ UnsafeNativeMethods.sqlite3_value_double_interop(ptr, ref value);
#else
throw new NotImplementedException();
#endif
return value;
}
@@ -1871,22 +1881,23 @@
{
Int64 value;
#if !PLATFORM_COMPACTFRAMEWORK
value = UnsafeNativeMethods.sqlite3_value_int64(ptr);
#elif !SQLITE_STANDARD
- UnsafeNativeMethods.sqlite3_value_int64_interop(ptr, out value);
+ value = 0;
+ UnsafeNativeMethods.sqlite3_value_int64_interop(ptr, ref value);
#else
throw new NotImplementedException();
#endif
return value;
}
internal override string GetParamValueText(IntPtr ptr)
{
#if !SQLITE_STANDARD
- int len;
- return UTF8ToString(UnsafeNativeMethods.sqlite3_value_text_interop(ptr, out len), len);
+ int len = 0;
+ return UTF8ToString(UnsafeNativeMethods.sqlite3_value_text_interop(ptr, ref len), len);
#else
return UTF8ToString(UnsafeNativeMethods.sqlite3_value_text(ptr),
UnsafeNativeMethods.sqlite3_value_bytes(ptr));
#endif
}
@@ -2377,11 +2388,11 @@
/// True if there are more pages to be copied, false otherwise.
///
internal override bool StepBackup(
SQLiteBackup backup,
int nPage,
- out bool retry
+ ref bool retry
)
{
retry = false;
if (backup == null)
@@ -2647,28 +2658,28 @@
}
internal override long GetRowIdForCursor(SQLiteStatement stmt, int cursor)
{
#if !SQLITE_STANDARD
- long rowid;
- SQLiteErrorCode rc = UnsafeNativeMethods.sqlite3_cursor_rowid_interop(stmt._sqlite_stmt, cursor, out rowid);
+ long rowid = 0;
+ SQLiteErrorCode rc = UnsafeNativeMethods.sqlite3_cursor_rowid_interop(stmt._sqlite_stmt, cursor, ref rowid);
if (rc == SQLiteErrorCode.Ok) return rowid;
return 0;
#else
return 0;
#endif
}
- internal override void GetIndexColumnExtendedInfo(string database, string index, string column, out int sortMode, out int onError, out string collationSequence)
+ internal override void GetIndexColumnExtendedInfo(string database, string index, string column, ref int sortMode, ref int onError, ref string collationSequence)
{
#if !SQLITE_STANDARD
- IntPtr coll;
- int colllen;
+ IntPtr coll = IntPtr.Zero;
+ int colllen = 0;
SQLiteErrorCode rc;
- rc = UnsafeNativeMethods.sqlite3_index_column_info_interop(_sql, ToUTF8(database), ToUTF8(index), ToUTF8(column), out sortMode, out onError, out coll, out colllen);
+ rc = UnsafeNativeMethods.sqlite3_index_column_info_interop(_sql, ToUTF8(database), ToUTF8(index), ToUTF8(column), ref sortMode, ref onError, ref coll, ref colllen);
if (rc != SQLiteErrorCode.Ok) throw new SQLiteException(rc, null);
collationSequence = UTF8ToString(coll, colllen);
#else
sortMode = 0;
Index: System.Data.SQLite/SQLite3_UTF16.cs
==================================================================
--- System.Data.SQLite/SQLite3_UTF16.cs
+++ System.Data.SQLite/SQLite3_UTF16.cs
@@ -163,17 +163,17 @@
{
// do nothing.
}
finally /* NOTE: Thread.Abort() protection. */
{
- IntPtr db;
+ IntPtr db = IntPtr.Zero;
SQLiteErrorCode n;
#if !SQLITE_STANDARD
if ((connectionFlags & SQLiteConnectionFlags.NoExtensionFunctions) != SQLiteConnectionFlags.NoExtensionFunctions)
{
- n = UnsafeNativeMethods.sqlite3_open16_interop(ToUTF8(strFilename), openFlags, out db);
+ n = UnsafeNativeMethods.sqlite3_open16_interop(ToUTF8(strFilename), openFlags, ref db);
}
else
#endif
{
//
@@ -183,11 +183,11 @@
// a flags parameter.
//
if (((openFlags & SQLiteOpenFlagsEnum.Create) != SQLiteOpenFlagsEnum.Create) && !File.Exists(strFilename))
throw new SQLiteException(SQLiteErrorCode.CantOpen, strFilename);
- n = UnsafeNativeMethods.sqlite3_open16(strFilename, out db);
+ n = UnsafeNativeMethods.sqlite3_open16(strFilename, ref db);
}
#if !NET_COMPACT_20 && TRACE_CONNECTION
Trace.WriteLine(String.Format("Open16: {0}", db));
#endif
@@ -274,12 +274,12 @@
}
internal override string ColumnName(SQLiteStatement stmt, int index)
{
#if !SQLITE_STANDARD
- int len;
- IntPtr p = UnsafeNativeMethods.sqlite3_column_name16_interop(stmt._sqlite_stmt, index, out len);
+ int len = 0;
+ IntPtr p = UnsafeNativeMethods.sqlite3_column_name16_interop(stmt._sqlite_stmt, index, ref len);
#else
IntPtr p = UnsafeNativeMethods.sqlite3_column_name16(stmt._sqlite_stmt, index);
#endif
if (p == IntPtr.Zero)
throw new SQLiteException(SQLiteErrorCode.NoMem, GetLastError());
@@ -291,53 +291,53 @@
}
internal override string GetText(SQLiteStatement stmt, int index)
{
#if !SQLITE_STANDARD
- int len;
- return UTF16ToString(UnsafeNativeMethods.sqlite3_column_text16_interop(stmt._sqlite_stmt, index, out len), len);
+ int len = 0;
+ return UTF16ToString(UnsafeNativeMethods.sqlite3_column_text16_interop(stmt._sqlite_stmt, index, ref len), len);
#else
return UTF16ToString(UnsafeNativeMethods.sqlite3_column_text16(stmt._sqlite_stmt, index),
UnsafeNativeMethods.sqlite3_column_bytes16(stmt._sqlite_stmt, index));
#endif
}
internal override string ColumnOriginalName(SQLiteStatement stmt, int index)
{
#if !SQLITE_STANDARD
- int len;
- return UTF16ToString(UnsafeNativeMethods.sqlite3_column_origin_name16_interop(stmt._sqlite_stmt, index, out len), len);
+ int len = 0;
+ return UTF16ToString(UnsafeNativeMethods.sqlite3_column_origin_name16_interop(stmt._sqlite_stmt, index, ref len), len);
#else
return UTF16ToString(UnsafeNativeMethods.sqlite3_column_origin_name16(stmt._sqlite_stmt, index), -1);
#endif
}
internal override string ColumnDatabaseName(SQLiteStatement stmt, int index)
{
#if !SQLITE_STANDARD
- int len;
- return UTF16ToString(UnsafeNativeMethods.sqlite3_column_database_name16_interop(stmt._sqlite_stmt, index, out len), len);
+ int len = 0;
+ return UTF16ToString(UnsafeNativeMethods.sqlite3_column_database_name16_interop(stmt._sqlite_stmt, index, ref len), len);
#else
return UTF16ToString(UnsafeNativeMethods.sqlite3_column_database_name16(stmt._sqlite_stmt, index), -1);
#endif
}
internal override string ColumnTableName(SQLiteStatement stmt, int index)
{
#if !SQLITE_STANDARD
- int len;
- return UTF16ToString(UnsafeNativeMethods.sqlite3_column_table_name16_interop(stmt._sqlite_stmt, index, out len), len);
+ int len = 0;
+ return UTF16ToString(UnsafeNativeMethods.sqlite3_column_table_name16_interop(stmt._sqlite_stmt, index, ref len), len);
#else
return UTF16ToString(UnsafeNativeMethods.sqlite3_column_table_name16(stmt._sqlite_stmt, index), -1);
#endif
}
internal override string GetParamValueText(IntPtr ptr)
{
#if !SQLITE_STANDARD
- int len;
- return UTF16ToString(UnsafeNativeMethods.sqlite3_value_text16_interop(ptr, out len), len);
+ int len = 0;
+ return UTF16ToString(UnsafeNativeMethods.sqlite3_value_text16_interop(ptr, ref len), len);
#else
return UTF16ToString(UnsafeNativeMethods.sqlite3_value_text16(ptr),
UnsafeNativeMethods.sqlite3_value_bytes16(ptr));
#endif
}
Index: System.Data.SQLite/SQLiteBase.cs
==================================================================
--- System.Data.SQLite/SQLiteBase.cs
+++ System.Data.SQLite/SQLiteBase.cs
@@ -152,11 +152,11 @@
/// The timeout to wait before aborting the prepare
/// The remainder of the statement that was not processed. Each call to prepare parses the
/// SQL up to to either the end of the text or to the first semi-colon delimiter. The remaining text is returned
/// here for a subsequent call to Prepare() until all the text has been processed.
/// Returns an initialized SQLiteStatement.
- internal abstract SQLiteStatement Prepare(SQLiteConnection cnn, string strSql, SQLiteStatement previous, uint timeoutMS, out string strRemain);
+ internal abstract SQLiteStatement Prepare(SQLiteConnection cnn, string strSql, SQLiteStatement previous, uint timeoutMS, ref string strRemain);
///
/// Steps through a prepared statement.
///
/// The SQLiteStatement to step through
/// True if a row was returned, False if not.
@@ -206,17 +206,17 @@
internal abstract int Bind_ParamIndex(SQLiteStatement stmt, SQLiteConnectionFlags flags, string paramName);
internal abstract int ColumnCount(SQLiteStatement stmt);
internal abstract string ColumnName(SQLiteStatement stmt, int index);
internal abstract TypeAffinity ColumnAffinity(SQLiteStatement stmt, int index);
- internal abstract string ColumnType(SQLiteStatement stmt, int index, out TypeAffinity nAffinity);
+ internal abstract string ColumnType(SQLiteStatement stmt, int index, ref TypeAffinity nAffinity);
internal abstract int ColumnIndex(SQLiteStatement stmt, string columnName);
internal abstract string ColumnOriginalName(SQLiteStatement stmt, int index);
internal abstract string ColumnDatabaseName(SQLiteStatement stmt, int index);
internal abstract string ColumnTableName(SQLiteStatement stmt, int index);
- internal abstract void ColumnMetaData(string dataBase, string table, string column, out string dataType, out string collateSequence, out bool notNull, out bool primaryKey, out bool autoIncrement);
- internal abstract void GetIndexColumnExtendedInfo(string database, string index, string column, out int sortMode, out int onError, out string collationSequence);
+ internal abstract void ColumnMetaData(string dataBase, string table, string column, ref string dataType, ref string collateSequence, ref bool notNull, ref bool primaryKey, ref bool autoIncrement);
+ internal abstract void GetIndexColumnExtendedInfo(string database, string index, string column, ref int sortMode, ref int onError, ref string collationSequence);
internal abstract double GetDouble(SQLiteStatement stmt, int index);
internal abstract SByte GetSByte(SQLiteStatement stmt, int index);
internal abstract Byte GetByte(SQLiteStatement stmt, int index);
internal abstract Int16 GetInt16(SQLiteStatement stmt, int index);
@@ -440,11 +440,11 @@
/// locking issues.
///
///
/// True if there are more pages to be copied, false otherwise.
///
- internal abstract bool StepBackup(SQLiteBackup backup, int nPage, out bool retry);
+ internal abstract bool StepBackup(SQLiteBackup backup, int nPage, ref bool retry);
///
/// Returns the number of pages remaining to be copied from the source
/// database to the destination database associated with the specified
/// backup object.
@@ -633,12 +633,12 @@
#endif
{
if (!hdl.IsInvalid && !hdl.IsClosed)
{
#if !SQLITE_STANDARD
- int len;
- result = UTF8ToString(UnsafeNativeMethods.sqlite3_errmsg_interop(db, out len), len);
+ int len = 0;
+ result = UTF8ToString(UnsafeNativeMethods.sqlite3_errmsg_interop(db, ref len), len);
#else
result = UTF8ToString(UnsafeNativeMethods.sqlite3_errmsg(db), -1);
#endif
}
else
@@ -812,11 +812,11 @@
}
else
{
n = UnsafeNativeMethods.sqlite3_exec(
db, ToUTF8("ROLLBACK"), IntPtr.Zero, IntPtr.Zero,
- out stmt);
+ ref stmt);
if (n == SQLiteErrorCode.Ok)
{
result = true;
}
Index: System.Data.SQLite/SQLiteCommand.cs
==================================================================
--- System.Data.SQLite/SQLiteCommand.cs
+++ System.Data.SQLite/SQLiteCommand.cs
@@ -345,11 +345,11 @@
if ((_cnn != null) && (_cnn._sql != null))
{
if (_statementList == null)
_remainingText = _commandText;
- stmt = _cnn._sql.Prepare(_cnn, _remainingText, (_statementList == null) ? null : _statementList[_statementList.Count - 1], (uint)(_commandTimeout * 1000), out _remainingText);
+ stmt = _cnn._sql.Prepare(_cnn, _remainingText, (_statementList == null) ? null : _statementList[_statementList.Count - 1], (uint)(_commandTimeout * 1000), ref _remainingText);
if (stmt != null)
{
stmt._command = this;
Index: System.Data.SQLite/SQLiteConnection.cs
==================================================================
--- System.Data.SQLite/SQLiteConnection.cs
+++ System.Data.SQLite/SQLiteConnection.cs
@@ -859,13 +859,13 @@
try
{
backup = sqliteBase.InitializeBackup(
destination, destinationName, sourceName); /* throw */
- bool retry;
+ bool retry = false;
- while (sqliteBase.StepBackup(backup, pages, out retry)) /* throw */
+ while (sqliteBase.StepBackup(backup, pages, ref retry)) /* throw */
{
//
// NOTE: If a callback was supplied by our caller, call it.
// If it returns false, halt the backup process.
//
@@ -4210,14 +4210,14 @@
row["TABLE_NAME"] = rdIndexes.GetString(2);
row["COLUMN_NAME"] = rdIndex.GetString(2);
row["INDEX_NAME"] = rdIndexes.GetString(1);
row["ORDINAL_POSITION"] = ordinal; // rdIndex.GetInt32(1);
- string collationSequence;
- int sortMode;
- int onError;
- _sql.GetIndexColumnExtendedInfo(strCatalog, rdIndexes.GetString(1), rdIndex.GetString(2), out sortMode, out onError, out collationSequence);
+ string collationSequence = null;
+ int sortMode = 0;
+ int onError = 0;
+ _sql.GetIndexColumnExtendedInfo(strCatalog, rdIndexes.GetString(1), rdIndex.GetString(2), ref sortMode, ref onError, ref collationSequence);
if (String.IsNullOrEmpty(collationSequence) == false)
row["COLLATION_NAME"] = collationSequence;
row["SORT_MODE"] = (sortMode == 0) ? "ASC" : "DESC";
Index: System.Data.SQLite/SQLiteDataReader.cs
==================================================================
--- System.Data.SQLite/SQLiteDataReader.cs
+++ System.Data.SQLite/SQLiteDataReader.cs
@@ -506,11 +506,11 @@
if (i >= VisibleFieldCount && _keyInfo != null)
return _keyInfo.GetDataTypeName(i - VisibleFieldCount);
SQLiteType typ = GetSQLiteType(SQLiteCommand.GetFlags(_command), i);
if (typ.Type == DbType.Object) return SQLiteConvert.SQLiteTypeToType(typ).Name;
- return _activeStatement._sql.ColumnType(_activeStatement, i, out typ.Affinity);
+ return _activeStatement._sql.ColumnType(_activeStatement, i, ref typ.Affinity);
}
///
/// Retrieve the column as a date/time value
///
@@ -961,23 +961,23 @@
if (String.IsNullOrEmpty(temp) == false) row[SchemaTableOptionalColumn.BaseCatalogName] = temp;
string dataType = null;
// If we have a table-bound column, extract the extra information from it
if (String.IsNullOrEmpty(strColumn) == false)
- {
- string collSeq;
- bool bNotNull;
- bool bPrimaryKey;
- bool bAutoIncrement;
+ {
+ string collSeq = null;
+ bool bNotNull = false;
+ bool bPrimaryKey = false;
+ bool bAutoIncrement = false;
string[] arSize;
// Get the column meta data
_command.Connection._sql.ColumnMetaData(
(string)row[SchemaTableOptionalColumn.BaseCatalogName],
(string)row[SchemaTableColumn.BaseTableName],
- strColumn,
- out dataType, out collSeq, out bNotNull, out bPrimaryKey, out bAutoIncrement);
+ strColumn,
+ ref dataType, ref collSeq, ref bNotNull, ref bPrimaryKey, ref bAutoIncrement);
if (bNotNull || bPrimaryKey) row[SchemaTableColumn.AllowDBNull] = false;
row[SchemaTableColumn.IsKey] = bPrimaryKey;
row[SchemaTableOptionalColumn.IsAutoIncrement] = bAutoIncrement;
@@ -1082,13 +1082,13 @@
}
}
}
if (String.IsNullOrEmpty(dataType))
- {
- TypeAffinity affin;
- dataType = _activeStatement._sql.ColumnType(_activeStatement, n, out affin);
+ {
+ TypeAffinity affin = TypeAffinity.Uninitialized;
+ dataType = _activeStatement._sql.ColumnType(_activeStatement, n, ref affin);
}
if (String.IsNullOrEmpty(dataType) == false)
row["DataTypeName"] = dataType;
}
@@ -1480,11 +1480,11 @@
typ = _fieldTypeArray[i];
// If not initialized, then fetch the declared column datatype and attempt to convert it
// to a known DbType.
if (typ.Affinity == TypeAffinity.Uninitialized)
- typ.Type = SQLiteConvert.TypeNameToDbType(GetConnection(this), _activeStatement._sql.ColumnType(_activeStatement, i, out typ.Affinity), flags);
+ typ.Type = SQLiteConvert.TypeNameToDbType(GetConnection(this), _activeStatement._sql.ColumnType(_activeStatement, i, ref typ.Affinity), flags);
else
typ.Affinity = _activeStatement._sql.ColumnAffinity(_activeStatement, i);
return typ;
}
Index: System.Data.SQLite/SQLiteModule.cs
==================================================================
--- System.Data.SQLite/SQLiteModule.cs
+++ System.Data.SQLite/SQLiteModule.cs
@@ -488,12 +488,12 @@
if (pValue == IntPtr.Zero) return default(long);
#if !PLATFORM_COMPACTFRAMEWORK
return UnsafeNativeMethods.sqlite3_value_int64(pValue);
#elif !SQLITE_STANDARD
- long value;
- UnsafeNativeMethods.sqlite3_value_int64_interop(pValue, out value);
+ long value = 0;
+ UnsafeNativeMethods.sqlite3_value_int64_interop(pValue, ref value);
return value;
#else
throw new NotImplementedException();
#endif
}
@@ -512,12 +512,12 @@
if (pValue == IntPtr.Zero) return default(double);
#if !PLATFORM_COMPACTFRAMEWORK
return UnsafeNativeMethods.sqlite3_value_double(pValue);
#elif !SQLITE_STANDARD
- double value;
- UnsafeNativeMethods.sqlite3_value_double_interop(pValue, out value);
+ double value = 0.0;
+ UnsafeNativeMethods.sqlite3_value_double_interop(pValue, ref value);
return value;
#else
throw new NotImplementedException();
#endif
}
Index: System.Data.SQLite/UnsafeNativeMethods.cs
==================================================================
--- System.Data.SQLite/UnsafeNativeMethods.cs
+++ System.Data.SQLite/UnsafeNativeMethods.cs
@@ -1229,62 +1229,62 @@
#region interop added textlength calls
#if !SQLITE_STANDARD
[DllImport(SQLITE_DLL)]
- internal static extern IntPtr sqlite3_bind_parameter_name_interop(IntPtr stmt, int index, out int len);
-
- [DllImport(SQLITE_DLL)]
- internal static extern IntPtr sqlite3_column_database_name_interop(IntPtr stmt, int index, out int len);
-
- [DllImport(SQLITE_DLL)]
- internal static extern IntPtr sqlite3_column_database_name16_interop(IntPtr stmt, int index, out int len);
-
- [DllImport(SQLITE_DLL)]
- internal static extern IntPtr sqlite3_column_decltype_interop(IntPtr stmt, int index, out int len);
-
- [DllImport(SQLITE_DLL)]
- internal static extern IntPtr sqlite3_column_decltype16_interop(IntPtr stmt, int index, out int len);
-
- [DllImport(SQLITE_DLL)]
- internal static extern IntPtr sqlite3_column_name_interop(IntPtr stmt, int index, out int len);
-
- [DllImport(SQLITE_DLL)]
- internal static extern IntPtr sqlite3_column_name16_interop(IntPtr stmt, int index, out int len);
-
- [DllImport(SQLITE_DLL)]
- internal static extern IntPtr sqlite3_column_origin_name_interop(IntPtr stmt, int index, out int len);
-
- [DllImport(SQLITE_DLL)]
- internal static extern IntPtr sqlite3_column_origin_name16_interop(IntPtr stmt, int index, out int len);
-
- [DllImport(SQLITE_DLL)]
- internal static extern IntPtr sqlite3_column_table_name_interop(IntPtr stmt, int index, out int len);
-
- [DllImport(SQLITE_DLL)]
- internal static extern IntPtr sqlite3_column_table_name16_interop(IntPtr stmt, int index, out int len);
-
- [DllImport(SQLITE_DLL)]
- internal static extern IntPtr sqlite3_column_text_interop(IntPtr stmt, int index, out int len);
-
- [DllImport(SQLITE_DLL)]
- internal static extern IntPtr sqlite3_column_text16_interop(IntPtr stmt, int index, out int len);
-
- [DllImport(SQLITE_DLL)]
- internal static extern IntPtr sqlite3_errmsg_interop(IntPtr db, out int len);
-
- [DllImport(SQLITE_DLL)]
- 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 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)]
- internal static extern IntPtr sqlite3_value_text16_interop(IntPtr p, out int len);
+ internal static extern IntPtr sqlite3_bind_parameter_name_interop(IntPtr stmt, int index, ref int len);
+
+ [DllImport(SQLITE_DLL)]
+ internal static extern IntPtr sqlite3_column_database_name_interop(IntPtr stmt, int index, ref int len);
+
+ [DllImport(SQLITE_DLL)]
+ internal static extern IntPtr sqlite3_column_database_name16_interop(IntPtr stmt, int index, ref int len);
+
+ [DllImport(SQLITE_DLL)]
+ internal static extern IntPtr sqlite3_column_decltype_interop(IntPtr stmt, int index, ref int len);
+
+ [DllImport(SQLITE_DLL)]
+ internal static extern IntPtr sqlite3_column_decltype16_interop(IntPtr stmt, int index, ref int len);
+
+ [DllImport(SQLITE_DLL)]
+ internal static extern IntPtr sqlite3_column_name_interop(IntPtr stmt, int index, ref int len);
+
+ [DllImport(SQLITE_DLL)]
+ internal static extern IntPtr sqlite3_column_name16_interop(IntPtr stmt, int index, ref int len);
+
+ [DllImport(SQLITE_DLL)]
+ internal static extern IntPtr sqlite3_column_origin_name_interop(IntPtr stmt, int index, ref int len);
+
+ [DllImport(SQLITE_DLL)]
+ internal static extern IntPtr sqlite3_column_origin_name16_interop(IntPtr stmt, int index, ref int len);
+
+ [DllImport(SQLITE_DLL)]
+ internal static extern IntPtr sqlite3_column_table_name_interop(IntPtr stmt, int index, ref int len);
+
+ [DllImport(SQLITE_DLL)]
+ internal static extern IntPtr sqlite3_column_table_name16_interop(IntPtr stmt, int index, ref int len);
+
+ [DllImport(SQLITE_DLL)]
+ internal static extern IntPtr sqlite3_column_text_interop(IntPtr stmt, int index, ref int len);
+
+ [DllImport(SQLITE_DLL)]
+ internal static extern IntPtr sqlite3_column_text16_interop(IntPtr stmt, int index, ref int len);
+
+ [DllImport(SQLITE_DLL)]
+ internal static extern IntPtr sqlite3_errmsg_interop(IntPtr db, ref int len);
+
+ [DllImport(SQLITE_DLL)]
+ internal static extern SQLiteErrorCode sqlite3_prepare_interop(IntPtr db, IntPtr pSql, int nBytes, ref IntPtr stmt, ref IntPtr ptrRemain, ref int nRemain);
+
+ [DllImport(SQLITE_DLL)]
+ internal static extern SQLiteErrorCode sqlite3_table_column_metadata_interop(IntPtr db, byte[] dbName, byte[] tblName, byte[] colName, ref IntPtr ptrDataType, ref IntPtr ptrCollSeq, ref int notNull, ref int primaryKey, ref int autoInc, ref int dtLen, ref int csLen);
+
+ [DllImport(SQLITE_DLL)]
+ internal static extern IntPtr sqlite3_value_text_interop(IntPtr p, ref int len);
+
+ [DllImport(SQLITE_DLL)]
+ internal static extern IntPtr sqlite3_value_text16_interop(IntPtr p, ref int len);
[DllImport(SQLITE_DLL)]
internal static extern int sqlite3_malloc_size_interop(IntPtr p);
#if INTEROP_LOG
@@ -1325,14 +1325,14 @@
[DllImport(SQLITE_DLL)]
internal static extern SQLiteErrorCode sqlite3_backup_finish_interop(IntPtr backup);
[DllImport(SQLITE_DLL)]
- internal static extern SQLiteErrorCode sqlite3_open_interop(byte[] utf8Filename, SQLiteOpenFlagsEnum flags, out IntPtr db);
+ internal static extern SQLiteErrorCode sqlite3_open_interop(byte[] utf8Filename, SQLiteOpenFlagsEnum flags, ref IntPtr db);
[DllImport(SQLITE_DLL)]
- internal static extern SQLiteErrorCode sqlite3_open16_interop(byte[] utf8Filename, SQLiteOpenFlagsEnum flags, out IntPtr db);
+ internal static extern SQLiteErrorCode sqlite3_open16_interop(byte[] utf8Filename, SQLiteOpenFlagsEnum flags, ref IntPtr db);
[DllImport(SQLITE_DLL)]
internal static extern SQLiteErrorCode sqlite3_reset_interop(IntPtr stmt);
[DllImport(SQLITE_DLL)]
@@ -1492,27 +1492,27 @@
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
#endif
- internal static extern SQLiteErrorCode 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, ref IntPtr stmt, ref IntPtr ptrRemain);
#if USE_PREPARE_V2
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
#endif
- internal static extern SQLiteErrorCode sqlite3_prepare_v2(IntPtr db, IntPtr pSql, int nBytes, out IntPtr stmt, out IntPtr ptrRemain);
+ internal static extern SQLiteErrorCode sqlite3_prepare_v2(IntPtr db, IntPtr pSql, int nBytes, ref IntPtr stmt, ref IntPtr ptrRemain);
#endif
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
#endif
- 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);
+ internal static extern SQLiteErrorCode sqlite3_table_column_metadata(IntPtr db, byte[] dbName, byte[] tblName, byte[] colName, ref IntPtr ptrDataType, ref IntPtr ptrCollSeq, ref int notNull, ref int primaryKey, ref int autoInc);
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
@@ -1536,20 +1536,20 @@
#region no equivalent standard method
#if !SQLITE_STANDARD
[DllImport(SQLITE_DLL)]
- internal static extern IntPtr sqlite3_context_collseq_interop(IntPtr context, out int type, out int enc, out int len);
+ internal static extern IntPtr sqlite3_context_collseq_interop(IntPtr context, ref int type, ref int enc, ref int len);
[DllImport(SQLITE_DLL)]
internal static extern int sqlite3_context_collcompare_interop(IntPtr context, byte[] p1, int p1len, byte[] p2, int p2len);
[DllImport(SQLITE_DLL)]
- internal static extern SQLiteErrorCode sqlite3_cursor_rowid_interop(IntPtr stmt, int cursor, out long rowid);
+ internal static extern SQLiteErrorCode sqlite3_cursor_rowid_interop(IntPtr stmt, int cursor, ref long rowid);
[DllImport(SQLITE_DLL)]
- 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);
+ internal static extern SQLiteErrorCode sqlite3_index_column_info_interop(IntPtr db, byte[] catalog, byte[] IndexName, byte[] ColumnName, ref int sortOrder, ref int onError, ref IntPtr Collation, ref int colllen);
[DllImport(SQLITE_DLL)]
internal static extern void sqlite3_resetall_interop(IntPtr db);
[DllImport(SQLITE_DLL)]
@@ -1689,18 +1689,18 @@
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
#endif
- internal static extern SQLiteErrorCode sqlite3_open_v2(byte[] utf8Filename, out IntPtr db, SQLiteOpenFlagsEnum flags, IntPtr vfs);
+ internal static extern SQLiteErrorCode sqlite3_open_v2(byte[] utf8Filename, ref IntPtr db, SQLiteOpenFlagsEnum 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 SQLiteErrorCode sqlite3_open16(string fileName, out IntPtr db);
+ internal static extern SQLiteErrorCode sqlite3_open16(string fileName, ref IntPtr db);
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
@@ -2146,11 +2146,11 @@
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
#endif
- internal static extern SQLiteErrorCode 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, ref IntPtr errMsg);
#if !PLATFORM_COMPACTFRAMEWORK
[DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
[DllImport(SQLITE_DLL)]
@@ -2293,20 +2293,20 @@
[DllImport(SQLITE_DLL, EntryPoint = "sqlite3_bind_int64_interop")]
internal static extern SQLiteErrorCode sqlite3_bind_uint64_interop(IntPtr stmt, int index, ref ulong value);
[DllImport(SQLITE_DLL)]
- internal static extern void sqlite3_column_double_interop(IntPtr stmt, int index, out double value);
+ internal static extern void sqlite3_column_double_interop(IntPtr stmt, int index, ref double value);
+
+ [DllImport(SQLITE_DLL)]
+ internal static extern void sqlite3_column_int64_interop(IntPtr stmt, int index, ref long value);
[DllImport(SQLITE_DLL)]
- internal static extern void sqlite3_column_int64_interop(IntPtr stmt, int index, out long value);
+ internal static extern void sqlite3_value_double_interop(IntPtr p, ref double value);
[DllImport(SQLITE_DLL)]
- internal static extern void sqlite3_value_double_interop(IntPtr p, out double value);
-
- [DllImport(SQLITE_DLL)]
- internal static extern void sqlite3_value_int64_interop(IntPtr p, out Int64 value);
+ internal static extern void sqlite3_value_int64_interop(IntPtr p, ref Int64 value);
[DllImport(SQLITE_DLL)]
internal static extern void sqlite3_result_double_interop(IntPtr context, ref double value);
[DllImport(SQLITE_DLL)]