Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | 64-bit fixes |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | sourceforge |
Files: | files | file ages | folders |
SHA1: |
5dea1671569dfe6a67afc1d16d4ab2ed |
User & Date: | rmsimpson 2006-04-11 18:02:08.000 |
Context
2006-04-11
| ||
18:03 | Minor updates check-in: 5f0ab8e135 user: rmsimpson tags: sourceforge | |
18:02 | 64-bit fixes check-in: 5dea167156 user: rmsimpson tags: sourceforge | |
2006-03-27
| ||
17:05 | Fix GetValue to retrieve guids properly check-in: 8ad750184a user: rmsimpson tags: sourceforge | |
Changes
Changes to System.Data.SQLite/SQLite3.cs.
︙ | ︙ | |||
16 17 18 19 20 21 22 | /// This class implements SQLiteBase completely, and is the guts of the code that interop's SQLite with .NET /// </summary> internal class SQLite3 : SQLiteBase { /// <summary> /// The opaque pointer returned to us by the sqlite provider /// </summary> | | | | | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | /// This class implements SQLiteBase completely, and is the guts of the code that interop's SQLite with .NET /// </summary> internal class SQLite3 : SQLiteBase { /// <summary> /// The opaque pointer returned to us by the sqlite provider /// </summary> protected IntPtr _sql; /// <summary> /// The user-defined functions registered on this connection /// </summary> protected SQLiteFunction[] _functionsArray; internal SQLite3(SQLiteDateFormats fmt) : base(fmt) { } protected override void Dispose(bool bDisposing) { Close(); } internal override void Close() { if (_sql != IntPtr.Zero) { int n = UnsafeNativeMethods.sqlite3_close_interop(_sql); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); SQLiteFunction.UnbindFunctions(this, _functionsArray); } _sql = IntPtr.Zero; } internal override void Cancel() { UnsafeNativeMethods.sqlite3_interrupt_interop(_sql); } |
︙ | ︙ | |||
67 68 69 70 71 72 73 | { return UnsafeNativeMethods.sqlite3_changes_interop(_sql); } } internal override void Open(string strFilename) { | | | | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | { return UnsafeNativeMethods.sqlite3_changes_interop(_sql); } } internal override void Open(string strFilename) { if (_sql != IntPtr.Zero) return; int n = UnsafeNativeMethods.sqlite3_open_interop(ToUTF8(strFilename), out _sql); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); _functionsArray = SQLiteFunction.BindFunctions(this); } internal override void SetTimeout(int nTimeoutMS) { int n = UnsafeNativeMethods.sqlite3_busy_timeout_interop(_sql, nTimeoutMS); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); } internal override void Execute(string strSql) { IntPtr p; string str = strSql; int len; int n = UnsafeNativeMethods.sqlite3_exec_interop(_sql, ToUTF8(strSql), IntPtr.Zero, IntPtr.Zero, out p, out len); if (p != IntPtr.Zero) { str = base.ToString(p, len); UnsafeNativeMethods.sqlite3_free_interop(p); } if (n > 0) throw new SQLiteException(n, str); } |
︙ | ︙ | |||
146 147 148 149 150 151 152 | } } } internal override void FinalizeStatement(SQLiteStatement stmt) { | | | | | 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | } } } internal override void FinalizeStatement(SQLiteStatement stmt) { if (stmt._sqlite_stmt != IntPtr.Zero) { int n = UnsafeNativeMethods.sqlite3_finalize_interop(stmt._sqlite_stmt); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); } stmt._sqlite_stmt = IntPtr.Zero; } internal override int Reset(SQLiteStatement stmt) { int n; n = UnsafeNativeMethods.sqlite3_reset_interop(stmt._sqlite_stmt); // If the schema changed, try and re-prepare it if (n == 17) // SQLITE_SCHEMA { // Recreate a dummy statement string str; using (SQLiteStatement tmp = Prepare(stmt._sqlStatement, null, out str)) { // Finalize the existing statement FinalizeStatement(stmt); // Reassign a new statement pointer to the old statement and clear the temporary one stmt._sqlite_stmt = tmp._sqlite_stmt; tmp._sqlite_stmt = IntPtr.Zero; // Reapply parameters stmt.BindParameters(); } return -1; // Reset was OK, with schema change } else if (n == 6) // SQLITE_LOCKED |
︙ | ︙ | |||
196 197 198 199 200 201 202 | { int len; return ToString(UnsafeNativeMethods.sqlite3_errmsg_interop(_sql, out len), len); } internal override SQLiteStatement Prepare(string strSql, SQLiteStatement previous, out string strRemain) { | | | | 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | { int len; return ToString(UnsafeNativeMethods.sqlite3_errmsg_interop(_sql, out len), len); } internal override SQLiteStatement Prepare(string strSql, SQLiteStatement previous, out string strRemain) { IntPtr stmt; IntPtr ptr; int len; byte[] b = ToUTF8(strSql); int n = UnsafeNativeMethods.sqlite3_prepare_interop(_sql, b, b.Length - 1, out stmt, out ptr, out len); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); strRemain = ToString(ptr, len); SQLiteStatement cmd = null; if (stmt != IntPtr.Zero) cmd = new SQLiteStatement(this, stmt, strSql.Substring(0, strSql.Length - strRemain.Length), previous); return cmd; } internal override void Bind_Double(SQLiteStatement stmt, int index, double value) { int n = UnsafeNativeMethods.sqlite3_bind_double_interop(stmt._sqlite_stmt, index, ref value); |
︙ | ︙ | |||
234 235 236 237 238 239 240 | int n = UnsafeNativeMethods.sqlite3_bind_int64_interop(stmt._sqlite_stmt, index, ref value); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); } internal override void Bind_Text(SQLiteStatement stmt, int index, string value) { byte[] b = ToUTF8(value); | | | | | 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | int n = UnsafeNativeMethods.sqlite3_bind_int64_interop(stmt._sqlite_stmt, index, ref value); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); } internal override void Bind_Text(SQLiteStatement stmt, int index, string value) { byte[] b = ToUTF8(value); int n = UnsafeNativeMethods.sqlite3_bind_text_interop(stmt._sqlite_stmt, index, b, b.Length - 1, (IntPtr)(-1)); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); } internal override void Bind_DateTime(SQLiteStatement stmt, int index, DateTime dt) { byte[] b = ToUTF8(dt); int n = UnsafeNativeMethods.sqlite3_bind_text_interop(stmt._sqlite_stmt, index, b, b.Length - 1, (IntPtr)(-1)); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); } internal override void Bind_Blob(SQLiteStatement stmt, int index, byte[] blobData) { int n = UnsafeNativeMethods.sqlite3_bind_blob_interop(stmt._sqlite_stmt, index, blobData, blobData.Length, (IntPtr)(-1)); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); } internal override void Bind_Null(SQLiteStatement stmt, int index) { int n = UnsafeNativeMethods.sqlite3_bind_null_interop(stmt._sqlite_stmt, index); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); |
︙ | ︙ | |||
435 436 437 438 439 440 441 | } internal override bool IsNull(SQLiteStatement stmt, int index) { return (UnsafeNativeMethods.sqlite3_column_type_interop(stmt._sqlite_stmt, index) == TypeAffinity.Null); } | | | | | | | | | | | | | | | | | | | | | | | | 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 | } internal override bool IsNull(SQLiteStatement stmt, int index) { return (UnsafeNativeMethods.sqlite3_column_type_interop(stmt._sqlite_stmt, index) == TypeAffinity.Null); } internal override int AggregateCount(IntPtr context) { return UnsafeNativeMethods.sqlite3_aggregate_count_interop(context); } internal override IntPtr CreateFunction(string strFunction, int nArgs, SQLiteCallback func, SQLiteCallback funcstep, SQLiteCallback funcfinal) { IntPtr nCookie; int n = UnsafeNativeMethods.sqlite3_create_function_interop(_sql, ToUTF8(strFunction), nArgs, 1, func, funcstep, funcfinal, out nCookie); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); return nCookie; } internal override IntPtr CreateCollation(string strCollation, SQLiteCollation func) { IntPtr nCookie; int n = UnsafeNativeMethods.sqlite3_create_collation_interop(_sql, ToUTF8(strCollation), 1, 0, func, out nCookie); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); return nCookie; } internal override void FreeFunction(IntPtr nCookie) { UnsafeNativeMethods.sqlite3_function_free_callbackcookie(nCookie); } internal override long GetParamValueBytes(IntPtr p, int nDataOffset, byte[] bDest, int nStart, int nLength) { IntPtr ptr; int nlen; int nCopied = nLength; nlen = UnsafeNativeMethods.sqlite3_value_bytes_interop(p); ptr = UnsafeNativeMethods.sqlite3_value_blob_interop(p); if (bDest == null) return nlen; if (nCopied + nStart > bDest.Length) nCopied = bDest.Length - nStart; if (nCopied + nDataOffset > nlen) nCopied = nlen - nDataOffset; if (nCopied > 0) Marshal.Copy((IntPtr)(ptr.ToInt32() + nDataOffset), bDest, nStart, nCopied); else nCopied = 0; return nCopied; } internal override double GetParamValueDouble(IntPtr ptr) { double value; UnsafeNativeMethods.sqlite3_value_double_interop(ptr, out value); return value; } internal override int GetParamValueInt32(IntPtr ptr) { return UnsafeNativeMethods.sqlite3_value_int_interop(ptr); } internal override long GetParamValueInt64(IntPtr ptr) { Int64 value; UnsafeNativeMethods.sqlite3_value_int64_interop(ptr, out value); return value; } internal override string GetParamValueText(IntPtr ptr) { int len; return ToString(UnsafeNativeMethods.sqlite3_value_text_interop(ptr, out len), len); } internal override TypeAffinity GetParamValueType(IntPtr ptr) { return UnsafeNativeMethods.sqlite3_value_type_interop(ptr); } internal override void ReturnBlob(IntPtr context, byte[] value) { UnsafeNativeMethods.sqlite3_result_blob_interop(context, value, value.Length, (IntPtr)(-1)); } internal override void ReturnDouble(IntPtr context, double value) { UnsafeNativeMethods.sqlite3_result_double_interop(context, ref value); } internal override void ReturnError(IntPtr context, string value) { UnsafeNativeMethods.sqlite3_result_error_interop(context, ToUTF8(value), value.Length); } internal override void ReturnInt32(IntPtr context, int value) { UnsafeNativeMethods.sqlite3_result_int_interop(context, value); } internal override void ReturnInt64(IntPtr context, long value) { UnsafeNativeMethods.sqlite3_result_int64_interop(context, ref value); } internal override void ReturnNull(IntPtr context) { UnsafeNativeMethods.sqlite3_result_null_interop(context); } internal override void ReturnText(IntPtr context, string value) { UnsafeNativeMethods.sqlite3_result_text_interop(context, ToUTF8(value), value.Length, (IntPtr)(-1)); } internal override IntPtr AggregateContext(IntPtr context) { return UnsafeNativeMethods.sqlite3_aggregate_context_interop(context, 1); } //internal override void SetRealColNames(bool bOn) //{ // UnsafeNativeMethods.sqlite3_realcolnames(_sql, Convert.ToInt32(bOn)); |
︙ | ︙ |
Changes to System.Data.SQLite/SQLite3_UTF16.cs.
︙ | ︙ | |||
39 40 41 42 43 44 45 | int len; return base.ToString(UnsafeNativeMethods.sqlite3_libversion_interop(out len), len); } } internal override void Open(string strFilename) { | | | | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | int len; return base.ToString(UnsafeNativeMethods.sqlite3_libversion_interop(out len), len); } } internal override void Open(string strFilename) { if (_sql != IntPtr.Zero) return; int n = UnsafeNativeMethods.sqlite3_open16_interop(strFilename, out _sql); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); _functionsArray = SQLiteFunction.BindFunctions(this); } internal override string SQLiteLastError() { int len; return ToString(UnsafeNativeMethods.sqlite3_errmsg16_interop(_sql, out len), len); } internal override SQLiteStatement Prepare(string strSql, SQLiteStatement previous, out string strRemain) { IntPtr stmt; IntPtr ptr; int len; int n = UnsafeNativeMethods.sqlite3_prepare16_interop(_sql, strSql, strSql.Length, out stmt, out ptr, out len); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); strRemain = ToString(ptr, len); |
︙ | ︙ | |||
142 143 144 145 146 147 148 | internal override string ColumnTableName(SQLiteStatement stmt, int index) { int len; return ToString(UnsafeNativeMethods.sqlite3_column_table_name16_interop(stmt._sqlite_stmt, index, out len), len); } | | | | | | | | | | 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | internal override string ColumnTableName(SQLiteStatement stmt, int index) { int len; return ToString(UnsafeNativeMethods.sqlite3_column_table_name16_interop(stmt._sqlite_stmt, index, out len), len); } internal override IntPtr CreateFunction(string strFunction, int nArgs, SQLiteCallback func, SQLiteCallback funcstep, SQLiteCallback funcfinal) { IntPtr nCookie; int n = UnsafeNativeMethods.sqlite3_create_function16_interop(_sql, strFunction, nArgs, 4, func, funcstep, funcfinal, out nCookie); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); return nCookie; } internal override IntPtr CreateCollation(string strCollation, SQLiteCollation func) { IntPtr nCookie; int n = UnsafeNativeMethods.sqlite3_create_collation16_interop(_sql, strCollation, 4, 0, func, out nCookie); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); return nCookie; } internal override string GetParamValueText(IntPtr ptr) { int len; return ToString(UnsafeNativeMethods.sqlite3_value_text16_interop(ptr, out len), len); } internal override void ReturnError(IntPtr context, string value) { UnsafeNativeMethods.sqlite3_result_error16_interop(context, value, value.Length); } internal override void ReturnText(IntPtr context, string value) { UnsafeNativeMethods.sqlite3_result_text16_interop(context, value, value.Length, (IntPtr)(-1)); } } } |
Changes to System.Data.SQLite/SQLiteBase.cs.
︙ | ︙ | |||
155 156 157 158 159 160 161 | if (typ.Type == DbType.Guid) return new Guid(GetText(stmt, index)); return GetText(stmt, index); } } | | | | | | | | | | | | | | | | | | | | 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | if (typ.Type == DbType.Guid) return new Guid(GetText(stmt, index)); return GetText(stmt, index); } } internal abstract IntPtr CreateCollation(string strCollation, SQLiteCollation func); internal abstract IntPtr CreateFunction(string strFunction, int nArgs, SQLiteCallback func, SQLiteCallback funcstep, SQLiteCallback funcfinal); internal abstract void FreeFunction(IntPtr cookie); internal abstract int AggregateCount(IntPtr context); internal abstract IntPtr AggregateContext(IntPtr context); internal abstract long GetParamValueBytes(IntPtr ptr, int nDataOffset, byte[] bDest, int nStart, int nLength); internal abstract double GetParamValueDouble(IntPtr ptr); internal abstract int GetParamValueInt32(IntPtr ptr); internal abstract Int64 GetParamValueInt64(IntPtr ptr); internal abstract string GetParamValueText(IntPtr ptr); internal abstract TypeAffinity GetParamValueType(IntPtr ptr); internal abstract void ReturnBlob(IntPtr context, byte[] value); internal abstract void ReturnDouble(IntPtr context, double value); internal abstract void ReturnError(IntPtr context, string value); internal abstract void ReturnInt32(IntPtr context, Int32 value); internal abstract void ReturnInt64(IntPtr context, Int64 value); internal abstract void ReturnNull(IntPtr context); internal abstract void ReturnText(IntPtr context, string value); internal abstract void SetPassword(byte[] passwordBytes); internal abstract void ChangePassword(byte[] newPasswordBytes); protected virtual void Dispose(bool bDisposing) { } |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteConvert.cs.
︙ | ︙ | |||
402 403 404 405 406 407 408 409 410 411 412 413 414 415 | DbType.Single, DbType.Double, DbType.Decimal, DbType.DateTime, DbType.Object, DbType.String, }; /// <summary> /// Convert a DbType to a Type /// </summary> /// <param name="typ">The DbType to convert from</param> /// <returns>The closest-match .NET type</returns> internal static Type DbTypeToType(DbType typ) | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 | DbType.Single, DbType.Double, DbType.Decimal, DbType.DateTime, DbType.Object, DbType.String, }; /// <summary> /// Returns the ColumnSize for the given DbType /// </summary> /// <param name="typ">The DbType to get the size of</param> /// <returns></returns> internal static int DbTypeToColumnSize(DbType typ) { return _dbtypetocolumnsize[(int)typ]; } private static int[] _dbtypetocolumnsize = { 2147483647, // 0 2147483647, // 1 1, // 2 1, // 3 8, // 4 8, // 5 8, // 6 8, // 7 8, // 8 16, // 9 2, 4, 8, 2147483647, 1, 4, 2147483647, 8, 2, 4, 8, 8, 2147483647, 2147483647, 2147483647, 2147483647, // 25 (Xml) }; /// <summary> /// Convert a DbType to a Type /// </summary> /// <param name="typ">The DbType to convert from</param> /// <returns>The closest-match .NET type</returns> internal static Type DbTypeToType(DbType typ) |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteDataReader.cs.
︙ | ︙ | |||
474 475 476 477 478 479 480 | for (int n = 0; n < _fieldCount; n++) { row = tbl.NewRow(); // Default settings for the column row[SchemaTableColumn.ColumnName] = GetName(n); row[SchemaTableColumn.ColumnOrdinal] = n; | | | | 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 | for (int n = 0; n < _fieldCount; n++) { row = tbl.NewRow(); // Default settings for the column row[SchemaTableColumn.ColumnName] = GetName(n); row[SchemaTableColumn.ColumnOrdinal] = n; row[SchemaTableColumn.ColumnSize] = SQLiteConvert.DbTypeToColumnSize(GetSQLiteType(n).Type); row[SchemaTableColumn.NumericPrecision] = 255; row[SchemaTableColumn.NumericScale] = 0; row[SchemaTableColumn.ProviderType] = GetSQLiteType(n).Type; row[SchemaTableColumn.IsLong] = (GetSQLiteType(n).Type == DbType.Binary); row[SchemaTableColumn.AllowDBNull] = true; row[SchemaTableOptionalColumn.IsReadOnly] = false; row[SchemaTableOptionalColumn.IsRowVersion] = false; row[SchemaTableColumn.IsUnique] = false; |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteFunction.cs.
︙ | ︙ | |||
37 38 39 40 41 42 43 | /// <summary> /// An internal callback delegate declaration. /// </summary> /// <param name="context">Raw context pointer for the user function</param> /// <param name="nArgs">Count of arguments to the function</param> /// <param name="argsptr">A pointer to the array of argument pointers</param> | | | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | /// <summary> /// An internal callback delegate declaration. /// </summary> /// <param name="context">Raw context pointer for the user function</param> /// <param name="nArgs">Count of arguments to the function</param> /// <param name="argsptr">A pointer to the array of argument pointers</param> internal delegate void SQLiteCallback(IntPtr context, int nArgs, IntPtr argsptr); /// <summary> /// Internal callback delegate for implementing collation sequences /// </summary> /// <param name="len1">Length of the string pv1</param> /// <param name="pv1">Pointer to the first string to compare</param> /// <param name="len2">Length of the string pv2</param> /// <param name="pv2">Pointer to the second string to compare</param> |
︙ | ︙ | |||
74 75 76 77 78 79 80 | /// <summary> /// The base connection this function is attached to /// </summary> private SQLiteBase _base; /// <summary> /// Used internally to keep track of memory allocated for aggregate functions /// </summary> | | | | 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | /// <summary> /// The base connection this function is attached to /// </summary> private SQLiteBase _base; /// <summary> /// Used internally to keep track of memory allocated for aggregate functions /// </summary> private IntPtr _interopCookie; /// <summary> /// Internal array used to keep track of aggregate function context data /// </summary> private Hashtable _contextDataList; /// <summary> /// Holds a reference to the callback function for user functions /// </summary> private SQLiteCallback _InvokeFunc; /// <summary> /// Holds a reference to the callbakc function for stepping in an aggregate function |
︙ | ︙ | |||
107 108 109 110 111 112 113 | private static List<SQLiteFunctionAttribute> _registeredFunctions = new List<SQLiteFunctionAttribute>(); /// <summary> /// Internal constructor, initializes the function's internal variables. /// </summary> protected SQLiteFunction() { | | | 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | private static List<SQLiteFunctionAttribute> _registeredFunctions = new List<SQLiteFunctionAttribute>(); /// <summary> /// Internal constructor, initializes the function's internal variables. /// </summary> protected SQLiteFunction() { _contextDataList = new Hashtable(); } /// <summary> /// Returns a reference to the underlying connection's SQLiteConvert class, which can be used to convert /// strings and DateTime's into the current connection's encoding schema. /// </summary> public SQLiteConvert SQLiteConvert |
︙ | ︙ | |||
198 199 200 201 202 203 204 | /// </remarks> /// <param name="nArgs">The number of arguments</param> /// <param name="argsptr">A pointer to the array of arguments</param> /// <returns>An object array of the arguments once they've been converted to .NET values</returns> internal object[] ConvertParams(int nArgs, IntPtr argsptr) { object[] parms = new object[nArgs]; | | | 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | /// </remarks> /// <param name="nArgs">The number of arguments</param> /// <param name="argsptr">A pointer to the array of arguments</param> /// <returns>An object array of the arguments once they've been converted to .NET values</returns> internal object[] ConvertParams(int nArgs, IntPtr argsptr) { object[] parms = new object[nArgs]; IntPtr[] argint = new IntPtr[nArgs]; //string s; //DateTime dt; Marshal.Copy(argsptr, argint, 0, nArgs); for (int n = 0; n < nArgs; n++) { |
︙ | ︙ | |||
247 248 249 250 251 252 253 | } /// <summary> /// Takes the return value from Invoke() and Final() and figures out how to return it to SQLite's context. /// </summary> /// <param name="context">The context the return value applies to</param> /// <param name="returnValue">The parameter to return to SQLite</param> | | | 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | } /// <summary> /// Takes the return value from Invoke() and Final() and figures out how to return it to SQLite's context. /// </summary> /// <param name="context">The context the return value applies to</param> /// <param name="returnValue">The parameter to return to SQLite</param> void SetReturnValue(IntPtr context, object returnValue) { if (returnValue == null || returnValue == DBNull.Value) { _base.ReturnNull(context); return; } |
︙ | ︙ | |||
298 299 300 301 302 303 304 | /// <summary> /// Internal scalar callback function, which wraps the raw context pointer and calls the virtual Invoke() method. /// </summary> /// <param name="context">A raw context pointer</param> /// <param name="nArgs">Number of arguments passed in</param> /// <param name="argsptr">A pointer to the array of arguments</param> | | | 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | /// <summary> /// Internal scalar callback function, which wraps the raw context pointer and calls the virtual Invoke() method. /// </summary> /// <param name="context">A raw context pointer</param> /// <param name="nArgs">Number of arguments passed in</param> /// <param name="argsptr">A pointer to the array of arguments</param> internal void ScalarCallback(IntPtr context, int nArgs, IntPtr argsptr) { SetReturnValue(context, Invoke(ConvertParams(nArgs, argsptr))); } /// <summary> /// Internal collation sequence function, which wraps up the raw string pointers and executes the Compare() virtual function. /// </summary> |
︙ | ︙ | |||
328 329 330 331 332 333 334 | /// This function takes care of doing the lookups and getting the important information put together to call the Step() function. /// That includes pulling out the user's contextData and updating it after the call is made. We use a sorted list for this so /// binary searches can be done to find the data. /// </remarks> /// <param name="context">A raw context pointer</param> /// <param name="nArgs">Number of arguments passed in</param> /// <param name="argsptr">A pointer to the array of arguments</param> | | | | | | 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | /// This function takes care of doing the lookups and getting the important information put together to call the Step() function. /// That includes pulling out the user's contextData and updating it after the call is made. We use a sorted list for this so /// binary searches can be done to find the data. /// </remarks> /// <param name="context">A raw context pointer</param> /// <param name="nArgs">Number of arguments passed in</param> /// <param name="argsptr">A pointer to the array of arguments</param> internal void StepCallback(IntPtr context, int nArgs, IntPtr argsptr) { int n = _base.AggregateCount(context); IntPtr nAux; object obj = null; nAux = _base.AggregateContext(context); if (n > 1) obj = _contextDataList[nAux]; Step(ConvertParams(nArgs, argsptr), n, ref obj); _contextDataList[nAux] = obj; } /// <summary> /// An internal aggregate Final function callback, which wraps the context pointer and calls the virtual Final() method. /// </summary> /// <param name="context">A raw context pointer</param> /// <param name="nArgs">Not used, always zero</param> /// <param name="argsptr">Not used, always zero</param> internal void FinalCallback(IntPtr context, int nArgs, IntPtr argsptr) { IntPtr n = _base.AggregateContext(context); object obj = null; if (_contextDataList.ContainsKey(n)) { obj = _contextDataList[n]; _contextDataList.Remove(n); } |
︙ | ︙ | |||
382 383 384 385 386 387 388 | /// </summary> public void Dispose() { Dispose(true); IDisposable disp; | | | 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 | /// </summary> public void Dispose() { Dispose(true); IDisposable disp; foreach (KeyValuePair<IntPtr, object> kv in _contextDataList) { disp = kv.Value as IDisposable; if (disp != null) disp.Dispose(); } _contextDataList.Clear(); |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteParameter.cs.
︙ | ︙ | |||
254 255 256 257 258 259 260 261 262 263 264 265 266 267 | { } } /// <summary> /// Returns the datatype of the parameter /// </summary> public override DbType DbType { get { if (_dbType == -1) return DbType.String; // Unassigned default value is String return (DbType)_dbType; } | > > > | 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | { } } /// <summary> /// Returns the datatype of the parameter /// </summary> #if !PLATFORM_COMPACTFRAMEWORK [DbProviderSpecificTypeProperty(true)] #endif public override DbType DbType { get { if (_dbType == -1) return DbType.String; // Unassigned default value is String return (DbType)_dbType; } |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteStatement.cs.
︙ | ︙ | |||
23 24 25 26 27 28 29 | /// <summary> /// The command text of this SQL statement /// </summary> internal string _sqlStatement; /// <summary> /// The actual statement pointer /// </summary> | | | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | /// <summary> /// The command text of this SQL statement /// </summary> internal string _sqlStatement; /// <summary> /// The actual statement pointer /// </summary> internal IntPtr _sqlite_stmt; /// <summary> /// An index from which unnamed parameters begin /// </summary> internal int _unnamedParameters; /// <summary> /// Names of the parameters as SQLite understands them to be /// </summary> |
︙ | ︙ | |||
48 49 50 51 52 53 54 | /// <summary> /// Initializes the statement and attempts to get all information about parameters in the statement /// </summary> /// <param name="sqlbase">The base SQLite object</param> /// <param name="stmt">The statement</param> /// <param name="strCommand">The command text for this statement</param> /// <param name="previous">The previous command in a multi-statement command</param> | | | 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | /// <summary> /// Initializes the statement and attempts to get all information about parameters in the statement /// </summary> /// <param name="sqlbase">The base SQLite object</param> /// <param name="stmt">The statement</param> /// <param name="strCommand">The command text for this statement</param> /// <param name="previous">The previous command in a multi-statement command</param> internal SQLiteStatement(SQLiteBase sqlbase, IntPtr stmt, string strCommand, SQLiteStatement previous) { _sql = sqlbase; _sqlite_stmt = stmt; _sqlStatement = strCommand; // Determine parameters for this statement (if any) and prepare space for them. int nCmdStart = 0; |
︙ | ︙ |
Changes to System.Data.SQLite/UnsafeNativeMethods.cs.
︙ | ︙ | |||
32 33 34 35 36 37 38 | [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_libversion_interop(out int len); [DllImport(SQLITE_DLL)] internal static extern void sqlite3_free_interop(IntPtr p); [DllImport(SQLITE_DLL)] | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < < < | | | | | | | | | | | | | | | | | | | | | | 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_libversion_interop(out int len); [DllImport(SQLITE_DLL)] internal static extern void sqlite3_free_interop(IntPtr p); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_open_interop(byte[] utf8Filename, out IntPtr db); [DllImport(SQLITE_DLL)] internal static extern void sqlite3_interrupt_interop(IntPtr db); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_close_interop(IntPtr db); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_exec_interop(IntPtr db, byte[] strSql, IntPtr pvCallback, IntPtr pvParam, out IntPtr errMsg, out int len); [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_errmsg_interop(IntPtr db, out int len); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_changes_interop(IntPtr db); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_busy_timeout_interop(IntPtr db, int ms); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_prepare_interop(IntPtr db, byte[] strSql, int nBytes, out IntPtr stmt, out IntPtr ptrRemain, out int nRemain); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_bind_blob_interop(IntPtr stmt, int index, Byte[] value, int nSize, IntPtr nTransient); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_bind_double_interop(IntPtr stmt, int index, ref double value); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_bind_int_interop(IntPtr stmt, int index, int value); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_bind_int64_interop(IntPtr stmt, int index, ref long value); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_bind_null_interop(IntPtr stmt, int index); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_bind_text_interop(IntPtr stmt, int index, byte[] value, int nlen, IntPtr pvReserved); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_bind_parameter_count_interop(IntPtr stmt); [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 int sqlite3_bind_parameter_index_interop(IntPtr stmt, byte[] strName); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_column_count_interop(IntPtr stmt); [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_decltype_interop(IntPtr stmt, int index, out int len); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_step_interop(IntPtr stmt); [DllImport(SQLITE_DLL)] internal static extern void sqlite3_column_double_interop(IntPtr stmt, int index, out double value); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_column_int_interop(IntPtr stmt, int index); [DllImport(SQLITE_DLL)] internal static extern void sqlite3_column_int64_interop(IntPtr stmt, int index, out long value); [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_blob_interop(IntPtr stmt, int index); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_column_bytes_interop(IntPtr stmt, int index); [DllImport(SQLITE_DLL)] internal static extern TypeAffinity sqlite3_column_type_interop(IntPtr stmt, int index); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_finalize_interop(IntPtr stmt); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_reset_interop(IntPtr stmt); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_create_collation_interop(IntPtr db, byte[] strName, int nType, int nArgs, SQLiteCollation func, out IntPtr nCookie); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_create_function_interop(IntPtr db, byte[] strName, int nArgs, int nType, SQLiteCallback func, SQLiteCallback fstep, SQLiteCallback ffinal, out IntPtr nCookie); [DllImport(SQLITE_DLL)] internal static extern void sqlite3_function_free_callbackcookie(IntPtr nCookie); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_aggregate_count_interop(IntPtr context); [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_value_blob_interop(IntPtr p); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_value_bytes_interop(IntPtr p); [DllImport(SQLITE_DLL)] internal static extern void sqlite3_value_double_interop(IntPtr p, out double value); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_value_int_interop(IntPtr p); [DllImport(SQLITE_DLL)] internal static extern void sqlite3_value_int64_interop(IntPtr p, out Int64 value); [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_value_text_interop(IntPtr p, out int len); [DllImport(SQLITE_DLL)] internal static extern TypeAffinity sqlite3_value_type_interop(IntPtr p); [DllImport(SQLITE_DLL)] internal static extern void sqlite3_result_blob_interop(IntPtr context, byte[] value, int nSize, IntPtr pvReserved); [DllImport(SQLITE_DLL)] internal static extern void sqlite3_result_double_interop(IntPtr context, ref double value); [DllImport(SQLITE_DLL)] internal static extern void sqlite3_result_error_interop(IntPtr context, byte[] strErr, int nLen); [DllImport(SQLITE_DLL)] internal static extern void sqlite3_result_int_interop(IntPtr context, int value); [DllImport(SQLITE_DLL)] internal static extern void sqlite3_result_int64_interop(IntPtr context, ref Int64 value); [DllImport(SQLITE_DLL)] internal static extern void sqlite3_result_null_interop(IntPtr context); [DllImport(SQLITE_DLL)] internal static extern void sqlite3_result_text_interop(IntPtr context, byte[] value, int nLen, IntPtr pvReserved); [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_aggregate_context_interop(IntPtr context, int nBytes); [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); [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_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_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_text16_interop(IntPtr stmt, int index, out int len); [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode)] internal static extern int sqlite3_open16_interop(string utf16Filename, out IntPtr db); [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_errmsg16_interop(IntPtr db, out int len); [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode)] internal static extern int sqlite3_prepare16_interop(IntPtr db, string strSql, int sqlLen, out IntPtr stmt, out IntPtr ptrRemain, out int len); [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode)] internal static extern int sqlite3_bind_text16_interop(IntPtr stmt, int index, string value, int nlen, int nTransient); [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_decltype16_interop(IntPtr stmt, int index, out int len); [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode)] internal static extern int sqlite3_create_collation16_interop(IntPtr db, string strName, int nType, int nArgs, SQLiteCollation func, out IntPtr nCookie); [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode)] internal static extern int sqlite3_create_function16_interop(IntPtr db, string strName, int nArgs, int nType, SQLiteCallback func, SQLiteCallback funcstep, SQLiteCallback funcfinal, out IntPtr nCookie); [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_value_text16_interop(IntPtr p, out int len); [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode)] internal static extern void sqlite3_result_error16_interop(IntPtr context, string strName, int nLen); [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode)] internal static extern void sqlite3_result_text16_interop(IntPtr context, string strName, int nLen, IntPtr pvReserved); [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode, SetLastError = true)] internal static extern int sqlite3_encryptfile(string fileName); [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode, SetLastError = true)] internal static extern int sqlite3_decryptfile(string fileName); [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode, SetLastError = true)] internal static extern int sqlite3_encryptedstatus(string fileName, out int fileStatus); [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode, SetLastError = true)] internal static extern int sqlite3_compressfile(string fileName); [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode, SetLastError = true)] internal static extern int sqlite3_decompressfile(string fileName); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_key_interop(IntPtr db, byte[] key, int keylen); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_rekey_interop(IntPtr db, byte[] key, int keylen); } } |